mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
Document new wait functions & move constants to their relevant header files
This commit is contained in:
parent
624f4b70f4
commit
4098500445
52
ata.c
52
ata.c
@ -19,29 +19,20 @@
|
||||
#include "scsi.h"
|
||||
#include "string.h"
|
||||
|
||||
#define WAIT_TIMEOUT_MS 0
|
||||
#define WAIT_TIMEOUT_S 5
|
||||
#define ATAPI_POLL_TRIES 100
|
||||
|
||||
static void ata_read_fast (void *, void *);
|
||||
static void ata_write_fast (void *, void *);
|
||||
|
||||
#define ATA_DRQ_WAIT_LOOP_US 50
|
||||
#define ATA_DRQ_WAIT_MS 10
|
||||
#define ATA_DRQ_WAIT_COUNT (ATA_DRQ_WAIT_MS * (1000 / ATA_DRQ_WAIT_LOOP_US))
|
||||
|
||||
#define ATA_BSY_WAIT_LOOP_US 50
|
||||
#define ATA_BSY_WAIT_S 3
|
||||
#define ATA_BSY_WAIT_COUNT (ATA_BSY_WAIT_S * 1000 * (1000 / ATA_BSY_WAIT_LOOP_US))
|
||||
|
||||
#define ATA_RDY_WAIT_LOOP_US 50
|
||||
#define ATA_RDY_WAIT_S 3
|
||||
#define ATA_RDY_WAIT_COUNT (ATA_RDY_WAIT_S * 1000 * (1000 / ATA_RDY_WAIT_LOOP_US))
|
||||
|
||||
static bool ata_wait_drq(struct IDEUnit *unit, ULONG count) {
|
||||
/**
|
||||
* ata_wait_drq
|
||||
*
|
||||
* Poll DRQ in the status register until set or timeout
|
||||
* @param unit Pointer to an IDEUnit struct
|
||||
* @param tries Tries, sets the timeout
|
||||
*/
|
||||
static bool ata_wait_drq(struct IDEUnit *unit, ULONG tries) {
|
||||
struct timerequest *tr = unit->TimeReq;
|
||||
|
||||
for (int i=0; i < count; i++) {
|
||||
for (int i=0; i < tries; i++) {
|
||||
for (int j=0; j<1000; j++) {
|
||||
if ((*unit->drive->status_command & ata_flag_drq) != 0) return true;
|
||||
}
|
||||
@ -54,11 +45,18 @@ static bool ata_wait_drq(struct IDEUnit *unit, ULONG count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ata_wait_not_busy(struct IDEUnit *unit, ULONG count) {
|
||||
/**
|
||||
* ata_wait_not_busy
|
||||
*
|
||||
* Poll BSY in the status register until clear or timeout
|
||||
* @param unit Pointer to an IDEUnit struct
|
||||
* @param tries Tries, sets the timeout
|
||||
*/
|
||||
static bool ata_wait_not_busy(struct IDEUnit *unit, ULONG tries) {
|
||||
struct timerequest *tr = unit->TimeReq;
|
||||
|
||||
for (int i=0; i < count; i++) {
|
||||
if ((*(volatile BYTE *)unit->drive->status_command & ata_flag_busy) == 0) return true;
|
||||
for (int i=0; i < tries; i++) {
|
||||
if ((*unit->drive->status_command & ata_flag_busy) == 0) return true;
|
||||
tr->tr_time.tv_micro = ATA_BSY_WAIT_LOOP_US;
|
||||
tr->tr_time.tv_secs = 0;
|
||||
tr->tr_node.io_Command = TR_ADDREQUEST;
|
||||
@ -67,10 +65,17 @@ static bool ata_wait_not_busy(struct IDEUnit *unit, ULONG count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ata_wait_ready(struct IDEUnit *unit, ULONG count) {
|
||||
/**
|
||||
* ata_wait_not_busy
|
||||
*
|
||||
* Poll RDY in the status register until set or timeout
|
||||
* @param unit Pointer to an IDEUnit struct
|
||||
* @param tries Tries, sets the timeout
|
||||
*/
|
||||
static bool ata_wait_ready(struct IDEUnit *unit, ULONG tries) {
|
||||
struct timerequest *tr = unit->TimeReq;
|
||||
|
||||
for (int i=0; i < count; i++) {
|
||||
for (int i=0; i < tries; i++) {
|
||||
if ((*unit->drive->status_command & (ata_flag_ready | ata_flag_busy)) == ata_flag_ready) return true;
|
||||
tr->tr_time.tv_micro = ATA_RDY_WAIT_LOOP_US;
|
||||
tr->tr_time.tv_secs = 0;
|
||||
@ -79,6 +84,7 @@ static bool ata_wait_ready(struct IDEUnit *unit, ULONG count) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* ata_identify
|
||||
*
|
||||
|
||||
13
ata.h
13
ata.h
@ -65,6 +65,19 @@ enum xfer_dir {
|
||||
WRITE
|
||||
};
|
||||
|
||||
#define ATA_DRQ_WAIT_LOOP_US 50
|
||||
#define ATA_DRQ_WAIT_MS 10
|
||||
#define ATA_DRQ_WAIT_COUNT (ATA_DRQ_WAIT_MS * (1000 / ATA_DRQ_WAIT_LOOP_US))
|
||||
|
||||
#define ATA_BSY_WAIT_LOOP_US 50
|
||||
#define ATA_BSY_WAIT_S 3
|
||||
#define ATA_BSY_WAIT_COUNT (ATA_BSY_WAIT_S * 1000 * (1000 / ATA_BSY_WAIT_LOOP_US))
|
||||
|
||||
#define ATA_RDY_WAIT_LOOP_US 50
|
||||
#define ATA_RDY_WAIT_S 3
|
||||
#define ATA_RDY_WAIT_COUNT (ATA_RDY_WAIT_S * 1000 * (1000 / ATA_RDY_WAIT_LOOP_US))
|
||||
|
||||
|
||||
bool ata_init_unit(struct IDEUnit *);
|
||||
bool ata_identify(struct IDEUnit *, UWORD *);
|
||||
BYTE ata_transfer(void *buffer, ULONG lba, ULONG count, ULONG *actual, struct IDEUnit *unit, enum xfer_dir direction);
|
||||
|
||||
47
atapi.c
47
atapi.c
@ -19,24 +19,17 @@
|
||||
#include "scsi.h"
|
||||
#include "string.h"
|
||||
|
||||
#define ATAPI_DRQ_WAIT_LOOP_US 50
|
||||
#define ATAPI_DRQ_WAIT_MS 10
|
||||
#define ATAPI_DRQ_WAIT_COUNT (ATAPI_DRQ_WAIT_MS * (1000 / ATAPI_DRQ_WAIT_LOOP_US))
|
||||
|
||||
#define ATAPI_BSY_WAIT_LOOP_US 50
|
||||
#define ATAPI_BSY_WAIT_S 5
|
||||
#define ATAPI_BSY_WAIT_COUNT (ATAPI_BSY_WAIT_S * 1000 * (1000 / ATAPI_BSY_WAIT_LOOP_US))
|
||||
|
||||
#define ATAPI_RDY_WAIT_LOOP_US 50
|
||||
#define ATAPI_RDY_WAIT_S 1
|
||||
#define ATAPI_RDY_WAIT_COUNT (ATAPI_RDY_WAIT_S * 1000 * (1000 / ATAPI_RDY_WAIT_LOOP_US))
|
||||
|
||||
static bool atapi_wait_drq(struct IDEUnit *unit, ULONG count) {
|
||||
/**
|
||||
* atapi_wait_drq
|
||||
*
|
||||
* Poll DRQ in the status register until set or timeout
|
||||
* @param unit Pointer to an IDEUnit struct
|
||||
* @param tries Tries, sets the timeout
|
||||
*/
|
||||
static bool atapi_wait_drq(struct IDEUnit *unit, ULONG tries) {
|
||||
struct timerequest *tr = unit->TimeReq;
|
||||
tr->tr_time.tv_micro = ATAPI_DRQ_WAIT_LOOP_US;
|
||||
tr->tr_time.tv_secs = 0;
|
||||
|
||||
for (int i=0; i < count; i++) {
|
||||
for (int i=0; i < tries; i++) {
|
||||
if ((*unit->drive->status_command & ata_flag_drq) != 0) return true;
|
||||
if ((*unit->drive->status_command & (ata_flag_df | ata_flag_error)) != 0) return false;
|
||||
tr->tr_time.tv_micro = ATAPI_DRQ_WAIT_LOOP_US;
|
||||
@ -48,10 +41,17 @@ static bool atapi_wait_drq(struct IDEUnit *unit, ULONG count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool atapi_wait_not_bsy(struct IDEUnit *unit, ULONG count) {
|
||||
/**
|
||||
* atapi_wait_not_bsy
|
||||
*
|
||||
* Poll BSY in the status register until clear or timeout
|
||||
* @param unit Pointer to an IDEUnit struct
|
||||
* @param tries Tries, sets the timeout
|
||||
*/
|
||||
static bool atapi_wait_not_bsy(struct IDEUnit *unit, ULONG tries) {
|
||||
struct timerequest *tr = unit->TimeReq;
|
||||
|
||||
for (int i=0; i < count; i++) {
|
||||
for (int i=0; i < tries; i++) {
|
||||
if ((*(volatile BYTE *)unit->drive->status_command & ata_flag_busy) == 0) return true;
|
||||
tr->tr_time.tv_micro = ATAPI_BSY_WAIT_LOOP_US;
|
||||
tr->tr_time.tv_secs = 0;
|
||||
@ -61,10 +61,17 @@ static bool atapi_wait_not_bsy(struct IDEUnit *unit, ULONG count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool atapi_wait_rdy(struct IDEUnit *unit, ULONG count) {
|
||||
/**
|
||||
* atapi_wait_rdy
|
||||
*
|
||||
* Poll RDY in the status register until set or timeout
|
||||
* @param unit Pointer to an IDEUnit struct
|
||||
* @param tries Tries, sets the timeout
|
||||
*/
|
||||
static bool atapi_wait_rdy(struct IDEUnit *unit, ULONG tries) {
|
||||
struct timerequest *tr = unit->TimeReq;
|
||||
|
||||
for (int i=0; i < count; i++) {
|
||||
for (int i=0; i < tries; i++) {
|
||||
if ((*unit->drive->status_command & (ata_flag_ready | ata_flag_busy)) == ata_flag_ready) return true;
|
||||
tr->tr_time.tv_micro = ATAPI_RDY_WAIT_LOOP_US;
|
||||
tr->tr_time.tv_secs = 0;
|
||||
|
||||
12
atapi.h
12
atapi.h
@ -19,6 +19,18 @@
|
||||
#define ATAPI_CMD_PACKET 0xA0
|
||||
#define ATAPI_CMD_IDENTIFY 0xA1
|
||||
|
||||
#define ATAPI_DRQ_WAIT_LOOP_US 50
|
||||
#define ATAPI_DRQ_WAIT_MS 10
|
||||
#define ATAPI_DRQ_WAIT_COUNT (ATAPI_DRQ_WAIT_MS * (1000 / ATAPI_DRQ_WAIT_LOOP_US))
|
||||
|
||||
#define ATAPI_BSY_WAIT_LOOP_US 50
|
||||
#define ATAPI_BSY_WAIT_S 5
|
||||
#define ATAPI_BSY_WAIT_COUNT (ATAPI_BSY_WAIT_S * 1000 * (1000 / ATAPI_BSY_WAIT_LOOP_US))
|
||||
|
||||
#define ATAPI_RDY_WAIT_LOOP_US 50
|
||||
#define ATAPI_RDY_WAIT_S 1
|
||||
#define ATAPI_RDY_WAIT_COUNT (ATAPI_RDY_WAIT_S * 1000 * (1000 / ATAPI_RDY_WAIT_LOOP_US))
|
||||
|
||||
bool atapi_identify(struct IDEUnit *unit, UWORD *buffer);
|
||||
BYTE atapi_translate(APTR io_Data,ULONG lba, ULONG count, ULONG *io_Actual, struct IDEUnit *unit, enum xfer_dir direction);
|
||||
BYTE atapi_packet(struct SCSICmd *cmd, struct IDEUnit *unit);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user