From 883cf37e850e5ee489d98c043167dea39fdc98ba Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 24 Mar 2023 13:53:40 -0500 Subject: [PATCH] Change to not mapping the startup code in the kernel mapping page --- kernel/start.68k | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/kernel/start.68k b/kernel/start.68k index ab06a41..b34c668 100644 --- a/kernel/start.68k +++ b/kernel/start.68k @@ -13,6 +13,9 @@ phead_loop: move.l (a1), d1 | If the type of the program header isn't 1 (LOAD), skip the header cmpi.l #0x1, d1 bne.b next_phead +move.b (9, a1), d1 | If the segment isn't for the high quarter, skip it +cmpi.b #0xc0, d1 +bgt.b next_phead move.l (20, a1), d4 | Put the memory size in d4 move.l d4, d3 | Copy the size to d3 lsr #8, d3 | Shift d3 right 12 bits to get the number of full pages the segment takes up @@ -24,7 +27,7 @@ addq.l #1, d3 even_page: subq.b #1, d3 | | Adjust the number of pages to map for dbra move.l (12, a1), d1 | Get the starting physical page in d3 -ori.l #3, d1 | Set the present and writable falgs on the entry +ori.l #3, d1 | Set the present and writable flags on the entry move.l (8, a1), d0 | Get the starting virtual page number in the quarter in d0 lsr.l #8, d0 lsr.l #4, d0 @@ -47,14 +50,12 @@ io_map_loop: move.l d1, (a1)+ | Write the entry to the mapping page and advance the entry pointer addi.l #0x1000, d1 | Advance the entry to the next physical page dbra d0, io_map_loop | Loop back if there are more pages to map +map_done: move.l #kernel_map, d0 | Load the pointer to the mapping page into d0 ori.l #0x1, d0 | Set the map page present flag move.l d0, (0x0, a0) | Write the mapping page to both the lower and upper quarter map registers move.l d0, (0xC, a0) -move.w #1, (0x14, a0) | Enable the MMU -move.w #0, 0xff0000 | Disable the IO space at the top of the lower 16MB of memory -move.l #bootstrap_stack, a7 | Load the initial stack pointer -jmp main | Jump to the kernel's main function +jmp (higher_bridge - 0xC00000) | Jump to the lower-half equivalent of the bridging function no_mmu: stop #2700 | If there was no MMU card, halt the CPU @@ -74,6 +75,20 @@ move.l #0x0, a0 ffc_early_done: rts + +.text +higher_bridge: +move.w #1, (0x14, a0) | Enable the MMU +jmp in_higher:l | Jump to the higher half (THis function has been called with the PC in the +| lower half, so this seemingly no-op jump instruction actually switches to the higher half) +in_higher: +move.w #0, 0xff0000 | Disable the IO space at the top of the lower 16MB of memory +move.l #0, (0x0, a0) | Disable the mapping in the lower quarter +move.l #bootstrap_stack, a7 | Load the initial stack pointer +jmp main | Jump to the kernel's main function + + + .section .early.bss, "aw", @nobits kernel_map: .balign 4096