--- src/ata.c | 8 ++++---- src/cdrom.c | 2 +- src/clock.c | 6 +++--- src/ps2port.c | 2 +- src/usb-ehci.c | 10 +++++----- src/usb-hub.c | 4 ++-- src/usb-ohci.c | 8 ++++---- src/usb-uhci.c | 6 +++--- src/util.h | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/ata.c b/src/ata.c index 346c340..62cdbb8 100644 --- a/src/ata.c +++ b/src/ata.c @@ -35,7 +35,7 @@ await_ide(u8 mask, u8 flags, u16 base, u16 timeout) u8 status = inb(base+ATA_CB_STAT); if ((status & mask) == flags) return status; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return -1; } @@ -106,7 +106,7 @@ ata_reset(struct atadrive_s *adrive_g) if (inb(iobase1 + ATA_CB_DH) == ATA_CB_DH_DEV1) break; // Change drive request failed to take effect - retry. - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); goto done; } @@ -453,7 +453,7 @@ ata_dma_transfer(struct disk_op_s *op) if (status & BM_STATUS_IRQ) break; // Transfer in progress - if (check_time(end)) { + if (check_tsc(end)) { // Timeout. warn_timeout(); break; @@ -850,7 +850,7 @@ powerup_await_non_bsy(u16 base) dprintf(4, "powerup IDE floating\n"); return orstatus; } - if (check_time(SpinupEnd)) { + if (check_tsc(SpinupEnd)) { warn_timeout(); return -1; } diff --git a/src/cdrom.c b/src/cdrom.c index a0fdc50..f7af425 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -197,7 +197,7 @@ atapi_is_ready(struct disk_op_s *op) int in_progress = 0; u64 end = calc_future_tsc(5000); for (;;) { - if (check_time(end)) { + if (check_tsc(end)) { dprintf(1, "read capacity failed\n"); return -1; } diff --git a/src/clock.c b/src/clock.c index c79f392..0567955 100644 --- a/src/clock.c +++ b/src/clock.c @@ -95,7 +95,7 @@ tscdelay(u64 diff) { u64 start = rdtscll(); u64 end = start + diff; - while (!check_time(end)) + while (!check_tsc(end)) cpu_relax(); }
@@ -104,7 +104,7 @@ tscsleep(u64 diff) { u64 start = rdtscll(); u64 end = start + diff; - while (!check_time(end)) + while (!check_tsc(end)) yield(); }
@@ -164,7 +164,7 @@ rtc_updating(void) for (;;) { if ((inb_cmos(CMOS_STATUS_A) & RTC_A_UIP) == 0) return 0; - if (check_time(end)) + if (check_tsc(end)) // update-in-progress never transitioned to 0 return -1; yield(); diff --git a/src/ps2port.c b/src/ps2port.c index f379eb3..5b73d23 100644 --- a/src/ps2port.c +++ b/src/ps2port.c @@ -161,7 +161,7 @@ ps2_recvbyte(int aux, int needack, int timeout) dprintf(1, "Discarding ps2 data %02x (status=%02x)\n", data, status); }
- if (check_time(end)) { + if (check_tsc(end)) { // Don't warn on second byte of a reset if (timeout > 100) warn_timeout(); diff --git a/src/usb-ehci.c b/src/usb-ehci.c index 4df4b1c..4e228bd 100644 --- a/src/usb-ehci.c +++ b/src/usb-ehci.c @@ -194,7 +194,7 @@ configure_ehci(void *data) cmd = readl(&cntl->regs->usbcmd); if (!(cmd & CMD_HCRESET)) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); goto fail; } @@ -314,7 +314,7 @@ ehci_wait_qh(struct usb_ehci_s *cntl, struct ehci_qh *qh) if (qh->qtd_next & EHCI_PTR_TERM) // XXX - confirm return 0; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return -1; } @@ -341,7 +341,7 @@ ehci_waittick(struct usb_ehci_s *cntl) if (!(cmd & CMD_IAAD)) break; } - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return; } @@ -354,7 +354,7 @@ ehci_waittick(struct usb_ehci_s *cntl) sts = readl(&cntl->regs->usbsts); if (sts & STS_IAA) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return; } @@ -566,7 +566,7 @@ ehci_wait_td(struct ehci_qtd *td) status = td->token; if (!(status & QTD_STS_ACTIVE)) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return -1; } diff --git a/src/usb-hub.c b/src/usb-hub.c index 1586bac..b2d9ff2 100644 --- a/src/usb-hub.c +++ b/src/usb-hub.c @@ -88,7 +88,7 @@ usb_hub_detect(struct usbhub_s *hub, u32 port) if (sts.wPortStatus & USB_PORT_STAT_CONNECTION) // Device connected. break; - if (check_time(end)) + if (check_tsc(end)) // No device found. return -1; msleep(5); @@ -129,7 +129,7 @@ usb_hub_reset(struct usbhub_s *hub, u32 port) goto fail; if (!(sts.wPortStatus & USB_PORT_STAT_RESET)) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); goto fail; } diff --git a/src/usb-ohci.c b/src/usb-ohci.c index 43fe238..7b975d9 100644 --- a/src/usb-ohci.c +++ b/src/usb-ohci.c @@ -60,7 +60,7 @@ ohci_hub_reset(struct usbhub_s *hub, u32 port) if (!(sts & RH_PS_PRS)) // XXX - need to ensure USB_TIME_DRSTR time in reset? break; - if (check_time(end)) { + if (check_tsc(end)) { // Timeout. warn_timeout(); ohci_hub_disconnect(hub, port); @@ -129,7 +129,7 @@ start_ohci(struct usb_ohci_s *cntl, struct ohci_hcca *hcca) u32 status = readl(&cntl->regs->cmdstatus); if (! status & OHCI_HCR) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return -1; } @@ -246,7 +246,7 @@ wait_ed(struct ohci_ed *ed) for (;;) { if (ed->hwHeadP == ed->hwTailP) return 0; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return -1; } @@ -265,7 +265,7 @@ ohci_waittick(struct usb_ohci_s *cntl) for (;;) { if (hcca->frame_no != startframe) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return; } diff --git a/src/usb-uhci.c b/src/usb-uhci.c index b05e09a..6549808 100644 --- a/src/usb-uhci.c +++ b/src/usb-uhci.c @@ -214,7 +214,7 @@ wait_qh(struct usb_uhci_s *cntl, struct uhci_qh *qh) for (;;) { if (qh->element & UHCI_PTR_TERM) return 0; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); struct uhci_td *td = (void*)(qh->element & ~UHCI_PTR_BITS); dprintf(1, "Timeout on wait_qh %p (td=%p s=%x c=%x/%x)\n" @@ -237,7 +237,7 @@ uhci_waittick(u16 iobase) for (;;) { if (inw(iobase + USBFRNUM) != startframe) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return; } @@ -417,7 +417,7 @@ wait_td(struct uhci_td *td) status = td->status; if (!(status & TD_CTRL_ACTIVE)) break; - if (check_time(end)) { + if (check_tsc(end)) { warn_timeout(); return -1; } diff --git a/src/util.h b/src/util.h index a5c5b75..7902e83 100644 --- a/src/util.h +++ b/src/util.h @@ -292,7 +292,7 @@ void lpt_setup(void); // clock.c #define PIT_TICK_RATE 1193180 // Underlying HZ of PIT #define PIT_TICK_INTERVAL 65536 // Default interval for 18.2Hz timer -static inline int check_time(u64 end) { +static inline int check_tsc(u64 end) { return (s64)(rdtscll() - end) > 0; } void timer_setup(void);