Compare commits

...

2 Commits

2 changed files with 35 additions and 35 deletions

View File

@ -1,5 +1,5 @@
; reloc.S
; Modified from Open Source A4091.device by Stefan Reinauer and Chris Hooper - https://github.com/A4091/a4091-software
; Modified from Open Source A4091.device by Stefan Reinauer and Chris Hooper - https://github.com/A4091/a3091-software
INCLUDE "exec/memory.i"
INCLUDE "lvo/exec_lib.i"
@ -9,6 +9,12 @@
NUM_ENTRIES EQU 5
; Frame pointer offsets
PHUNKS EQU -4
READHANDLE_TYPE EQU -8
READHANDLE_CURRENT EQU -12
FP_SIZE EQU READHANDLE_CURRENT
; API:
; Zorro ROM access:
; a0: rombase
@ -19,6 +25,7 @@ NUM_ENTRIES EQU 5
public _relocate
_relocate
movem.l d1-d7/a0-a6,-(sp)
link a4,#FP_SIZE
bsr InitHandle
@ -39,7 +46,7 @@ _relocate
; Go through hunk header and allocate all segments
move.l 4,a6 ; execbase
move.l pHunks(pc),a2 ; segment pointers
move.l PHUNKS(a4),a2 ; segment pointers
lea.l 4*NUM_ENTRIES(a2),a3 ; segment lengths
.AllocateLoop
moveq.l #MEMF_PUBLIC,d1
@ -54,7 +61,7 @@ _relocate
move.l d0,(a2)+ ; segment pointer
dbra d7,.AllocateLoop
move.l pHunks(pc),a5
move.l PHUNKS(a4),a5
.HunkLoop
move.l (a5),a0 ; current hunk
bsr RomFetch32
@ -85,6 +92,7 @@ _relocate
ENDIF
bsr .RelocateCleanup
moveq.l #0,d0 ; NULL = Failure
unlk a4
movem.l (sp)+,d1-d7/a0-a6
rts
@ -129,16 +137,16 @@ _relocate
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
lsl.l #2,d2 ; *4 ; offset from Hunks
move.l pHunks(pc),a2
move.l PHUNKS(a4),a2
add.l d2,a2 ; hunk number num
move.l (a2),d3 ; base address of hunk
.Reloc32Tight
bsr RomFetch32
; get baseaddr + d0, add d3 to the data there.
move.l a0,a4
add.l d0,a4
add.l d3,(a4)
move.l a0,a3
add.l d0,a3
add.l d3,(a3)
dbra d1,.Reloc32Tight
bra .HunkReloc32
@ -158,21 +166,21 @@ _relocate
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
lsl.l #2,d2 ; *4 ; offset from Hunks
move.l pHunks(pc),a2
move.l PHUNKS(a4),a2
add.l d2,a2 ; hunk number num
move.l (a2),d3 ; base address of hunk
.Reloc32ShortTight
bsr RomFetch16
; get baseaddr + d0, add d3 to the data there.
move.l a0,a4
add.l d0,a4
add.l d3,(a4)
move.l a0,a3
add.l d0,a3
add.l d3,(a3)
dbra d1,.Reloc32ShortTight
bra .HunkReloc32Short
.HunkLoopPrep
lea ReadHandle(pc),a2
lea READHANDLE_CURRENT(a4),a2
move.l (a2),d0 ; align pointer to longword
addq.l #2,d0 ; in case we had an odd number
and.l #$fffffffc,d0 ; of relocations
@ -202,17 +210,18 @@ _relocate
bsr.s CreateSegList
move.l pHunks(pc),a0
move.l PHUNKS(a4),a0
move.l (a0),d2
subq.l #4,d2
bsr.s .RelocateCleanup
move.l d2,d0
unlk a4
movem.l (sp)+,d1-d7/a0-a6
rts
.RelocateCleanup
move.l pHunks(pc),a1
move.l PHUNKS(a4),a1
moveq.l #(8*NUM_ENTRIES),d0
jsr _LVOFreeMem(a6)
rts
@ -233,7 +242,7 @@ _relocate
; +->| | | | 0| | | | | 0|
; +--+--+--+--+ +--+--+--+--+
CreateSegList:
move.l pHunks(pc),a0
move.l PHUNKS(a4),a0
.NextSeg
move.l (a0),a1 ; Hunks[x]
@ -269,10 +278,10 @@ RomFetch32
RomFetch
movem.l a0-a1/d1-d3,-(sp)
lea ReadHandle(pc),a1
lea READHANDLE_CURRENT(a4),a1
move.l (a1),a0
tst.l 4(a1) ; access type Zorro?
tst.l READHANDLE_TYPE(a4) ; access type Zorro?
bne.s .RomFetchZ
cmp.b #3,d0
@ -310,7 +319,7 @@ RomFetch
rts
InitHandle
; initialize readhandle to beginning of device driver
; initialize READHANDLE_CURRENT to beginning of device driver
; ROM_OFFSET needs to be multiplied by 4 because of the
; nibble mapped nature of the AutoConfig ROM.
; ROM_ADDRESS is passed in a0
@ -320,24 +329,15 @@ InitHandle
ENDIF
add.l d0,a0
lea ReadHandle(pc),a1
move.l a0,(a1) ; memory location passed in a0
move.l d0,4(a1) ; Set access type: 0 = memory, Zorro otherwise
move.l a0,READHANDLE_CURRENT(a4) ; memory location passed in a0
move.l d0,READHANDLE_TYPE(a4) ; Set access type: 0 = memory, Zorro otherwise
moveq.l #(8*NUM_ENTRIES),d0
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
jsr _LVOAllocMem(a6)
lea pHunks(pc),a1
move.l d0,(a1)
move.l d0,PHUNKS(a4)
rts
ReadHandle
dc.l 0 ; Current address
dc.l 0 ; 0=memory, otherwise Zorro
pHunks
dc.l 0
IFD HAVE_ERRNO
public _rErrno
_rErrno

