void
timer_setup(void)
{
- if (!CONFIG_TSC_TIMER || (CONFIG_PMTIMER && TimerPort != PORT_PIT_COUNTER0))
+ if (!CONFIG_TSC_TIMER)
return;
+ if (TimerPort != PORT_PIT_COUNTER0)
+ return; // have timer already
// Check if CPU has a timestamp counter
u32 eax, ebx, ecx, edx, cpuid_features = 0;
tsctimer_setup();
}
+void
+tsctimer_setfreq(u32 khz, const char *src)
+{
+ if (!CONFIG_TSC_TIMER)
+ return;
+ if (TimerPort != PORT_PIT_COUNTER0)
+ return; // have timer already
+
+ TimerKHz = khz;
+ ShiftTSC = 0;
+ while (TimerKHz >= 6000) {
+ ShiftTSC++;
+ TimerKHz = (TimerKHz + 1) >> 1;
+ }
+ TimerPort = 0;
+
+ dprintf(1, "CPU Mhz=%u (%s)\n", (TimerKHz << ShiftTSC) / 1000, src);
+}
+
void
pmtimer_setup(u16 ioport)
{
if (!CONFIG_PMTIMER)
return;
+ if (TimerPort != PORT_PIT_COUNTER0)
+ return; // have timer already
+
dprintf(1, "Using pmtimer, ioport 0x%x\n", ioport);
TimerPort = ioport;
TimerKHz = DIV_ROUND_UP(PMTIMER_HZ, 1000);
// hw/timer.c
void timer_setup(void);
void pmtimer_setup(u16 ioport);
+void tsctimer_setfreq(u32 khz, const char *src);
u32 timer_calc(u32 msecs);
u32 timer_calc_usec(u32 usecs);
int timer_check(u32 end);