diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-21 22:14:12 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-21 22:14:12 +0200 |
commit | d4405dfb012ca70c06dfc3217265e4e9cd01b68a (patch) | |
tree | 76a99805e7a0f948bd885c89b219db13240efebd /src | |
parent | Check multiboot2 header length, and if needed map the next page as well (diff) | |
download | kernel.cpp-d4405dfb012ca70c06dfc3217265e4e9cd01b68a.tar.xz |
Place bootstrap code into multiboot section
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.S | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -34,6 +34,11 @@ module_tag_end: .int 8 header_end: +.section .multiboot.pages, "aw", @nobits +.align 4096 +bootstrap_page0: + .skip 1024 * 4 + /* The stack on x86 must be 16-byte aligned according to the 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. @@ -60,7 +65,7 @@ kernel_ptable0: */ .section .multiboot.text, "ax" .global VADDR_OFFSET - .set VADDR_OFFSET, 0xc0000000 - 0x400000 +.set VADDR_OFFSET, 0 .macro map begin, end, access mov $\begin - VADDR_OFFSET, %esi @@ -83,6 +88,12 @@ kernel_ptable0: _start: cli + movl $bootstrap_page0, %edi + movl $1024, %ecx + map begin_multiboot, end_multiboot, 0x003 + +.set VADDR_OFFSET, 0xc0000000 - 0x400000 + # Physical address of kernel_ptable0. movl $(kernel_ptable0 - VADDR_OFFSET), %edi # Map 1024 pages @@ -98,6 +109,7 @@ _start: # Use the page table at: # - entry 1 starts 0x0040 0000 ends 0x007f ffff # - entry 768 starts 0xc000 0000 ends 0xc03f ffff + movl $(bootstrap_page0 + 0x003), kernel_pagedir - VADDR_OFFSET + 0 * 4 movl $(kernel_ptable0 - VADDR_OFFSET + 0x003), kernel_pagedir - VADDR_OFFSET + 1 * 4 movl $(kernel_ptable0 - VADDR_OFFSET + 0x003), kernel_pagedir - VADDR_OFFSET + 768 * 4 @@ -120,6 +132,7 @@ _start: kinit: # At this point, paging is fully set up and enabled. # Unmap the identity mapping as it is now unnecessary. + movl $0, kernel_pagedir + 0 * 4 movl $0, kernel_pagedir + 1 * 4 # Reload crc3 to force a TLB flush so the changes to take effect. movl %cr3, %ecx |