View File

@ -165,7 +165,7 @@ static BYTE scsi_read_capacity_ata(struct IDEUnit *unit, struct SCSICmd *scsi_co
if (cdb->flags & 0x01) {
// Partial Medium Indicator - Return end of cylinder
// Implement this so HDToolbox stops moaning about track size
ULONG spc = unit->cylinders * unit->heads;
ULONG spc = unit->sectorsPerTrack * unit->heads;
data->lba = (((cdb->lba / spc) + 1) * spc) - 1;
} else {
data->lba = (unit->logicalSectors) - 1;
@ -213,7 +213,7 @@ static BYTE scsi_mode_sense_ata(struct IDEUnit *unit, struct SCSICmd *scsi_comma
UBYTE idx = 4;
if (page == 0x3F || page == 0x03) {
data[idx++] = 0x03; // Page Code: Format Parameters
data[idx++] = 0x18; // Page length
data[idx++] = 0x16; // Page length
for (int i=0; i <8; i++) {
data[idx++] = 0;
}
@ -221,19 +221,19 @@ static BYTE scsi_mode_sense_ata(struct IDEUnit *unit, struct SCSICmd *scsi_comma
data[idx++] = unit->sectorsPerTrack;
data[idx++] = (unit->blockSize >> 8);
data[idx++] = unit->blockSize;
for (int i=0; i<12; i++) {
for (int i=0; i<10; i++) {
data[idx++] = 0;
}
}
if (page == 0x3F || page == 0x04) {
data[idx++] = 0x04; // Page code: Rigid Drive Geometry Parameters
data[idx++] = 0x17; // Page length
data[idx++] = 0x16; // Page length
data[idx++] = (unit->cylinders >> 16);
data[idx++] = (unit->cylinders >> 8);
data[idx++] = unit->cylinders;
data[idx++] = unit->heads;
for (int i=0; i<19; i++) {
for (int i=0; i<18; i++) {
data[idx++] = 0;
}
}