mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-14 00:39:19 +00:00
Make kernel to boot in x32
This commit is contained in:
@ -18,50 +18,3 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.code32
|
||||
|
||||
.equ PAGE_TABLE_SIZE, 0x4
|
||||
|
||||
.section .bootstrap.data
|
||||
.align 0x1000
|
||||
.global BootPageTable
|
||||
BootPageTable:
|
||||
.rept 0x10000 /* 0x4000 bytes will be used in UpdatePageTable */
|
||||
.long 0
|
||||
.endr
|
||||
|
||||
.section .bootstrap.text
|
||||
.global UpdatePageTable
|
||||
UpdatePageTable:
|
||||
mov edi, (BootPageTable + 0x0000) /* First PML4E */
|
||||
mov eax, (BootPageTable + 0x1000) /* First PDPTE */
|
||||
or eax, 0b11 /* Bitwise OR on rax (PDPTE) with 11b (Present, Write) */
|
||||
mov dword [edi], eax /* Write 11b to PML4E */
|
||||
|
||||
mov edi, (BootPageTable + 0x1000) /* First PDPTE */
|
||||
mov eax, (BootPageTable + 0x2000) /* First PDE */
|
||||
or eax, 0b11 /* Bitwise OR on rax (PDE) with 11b (Present, Write) */
|
||||
|
||||
mov ecx, PAGE_TABLE_SIZE /* For loop instruction */
|
||||
mov ebx, 0x0 /* Value to store in the next 4 bytes */
|
||||
.FillPageTableLevel3:
|
||||
mov dword [edi], eax /* Store modified PDE in PDPTE */
|
||||
mov dword [edi + 4], ebx /* Store the rbx value in the next 4 bytes */
|
||||
add eax, 0x1000 /* Increment (page size) */
|
||||
adc ebx, 0 /* Add 0 to carry flag */
|
||||
add edi, 8 /* Add 8 to rdi (next PDE) */
|
||||
loop .FillPageTableLevel3 /* Loop until rcx is 0 */
|
||||
|
||||
mov edi, (BootPageTable + 0x2000) /* First PDE */
|
||||
mov eax, 0b10000011 /* Present, Write, Large Page */
|
||||
|
||||
mov ecx, (512 * PAGE_TABLE_SIZE) /* For loop instruction */
|
||||
mov ebx, 0x0 /* Value to store in the next 4 bytes */
|
||||
.FillPageTableLevel2:
|
||||
mov dword [edi], eax /* Store modified PDE in PDPTE */
|
||||
mov dword [edi + 4], ebx /* Store the rbx value in the next 4 bytes */
|
||||
add eax, 1 << 21 /* Increment (page size) */
|
||||
adc ebx, 0 /* Add 0 (carry flag) to rbx to increment if there was a carry */
|
||||
add edi, 8 /* Add 8 to rdi (next PDE) */
|
||||
loop .FillPageTableLevel2 /* Loop until rcx is 0 */
|
||||
|
||||
ret
|
||||
|
Reference in New Issue
Block a user