kstart.S: remove leftovers from the 64-bit version.
This commit is contained in:
parent
e1bcd70747
commit
5a05c48afc
@ -12,36 +12,22 @@
|
|||||||
.global _start
|
.global _start
|
||||||
.asciz "kernel start\n"
|
.asciz "kernel start\n"
|
||||||
_start:
|
_start:
|
||||||
.code32
|
// zero out PD at 0x1000
|
||||||
mov dword ptr [patch_addr - KERNBASE], offset gdt32_begin - KERNBASE
|
|
||||||
lgdt gdtr32 - KERNBASE
|
|
||||||
|
|
||||||
// zero our PD at 0x1000 and PT at 0x2000
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov ecx, 2048
|
mov ecx, 1024
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
// Set up the page table for the lowest 4 MiB: PD[0] -> PT
|
|
||||||
mov dword ptr [0x1000], 0x2000 | 0x3
|
|
||||||
|
|
||||||
// KERNBASE = 0x8000_0000
|
|
||||||
// Use the same page table for the first 4 MiB after KERNBASE: PD[0x200] -> PT
|
|
||||||
mov dword ptr [0x1000 + ((KERNBASE >> 22) * 4)], 0x2000 | 0x3
|
|
||||||
|
|
||||||
// Enable 4 MiB pages
|
// Enable 4 MiB pages
|
||||||
mov eax, cr4
|
mov eax, cr4
|
||||||
or eax, 0x10 // Set the PSE bit (bit 4)
|
or eax, 0x10 // Set the PSE bit (bit 4)
|
||||||
mov cr4, eax
|
mov cr4, eax
|
||||||
|
|
||||||
// Identity map the first 2 MiB
|
// Identity map low 4 MiB
|
||||||
mov edi, 0x2000 // Start of the PT
|
mov dword ptr [0x1000], 0 | PTE_P | PTE_W | PTE_PS
|
||||||
mov ebx, 0x00000003 // Present, R/W
|
|
||||||
mov ecx, 512 // 2 MiB / 4 KiB = 512
|
// KERNBASE = 0x8000_0000
|
||||||
SetEntry:
|
// Same mapping for the first 4 MiB after KERNBASE
|
||||||
mov dword ptr [edi], ebx
|
mov dword ptr [0x1000 + ((KERNBASE >> 22) * 4)], 0 | PTE_P | PTE_W | PTE_PS
|
||||||
add ebx, 0x1000
|
|
||||||
add edi, 4
|
|
||||||
loop SetEntry
|
|
||||||
|
|
||||||
// Load physical address of PD into CR3
|
// Load physical address of PD into CR3
|
||||||
mov edi, 0x1000
|
mov edi, 0x1000
|
||||||
@ -52,25 +38,7 @@ SetEntry:
|
|||||||
or eax, 1 << 31 // Set the PG bit
|
or eax, 1 << 31 // Set the PG bit
|
||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
|
|
||||||
.att_syntax
|
|
||||||
jmp $0x8, $loadseg - KERNBASE
|
|
||||||
.intel_syntax noprefix
|
|
||||||
|
|
||||||
loadseg:
|
|
||||||
// jump to the high half
|
// jump to the high half
|
||||||
add esp, KERNBASE
|
add esp, KERNBASE
|
||||||
lea eax, kmain
|
lea eax, kmain
|
||||||
jmp eax
|
jmp eax
|
||||||
|
|
||||||
.align 16
|
|
||||||
gdtr32:
|
|
||||||
.word gdt32_end - gdt32_begin - 1
|
|
||||||
patch_addr:
|
|
||||||
.long gdt32_begin - KERNBASE
|
|
||||||
|
|
||||||
.align 16
|
|
||||||
gdt32_begin:
|
|
||||||
.long 0x00000000, 0x00000000 # Null descriptor
|
|
||||||
.long 0x0000ffff, 0x00cf9a00 # Code segment
|
|
||||||
.long 0x0000ffff, 0x00cf9200 # Data segment
|
|
||||||
gdt32_end:
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user