1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-01-13 15:17:43 +00:00

IDE: don't write the TFR when drq is possibly asserted

This commit is contained in:
Gyorgy Szombathelyi 2022-08-28 17:44:39 +02:00
parent c4de68b85c
commit 66d9b9718f

61
hdd.c
View File

@ -1191,6 +1191,38 @@ static inline void ATA_ReadSectors(unsigned char* tfr, unsigned short sector, un
WriteStatus(IDE_STATUS_RDY); // pio in (class 1) command type
while (!(GetFPGAStatus() & CMD_IDECMD)); // wait for empty sector buffer
/* Advance CHS address while DRQ is not asserted with the address of last (anticipated) read. */
int block_count_tmp = block_count;
while(block_count_tmp--)
{
if (sector_count!=1)
{
if (sector == hdf[unit].sectors)
{
sector = 1;
head++;
if (head == hdf[unit].heads)
{
head = 0;
cylinder++;
}
}
else
sector++;
}
--sector_count;
}
if (lbamode) {
long newlba = lba+block_count;
sector = newlba & 0xff;
cylinder = newlba >> 8;
head = newlba >> 24;
}
/* Update task file with CHS address */
WriteTaskFile(0, tfr[2], sector, cylinder, (cylinder >> 8), (tfr[6] & 0xF0) | head);
// Indicate the start of the transfer
WriteStatus(IDE_STATUS_IRQ);
switch(hdf[unit].type)
@ -1280,35 +1312,6 @@ static inline void ATA_ReadSectors(unsigned char* tfr, unsigned short sector, un
#endif
break;
}
/* Advance CHS address - address of last read remains. */
while(block_count--)
{
if (sector_count!=1)
{
if (sector == hdf[unit].sectors)
{
sector = 1;
head++;
if (head == hdf[unit].heads)
{
head = 0;
cylinder++;
}
}
else
sector++;
}
--sector_count;
}
if (lbamode) {
sector = lba & 0xff;
cylinder = lba >> 8;
head = lba >> 24;
}
/* Update task file with CHS address */
WriteTaskFile(0, tfr[2], sector, cylinder, (cylinder >> 8), (tfr[6] & 0xF0) | head);
}
WriteStatus(IDE_STATUS_END);
}