Change to not mapping the startup code in the kernel mapping page

This commit is contained in:
pjht 2023-03-24 13:53:40 -05:00
parent 912f4534a4
commit 883cf37e85
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -13,6 +13,9 @@ phead_loop:
move.l (a1), d1 | If the type of the program header isn't 1 (LOAD), skip the header move.l (a1), d1 | If the type of the program header isn't 1 (LOAD), skip the header
cmpi.l #0x1, d1 cmpi.l #0x1, d1
bne.b next_phead 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 (20, a1), d4 | Put the memory size in d4
move.l d4, d3 | Copy the size to d3 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 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: even_page:
subq.b #1, d3 | | Adjust the number of pages to map for dbra 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 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 move.l (8, a1), d0 | Get the starting virtual page number in the quarter in d0
lsr.l #8, d0 lsr.l #8, d0
lsr.l #4, 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 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 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 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 move.l #kernel_map, d0 | Load the pointer to the mapping page into d0
ori.l #0x1, d0 | Set the map page present flag 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, (0x0, a0) | Write the mapping page to both the lower and upper quarter map registers
move.l d0, (0xC, a0) move.l d0, (0xC, a0)
move.w #1, (0x14, a0) | Enable the MMU jmp (higher_bridge - 0xC00000) | Jump to the lower-half equivalent of the bridging function
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
no_mmu: no_mmu:
stop #2700 | If there was no MMU card, halt the CPU stop #2700 | If there was no MMU card, halt the CPU
@ -74,6 +75,20 @@ move.l #0x0, a0
ffc_early_done: ffc_early_done:
rts 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 .section .early.bss, "aw", @nobits
kernel_map: kernel_map:
.balign 4096 .balign 4096