feat: start of paging setup
This commit is contained in:
25
boot/boot.S
25
boot/boot.S
@@ -19,7 +19,7 @@ forced to be within the first 8 KiB of the kernel file.
|
||||
.long CHECKSUM
|
||||
|
||||
#.include "gdt.S"
|
||||
.section .data
|
||||
.section .data.boot
|
||||
gdt:
|
||||
.quad 0x0000000000000000
|
||||
.quad 0x00CF9A000000FFFF
|
||||
@@ -42,7 +42,7 @@ System V ABI standard and de-facto extensions. The compiler will assume the
|
||||
stack is properly aligned and failure to align the stack will result in
|
||||
undefined behavior.
|
||||
*/
|
||||
.section .bss
|
||||
.section .bss.boot
|
||||
.align 16
|
||||
stack_bottom:
|
||||
.skip 16384 # 16 KiB
|
||||
@@ -53,7 +53,7 @@ The linker script specifies _start as the entry point to the kernel and the
|
||||
bootloader will jump to this position once the kernel has been loaded. It
|
||||
doesn't make sense to return from this function as the bootloader is gone.
|
||||
*/
|
||||
.section .text
|
||||
.section .text.boot
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
@@ -103,6 +103,25 @@ _start:
|
||||
|
||||
continue_boot:
|
||||
sti
|
||||
|
||||
// setting up paging
|
||||
// id map first 4MB using PSE. With
|
||||
movl $135, kernel_page_directory - 0xC0000000
|
||||
movl $135, kernel_page_directory - 0xC0000000 + 3072
|
||||
// load into cr3
|
||||
movl $kernel_page_directory - 0xC0000000, %eax
|
||||
movl %eax, %cr3
|
||||
// enable PSE TODO validate if PSE is actually supported
|
||||
movl %cr4, %eax
|
||||
orl $0x10, %eax
|
||||
movl %eax, %cr4
|
||||
// enable paging
|
||||
movl %cr0, %eax
|
||||
orl $0x80000000, %eax
|
||||
movl %eax, %cr0
|
||||
nop
|
||||
pushl 0
|
||||
popl %eax
|
||||
/*
|
||||
Enter the high-level kernel. The ABI requires the stack is 16-byte
|
||||
aligned at the time of the call instruction (which afterwards pushes
|
||||
|
||||
Reference in New Issue
Block a user