mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
Rename wait() and wait_us() to sleep_s() and sleep_us()
This commit is contained in:
parent
f5072bc308
commit
7ebee9f2ea
10
ata.c
10
ata.c
@ -18,7 +18,7 @@
|
|||||||
#include "scsi.h"
|
#include "scsi.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "blockcopy.h"
|
#include "blockcopy.h"
|
||||||
#include "wait.h"
|
#include "sleep.h"
|
||||||
#include "lide_alib.h"
|
#include "lide_alib.h"
|
||||||
|
|
||||||
static BYTE write_taskfile_lba(struct IDEUnit *unit, UBYTE command, ULONG lba, UBYTE sectorCount, UBYTE features);
|
static BYTE write_taskfile_lba(struct IDEUnit *unit, UBYTE command, ULONG lba, UBYTE sectorCount, UBYTE features);
|
||||||
@ -94,7 +94,7 @@ static bool ata_wait_drq(struct IDEUnit *unit, ULONG tries, bool fast) {
|
|||||||
if ((status & ata_flag_drq) != 0) return true;
|
if ((status & ata_flag_drq) != 0) return true;
|
||||||
if (status & (ata_flag_error | ata_flag_df)) return false;
|
if (status & (ata_flag_error | ata_flag_df)) return false;
|
||||||
}
|
}
|
||||||
wait_us(tr,ATA_DRQ_WAIT_LOOP_US);
|
sleep_us(tr,ATA_DRQ_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
Trace("wait_drq timeout\n");
|
Trace("wait_drq timeout\n");
|
||||||
return false;
|
return false;
|
||||||
@ -117,7 +117,7 @@ static bool ata_wait_not_busy(struct IDEUnit *unit, ULONG tries) {
|
|||||||
for (int j=0; j<100; j++) {
|
for (int j=0; j<100; j++) {
|
||||||
if ((*unit->drive.status_command & ata_flag_busy) == 0) return true;
|
if ((*unit->drive.status_command & ata_flag_busy) == 0) return true;
|
||||||
}
|
}
|
||||||
wait_us(tr,ATA_BSY_WAIT_LOOP_US);
|
sleep_us(tr,ATA_BSY_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ static bool ata_wait_ready(struct IDEUnit *unit, ULONG tries) {
|
|||||||
for (int j=0; j<1000; j++) {
|
for (int j=0; j<1000; j++) {
|
||||||
if ((*unit->drive.status_command & (ata_flag_ready | ata_flag_busy)) == ata_flag_ready) return true;
|
if ((*unit->drive.status_command & (ata_flag_ready | ata_flag_busy)) == ata_flag_ready) return true;
|
||||||
}
|
}
|
||||||
wait_us(tr,ATA_RDY_WAIT_LOOP_US);
|
sleep_us(tr,ATA_RDY_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ bool ata_select(struct IDEUnit *unit, UBYTE select, bool wait)
|
|||||||
*unit->drive.devHead = select;
|
*unit->drive.devHead = select;
|
||||||
|
|
||||||
if (changed && wait) {
|
if (changed && wait) {
|
||||||
wait_us(unit->itask->tr,5); // Could possibly be replaced with call to ata_status_reg_delay
|
sleep_us(unit->itask->tr,5); // Could possibly be replaced with call to ata_status_reg_delay
|
||||||
ata_wait_not_busy(unit,ATA_BSY_WAIT_COUNT);
|
ata_wait_not_busy(unit,ATA_BSY_WAIT_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
atapi.c
16
atapi.c
@ -18,7 +18,7 @@
|
|||||||
#include "atapi.h"
|
#include "atapi.h"
|
||||||
#include "scsi.h"
|
#include "scsi.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "wait.h"
|
#include "sleep.h"
|
||||||
#include "blockcopy.h"
|
#include "blockcopy.h"
|
||||||
#include "lide_alib.h"
|
#include "lide_alib.h"
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ static bool atapi_wait_drq(struct IDEUnit *unit, ULONG tries) {
|
|||||||
atapi_status_reg_delay(unit);
|
atapi_status_reg_delay(unit);
|
||||||
for (int i=0; i < tries; 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_drq) != 0) return true;
|
||||||
wait_us(tr,ATAPI_DRQ_WAIT_LOOP_US);
|
sleep_us(tr,ATAPI_DRQ_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
Trace("atapi_wait_drq timeout\n");
|
Trace("atapi_wait_drq timeout\n");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ static bool atapi_wait_drq_not_bsy(struct IDEUnit *unit, ULONG tries) {
|
|||||||
|
|
||||||
for (int i=0; i < tries; i++) {
|
for (int i=0; i < tries; i++) {
|
||||||
if ((*unit->drive.status_command & (ata_flag_busy | ata_flag_drq)) == ata_flag_drq) return true;
|
if ((*unit->drive.status_command & (ata_flag_busy | ata_flag_drq)) == ata_flag_drq) return true;
|
||||||
wait_us(tr,ATAPI_DRQ_WAIT_LOOP_US);
|
sleep_us(tr,ATAPI_DRQ_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ static bool atapi_wait_not_bsy(struct IDEUnit *unit, ULONG tries) {
|
|||||||
|
|
||||||
for (int i=0; i < tries; i++) {
|
for (int i=0; i < tries; i++) {
|
||||||
if ((*unit->drive.status_command & ata_flag_busy) == 0) return true;
|
if ((*unit->drive.status_command & ata_flag_busy) == 0) return true;
|
||||||
wait_us(tr,ATAPI_BSY_WAIT_LOOP_US);
|
sleep_us(tr,ATAPI_BSY_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
Trace("atapi_wait_not_bsy timeout\n");
|
Trace("atapi_wait_not_bsy timeout\n");
|
||||||
return false;
|
return false;
|
||||||
@ -106,7 +106,7 @@ static bool atapi_wait_not_drqbsy(struct IDEUnit *unit, ULONG tries) {
|
|||||||
|
|
||||||
for (int i=0; i < tries; i++) {
|
for (int i=0; i < tries; i++) {
|
||||||
if ((*(volatile BYTE *)unit->drive.status_command & (ata_flag_busy | ata_flag_drq)) == 0) return true;
|
if ((*(volatile BYTE *)unit->drive.status_command & (ata_flag_busy | ata_flag_drq)) == 0) return true;
|
||||||
wait_us(tr,ATAPI_BSY_WAIT_LOOP_US);
|
sleep_us(tr,ATAPI_BSY_WAIT_LOOP_US);
|
||||||
}
|
}
|
||||||
Trace("atapi_wait_not_drqbsy timeout\n");
|
Trace("atapi_wait_not_drqbsy timeout\n");
|
||||||
return false;
|
return false;
|
||||||
@ -155,7 +155,7 @@ void atapi_dev_reset(struct IDEUnit *unit) {
|
|||||||
bool atapi_check_signature(struct IDEUnit *unit) {
|
bool atapi_check_signature(struct IDEUnit *unit) {
|
||||||
|
|
||||||
atapi_dev_reset(unit);
|
atapi_dev_reset(unit);
|
||||||
wait_us(unit->itask->tr,10000);
|
sleep_us(unit->itask->tr,10000);
|
||||||
for (int i=0; i<20; i++) {
|
for (int i=0; i<20; i++) {
|
||||||
if ((*unit->drive.lbaHigh == 0xEB) && (*unit->drive.lbaMid == 0x14)) return true;
|
if ((*unit->drive.lbaHigh == 0xEB) && (*unit->drive.lbaMid == 0x14)) return true;
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ BYTE atapi_translate(APTR io_Data, ULONG lba, ULONG count, ULONG *io_Actual, str
|
|||||||
case 0x02: // Unit not ready
|
case 0x02: // Unit not ready
|
||||||
if (asc == 0x4) { // Becoming ready
|
if (asc == 0x4) { // Becoming ready
|
||||||
ret = TDERR_DiskChanged;
|
ret = TDERR_DiskChanged;
|
||||||
wait(unit->itask->tr,1); // Wait
|
sleep_s(unit->itask->tr,1); // Wait
|
||||||
continue; // and try again
|
continue; // and try again
|
||||||
} else {
|
} else {
|
||||||
ret = TDERR_DiskChanged; // No media
|
ret = TDERR_DiskChanged; // No media
|
||||||
@ -538,7 +538,7 @@ BYTE atapi_test_unit_ready(struct IDEUnit *unit) {
|
|||||||
if (asc == 4) { // Becoming ready
|
if (asc == 4) { // Becoming ready
|
||||||
// The medium is becoming ready, wait a few seconds before checking again
|
// The medium is becoming ready, wait a few seconds before checking again
|
||||||
ret = TDERR_DiskChanged;
|
ret = TDERR_DiskChanged;
|
||||||
if (tries > 0) wait(unit->itask->tr,3);
|
if (tries > 0) sleep_s(unit->itask->tr,3);
|
||||||
} else { // Anything else - No medium/bad medium etc
|
} else { // Anything else - No medium/bad medium etc
|
||||||
ret = TDERR_DiskChanged;
|
ret = TDERR_DiskChanged;
|
||||||
goto done;
|
goto done;
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
#include "newstyle.h"
|
#include "newstyle.h"
|
||||||
#include "scsi.h"
|
#include "scsi.h"
|
||||||
#include "td64.h"
|
#include "td64.h"
|
||||||
#include "wait.h"
|
#include "sleep.h"
|
||||||
#include "lide_alib.h"
|
#include "lide_alib.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -320,7 +320,7 @@ static BYTE handle_scsi_command(struct IOStdReq *ioreq) {
|
|||||||
if ((atapi_autosense(scsi_command,unit)) == 0)
|
if ((atapi_autosense(scsi_command,unit)) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
wait_us(unit->itask->tr,250000); // Wait 250ms before retrying
|
sleep_us(unit->itask->tr,250000); // Wait 250ms before retrying
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ void __attribute__((noreturn)) diskchange_task () {
|
|||||||
ReleaseSemaphore(&dev->ulSem);
|
ReleaseSemaphore(&dev->ulSem);
|
||||||
|
|
||||||
Trace("Wait...\n");
|
Trace("Wait...\n");
|
||||||
wait(TimerReq,CHANGEINT_INTERVAL);
|
sleep_s(TimerReq,CHANGEINT_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
die:
|
die:
|
||||||
|
|||||||
@ -2,14 +2,14 @@
|
|||||||
/* This file is part of lide.device
|
/* This file is part of lide.device
|
||||||
* Copyright (C) 2023 Matthew Harlum <matt@harlum.net>
|
* Copyright (C) 2023 Matthew Harlum <matt@harlum.net>
|
||||||
*/
|
*/
|
||||||
#ifndef _WAIT_H
|
#ifndef _SLEEP_H
|
||||||
#define _WAIT_H
|
#define _SLEEP_H
|
||||||
|
|
||||||
#include <devices/timer.h>
|
#include <devices/timer.h>
|
||||||
#include <exec/types.h>
|
#include <exec/types.h>
|
||||||
#include <proto/exec.h>
|
#include <proto/exec.h>
|
||||||
|
|
||||||
static inline void wait(struct timerequest *tr, ULONG seconds) {
|
static inline void sleep_s(struct timerequest *tr, ULONG seconds) {
|
||||||
struct ExecBase *SysBase = *(struct ExecBase **)4UL;
|
struct ExecBase *SysBase = *(struct ExecBase **)4UL;
|
||||||
tr->tr_node.io_Command = TR_ADDREQUEST;
|
tr->tr_node.io_Command = TR_ADDREQUEST;
|
||||||
tr->tr_time.tv_sec = seconds;
|
tr->tr_time.tv_sec = seconds;
|
||||||
@ -17,7 +17,7 @@ static inline void wait(struct timerequest *tr, ULONG seconds) {
|
|||||||
DoIO((struct IORequest *)tr);
|
DoIO((struct IORequest *)tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void wait_us(struct timerequest *tr, ULONG micros) {
|
static inline void sleep_us(struct timerequest *tr, ULONG micros) {
|
||||||
struct ExecBase *SysBase = *(struct ExecBase **)4UL;
|
struct ExecBase *SysBase = *(struct ExecBase **)4UL;
|
||||||
tr->tr_node.io_Command = TR_ADDREQUEST;
|
tr->tr_node.io_Command = TR_ADDREQUEST;
|
||||||
tr->tr_time.tv_sec = 0;
|
tr->tr_time.tv_sec = 0;
|
||||||
Loading…
x
Reference in New Issue
Block a user