Correction of the mapping that sucked
This commit is contained in:
parent
58754a32af
commit
c49941df7c
|
@ -36,18 +36,20 @@ Setup_paging:
|
|||
or eax, 1 << 1 | 1 << 0 ; present + writable
|
||||
mov [PML4_table], eax
|
||||
|
||||
;; Map the first PDP entries to PD table
|
||||
mov ecx, 0x0
|
||||
mov eax, PD_table
|
||||
;; Map the PDP entries to PD tables
|
||||
mov ebx, PD_table ; start address
|
||||
mov ecx, 0x0 ; counter variable
|
||||
.map_pdp_table:
|
||||
mov eax, ebx
|
||||
or eax, 1 << 1 | 1 << 0 ; present + writable
|
||||
mov [PDP_table + ecx * 8], eax
|
||||
add eax, 8
|
||||
mov [PDP_table + 8 * ecx], eax
|
||||
inc ecx
|
||||
cmp ecx, MAX_MEMORY
|
||||
jne .map_pdp_table
|
||||
add ebx, 4096
|
||||
cmp ecx, MAX_MEMORY ; PDP table is mapped if MAX_MEMORY
|
||||
jne .map_pdp_table ; else map the next entry
|
||||
|
||||
;; Map each PD entry to a 'huge' 2MiB page
|
||||
|
||||
mov ecx, 0x0 ; counter variable
|
||||
.map_pd_table:
|
||||
;; map ecx-th PD entry to a huge page that starts at address 2MiB*ecx
|
||||
|
@ -59,8 +61,6 @@ Setup_paging:
|
|||
cmp ecx, 512 * MAX_MEMORY ; PD table is mapped if 512
|
||||
jne .map_pd_table ; else map the next entry
|
||||
|
||||
ret
|
||||
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
; Enable long mode and paging ;
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
|
|
|
@ -59,4 +59,4 @@ PML4_table:
|
|||
PDP_table:
|
||||
resb 4096
|
||||
PD_table:
|
||||
resb 4096 * MAX_MEMORY
|
||||
times MAX_MEMORY resb 4096
|
||||
|
|
|
@ -150,10 +150,31 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic)
|
|||
//if(rc)KernLog("error\n");
|
||||
//KernLog((char*)buf->buf);
|
||||
|
||||
uchar *addr = (uchar *)(ullong)(1024*5*MB - 7);
|
||||
uchar *addr = (uchar *)(ullong)(10);
|
||||
*addr = 2;
|
||||
|
||||
addr = (uchar *)(ullong)(1*GB+10);
|
||||
*addr = 4;
|
||||
|
||||
addr = (uchar *)(ullong)(2*GB+10);
|
||||
*addr = 9;
|
||||
|
||||
addr = (uchar *)(ullong)(4*GB + 10);
|
||||
*addr = 16;
|
||||
|
||||
addr = (uchar *)(ullong)(10);
|
||||
KernLog("Test, valeur autour de %p: %hhu\n", addr, *addr);
|
||||
|
||||
addr = (uchar *)(ullong)(1*GB+10);
|
||||
KernLog("Test, valeur autour de %p: %hhu\n", addr, *addr);
|
||||
|
||||
addr = (uchar *)(ullong)(2*GB+10);
|
||||
KernLog("Test, valeur autour de %p: %hhu\n", addr, *addr);
|
||||
|
||||
addr = (uchar *)(ullong)(4*GB + 10);
|
||||
KernLog("Test, valeur autour de %p: %hhu\n", addr, *addr);
|
||||
|
||||
|
||||
// We're out
|
||||
PsFiniSched();
|
||||
KeCrashSystem(); //yay
|
||||
|
|
Loading…
Reference in New Issue