From d4405dfb012ca70c06dfc3217265e4e9cd01b68a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 21 Mar 2021 22:14:12 +0200 Subject: Place bootstrap code into multiboot section --- src/boot.S | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/boot.S b/src/boot.S index 3a07c19..976a6f4 100644 --- a/src/boot.S +++ b/src/boot.S @@ -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 -- cgit v1.2.1