1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Correction of the mapping that sucked

This commit is contained in:
Adrien Bourmault 2019-03-28 10:34:18 +01:00
parent 58754a32af
commit c49941df7c
3 changed files with 32 additions and 11 deletions

View File

@ -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 ;
; ---------------------------------------------------------------------------- ;

View File

@ -59,4 +59,4 @@ PML4_table:
PDP_table:
resb 4096
PD_table:
resb 4096 * MAX_MEMORY
times MAX_MEMORY resb 4096

View File

@ -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