View Single Post
Old 24 March 2015, 14:36   #5
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,175
Byte accesses. I'm trying to understand the DataFlyer 4000 SCSI+ driver code. The DataFlyer 1200 SCSI+ code differs by only a few bytes due to the different IDE base address. [The wrong driver disk is linked on the amiga.resource.cx page. The correct driver is http://www.l8r.net/install/hard_driv...erScsiPlus.DMS.]

Those products are a bit weird/interesting. A small board which contains a 5380 SCSI chip and one other chip (a PAL/GAL I assume), and connects to the A4000 IDE port. So the driver code accesses the 5380 via the IDE port registers somehow. (The driver code is a bit difficult to follow. Written by the same developer who did the old C Ltd SCSI software. Too many files/layers, though this time they're all in a single driver file.)

Anyway, here are a couple of code fragments that access $1000+ registers.
Code:
IssueIdentifyDrive	MOVE.B	#8,($101A,A4)
	BSR.W	CheckForDrive
	BNE.B	.ReturnMinus1

	MOVE.W	#$EC,D0	;$EC = IDENTIFY DRIVE
	BSR.W	WriteDriveHeadRegAndIssueATACommand
	BNE.B	.ReturnMinus1

	BSR.W	lbC001D08
	BNE.B	.ReturnMinus1

	BSR.W	WaitUntilNotBusyWithTimeout
	BNE.B	.ReturnMinus1

	MOVE.B	($1C,A4),D0	;Read Status Register
	ANDI.B	#%11101001,D0	;Look at busy, drive ready, drive write fault, data request, error bits
	EORI.B	#%01001000,D0	;Want drive ready and drive seek complete bits to be set, others clear
	BNE.B	.ReturnMinus1

	MOVEQ	#0,D0
	RTS

.ReturnMinus1	MOVEQ	#-1,D0
	RTS



CheckForDrive	MOVEM.L	D0/D1/A2,-(SP)
	LEA	($9E,A5),A2
	MOVE.B	($33,A3),D0
	BEQ.B	lbC001E8E

	LEA	($AE,A5),A2
lbC001E8E	ORI.B	#%10100000,D0	;Set the must-be-1 bits
	MOVE.B	D0,($18,A4)	;Write to Drive/Head Register
	MOVE.B	#8,($101A,A4)
	BSR.W	WriteToDriveHeadRegWaitUntilNotBusy
	BNE.B	.ReturnMinus1

lbC001EA2	MOVE.B	D0,(12,A4)	;Write to Sector Number Register
	TST.L	(_custom+intenar).L
	CMP.B	(12,A4),D0	;Read Sector Number Register
	BNE.B	.ReturnMinus1

	ADDQ.B	#1,D0
	ANDI.B	#31,D0
	BNE.B	lbC001EA2

.Return	MOVE.B	D0,(14,A2)
	MOVEM.L	(SP)+,D0/D1/A2
	RTS

.ReturnMinus1	MOVEQ	#-1,D0
	BRA.B	.Return



WriteDriveHeadRegAndIssueATACommand
	MOVE.B	($33,A3),D1
	ORI.B	#%10100000,D1	;Set the must-be-1 bits
	MOVE.B	D1,($18,A4)	;Write to Drive/Head Register

IssueATACommand	MOVE.B	#8,($101A,A4)
	MOVE.B	($1C,A4),D1	;Read Status Register
	ANDI.B	#%11000000,D1	;Look at BSY and DRDY bits
	EORI.B	#%01000000,D1	;Want BSY = 0, DRDY = 1
	BNE.B	.ReturnMinus1

	MOVE.B	D0,($1C,A4)	;Write to Command Register
	MOVEQ	#0,D0
	RTS

.ReturnMinus1	MOVEQ	#-1,D0
	RTS



lbC001D08	MOVE.W	#300,D1
	BSR.W	ReadCiaaTODPlusD1
lbC001D10	BSR.W	HasTimeoutExpired
	BCC.B	.TimeoutNotExpired

	BSR.B	lbC001D50
	MOVEQ	#-1,D0
	RTS

.TimeoutNotExpired	MOVE.B	#5,($100E,A4)
	MOVE.B	#0,($1006,A4)
	MOVE.B	#15,D0
	AND.B	($100E,A4),D0
	CMPI.B	#5,D0
	BNE.B	lbC001D10

	MOVE.B	#10,($100E,A4)
	MOVE.B	#0,($1006,A4)
	MOVE.B	#15,D0
	AND.B	($100E,A4),D0
	CMPI.B	#10,D0
	BNE.B	lbC001D10


lbC001D50	MOVEQ	#0,D0
	MOVE.B	D0,($1006,A4)
	MOVE.B	D0,($100A,A4)
	MOVE.B	D0,($100E,A4)
	RTS
mark_k is offline  
 
Page generated in 0.04397 seconds with 11 queries