aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2013-07-20 18:22:57 -0400
committerKevin O'Connor <kevin@koconnor.net>2013-07-21 14:10:15 -0400
commit018bdd77cecd7d40d6685a0ec02ef3600214695d (patch)
tree203fcc2a01c8383532236bfd48e903f927eec79b
parent95ee382b65fe18423e48698a242444dc4d0ef0ba (diff)
downloadseabios-018bdd77cecd7d40d6685a0ec02ef3600214695d.tar.gz
Rename check_tsc() (and similar) to timer_check() and use u32.
Rename the check_tsc() function to timer_check(). The CPU TSC is often not the basis of the timer, so use a more appropriate name. Convert all callers that were using u64 for the timers to use u32. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/ahci.c19
-rw-r--r--src/ata.c18
-rw-r--r--src/blockcmd.c6
-rw-r--r--src/clock.c4
-rw-r--r--src/floppy.c8
-rw-r--r--src/megasas.c10
-rw-r--r--src/ps2port.c8
-rw-r--r--src/timer.c48
-rw-r--r--src/usb-ehci.c14
-rw-r--r--src/usb-hub.c8
-rw-r--r--src/usb-ohci.c16
-rw-r--r--src/usb-uhci.c12
-rw-r--r--src/util.h12
13 files changed, 89 insertions, 94 deletions
diff --git a/src/ahci.c b/src/ahci.c
index 879a991..0e99d14 100644
--- a/src/ahci.c
+++ b/src/ahci.c
@@ -113,7 +113,6 @@ static int ahci_command(struct ahci_port_s *port, int iswrite, int isatapi,
struct ahci_fis_s *fis = GET_GLOBAL(port->fis);
struct ahci_list_s *list = GET_GLOBAL(port->list);
u32 pnr = GET_GLOBAL(port->pnr);
- u64 end;
SET_LOWFLAT(cmd->fis.reg, 0x27);
SET_LOWFLAT(cmd->fis.pmp_type, (1 << 7)); /* cmd fis */
@@ -137,7 +136,7 @@ static int ahci_command(struct ahci_port_s *port, int iswrite, int isatapi,
ahci_port_writel(ctrl, pnr, PORT_SCR_ACT, 1);
ahci_port_writel(ctrl, pnr, PORT_CMD_ISSUE, 1);
- end = calc_future_tsc(AHCI_REQUEST_TIMEOUT);
+ u32 end = timer_calc(AHCI_REQUEST_TIMEOUT);
do {
for (;;) {
intbits = ahci_port_readl(ctrl, pnr, PORT_IRQ_STAT);
@@ -154,7 +153,7 @@ static int ahci_command(struct ahci_port_s *port, int iswrite, int isatapi,
break;
}
}
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return -1;
}
@@ -329,10 +328,9 @@ static void
ahci_port_reset(struct ahci_ctrl_s *ctrl, u32 pnr)
{
u32 val;
- u64 end;
/* disable FIS + CMD */
- end = calc_future_tsc(AHCI_RESET_TIMEOUT);
+ u32 end = timer_calc(AHCI_RESET_TIMEOUT);
for (;;) {
val = ahci_port_readl(ctrl, pnr, PORT_CMD);
if (!(val & (PORT_CMD_FIS_RX | PORT_CMD_START |
@@ -340,7 +338,7 @@ ahci_port_reset(struct ahci_ctrl_s *ctrl, u32 pnr)
break;
val &= ~(PORT_CMD_FIS_RX | PORT_CMD_START);
ahci_port_writel(ctrl, pnr, PORT_CMD, val);
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
break;
}
@@ -429,7 +427,6 @@ static int ahci_port_setup(struct ahci_port_s *port)
char model[MAXMODEL+1];
u16 buffer[256];
u32 cmd, stat, err, tf;
- u64 end;
int rc;
/* enable FIS recv */
@@ -440,14 +437,14 @@ static int ahci_port_setup(struct ahci_port_s *port)
/* spin up */
cmd |= PORT_CMD_SPIN_UP;
ahci_port_writel(ctrl, pnr, PORT_CMD, cmd);
- end = calc_future_tsc(AHCI_LINK_TIMEOUT);
+ u32 end = timer_calc(AHCI_LINK_TIMEOUT);
for (;;) {
stat = ahci_port_readl(ctrl, pnr, PORT_SCR_STAT);
if ((stat & 0x07) == 0x03) {
dprintf(2, "AHCI/%d: link up\n", port->pnr);
break;
}
- if (check_tsc(end)) {
+ if (timer_check(end)) {
dprintf(2, "AHCI/%d: link down\n", port->pnr);
return -1;
}
@@ -460,13 +457,13 @@ static int ahci_port_setup(struct ahci_port_s *port)
ahci_port_writel(ctrl, pnr, PORT_SCR_ERR, err);
/* wait for device becoming ready */
- end = calc_future_tsc(AHCI_REQUEST_TIMEOUT);
+ end = timer_calc(AHCI_REQUEST_TIMEOUT);
for (;;) {
tf = ahci_port_readl(ctrl, pnr, PORT_TFDATA);
if (!(tf & (ATA_CB_STAT_BSY |
ATA_CB_STAT_DRQ)))
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
dprintf(1, "AHCI/%d: device not ready (tf 0x%x)\n", port->pnr, tf);
return -1;
diff --git a/src/ata.c b/src/ata.c
index 55bfa9a..e319aa9 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -31,12 +31,12 @@
static inline int
await_ide(u8 mask, u8 flags, u16 base, u16 timeout)
{
- u64 end = calc_future_tsc(timeout);
+ u32 end = timer_calc(timeout);
for (;;) {
u8 status = inb(base+ATA_CB_STAT);
if ((status & mask) == flags)
return status;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return -1;
}
@@ -98,7 +98,7 @@ ata_reset(struct atadrive_s *adrive_g)
goto done;
if (slave) {
// Change device.
- u64 end = calc_future_tsc(IDE_TIMEOUT);
+ u32 end = timer_calc(IDE_TIMEOUT);
for (;;) {
outb(ATA_CB_DH_DEV1, iobase1 + ATA_CB_DH);
status = ndelay_await_not_bsy(iobase1);
@@ -107,7 +107,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_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
goto done;
}
@@ -421,14 +421,14 @@ ata_dma_transfer(struct disk_op_s *op)
u8 oldcmd = inb(iomaster + BM_CMD);
outb(oldcmd | BM_CMD_START, iomaster + BM_CMD);
- u64 end = calc_future_tsc(IDE_TIMEOUT);
+ u32 end = timer_calc(IDE_TIMEOUT);
u8 status;
for (;;) {
status = inb(iomaster + BM_STATUS);
if (status & BM_STATUS_IRQ)
break;
// Transfer in progress
- if (check_tsc(end)) {
+ if (timer_check(end)) {
// Timeout.
warn_timeout();
break;
@@ -807,7 +807,7 @@ init_drive_ata(struct atadrive_s *dummy, u16 *buffer)
return adrive_g;
}
-static u64 SpinupEnd;
+static u32 SpinupEnd;
// Wait for non-busy status and check for "floating bus" condition.
static int
@@ -824,7 +824,7 @@ powerup_await_non_bsy(u16 base)
dprintf(4, "powerup IDE floating\n");
return orstatus;
}
- if (check_tsc(SpinupEnd)) {
+ if (timer_check(SpinupEnd)) {
warn_timeout();
return -1;
}
@@ -1034,7 +1034,7 @@ ata_setup(void)
dprintf(3, "init hard drives\n");
- SpinupEnd = calc_future_tsc(IDE_TIMEOUT);
+ SpinupEnd = timer_calc(IDE_TIMEOUT);
ata_scan();
SET_BDA(disk_control_byte, 0xc0);
diff --git a/src/blockcmd.c b/src/blockcmd.c
index c3e4b58..5cd4eb0 100644
--- a/src/blockcmd.c
+++ b/src/blockcmd.c
@@ -64,9 +64,9 @@ scsi_is_ready(struct disk_op_s *op)
* reported by the device. If the device reports "IN PROGRESS",
* 30 seconds is added. */
int in_progress = 0;
- u64 end = calc_future_tsc(5000);
+ u32 end = timer_calc(5000);
for (;;) {
- if (check_tsc(end)) {
+ if (timer_check(end)) {
dprintf(1, "test unit ready failed\n");
return -1;
}
@@ -92,7 +92,7 @@ scsi_is_ready(struct disk_op_s *op)
/* IN PROGRESS OF BECOMING READY */
printf("Waiting for device to detect medium... ");
/* Allow 30 seconds more */
- end = calc_future_tsc(30000);
+ end = timer_calc(30000);
in_progress = 1;
}
}
diff --git a/src/clock.c b/src/clock.c
index 4b33bb8..5014b60 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -44,11 +44,11 @@ rtc_updating(void)
if ((inb_cmos(CMOS_STATUS_A) & RTC_A_UIP) == 0)
return 0;
- u64 end = calc_future_tsc(15);
+ u32 end = timer_calc(15);
for (;;) {
if ((inb_cmos(CMOS_STATUS_A) & RTC_A_UIP) == 0)
return 0;
- if (check_tsc(end))
+ if (timer_check(end))
// update-in-progress never transitioned to 0
return -1;
yield();
diff --git a/src/floppy.c b/src/floppy.c
index 83dfaf8..37b7092 100644
--- a/src/floppy.c
+++ b/src/floppy.c
@@ -211,12 +211,12 @@ static int
floppy_pio(struct floppy_pio_s *pio)
{
// Send command to controller.
- u64 end = calc_future_tsc(FLOPPY_PIO_TIMEOUT);
+ u32 end = timer_calc(FLOPPY_PIO_TIMEOUT);
int i = 0;
for (;;) {
u8 sts = inb(PORT_FD_STATUS);
if (!(sts & 0x80)) {
- if (check_tsc(end)) {
+ if (timer_check(end)) {
floppy_disable_controller();
return DISK_RET_ETIMEOUT;
}
@@ -239,12 +239,12 @@ floppy_pio(struct floppy_pio_s *pio)
}
// Read response from controller.
- end = calc_future_tsc(FLOPPY_PIO_TIMEOUT);
+ end = timer_calc(FLOPPY_PIO_TIMEOUT);
i = 0;
for (;;) {
u8 sts = inb(PORT_FD_STATUS);
if (!(sts & 0x80)) {
- if (check_tsc(end)) {
+ if (timer_check(end)) {
floppy_disable_controller();
return DISK_RET_ETIMEOUT;
}
diff --git a/src/megasas.c b/src/megasas.c
index 170700f..f4eeba0 100644
--- a/src/megasas.c
+++ b/src/megasas.c
@@ -118,7 +118,6 @@ static int megasas_fire_cmd(u16 pci_id, u32 ioaddr,
u32 frame_addr = (u32)frame;
int frame_count = 1;
u8 cmd_state;
- u64 end;
dprintf(2, "Frame 0x%x\n", frame_addr);
if (pci_id == PCI_DEVICE_ID_LSI_SAS2004 ||
@@ -133,13 +132,13 @@ static int megasas_fire_cmd(u16 pci_id, u32 ioaddr,
outl(frame_addr | frame_count << 1 | 1, ioaddr + MFI_IQP);
}
- end = calc_future_tsc(MEGASAS_POLL_TIMEOUT);
+ u32 end = timer_calc(MEGASAS_POLL_TIMEOUT);
do {
for (;;) {
cmd_state = GET_LOWFLAT(frame->cmd_status);
if (cmd_state != 0xff)
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return -1;
}
@@ -270,7 +269,6 @@ static void megasas_scan_target(struct pci_device *pci, u32 iobase)
static int megasas_transition_to_ready(struct pci_device *pci, u32 ioaddr)
{
u32 fw_state = 0, new_state, mfi_flags = 0;
- u64 end;
if (pci->device == PCI_DEVICE_ID_LSI_SAS1064R ||
pci->device == PCI_DEVICE_ID_DELL_PERC5)
@@ -327,9 +325,9 @@ static int megasas_transition_to_ready(struct pci_device *pci, u32 ioaddr)
return 0;
}
// The current state should not last longer than poll timeout
- end = calc_future_tsc(MEGASAS_POLL_TIMEOUT);
+ u32 end = timer_calc(MEGASAS_POLL_TIMEOUT);
for (;;) {
- if (check_tsc(end)) {
+ if (timer_check(end)) {
break;
}
yield();
diff --git a/src/ps2port.c b/src/ps2port.c
index cfcd5eb..4b6c5df 100644
--- a/src/ps2port.c
+++ b/src/ps2port.c
@@ -153,7 +153,7 @@ i8042_reboot(void)
static int
ps2_recvbyte(int aux, int needack, int timeout)
{
- u64 end = calc_future_tsc(timeout);
+ u32 end = timer_calc(timeout);
for (;;) {
u8 status = inb(PORT_PS2_STATUS);
if (status & I8042_STR_OBF) {
@@ -175,7 +175,7 @@ ps2_recvbyte(int aux, int needack, int timeout)
dprintf(1, "Discarding ps2 data %02x (status=%02x)\n", data, status);
}
- if (check_tsc(end)) {
+ if (timer_check(end)) {
// Don't warn on second byte of a reset
if (timeout > 100)
warn_timeout();
@@ -450,12 +450,12 @@ ps2_keyboard_setup(void *data)
/* ------------------- keyboard side ------------------------*/
/* reset keyboard and self test (keyboard side) */
int spinupdelay = romfile_loadint("etc/ps2-keyboard-spinup", 0);
- u64 end = calc_future_tsc(spinupdelay);
+ u32 end = timer_calc(spinupdelay);
for (;;) {
ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
if (!ret)
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
if (spinupdelay)
warn_timeout();
return;
diff --git a/src/timer.c b/src/timer.c
index 4dc851c..41d0ed8 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -21,7 +21,7 @@
/****************************************************************
- * TSC timer
+ * Internal timers
****************************************************************/
#define CALIBRATE_COUNT 0x800 // Approx 1.7ms
@@ -93,7 +93,7 @@ u32 TSC_8254 VARLOW;
int Last_TSC_8254 VARLOW;
static u32
-emulate_tsc(void)
+pittimer_read(void)
{
/* read timer 0 current count */
u32 ret = GET_LOW(TSC_8254);
@@ -118,7 +118,7 @@ void pmtimer_setup(u16 ioport)
TimerKHz = DIV_ROUND_UP(PMTIMER_HZ, 1000);
}
-static u32 pmtimer_get(void)
+static u32 pmtimer_read(void)
{
u16 ioport = GET_GLOBAL(pmtimer_ioport);
u32 wraps = GET_LOW(pmtimer_wraps);
@@ -135,69 +135,69 @@ static u32 pmtimer_get(void)
}
static u32
-get_tsc(void)
+timer_read(void)
{
if (unlikely(GET_GLOBAL(no_tsc)))
- return emulate_tsc();
+ return pittimer_read();
if (CONFIG_PMTIMER && GET_GLOBAL(pmtimer_ioport))
- return pmtimer_get();
+ return pmtimer_read();
return rdtscll() >> GET_GLOBAL(ShiftTSC);
}
int
-check_tsc(u32 end)
+timer_check(u32 end)
{
- return (s32)(get_tsc() - end) > 0;
+ return (s32)(timer_read() - end) > 0;
}
static void
-tscdelay(u32 diff)
+timer_delay(u32 diff)
{
- u32 start = get_tsc();
+ u32 start = timer_read();
u32 end = start + diff;
- while (!check_tsc(end))
+ while (!timer_check(end))
cpu_relax();
}
static void
-tscsleep(u32 diff)
+timer_sleep(u32 diff)
{
- u32 start = get_tsc();
+ u32 start = timer_read();
u32 end = start + diff;
- while (!check_tsc(end))
+ while (!timer_check(end))
yield();
}
void ndelay(u32 count) {
- tscdelay(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000000));
+ timer_delay(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000000));
}
void udelay(u32 count) {
- tscdelay(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000));
+ timer_delay(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000));
}
void mdelay(u32 count) {
- tscdelay(count * GET_GLOBAL(TimerKHz));
+ timer_delay(count * GET_GLOBAL(TimerKHz));
}
void nsleep(u32 count) {
- tscsleep(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000000));
+ timer_sleep(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000000));
}
void usleep(u32 count) {
- tscsleep(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000));
+ timer_sleep(DIV_ROUND_UP(count * GET_GLOBAL(TimerKHz), 1000));
}
void msleep(u32 count) {
- tscsleep(count * GET_GLOBAL(TimerKHz));
+ timer_sleep(count * GET_GLOBAL(TimerKHz));
}
// Return the TSC value that is 'msecs' time in the future.
u32
-calc_future_tsc(u32 msecs)
+timer_calc(u32 msecs)
{
- return get_tsc() + (GET_GLOBAL(TimerKHz) * msecs);
+ return timer_read() + (GET_GLOBAL(TimerKHz) * msecs);
}
u32
-calc_future_tsc_usec(u32 usecs)
+timer_calc_usec(u32 usecs)
{
- return get_tsc() + DIV_ROUND_UP(GET_GLOBAL(TimerKHz) * usecs, 1000);
+ return timer_read() + DIV_ROUND_UP(GET_GLOBAL(TimerKHz) * usecs, 1000);
}
diff --git a/src/usb-ehci.c b/src/usb-ehci.c
index c1638e4..978ca68 100644
--- a/src/usb-ehci.c
+++ b/src/usb-ehci.c
@@ -189,7 +189,7 @@ ehci_waittick(struct usb_ehci_s *cntl)
// Wait for access to "doorbell"
barrier();
u32 cmd, sts;
- u64 end = calc_future_tsc(100);
+ u32 end = timer_calc(100);
for (;;) {
sts = readl(&cntl->regs->usbsts);
if (!(sts & STS_IAA)) {
@@ -197,7 +197,7 @@ ehci_waittick(struct usb_ehci_s *cntl)
if (!(cmd & CMD_IAAD))
break;
}
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return;
}
@@ -210,7 +210,7 @@ ehci_waittick(struct usb_ehci_s *cntl)
sts = readl(&cntl->regs->usbsts);
if (sts & STS_IAA)
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return;
}
@@ -267,12 +267,12 @@ configure_ehci(void *data)
// Reset the HC
u32 cmd = readl(&cntl->regs->usbcmd);
writel(&cntl->regs->usbcmd, (cmd & ~(CMD_ASE | CMD_PSE)) | CMD_HCRESET);
- u64 end = calc_future_tsc(250);
+ u32 end = timer_calc(250);
for (;;) {
cmd = readl(&cntl->regs->usbcmd);
if (!(cmd & CMD_HCRESET))
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
goto fail;
}
@@ -529,13 +529,13 @@ ehci_reset_pipe(struct ehci_pipe *pipe)
static int
ehci_wait_td(struct ehci_pipe *pipe, struct ehci_qtd *td, int timeout)
{
- u64 end = calc_future_tsc(timeout);
+ u32 end = timer_calc(timeout);
u32 status;
for (;;) {
status = td->token;
if (!(status & QTD_STS_ACTIVE))
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
u32 cur = GET_LOWFLAT(pipe->qh.current);
u32 tok = GET_LOWFLAT(pipe->qh.token);
u32 next = GET_LOWFLAT(pipe->qh.qtd_next);
diff --git a/src/usb-hub.c b/src/usb-hub.c
index 894ed7d..0b55d15 100644
--- a/src/usb-hub.c
+++ b/src/usb-hub.c
@@ -80,7 +80,7 @@ usb_hub_detect(struct usbhub_s *hub, u32 port)
// Check periodically for a device connect.
struct usb_port_status sts;
- u64 end = calc_future_tsc(USB_TIME_SIGATT);
+ u32 end = timer_calc(USB_TIME_SIGATT);
for (;;) {
ret = get_port_status(hub, port, &sts);
if (ret)
@@ -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_tsc(end))
+ if (timer_check(end))
// No device found.
return -1;
msleep(5);
@@ -122,14 +122,14 @@ usb_hub_reset(struct usbhub_s *hub, u32 port)
// Wait for reset to complete.
struct usb_port_status sts;
- u64 end = calc_future_tsc(USB_TIME_DRST * 2);
+ u32 end = timer_calc(USB_TIME_DRST * 2);
for (;;) {
ret = get_port_status(hub, port, &sts);
if (ret)
goto fail;
if (!(sts.wPortStatus & USB_PORT_STAT_RESET))
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
goto fail;
}
diff --git a/src/usb-ohci.c b/src/usb-ohci.c
index b2e1d7f..e5c9fa5 100644
--- a/src/usb-ohci.c
+++ b/src/usb-ohci.c
@@ -62,13 +62,13 @@ ohci_hub_reset(struct usbhub_s *hub, u32 port)
struct usb_ohci_s *cntl = container_of(hub->cntl, struct usb_ohci_s, usb);
writel(&cntl->regs->roothub_portstatus[port], RH_PS_PRS);
u32 sts;
- u64 end = calc_future_tsc(USB_TIME_DRSTR * 2);
+ u32 end = timer_calc(USB_TIME_DRSTR * 2);
for (;;) {
sts = readl(&cntl->regs->roothub_portstatus[port]);
if (!(sts & RH_PS_PRS))
// XXX - need to ensure USB_TIME_DRSTR time in reset?
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
// Timeout.
warn_timeout();
ohci_hub_disconnect(hub, port);
@@ -124,11 +124,11 @@ ohci_waittick(struct usb_ohci_s *cntl)
barrier();
struct ohci_hcca *hcca = (void*)cntl->regs->hcca;
u32 startframe = hcca->frame_no;
- u64 end = calc_future_tsc(1000 * 5);
+ u32 end = timer_calc(1000 * 5);
for (;;) {
if (hcca->frame_no != startframe)
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return;
}
@@ -181,13 +181,13 @@ start_ohci(struct usb_ohci_s *cntl, struct ohci_hcca *hcca)
msleep(USB_TIME_DRSTR);
// Do software init (min 10us, max 2ms)
- u64 end = calc_future_tsc_usec(10);
+ u32 end = timer_calc_usec(10);
writel(&cntl->regs->cmdstatus, OHCI_HCR);
for (;;) {
u32 status = readl(&cntl->regs->cmdstatus);
if (! status & OHCI_HCR)
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return -1;
}
@@ -422,11 +422,11 @@ static int
wait_ed(struct ohci_ed *ed)
{
// XXX - 500ms just a guess
- u64 end = calc_future_tsc(500);
+ u32 end = timer_calc(500);
for (;;) {
if (ed->hwHeadP == ed->hwTailP)
return 0;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return -1;
}
diff --git a/src/usb-uhci.c b/src/usb-uhci.c
index 5fa05a8..d8f9b1e 100644
--- a/src/usb-uhci.c
+++ b/src/usb-uhci.c
@@ -111,11 +111,11 @@ uhci_waittick(u16 iobase)
{
barrier();
u16 startframe = inw(iobase + USBFRNUM);
- u64 end = calc_future_tsc(1000 * 5);
+ u32 end = timer_calc(1000 * 5);
for (;;) {
if (inw(iobase + USBFRNUM) != startframe)
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return;
}
@@ -386,12 +386,12 @@ uhci_alloc_pipe(struct usbdevice_s *usbdev
static int
wait_pipe(struct uhci_pipe *pipe, int timeout)
{
- u64 end = calc_future_tsc(timeout);
+ u32 end = timer_calc(timeout);
for (;;) {
u32 el_link = GET_LOWFLAT(pipe->qh.element);
if (el_link & UHCI_PTR_TERM)
return 0;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
u16 iobase = GET_LOWFLAT(pipe->iobase);
struct uhci_td *td = (void*)(el_link & ~UHCI_PTR_BITS);
@@ -410,13 +410,13 @@ wait_pipe(struct uhci_pipe *pipe, int timeout)
static int
wait_td(struct uhci_td *td)
{
- u64 end = calc_future_tsc(5000); // XXX - lookup real time.
+ u32 end = timer_calc(5000); // XXX - lookup real time.
u32 status;
for (;;) {
status = td->status;
if (!(status & TD_CTRL_ACTIVE))
break;
- if (check_tsc(end)) {
+ if (timer_check(end)) {
warn_timeout();
return -1;
}
diff --git a/src/util.h b/src/util.h
index 10c2364..6944cfb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -282,19 +282,19 @@ void useRTC(void);
void releaseRTC(void);
// timer.c
-u32 ticks_to_ms(u32 ticks);
-u32 ticks_from_ms(u32 ms);
-void pmtimer_setup(u16 ioport);
-int check_tsc(u32 end);
void timer_setup(void);
+void pmtimer_setup(u16 ioport);
+u32 timer_calc(u32 msecs);
+u32 timer_calc_usec(u32 usecs);
+int timer_check(u32 end);
void ndelay(u32 count);
void udelay(u32 count);
void mdelay(u32 count);
void nsleep(u32 count);
void usleep(u32 count);
void msleep(u32 count);
-u32 calc_future_tsc(u32 msecs);
-u32 calc_future_tsc_usec(u32 usecs);
+u32 ticks_to_ms(u32 ticks);
+u32 ticks_from_ms(u32 ms);
u32 irqtimer_calc_ticks(u32 count);
u32 irqtimer_calc(u32 msecs);
int irqtimer_check(u32 end);