diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-28 15:07:12 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-28 15:07:12 +0200 |
| commit | 067d6e340be698b0e26b7732215a1969e0e683f3 (patch) | |
| tree | 88cf82e14bdcfc460a18980a73e419fbb0c58763 /src/core | |
| parent | 778e43c0a2d1f1cc952c3ec0c0b9d5bd3ff4995a (diff) | |
Refactoring
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/paging.cc | 10 | ||||
| -rw-r--r-- | src/core/paging.hpp | 13 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/core/paging.cc b/src/core/paging.cc index da442bf..ae390ff 100644 --- a/src/core/paging.cc +++ b/src/core/paging.cc @@ -9,7 +9,7 @@ int kpages_next=1; // First page is for the pml4 u64* paging_allocate_table(){ u64 addr=(u64)kpages[kpages_next]; - u64* allocated=(u64*)(addr-kernel_vma); + u64* allocated=(u64*)(addr-kvar_kernel_vma); kpages_next++; return allocated; } @@ -29,17 +29,17 @@ void paging_enable() { // Allocate paging for the kernel (to not override the source // code during the next paging_allocate_table() calls) - paging_allocate_contiguous(userspace_pma/4096); + paging_allocate_contiguous(kvar_userspace_pma/4096); // Setting up new kernel address space for(u64 i=0;i<=0x10000000;i+=4096){ - paging_allocate_addr(kpages[0],kernel_vma+i,i, 0x3,0); // Identity map + paging_allocate_addr(kpages[0],kvar_kernel_vma+i,i, 0x3,0); // Identity map } // 4096 bytes stack - paging_allocate_addr(kpages[0],kernel_vma-4096,stack_pma,0x3,0); + paging_allocate_addr(kpages[0],kvar_kernel_vma-4096,kvar_stack_pma,0x3,0); // Load new pml4 - u64 kpage_phy=((u64)kpages[0]-kernel_vma); + u64 kpage_phy=((u64)kpages[0]-kvar_kernel_vma); asm volatile( "mov %0, %%rax \n\t" "mov %%rax, %%cr3 \n\t" diff --git a/src/core/paging.hpp b/src/core/paging.hpp index 01e45a7..5817765 100644 --- a/src/core/paging.hpp +++ b/src/core/paging.hpp @@ -2,6 +2,7 @@ #include "core/types.hpp" +#define MAX_TABLES 280 #define PAGING_MAX_PAGE (20*512) /** * Current number of page (from the beginning of the ram) used by the kernel that @@ -18,15 +19,17 @@ /// @brief Get page address that contain addr #define PAGE(addr) (addr&(~(0xFFF))) -#define PAGING_MAP(addr) paging_allocate_addr(kpages[0],(u64)(addr),(u64)(addr),PAGING_OPT_P|PAGING_OPT_RW,kernel_vma) -#define MAX_TABLES 280 +#define PAGING_MAP(addr) paging_allocate_addr(kpages[0],(u64)(addr),(u64)(addr),PAGING_OPT_P|PAGING_OPT_RW,kvar_kernel_vma) +#define PAGING_MAP_RANGE(addr, n) { \ + for(u64 i=0;i<(n);i++){ \ + paging_allocate_addr(kpages[0],((u64)(addr))+i,((u64)(addr))+i,PAGING_OPT_P|PAGING_OPT_RW,kvar_kernel_vma); \ +}} /// @brief All PAE table structures are allocated here extern u64 kpages[MAX_TABLES][512]; -/// cf boucane.hpp -extern u64 kernel_vma,stack_pma,userspace_pma; - +/// CF boucane.hpp +extern u64 kvar_kernel_vma,kvar_stack_pma,kvar_userspace_pma; /** * Setup and enable PAE paging |
