feat: add paging
This commit is contained in:
@@ -12,7 +12,7 @@ multiboot_header:
|
||||
.long 8
|
||||
multiboot_header_end:
|
||||
|
||||
.section .text
|
||||
.section .text.boot
|
||||
.code32
|
||||
|
||||
.global _start
|
||||
@@ -27,15 +27,23 @@ _start:
|
||||
movl %eax, multiboot_magic
|
||||
movl %ebx, multiboot_info
|
||||
|
||||
movl $stack_top, %esp
|
||||
movl $__boot_stack_top, %esp
|
||||
|
||||
/**
|
||||
* Bootstrap page tables
|
||||
*
|
||||
* PML4[0] = PML4[511] = PDPT
|
||||
* PDPT[0] = PDPT[510] = PD
|
||||
*/
|
||||
movl $pdpt_table, %eax
|
||||
orl $0x3, %eax
|
||||
movl %eax, pml4_table
|
||||
movl %eax, pml4_table + (511 * 8)
|
||||
|
||||
movl $pd_table, %eax
|
||||
orl $0x3, %eax
|
||||
movl %eax, pdpt_table
|
||||
movl %eax, pdpt_table + (510 * 8)
|
||||
|
||||
xorl %ecx, %ecx
|
||||
movl $pd_table, %edi
|
||||
@@ -65,7 +73,7 @@ _start:
|
||||
movl $0xC0000080, %ecx
|
||||
rdmsr
|
||||
|
||||
orl $0x100, %eax
|
||||
orl $0x900, %eax
|
||||
|
||||
wrmsr
|
||||
|
||||
@@ -100,7 +108,7 @@ long_mode_entry:
|
||||
movw %ax, %fs
|
||||
movw %ax, %gs
|
||||
|
||||
movq $stack_top, %rsp
|
||||
movq $__boot_stack_top, %rsp
|
||||
|
||||
andq $-16, %rsp
|
||||
|
||||
@@ -110,7 +118,8 @@ long_mode_entry:
|
||||
|
||||
call enable_sse
|
||||
|
||||
call kmain
|
||||
movabs $kmain, %rax
|
||||
jmp *%rax
|
||||
.hang:
|
||||
cli
|
||||
hlt
|
||||
@@ -154,7 +163,7 @@ gdt_descriptor:
|
||||
.long gdt
|
||||
|
||||
|
||||
.section .bss
|
||||
.section .bss.boot
|
||||
|
||||
.align 8
|
||||
|
||||
@@ -182,9 +191,12 @@ pdpt_table:
|
||||
pd_table:
|
||||
.skip 4096
|
||||
|
||||
|
||||
.section .stack.boot, "aw", @nobits
|
||||
.align 16
|
||||
|
||||
stack_bottom:
|
||||
.global __boot_stack_bottom
|
||||
__boot_stack_bottom:
|
||||
.skip 16384
|
||||
stack_top:
|
||||
|
||||
.global __boot_stack_top
|
||||
__boot_stack_top:
|
||||
|
||||
Reference in New Issue
Block a user