[hatari-devel] HDC/ACSI command sector count & error handling?
Eero Tamminen
eerot at users.berlios.de
Sun May 1 23:14:06 CEST 2011
Hi,
Uwe, could you comment on this?
On sunnuntai 01 toukokuu 2011, Thomas Huth wrote:
> schrieb Nicolas Pomarède <npomarede at corp.free.fr>:
> > >>> PS. While doing the patches, I noticed:
> > >>> $ grep HDCSectorCount $(find . -type f)
> > >>> ./hdc.h:extern short int HDCSectorCount;
> > >>> ./hdc.c:short int HDCSectorCount;
> > >>> ./hdc.c: fprintf(hdlogFile, "HDC sector count: 0x%x\n",
> > >>> HDCSectorCount);
> > >>> ./fdc.c: HDCSectorCount = 0;
> > >>> ./fdc.c: DMAStatus_ff8606rd |=
> > >>> (HDCSectorCount)?0x2:0; /* HDC */
> > >>> ./fdc.c: DiskControllerByte = HDCSectorCount;
> > >>
> > > From above you can see that "HDCSectorCount" can never get any
> > > other value than zero (unlike e.g. FDCSectorCountRegister which
> > > seems to be used for similar purpose). So what's the point in
> > > having that variable?
> > >
> > > hdc.c code gets the HDC sector count with this macro, it doesn't use
> > > the variable:
> > > #define HD_SECTORCOUNT(a) (a.command[4]& 0xFF) /* get
> > > sector count */
Attached is a cleanup patch for hdc.c which also makes this mismatch
clearer.
> hdc.c originally hasn't been written by me but by Sven de Marothy...
> Dunno why this variable isn't used (anymore)? Maybe it was used in the
> past,
Looking at the first hdc.c source version from 2002:
http://hg.berlios.de/repos/hatari/rev/b518e26c49a6
That code worked similarly already from the beginning.
> or it is not necessary since the ACSI commands are executed
> immediately instead of delayed like the FDC commands?
In fdc.c, that variable (would) affect:
- Read DMA status byte (DMAStatus_ff8606rd variable)
- DiskControllerByte (0xff8604 HW register), when:
if ((DMAModeControl_ff8606wr & 0x18) == 0x08) /* HDC status reg
selected? */
Should those be affected by HDC command sector count, as the fdc.c code
seems to expect, or not, as it happens with the current hdc.c code?
If it should affect them, do all HDC commands have a valid sector count at
command[4], or is the sector count something that's valid only for specific
HDC commands?
If former is true, the new HDC_GetSectorCount() function can just
return HDCCommand.command[4], otherwise e.g. the HD_SECTORCOUNT() macro
could be changed to store the queried sector count to an internal hdc.c
variable that will be returned by that function.
Or if the sector count isn't actually needed, it can be just removed
competely...
And another thing I noticed is that the DMA status register bit is set only
floppy read/write errors, not on HDC/ASCI read/write errors...
- Eero
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hdc.diff
Type: text/x-patch
Size: 9291 bytes
Desc: not available
URL: <https://lists.berlios.de/pipermail/hatari-devel/attachments/20110502/9b7b42ec/attachment.bin>
More information about the hatari-devel
mailing list