From 66f2ca62469eba4b46e1f19f54dde9476b08d956 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Fri, 30 Apr 2021 09:31:30 +0200 Subject: Debug interrupts, allow to show bmp images --- src/core/paging.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/core/paging.cc') diff --git a/src/core/paging.cc b/src/core/paging.cc index b21e660..b12fb4c 100644 --- a/src/core/paging.cc +++ b/src/core/paging.cc @@ -36,7 +36,10 @@ void paging_enable() { // Setting up new kernel address space for(u64 i=0;i<=0x10000000;i+=4096){ + // Higher half mapping PAGE_MAP(i); + // Allow access to RAM: + paging_allocate_addr(kpages[0], i, i, PAGING_OPT_P|PAGING_OPT_RW, 1); } // 4096 bytes stack @@ -145,32 +148,35 @@ void paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 options, char // Solve pdp if(pml4_table[pml4] == 0){ - pml4_table[pml4]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE())); + pml4_table[pml4]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE()); pml4_table[pml4]|=options; paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables); return; } // Solve pd - u64* pdp_table=(u64*)(VIRT(PAGE(pml4_table[pml4]))); + u64* pdp_table=(u64*)(PAGE(pml4_table[pml4])); + pdp_table=useKernelTables ? VIRT(pdp_table) : pdp_table; if(pdp_table[pdp] == 0){ - pdp_table[pdp]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE())); + pdp_table[pdp]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE()); pdp_table[pdp]|=options; paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables); return; } // Solve pt - u64* pd_table=(u64*)(VIRT(PAGE(pdp_table[pdp]))); + u64* pd_table=(u64*)(PAGE(pdp_table[pdp])); + pd_table=useKernelTables ? VIRT(pd_table) : pd_table; if(pd_table[pd] == 0){ - pd_table[pd]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE())); + pd_table[pd]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE()); pd_table[pd]|=options; paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables); return; } // Solve address - u64* pt_table=(u64*)(VIRT(PAGE(pd_table[pd]))); + u64* pt_table=(u64*)(PAGE(pd_table[pd])); + pt_table=useKernelTables ? VIRT(pt_table) : pt_table; if(pt_table[pt] == 0){ pt_table[pt]=PAGE(phy); pt_table[pt]|=options; @@ -180,8 +186,7 @@ void paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 options, char } u64* paging_create_task(int npages){ - u64 *pml4=VIRT(PAGE_ALLOCATE()); - u64 sum=(u64)pml4+kvar_kernel_vma; - paging_allocate_addr(pml4, 0, (u64)PAGE_ALLOCATE(), PAGING_OPT_P|PAGING_OPT_RW, 0); + u64 *pml4=PAGE_ALLOCATE(); + // paging_allocate_addr(pml4, 0, (u64)PAGE_ALLOCATE(), PAGING_OPT_P|PAGING_OPT_RW, 0); return pml4; } \ No newline at end of file -- cgit v1.2.3