English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   support.WinUAE (https://eab.abime.net/forumdisplay.php?f=5)
-   -   Masoboshi Mastercard reverse-engineering (was: crashes WinUAE) (https://eab.abime.net/showthread.php?t=87446)

thomas 05 June 2017 13:56

Masoboshi Mastercard reverse-engineering (was: crashes WinUAE)
 
4 Attachment(s)
Choose any quickstart config, add Masoboshi MasterCard IDE controller, click on Start -> WinUAE is gone.

Happens in 3.4.0, 3.3.0 is ok.

Toni Wilen 05 June 2017 15:13

Fixed. (Broke when hw info panel was added)

Note that Masoboshi emulation is not complete. It has weird custom DMA chip and driver also does weird things and at least 2.201 boot ROM does red flashes because it apparently misdetects some IDE transfers as failing (was reported happening with real hardware too).

Really need very rare 2.204 which supposedly fixes all bugs.

mark_k 05 June 2017 22:15

Do you get the red flashes with the 2.202 ROM too (in the SetPatchMC702 1.2 archive on Aminet)?

Toni Wilen 06 June 2017 08:19

I don't remember and I don't want to waste more time with this weird thing without having the board or at least someone confirming its behavior with exact same rom version.

mark_k 06 June 2017 21:30

I'm trying to test a Masoboshi config to see what the problem might be, but (with winuae.exe 2017-06-05 20:21) there are no SCSI accesses in the log.

Config:
Code:

https://www.media!fire.com/?dj5znuesw5b5o7w
Example log output:
Code:

Adding SCSI HD 'masoboshi' unit 0 ('C:\Users\admin\Desktop\WinUAE_shared\Test_HDFs\Masoboshi20MB.hdf')
hfd attempting to open: 'C:\Users\admin\Desktop\WinUAE_shared\Test_HDFs\Masoboshi20MB.hdf'
HDF 'C:\Users\admin\Desktop\WinUAE_shared\Test_HDFs\Masoboshi20MB.hdf' 0F6AD398 opened, size=20480K mode=1 empty=0
memory init end
Reset at 00000000. Chipset mask = 00000001
00000000    2048K/4 =    512K Chip memory
00200000    8192K/0 =    8192K <none>
00A00000    2048K/0 =    2048K CIA
00C00000    512K/1 =    512K Slow memory
00C80000    1024K/0 =    1024K Custom chipset
00D80000    256K/0 =    256K <none>
00DC0000      64K/0 =      64K Battery backed up clock (none)
00DD0000      64K/0 =      64K <none>
00DE0000    128K/0 =    128K Custom chipset
00E00000    512K/1 =    512K Kickstart ROM (FC24AE0D)
=KS ROM v3.1 (A500,A600,A2000) rev 40.63 (512k)
00E80000      64K/0 =      64K Autoconfig Z2
00E90000    960K/0 =    960K <none>
00F80000    512K/1 =    512K Kickstart ROM (FC24AE0D)
=KS ROM v3.1 (A500,A600,A2000) rev 40.63 (512k)
ROM 'Masoboshi MC-702' loaded, 32768 bytes.
Autoconfig board list:
Card 01: 'Z2 Fast RAM'
  ee.03.00.00.08.6d.00.00.00.00.00.00.00.00.00.00
  MID 2157 (086d) PID 3 (03) SER 00000000
  Z2 0x00200000 0x00200000 2048K RAM 0
ROM 'Masoboshi MC-702' loaded, 32768 bytes.
Card 02: 'MasterCard'
  d1.04.40.00.08.6d.00.00.00.00.00.80.00.00.00.00
  MID 2157 (086d) PID 4 (04) SER 00000000
  Z2 0x00e90000 0x00e90000  64K ROM 1
END
PAL mode V=50.0804Hz H=15625.0881Hz (227x312+0) IDX=10 (PAL) D=0 RTG=0/0
D3D9: 752*574 main texture, depth 32
Buffer size (752*574) Native
RTGFREQ: 312*50.0804 = 15625.0879 / 50.1 = 312
POS (0 0 1536 1152) - (-392 -289 376 287)[768,576] (384 288)
ROM VP 00F80000 - 01000000 80000 (512k) UNPROT
hardreset, memory cleared
WASAPI: GetCurrentSharedModeEnginePeriod() CH=2 FREQ=48000 BITS=32 CurrentPeriodInFrames=480
WASAPI: GetSharedModeEnginePeriod() DPIF=480 FPIF=480 MinPIF=480 MaxPIF=480
WASAPI: IsOffloadCapable() returned 0 00000000
WASAPI: '{0.0.0.00000000}.{256d0d50-f86c-485a-a194-b05a5411da52}'
WASAPI: Shared Pull CH=2 FREQ=48000 BUF=1366 (2732)
SERIAL: period=372, baud=9600, hsyncs=14, bits=8, PC=f8018a
Illegal instruction: 4e7b at 00F80C38 -> 00F80CC0
Card 1: Z2 0x00200000 2048K RAM Fast memory
ROM 'Masoboshi MC-702' loaded, 32768 bytes.
PAL mode V=49.9204Hz H=15625.0881Hz (227x312+1) IDX=10 (PAL) D=0 RTG=0/0


Toni Wilen 06 June 2017 21:47

It was even more broken.. Now autoconfig works again.

SCSI does not seem to work (or I did something else wrong), IDE at least still works and causes red flashes.

(btw, check old emails, we really tried to get this working but the SCSI part of driver, at least write code path made no sense)

mark_k 06 June 2017 22:32

Thanks. Looking at the 2.201 driver code, it does some bogus/broken things. For example see the code below from the scan-for-SCSI-drives routine and wince...

It issues MODE SENSE (6) for page 3 (format device page). The CDB has DBD bit 0, but the driver seems to assume the drive doesn't send any block descriptors. And the code checks for some things at the wrong offset...
Code:

READ_CAPACITY_10_CDB
        db        $25,0,0,0,0,0,0,0,0,0

; MODE SENSE (6), page code 3, current values, DBD=0, allocation length $30
MODE_SENSE_6_CDB
        db        $1A,0,3,0,$30,0


; Call with SCSI ID in D7
ScanForScsiDevice
        MOVEQ        #$68,D0        ;$64 + 4 for length
        BSR.W        AllocatePublicMem
        MOVEA.L        A0,A4        ;Pointer to $64 bytes memory
        CLR.W        (2,A4)        ;Clear the 3rd & 4th bytes
        MOVE.L        A4,(SCSICmd-DataArea,A5)        ;Set scsi_Data field
        MOVEQ        #2,D2        ;Try 3 times?

.TryAgain
        MOVE.W        D7,(ioReq_UNIT_low_word-DataArea,A5)
        MOVE.W        #28,(ioReq_COMMAND-DataArea,A5)        ;HD_SCSICMD

        LEA        (SCSICmd-DataArea,A5),A0
        MOVE.L        A0,(ioReq_DATA-DataArea,A5)
; BUG! We issue MODE SENSE (6) with DBD bit 0, meaning the drive may return block descriptors. But the code assumes it doesn't.
        LEA        (MODE_SENSE_6_CDB,PC),A0        ;Page code 3 (format device page), allocation length $30
        MOVE.L        A0,(SCSICmd_Command-DataArea,A5)
        LEA        (SomeIoRequest-DataArea,A5),A1
        MOVEA.L        (_SysBase-DataArea,A5),A6
        JSR        (_LVODoIO,A6)
        CMPI.B        #HFERR_SelTimeout,D0
        BEQ.W        FreeMemReturnMinus1        ;Assume no drive with that ID if HFERR_SelTimeout

        TST.W        D0
        DBEQ        D2,.TryAgain
        BEQ.B        .ModeSense6ExecutedOK

.TryReadCapacityInstead
        MOVE.W        (2,A4),D2
        MOVE.W        D7,(ioReq_UNIT_low_word-DataArea,A5)
        MOVE.W        #28,(ioReq_COMMAND-DataArea,A5)        ;HD_SCSICMD

        LEA        (SCSICmd-DataArea,A5),A0
        MOVE.L        A0,(ioReq_DATA-DataArea,A5)

        LEA        (READ_CAPACITY_10_CDB,PC),A0
        MOVE.L        A0,(SCSICmd_Command-DataArea,A5)

        MOVE.W        #10,(SCSICmd_CmdLength-DataArea,A5)

        LEA        (SomeIoRequest-DataArea,A5),A1
        MOVEA.L        (_SysBase-DataArea,A5),A6
        JSR        (_LVODoIO,A6)
        MOVE.W        #6,(SCSICmd_CmdLength-DataArea,A5)
        TST.W        D0
        BEQ.B        .ReadCapacity10OK

        CLR.W        (6,A4)
        CLR.L        (A4)

.ReadCapacity10OK        MOVE.W        (6,A4),(10,A4)
        MOVE.L        (A4),(4,A4)
        MOVE.W        #$2000,($20,A4)        ;To set bit 5 at offset $20
        MOVE.W        D2,(2,A4)
        BRA.B        lbC000A48

.ModeSense6ExecutedOK
        TST.L        (4,A4)        ;Check tracks per zone and alternate sectors per zone fields (assume page data follows 4-byte mode parameter header)
        BEQ.B        .TryReadCapacityInstead

        TST.W        (10,A4)        ;Check alternate tracks per zone field
        BEQ.B        .TryReadCapacityInstead

lbC000A48
        BTST        #7,(2,A4)        ;Check WP bit (device specific parameter in mode parameter header)
        BEQ.B        .WriteEnabled

        MOVE.W        (OtherWriteProtectedBits???-DataArea,A5),D1
        BSET        D7,D1
        MOVE.W        D1,(OtherWriteProtectedBits???-DataArea,A5)
        MOVE.W        (WriteProtectedBits-DataArea,A5),D1
        BSET        D7,D1
        MOVE.W        D1,(WriteProtectedBits-DataArea,A5)
        BRA.B        lbC000A7A

.WriteEnabled
        MOVE.W        (OtherWriteProtectedBits???-DataArea,A5),D1
        BCLR        D7,D1
        MOVE.W        D1,(OtherWriteProtectedBits???-DataArea,A5)

        MOVE.W        (WriteProtectedBits-DataArea,A5),D1
        BCLR        D7,D1
        MOVE.W        D1,(WriteProtectedBits-DataArea,A5)

; BUG!!! RMB bit is in byte 20 of format device page. Which will be (assuming no block descriptors) at offset 20 + 4 = $18
lbC000A7A        BTST        #5,($20,A4)        ;Check RMB (removable) bit. BUG!!! Should check ($18,A4) !!! ($18 = 20 + 4)
        BEQ.B        .NotRemovable

        MOVE.W        (DriveIsRemovableBits-DataArea,A5),D1
        BSET        D7,D1
        MOVE.W        D1,(DriveIsRemovableBits-DataArea,A5)

        LEA        (AutoParkHalfSecondsTable-DataArea,A5),A0
        MOVE.W        D7,D0
        ADD.W        D0,D0
        ADD.W        D0,D0
        MOVE.L        #6,(A0,D0.W)        ;Default disk change check interval 3 seconds(?)
        BRA.B        .Continue

.NotRemovable
        MOVE.W        (DriveIsRemovableBits-DataArea,A5),D1
        BCLR        D7,D1
        MOVE.W        D1,(DriveIsRemovableBits-DataArea,A5)

.Continue
        MOVE.W        D7,D2
        ADD.W        D2,D2
        MOVE.W        (10,A4),D0        ;BUG!!! Bytes per sector is at offset 12+4 = $10, not 10 decimal!!!
        BNE.B        lbC000AB8

        MOVE.W        #512,D0        ;Default to 512 bytes/sector
lbC000AB8
        MOVE.W        D0,(SectorSizesTable?-DataArea,A5,D2.W)
        MOVE.L        D0,D3
        MULU.W        #9,D3
        MOVE.W        D3,(NineTimesSectorSizeTable-DataArea,A5,D2.W)
        NEG.L        D3


Toni Wilen 07 June 2017 08:16

Quote:

Originally Posted by mark_k (Post 1163252)
Thanks. Looking at the 2.201 driver code, it does some bogus/broken things. For example see the code below from the scan-for-SCSI-drives routine and wince...

It issues MODE SENSE (6) for page 3 (format device page). The CDB has DBD bit 0, but the driver seems to assume the drive doesn't send any block descriptors. And the code checks for some things at the wrong offset...

Nice. Now we have at least one driver that wants at least empty block descriptor (or it blows up, I don't remember which one but I remember adding it because some driver required it) and here is one that don't expect it (or it blows up).

mark_k 07 June 2017 13:56

Looking at the code again I was wrong. The driver assumes the drive does return a block descriptor. It's still broken in various ways though, not only if the drive doesn't return a block descriptor.

The memory it allocates isn't cleared so could contain garbage values.

Assuming the drive returns a block descriptor, then you have:
- four-byte mode parameter header
- 8-byte block descriptor
- mode page 3 data

If MODE SENSE executes OK, driver checks longword at offset 4. That's the first four bytes of the block descriptor, which are: density code (1 byte), number of blocks (3 bytes).

Then it checks the word at offset 10. That's the (low 16 bits of) the block length in the block descriptor.

If both those values are non-zero, it uses them as the number of blocks and block size.

The driver assumes the density code will be zero, i.e. that the 1st 4 bytes are effectively the number of blocks (8GB limit for 512-byte sectors...). But note the SCSI standard says "A value of zero indicates that all of the remaining logical blocks of the logical unit shall have the medium characteristics specified"
(So if a drive returns 0 for the number of blocks field in the block descriptor, providing the density code byte is also 0, the driver will issue READ CAPACITY instead.)

If the driver does issue READ CAPACITY, there's an off-by-one bug; the maximum LBA returned by READ CAPACITY is (number of sectors)-1


Googling for masoboshi 2.204 leads to a page which lists changes between 2.202 and 2.204 firmware:
Code:

-------------------------------------------------- -------------------- -
Masoboshi MC-702 version 2.204
-------------------------------------------------- -------------------- -


History:

2.203 - added auto-detection of removable media (CD-ROMs, ZIPs, etc.)

- sets default parameters now when an alien RDB is read -
DMA OFF, FastTransfer ON, Parity ON, WriteProtect OFF,
WriteCache OFF, RDB-Protection OFF

- fixed some enforcer hits

2.204 - removed red flashing in uncritical situations

- addedVersionString to ROM file


Toni Wilen 07 June 2017 17:03

I think I saw that change log. No red flashes and enforcer hit fixes would be nice to have.

SCSI now works, it was later NCR update that broke it. (in pio mode fifo always contains max 1 byte but there is a special case, it will contain status + message byte(s) after command $11 ICCS. With only status byte in fifo, masoboshi driver still sent $12 accept message but then decided that there is nothing else to do anymore)

mark_k 07 June 2017 20:38

Thanks. Testing with 3.5.0b12 now. SCSI reading seems to work OK. I could boot an OS 3.1-installed HDF which I had previously prepared when IDE-connected. [Not sure if relevant, but I had previously used MasterInstall to disable DMA, so the driver probably wouldn't have tried to use DMA when SCSI-connected.]

But on attempting the first write to it when SCSI-connected, got an error requester:
Part0
has a write error
on disk block 20224


Log output prior to that:
Code:

SCSIEMU HD 0: 08.00.51.05.09.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=4608 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0
SCSIEMU HD 0: 0A.00.51.00.01.00.00.00.00.00.00.00 CMDLEN=6 DATA=0000000007ED06A0
-> DATAOUT=512 ST=0 SENSELEN=0 REPLYLEN=0


There are both A-Max and Chamäleon II drivers for the MasterCard, so next step could be to try those over IDE. I can test the A-Max one myself, but if someone else could try the Chamäleon II (Atari ST emulator) driver that would be great, since I have almost no ST knowledge.

Toni Wilen 07 June 2017 20:41

Yes, SCSI writing is not working, this is the part where driver code makes no sense..

EDIT: Does it have SCSI A-Max driver? It probably is much much much simpler than ROM driver.

mark_k 07 June 2017 21:53

Yes the AMHD handles both IDE and SCSI. Disassembly at
Code:

https://www.media!fire.com/?pfhzp655u7h6m14

Toni Wilen 07 June 2017 21:55

This is the mysterious part from rom driver (from your 2 year old disassembly with extra comments)

Code:

        BTST        #0,(ScsiStatus_DestID_Reg_FA08-ScsiTransferCountLow_FA00,A6)
        BNE.W        lbC0038CA ;data direction out? -> jump to read routine (This works normally, no weird extra 16 bytes)

        MOVE.W        #$1000,D0
        MOVEP.W        D0,(0,A6)        ;Write to BoardAddr+$FA00,$FA02
        MOVE.B        #$90,(ScsiCmdReg_FA06-ScsiTransferCountLow_FA00,A6)        ;$90 = DMA, Information Transfer
        BTST        #3,(IO_FLAGS,A0)
        BNE.B        lbC003730

; First transfer 16 bytes and increase IO_ACTUAL. This is the really weird part.

        MOVEA.L        (IO_ACTUAL,A0),A5
        MOVEM.L        D2-D7/A0-A4/A6,-(SP)
        LEA        (BoardPlusF9CC-ScsiTransferCountLow_FA00,A6),A3
        ADDA.L        (IO_DATA,A0),A5
        MOVE.L        (A5)+,(A3)
        MOVE.L        (A5)+,(A3)
        MOVE.L        (A5)+,(A3)
        MOVE.L        (A5)+,(A3)
        ADDI.L        #$10,(IO_ACTUAL,A0)
        MOVEQ        #0,D0
        MOVEP.W        D0,(0,A6)        ;Write to BoardAddr+$FA00,$FA02
        MOVE.B        #$90,(ScsiCmdReg_FA06-ScsiTransferCountLow_FA00,A6)        ;$90 = DMA, Information Transfer
        MOVEQ        #$11,D1
lbC0037B2        TST.B        (ScsiStatus_DestID_Reg_FA08-ScsiTransferCountLow_FA00,A6)
        BPL.B        lbC0037B2

        TST.B        (ScsiInterrupt_SelReselTimeout_Reg_FA0A-ScsiTransferCountLow_FA00,A6)
        MOVE.B        (IO_FLAGS,A0),D0
        BPL.W        lbC003DB4

<snip IO_FLAGS is not negative>

lbC003DB4        MOVE.B        #8,(BoardPlusF007-ScsiTransferCountLow_FA00,A6)
        MOVE.B        #1,(BoardPlusF004-ScsiTransferCountLow_FA00,A6)
        BRA.B        lbC003DDC

lbC003DC2        MOVEA.L        (_IoRequest-DataArea,A1),A0
        MOVEA.L        (IO_ACTUAL,A0),A5
        MOVEM.L        D2-D7/A0-A4/A6,-(SP)
        BTST        #1,(lbB004805-DataArea,A1)
        BNE.W        lbC003D32

; 256 byte MOVEM transfer loop

lbC003DD8        ADDA.L        (IO_DATA,A0),A5
lbC003DDC        LEA        (BoardPlusF9CC-ScsiTransferCountLow_FA00,A6),A3
lbC003DE0        MOVEM.L        (A5)+,D0-D7/A0-A2/A4/A6
lbC003DE4        MOVEM.L        D0-D7/A0-A2/A4/A6,(A3)
        MOVEM.L        (A5)+,D0-D7/A0-A2/A4/A6
        MOVEM.L        D0-D7/A0-A2/A4/A6,(A3)
        MOVEM.L        (A5)+,D0-D7/A0-A2/A4/A6
        MOVEM.L        D0-D7/A0-A2/A4/A6,(A3)
        MOVEM.L        (A5)+,D0-D7/A0-A2/A4/A6
        MOVEM.L        D0-D7/A0-A2/A4/A6,(A3)
        MOVEM.L        (A5)+,D0-D7/A0-A2/A4
        MOVEM.L        D0-D7/A0-A2/A4,(A3)
        BTST        #0,(BoardPlusF000-BoardPlusF9CC,A3)
        BEQ.B        lbC003DE0

        BTST        #1,(ScsiStatus_DestID_Reg_FA08-BoardPlusF9CC,A3)
        BNE.B        lbC003E48

        MOVEM.L        (A5)+,D0-D7/A0-A2/A4/A6
        BTST        #0,(BoardPlusF000-BoardPlusF9CC,A3)
        BEQ.B        lbC003DE4

        LEA        (-$34,A5),A5
        MOVEM.L        (SP),D2-D7/A0-A4/A6

; final result: if request was 512 byte transfer, actual count was 512+16. Which can't work..

        SUBA.L        (IO_DATA,A0),A5
        MOVE.L        A5,(IO_ACTUAL,A0)
        ST        (BoardPlusF000-ScsiTransferCountLow_FA00,A6)
        BTST        #0,(BoardPlusF000-ScsiTransferCountLow_FA00,A6)
        BEQ.B        lbC003DD8

        LEA        ($30,SP),SP
        MOVEQ        #0,D0
        RTS

lbC003E48        MOVEM.L        (SP)+,D2-D7/A0-A4/A6
        SUBA.L        (IO_DATA,A0),A5
        MOVE.L        A5,(IO_ACTUAL,A0)
        ST        (BoardPlusF000-ScsiTransferCountLow_FA00,A6)
        MOVEQ        #0,D0
        RTS


Toni Wilen 07 June 2017 22:00

Quote:

Originally Posted by mark_k (Post 1163544)
Yes the AMHD handles both IDE and SCSI. Disassembly at
Code:

https://www.media!fire.com/?pfhzp655u7h6m14

This looks normal (and probably already works just fine). 256 unrolled copy loops only. No weird extra 16 bytes anywhere.

Toni Wilen 08 June 2017 17:44

Quote:

- sets default parameters now when an alien RDB is read -
DMA OFF, FastTransfer ON, Parity ON, WriteProtect OFF,
WriteCache OFF, RDB-Protection OFF
Perhaps this change makes the difference? Pre-2.203 defaults to some weird mode that can't work if "alien RDB" (as in normal, I guess..) ? :)

Time to test official installer..

EDIT: 2.1 installer uses same code path. Same 16+512 byte writes (that are impossible because scsi commands are based on blocks, not bytes)

mark_k 08 June 2017 19:47

Masoboshi IDE and SCSI configs, 20MB HDF:
Code:

https://www.media!fire.com/?nx57zhgx6z95935
https://www.media!fire.com/?jnrd52xri71zj4r

To change MasterCard-specific options... Since SCSI writing doesn't work yet, boot with the HDF connected to IDE and make changes. Then try booting with it connected to SCSI. [I'm assuming MasterInstall does actually set the relevant bits in the RDB even if they don't apply to IDE drives.]

Run MasterInstall. Click Spezial. You can select Asynchron, Disconnect/Relselect.
Click MasterCard. There you can select MasterCard-specific options:
- DMA
- "Schnelle ubertragung" (fast transfers?)
- Parity Bit
- Schreibschutz (write-protection)
- RDB-Schutz (write-protection of the RDB area)
- Write Cache

Note: you have to re-set the manual geometry every time you change HDF, since WinUAE helpfully "forgets" it every time... C/H/S 320/4/32.

Toni Wilen 08 June 2017 21:01

I already tested those and I can't get DMA mode active (even if I make CPU very slow or DMA instant). It always does the DMA speed test but then it always uses PIO, ignoring special options, even if only DMA is checked.

SCSI writing "works" as long as caller does not check IO_ACTUAL (Which will be +$10 compared to IO_LENGTH) or IO_ERROR.. ("HFERR_DMA" = $29)

My crystal ball says pre-2.203 DMA mode was always the default which worked as long as speed test selected DMA. (Probably practically always except with some later accelerators).

They also probably didn't want to mention in changelog that the driver was practically broken ("some harmless red flashes fixed"..) :)

mark_k 08 June 2017 21:59

This probably won't help, but here's info on how the MasterCard-specific options are stored in the RDSK sector.

Starting at rdb_ControllerVendor (byte offset $BC) there are 24 bytes:
- 4 ASCII bytes "MaCa"
- checksum byte
- options byte (see below)
- 00 00
- 16 ASCII bytes "MasterCard "
- 00 00 00 00

The checksum byte is chosen so that (the low byte of) the sum of all 28 bytes is 0.

Also, the RDBFB_CTRLRID bit is set in rdb_Flags (not sure whether or not the ROM checks that).

Options byte:
bit 0: DMA
bit 1: Fast transfer
bit 2: Parity bit
bit 3: Write-protection
bit 4: Write cache
bit 5: RDB write-protection

mark_k 09 June 2017 15:48

My current ROM 2.201 disassembly:
Code:

https://www.media!fire.com/?x86d85cx2yv2qfn
About the IO_ACTUAL problem... could that be related to there being a FIFO (in the Masoboshi ASIC)? Look at this code:
Code:

; Called with A6 pointing to board address + $FA00
lbC003A18        MOVEQ        #$11,D0        ;$11 = Initiator command complete sequence
        TST.B        (lbB004805-DataArea,A1)
        BEQ.B        lbC003A76

lbC003A20        BMI.B        lbC003A9A

        MOVEA.L        (_IoRequest-DataArea,A1),A0
        BTST        #2,(IO_FLAGS,A0)
        BEQ.B        lbC003A64

        MOVEA.L        (_BoardPlusF000-DataArea,A1),A5
        MOVE.B        #$10,(BoardPlusF007-BoardPlusF000,A5)
        MOVEQ        #0,D1
        MOVE.B        (ScsiFifoFlags_SynchOffset_Reg_FA0E-ScsiTransferCountLow_FA00,A6),D1
        MOVE.B        #1,(ScsiCmdReg_FA06-ScsiTransferCountLow_FA00,A6)        ;Flush FIFO
        ST        (A5)        ;BoardAddr+$F000
        ANDI.B        #$1F,D1
        NEG.L        D1
        ADD.L        (BoardPlusF10C-BoardPlusF000,A5),D1
        SUB.L        (IO_DATA,A0),D1
        MOVE.L        D1,(IO_ACTUAL,A0)
        CLR.B        (lbB004805-DataArea,A1)
        MOVE.B        D0,(ScsiCmdReg_FA06-ScsiTransferCountLow_FA00,A6)
        MOVEQ        #0,D0
        RTS

lbC003A64        CLR.B        (BoardPlusF007-ScsiTransferCountLow_FA00,A6)
        CLR.B        (lbB004805-DataArea,A1)
        BRA.B        lbC003A76


; Called with A6 pointing to board address + $FA00
lbC003A6E        MOVEQ        #$10,D0        ;$10 = Transfer information
        TST.B        (lbB004805-DataArea,A1)
        BNE.B        lbC003A20

lbC003A76        MOVE.B        (ScsiFifoFlags_SynchOffset_Reg_FA0E-ScsiTransferCountLow_FA00,A6),D1
        ANDI.W        #$1F,D1
        BEQ.B        lbC003A96

        MOVEA.L        (_IoRequest-DataArea,A1),A0
        EXT.L        D1
        SUB.L        D1,(IO_ACTUAL,A0)
        LEA        (ScsiFIFOReg_FA04-ScsiTransferCountLow_FA00,A6),A5
        SUBQ.W        #1,D1
lbC003A90        TST.B        (A5)
        DBRA        D1,lbC003A90

lbC003A96        MOVE.B        D0,(ScsiCmdReg_FA06-ScsiTransferCountLow_FA00,A6)
lbC003A9A        MOVEQ        #0,D0
        RTS

Could the longword at Board+$F10C be a DMA pointer??? And look at the code at lbC003A76. Related to synchronous transfers?
The FAS216 datasheets mentions "Programmable Synchronous Transfer Offsets up to 15 Bytes". Maybe that's why the driver writes 16 "extra" bytes?


All times are GMT +2. The time now is 20:30.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04970 seconds with 11 queries