Switch to use DMA and clean up boot code
This commit is contained in:
parent
52d5e67f44
commit
cbcb7010c6
@ -22,21 +22,20 @@ phead_loop:
|
|||||||
move.l (a0), d1 | If the type of the program header isn't 1 (LOAD), skip the header
|
move.l (a0), 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_seg
|
bne.b next_seg
|
||||||
| Zero the destination memory of the program header
|
| Zero the destination memory
|
||||||
move.l (20, a0), d1 | Put the memory size of the program header - 1 in d1
|
move.l (20, a0), d1 | Put the memory size - 1 in d1
|
||||||
subq.l #0x1, d1
|
subq.l #0x1, d1
|
||||||
move.l (8, a0), a1 | Put the starting memory address of the program header in a1
|
move.l (8, a0), a1 | Put the starting memory address in a1
|
||||||
zero_loop:
|
zero_loop:
|
||||||
move.b #0, (a1)+ | Zero a byte of the destination memory
|
move.b #0, (a1)+ | Zero a byte of the destination memory
|
||||||
dbra d1, zero_loop | Loop back if there is more to zero
|
dbra d1, zero_loop | Loop back if there is more to zero
|
||||||
| Copy the data of the program header from the loaded file into position
|
| Copy the data from the loaded file into position
|
||||||
move.l (16, a0), d1 | Put the file size of the program header - 1 in d1
|
move.l (16, a0), d1 | Put the file size - 1 in d1
|
||||||
|
beq.b next_seg | If the file size is 0, skip the copy (ex, .bss section)
|
||||||
subq.l #0x1, d1
|
subq.l #0x1, d1
|
||||||
cmpi.l #0xFFFFFFFF, d1 | If the file size is 0, skip the copy (ex, .bss section)
|
move.l (4, a0), a1 | Put the address of the loaded data in a1
|
||||||
beq.b next_seg
|
|
||||||
move.l (4, a0), a1 | Put the address of the start of the loaded program header's data in a1
|
|
||||||
adda.l #0xA000, a1
|
adda.l #0xA000, a1
|
||||||
move.l (8, a0), a2 | Put the starting memory address of the program header in a2
|
move.l (8, a0), a2 | Put the starting memory address in a2
|
||||||
load_loop:
|
load_loop:
|
||||||
move.b (a1)+, (a2)+ | Copy a byte of data into position
|
move.b (a1)+, (a2)+ | Copy a byte of data into position
|
||||||
dbra d1, load_loop | Loop back if there is more to copy
|
dbra d1, load_loop | Loop back if there is more to copy
|
||||||
@ -68,22 +67,11 @@ ffc_done:
|
|||||||
| Destination in a1
|
| Destination in a1
|
||||||
| Start sector in d0.l
|
| Start sector in d0.l
|
||||||
| Sector count in d1.l
|
| Sector count in d1.l
|
||||||
| Clobbers a1, d1
|
|
||||||
read_sectors:
|
read_sectors:
|
||||||
move.l d0, (a0) | Set the sector number
|
move.l d0, (a0) | Set the sector number
|
||||||
move.l d1, (4, a0) | Set the sector count
|
move.l d1, (4, a0) | Set the sector count
|
||||||
move.w #0x0, (8, a0) | Issue a read command
|
move.l a1, (0xC, a0) | Set the destination address
|
||||||
| Transfer 0x200 (512) * sector_count bytes from the storage card's data register to (a1)
|
move.w #0x1, (8, a0) | Issue a DMA read command
|
||||||
lsl.l #8, d1 | d0 = d0 * 256 to compute the number of words to transfer
|
|
||||||
subq.l #0x1, d1 | Subtract 1 from the word count to account for the extra loop done by dbra
|
|
||||||
bra.b rs_loop
|
|
||||||
rs_loop_swap:
|
|
||||||
swap.w d1
|
|
||||||
rs_loop:
|
|
||||||
move.w (0xA, a0), (a1)+ | Transfer a word of sector data to the destination
|
|
||||||
dbra.w d1, rs_loop
|
|
||||||
swap.w d1
|
|
||||||
dbra.w d1, rs_loop_swap
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.if . != 512
|
.if . != 512
|
||||||
|
Loading…
Reference in New Issue
Block a user