Compare commits
3 Commits
5397400960
...
d8565dcd78
Author | SHA1 | Date | |
---|---|---|---|
d8565dcd78 | |||
883cf37e85 | |||
912f4534a4 |
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
| Finds the first card with the type in d0.b, and returns it's IO base address in a0, or 0 if not found
|
| Finds the first card with the type in d0.b, and returns it's IO base address in a0, or 0 if not found
|
||||||
| Clobbers d1
|
| Clobbers d1
|
||||||
|
| Warning to developers: This function must only use PC-relative addressing as it is called from early boot before the kernel is properly mapped.
|
||||||
find_first_card:
|
find_first_card:
|
||||||
move.l #0xff0000, a0 | a0 holds the address of the current card
|
move.l #0xff0000, a0 | a0 holds the address of the current card
|
||||||
ffc_loop:
|
ffc_loop:
|
||||||
|
@ -5,7 +5,7 @@ _start:
|
|||||||
move.l d0, d2 | Move the number of program headers to d2
|
move.l d0, d2 | Move the number of program headers to d2
|
||||||
move.l a0, a1 | Move the program headaer pointer to a1
|
move.l a0, a1 | Move the program headaer pointer to a1
|
||||||
move.b #0x5, d0 | Get the pointer to the MMU card
|
move.b #0x5, d0 | Get the pointer to the MMU card
|
||||||
bsr.w find_first_card_early
|
jsr (find_first_card - 0xC00000)
|
||||||
cmpa.l #0, a0 | Abort if there is no MMU card
|
cmpa.l #0, a0 | Abort if there is no MMU card
|
||||||
beq.w no_mmu
|
beq.w no_mmu
|
||||||
subq.w #0x1, d2 | Adjust the number of program headers for dbra
|
subq.w #0x1, d2 | Adjust the number of program headers for dbra
|
||||||
@ -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
|
||||||
@ -23,8 +26,8 @@ beq.b even_page
|
|||||||
addq.l #1, d3
|
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), d2 | 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,32 +50,27 @@ 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
|
||||||
|
|
||||||
| Finds the first card with the type in d0.b, and returns it's IO base address in a0, or 0 if not found
|
.text
|
||||||
| Clobbers d1
|
higher_bridge:
|
||||||
find_first_card_early:
|
move.w #1, (0x14, a0) | Enable the MMU
|
||||||
move.l #0xff0000, a0 | a0 holds the address of the current card
|
jmp in_higher:l | Jump to the higher half (THis function has been called with the PC in the
|
||||||
ffc_early_loop:
|
| lower half, so this seemingly no-op jump instruction actually switches to the higher half)
|
||||||
lea (0x100, a0), a0 | Move to the next card
|
in_higher:
|
||||||
move.b (0xff, a0), d1 | Load the type of the card into d1
|
move.w #0, 0xff0000 | Disable the IO space at the top of the lower 16MB of memory
|
||||||
beq.b ffc_early_notfound | If the type is 0 (empty slot), we have scanned all cards, so exit the loop
|
move.l #0, (0x0, a0) | Disable the mapping in the lower quarter
|
||||||
cmp.b d0, d1 | If the card is the type we want, return with the address in a0
|
move.l #bootstrap_stack, a7 | Load the initial stack pointer
|
||||||
beq.b ffc_early_done
|
jmp main | Jump to the kernel's main function
|
||||||
bra.b ffc_early_loop | Loop back and check the next card
|
|
||||||
ffc_early_notfound:
|
|
||||||
move.l #0x0, a0
|
|
||||||
ffc_early_done:
|
|
||||||
rts
|
|
||||||
|
|
||||||
.section .early.bss, "aw", @nobits
|
.section .early.bss, "aw", @nobits
|
||||||
kernel_map:
|
kernel_map:
|
||||||
|
Loading…
Reference in New Issue
Block a user