relocate stack
This commit is contained in:
@@ -35,38 +35,43 @@ void Thread::load_paging(Thread* t){
|
||||
|
||||
Thread::Thread (bool kernel, void * startframe, int num_pages): queue_link(nullptr), isKernel(kernel), start(startframe), id(idCounter++), kill_flag(false){
|
||||
StackPointer.isr = reinterpret_cast<void *>((uintptr_t)PageFrameAllocator::alloc(true)+STACK_SIZE);//(reserved_stack_space_isr + STACK_SIZE);
|
||||
StackPointer.user = (void*)(0x4100000+STACK_SIZE);
|
||||
StackPointer.user = (void*)(0x61FF000+STACK_SIZE);
|
||||
|
||||
paging_tree = (four_lvl_paging_t*)PageFrameAllocator::alloc(true);
|
||||
create_basic_page_table(paging_tree, &identity_table);
|
||||
appcode_table = (pagetable_t*) PageFrameAllocator::alloc(true);
|
||||
|
||||
subtable = (pagetable_t*) PageFrameAllocator::alloc(true);
|
||||
assert(num_pages < 512); //limit for application code size is 2M
|
||||
for(uint8_t i=0; i<num_pages; i++){
|
||||
subtable->entries[i] = {
|
||||
appcode_table->entries[i] = {
|
||||
.present = 1,
|
||||
.user = 1,
|
||||
.address = ((uintptr_t)startframe >> 12) + i
|
||||
};
|
||||
}
|
||||
// insert app code pages at 32*512*4096 = 0x4000000
|
||||
paging_tree->l2->entries[32] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)(appcode_table) >> 12
|
||||
};
|
||||
|
||||
uintptr_t user_stackframe_p = ((uintptr_t)PageFrameAllocator::alloc(false));
|
||||
subtable->entries[256] = {
|
||||
appstack_table->entries[511] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = user_stackframe_p >> 12
|
||||
};
|
||||
|
||||
//pagetable_t* l2addr = (pagetable_t*)(paging_tree.l3.entries[0].address<<12);
|
||||
//l2addr->entries[32] = {
|
||||
paging_tree->l2->entries[32] = {
|
||||
// insert stack page at 48*512*4096 = 0x6000000
|
||||
paging_tree->l2->entries[48] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)(subtable) >> 12
|
||||
.address = (uintptr_t)(appstack_table) >> 12
|
||||
};
|
||||
|
||||
//map_pageframe(&paging_tree, (uintptr_t)StackPointer.user, 0x4001000);
|
||||
|
||||
prepareContext(StackPointer.isr, context, kickoff, reinterpret_cast<uintptr_t>(this), 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ class Thread {
|
||||
void* start;
|
||||
|
||||
|
||||
four_lvl_paging_t* paging_tree;
|
||||
|
||||
friend class Queue<Thread>;
|
||||
friend class Semaphore;
|
||||
@@ -75,7 +74,10 @@ class Thread {
|
||||
void* isr;
|
||||
} StackPointer;
|
||||
void* operator new ( size_t count )noexcept;
|
||||
pagetable_t* subtable;
|
||||
|
||||
four_lvl_paging_t* paging_tree;
|
||||
pagetable_t* appcode_table;
|
||||
pagetable_t* appstack_table;
|
||||
|
||||
/*! \brief Unique thread id */
|
||||
const int id;
|
||||
|
||||
Reference in New Issue
Block a user