Tweak timeouts

* Increase loop wait from 100us to 1ms - this makes the timers more accurate on slow 68000 systems
* Increase ATA BSY wait to 10s - Spinning rust can take a while to spool up and become ready
* Skip ata_identify drq wait if error/fault is indicated - this will usually be an ATAPI drive and there's no point waiting
This commit is contained in:
Matt Harlum 2023-09-06 19:06:20 +00:00
parent 25c145c3e1
commit 5db68783fe
3 changed files with 16 additions and 18 deletions

4
ata.c
View File

@ -147,8 +147,7 @@ bool ata_identify(struct IDEUnit *unit, UWORD *buffer)
*unit->drive->error_features = 0;
*unit->drive->status_command = ATA_CMD_IDENTIFY;
if (!ata_wait_drq(unit,5000)) {
if (*unit->drive->status_command & (ata_flag_error | ata_flag_df)) {
if (*unit->drive->status_command & (ata_flag_error | ata_flag_df) || !ata_wait_drq(unit,500)) {
Warn("ATA: IDENTIFY Status: Error\n");
Warn("ATA: last_error: %08lx\n",&unit->last_error[0]);
// Save error information
@ -157,7 +156,6 @@ bool ata_identify(struct IDEUnit *unit, UWORD *buffer)
unit->last_error[2] = *unit->drive->lbaMid;
unit->last_error[3] = *unit->drive->lbaLow;
unit->last_error[4] = *unit->drive->status_command;
}
return false;
}

8
ata.h
View File

@ -72,15 +72,15 @@ enum xfer_dir {
WRITE
};
#define ATA_DRQ_WAIT_LOOP_US 100
#define ATA_DRQ_WAIT_LOOP_US 1000
#define ATA_DRQ_WAIT_S 1
#define ATA_DRQ_WAIT_COUNT (ATA_DRQ_WAIT_S * 1000 * (1000 / ATA_DRQ_WAIT_LOOP_US))
#define ATA_BSY_WAIT_LOOP_US 100
#define ATA_BSY_WAIT_S 3
#define ATA_BSY_WAIT_LOOP_US 1000
#define ATA_BSY_WAIT_S 10
#define ATA_BSY_WAIT_COUNT (ATA_BSY_WAIT_S * 1000 * (1000 / ATA_BSY_WAIT_LOOP_US))
#define ATA_RDY_WAIT_LOOP_US 100
#define ATA_RDY_WAIT_LOOP_US 1000
#define ATA_RDY_WAIT_S 3
#define ATA_RDY_WAIT_COUNT (ATA_RDY_WAIT_S * 1000 * (1000 / ATA_RDY_WAIT_LOOP_US))

View File

@ -19,11 +19,11 @@
#define ATAPI_CMD_PACKET 0xA0
#define ATAPI_CMD_IDENTIFY 0xA1
#define ATAPI_DRQ_WAIT_LOOP_US 100
#define ATAPI_DRQ_WAIT_LOOP_US 1000
#define ATAPI_DRQ_WAIT_MS 500
#define ATAPI_DRQ_WAIT_COUNT (ATAPI_DRQ_WAIT_MS * (1000 / ATAPI_DRQ_WAIT_LOOP_US))
#define ATAPI_BSY_WAIT_LOOP_US 100
#define ATAPI_BSY_WAIT_LOOP_US 1000
#define ATAPI_BSY_WAIT_S 5
#define ATAPI_BSY_WAIT_COUNT (ATAPI_BSY_WAIT_S * 1000 * (1000 / ATAPI_BSY_WAIT_LOOP_US))