News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

symbiface 2 ide

Started by arnoldemu, 13:46, 05 August 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arnoldemu

I have been testing the IDE interface of the symbiface 2 and found some weirdness.

The symbiface 2 supports devices that send back 16-bit data.

When reading a sector I noticed that for every odd byte, (i.e. 2nd byte of the 16-bit data) a read of the status register (and possibly any other IDE register - but I need to confirm that) will return that data and not the status register.

Therefore the following code doesn't work:


c:
ld bc,&fd0f
c1:
in a,(c)
bit 7,a
jr nz,c1
bit 3,a
ret z
ld bc,&fd08
in a,(c)
ld (hl),a
inc hl
jr c


Yes this is a *slow* way to read data because it checks the DRQ is set for each byte. But this should(1) work with multi-sector IDE commands ;)

If I do this:


c:
ld bc,&fd0f
c1:
in a,(c)
bit 7,a
jr nz,c1
bit 3,a
ret z
ld bc,&fd08
in a,(c)
ld (hl),a
inc hl
ld bc,&fd0f
in a,(c)    ;; <- returns second byte of the 16-bit data.
jr c


the read of the status register after reading the data register returns the 2nd byte from the 16-bit data. If I read the status register a 3rd time, I see real status data.

Therefore to do this on a symbiface 2 you need to do this:


c:
ld bc,&fd0f
c1:
in a,(c)
bit 7,a
jr nz,c1
bit 3,a
ret z
ld bc,&fd08
in a,(c)
ld (hl),a
inc hl
ld bc,&fd08
in a,(c)
ld (hl),a
inc hl
jr c


Now, most code will probably do this:


ld bc,&fd0f
c1:
in a,(c)
bit 7,a
jr nz,c1
bit 3,a
ret z

ld de,512
ld bc,&fd08
loop:
in a,(c)
ld (hl),a
inc hl
dec de
ld a,d
or e
jr nz,loop

Or a big long list of INI ;)

I found this while I was verifying the status register values during writing command, transfering data and reading the results.

NOTE (1) - Multi sector reads can be done by setting the number of sectors to read in a read data command.

NOTE:
- X-Mass doesn't have this problem because it sets the DOM into 8-bit transfer mode and the hardware implementation is slightly different
- The ATA specification says that BSY must be checked. If it's 1 the other bits of the status register are not useable. If it's 0, the other bits are valid. To do multisector it will set BSY between sectors, and then BSY=0, DRQ=1 for each byte. The command finishes when both BSY=0 and DRQ=0. This explains this bit of code:

ld bc,&fd0f
c1:
in a,(c)
bit 7,a
jr nz,c1
bit 3,a
ret z


EDIT: I am testing on various old 3.5" HDs which range in size from 512MB up to 8GB and vary in the ATA specification and commands they support.






My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

TFM

The way I do it is to check for availability of the first byte. Then just read 512 bytes in a row. This will work with all devices IMO.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: TFM on 15:40, 05 August 16
The way I do it is to check for availability of the first byte. Then just read 512 bytes in a row. This will work with all devices IMO.  :)
Yes this is the best way. :)
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

#3
Quote from: arnoldemu on 13:46, 05 August 16
When reading a sector I noticed that for every odd byte, (i.e. 2nd byte of the 16-bit data) a read of the status register (and possibly any other IDE register - but I need to confirm that) will return that data and not the status register.
confirmed. A read of *any* register (fd06-fd0f) after the data register will read the 2nd byte of data.

EDIT: You must do a read of the data register to get the first byte.
EDIT: The symbiface 2 can read 16-bit data from the IDE. The first data read probably sets an internal flip-flop so that that the next read reads the next byte.
EDIT: Flip flop is possibly reset and data cached from device when /DACK or similar is output from device.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

TFM

The CPC-IDE is the IDE part of the SF2. Back the day I was part of the development team, and one of the main goals was to read from 16 bit data bus devices. So yes, 16 bit get read and then transferred in two 8 bit steps.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: TFM on 23:36, 06 August 16
The CPC-IDE is the IDE part of the SF2. Back the day I was part of the development team, and one of the main goals was to read from 16 bit data bus devices. So yes, 16 bit get read and then transferred in two 8 bit steps.  :)
:)
It's nice. I hope one day to do some testing with CD-ROM.

I like to find the exact operation so I can emulate it fully and document it fully. I know most people who write their own code will check for first byte and then read all 512 bytes because it is the most efficient way.

I read from the wiki that CPC-IDE is based on GIDE.

My testing shows it is the same idea but not the same implementation (i.e. the equations are not reimplemented exactly in the Symbiface 2 ICs).

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

TFM

Yes, Tilman's GIDE is the base.  But GIDE used 8 bit I/O while the CPC needs 16 bit I/O (address bus). So GIDE can work f.e. with the Joyce PCW.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Powered by SMFPacks Menu Editor Mod