mirror of
https://github.com/elliotnunn/tbxi-patches.git
synced 2024-06-01 08:41:26 +00:00
a8c1a4de1c
Key realisations: 1. The driver entry point only needs to be called once per disk, not once per bootable partition. Bootability is decided elsewhere. 2. As a result, my shim code does not need to access the disk at all. 3. None of the ROM-based ATADisk drivers support "slave" drives. 4. Apple drivers (contrary to the Monster Disk Driver Technote) only care about D5 (the drive ID and some flags) on entry.
107 lines
2.4 KiB
Plaintext
107 lines
2.4 KiB
Plaintext
; Asm ATALoad.a -o ATALoad.a.o; DumpObj ATALoad.a.o > ATALoad.dmp
|
|
; The python script does the rest.
|
|
|
|
MAIN
|
|
MACHINE MC68030
|
|
|
|
lea $10(sp),a0 ; re-push the 12 bytes of arguments onto the stack
|
|
move.l -(a0),-(sp)
|
|
move.l -(a0),-(sp)
|
|
move.l -(a0),-(sp)
|
|
bsr.s OriginalFunc ; ... and call the function
|
|
add.l #$C,sp ; pop those copied arguments, we don't need them
|
|
|
|
; move.l d0,-(sp)
|
|
; move.l d0,a0
|
|
; bsr PrintHex
|
|
; move.l (sp)+,d0
|
|
|
|
cmp.l #$FFFFDB93,d0 ; ATANoDriverErr -> try our method
|
|
beq.s NewFunc
|
|
cmp.l #$FFFFDB92,d0 ; ATANoDDMErr -> try our method
|
|
beq.s NewFunc
|
|
rts ; don't try our method
|
|
|
|
|
|
OriginalFunc
|
|
string asis
|
|
dc.b 'Nsrt' ; LINKER SCRIPT
|
|
bra *+2+'ID' ; LINKER SCRIPT
|
|
|
|
|
|
NewFunc
|
|
link a6,#-4
|
|
movem.l d5,-4(a6)
|
|
|
|
; 16(a6).L = !AfterSystemStartupTime
|
|
; 12(a6).L = $0701, the DDMap ID for a Mac driver
|
|
; 8(a6).L = device ID (i.e. devNum<<8 | busNum)
|
|
|
|
; move.l 16(a6),a0
|
|
; bsr PrintHex
|
|
; move.l 12(a6),a0
|
|
; bsr PrintHex
|
|
; move.l 8(a6),a0
|
|
; bsr PrintHex
|
|
|
|
cmp.w #$0701,12+2(a6)
|
|
bne.s @fail
|
|
|
|
move.l #'Size',d0 ; LINKER SCRIPT
|
|
dc.w $A51E ; _NewPtrSys
|
|
tst.l A0
|
|
beq.s @fail
|
|
|
|
move.l a0,a1
|
|
lea *+2+'At',a0 ; LINKER SCRIPT
|
|
move.l #'Size',d0 ; LINKER SCRIPT
|
|
dc.w $A02E ; _BlockMove
|
|
|
|
move.l 8(a6),d5 ; put device number in this byte
|
|
and.l #$0000FF00,d5
|
|
|
|
move.l 8(a6),d0 ; put bus number in this byte
|
|
swap d0
|
|
and.l #$00FF0000,d0
|
|
or.l d0,d5
|
|
|
|
tst.b 16+3(a6)
|
|
bne.s @rom
|
|
bset.l #31,d5 ; kAfterSystemStartupTime
|
|
@rom
|
|
|
|
jsr 8(a0) ; ATAMgr v2 entry point
|
|
; never mind the spec, only set d5
|
|
|
|
; move.l d0,a0
|
|
; bsr PrintHex
|
|
|
|
bra.s @return
|
|
|
|
@fail
|
|
move.l #$FFFFDB93,d0
|
|
@return
|
|
movem.l -4(a6),d5
|
|
unlk a6
|
|
rts
|
|
|
|
|
|
END
|
|
|
|
|
|
string c
|
|
mystring dc.b 'log from ATALoad ^n'
|
|
PrintHex ; A0 is already set to a number...
|
|
MOVE.L #4, D1 ; r4 arg (1: byte, 2: 2byte, else: 4byte)
|
|
MOVE.L #97, D0 ; call NKPrintHex
|
|
DC.W $FE1F
|
|
|
|
LEA mystring,A0
|
|
MOVE.L #96, D0 ; call NKXprintf
|
|
DC.W $FE1F
|
|
|
|
RTS ; stack is safe!
|
|
|
|
|
|
END
|