From a05bab362f66ddd6fa65f2e7cda9eaaa0217ec08 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 17 Jan 2021 21:21:12 +0100 Subject: pc, pc64: add minimal HPET driver to measure LAPIC and TSC frequencies This adds the new function pointer PCArch.clockinit(), which is a timer dependent initialization routine. It also takes over the job of guesscpuhz(). This way, the architecture ident code can switch between different timers (i8253, HPET and XEN timer). --- sys/src/9/pc/archgeneric.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'sys/src/9/pc/archgeneric.c') diff --git a/sys/src/9/pc/archgeneric.c b/sys/src/9/pc/archgeneric.c index e51bf7ad7..dda06c196 100644 --- a/sys/src/9/pc/archgeneric.c +++ b/sys/src/9/pc/archgeneric.c @@ -40,6 +40,41 @@ archreset(void) idle(); } +void +delay(int millisecs) +{ + millisecs *= m->loopconst; + if(millisecs <= 0) + millisecs = 1; + aamloop(millisecs); +} + +void +microdelay(int microsecs) +{ + microsecs *= m->loopconst; + microsecs /= 1000; + if(microsecs <= 0) + microsecs = 1; + aamloop(microsecs); +} + +/* + * performance measurement ticks. must be low overhead. + * doesn't have to count over a second. + */ +ulong +perfticks(void) +{ + uvlong x; + + if(m->havetsc) + cycles(&x); + else + x = 0; + return x; +} + PCArch archgeneric = { .id= "generic", .ident= 0, @@ -53,6 +88,7 @@ PCArch archgeneric = { .intron= i8259on, .introff= i8259off, +.clockinit= i8253init, .clockenable= i8253enable, .fastclock= i8253read, .timerset= i8253timerset, -- cgit v1.2.3