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/pc64/dat.h | 2 ++ sys/src/9/pc64/fns.h | 1 - sys/src/9/pc64/main.c | 3 ++- sys/src/9/pc64/pc64 | 2 +- sys/src/9/pc64/squidboy.c | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-) (limited to 'sys/src/9/pc64') diff --git a/sys/src/9/pc64/dat.h b/sys/src/9/pc64/dat.h index b597f8988..1d581f371 100644 --- a/sys/src/9/pc64/dat.h +++ b/sys/src/9/pc64/dat.h @@ -221,6 +221,7 @@ struct Mach int lastintr; int loopconst; + int aalcycles; int cpumhz; uvlong cyclefreq; /* Frequency of user readable cycle counter */ @@ -278,6 +279,7 @@ struct PCArch void (*introff)(void); void (*intron)(void); + void (*clockinit)(void); void (*clockenable)(void); uvlong (*fastclock)(uvlong*); void (*timerset)(uvlong); diff --git a/sys/src/9/pc64/fns.h b/sys/src/9/pc64/fns.h index 90d831e3a..01a1959d3 100644 --- a/sys/src/9/pc64/fns.h +++ b/sys/src/9/pc64/fns.h @@ -52,7 +52,6 @@ u64int getcr4(void); u64int getxcr0(void); u64int getdr6(void); char* getconf(char*); -void guesscpuhz(int); void halt(void); void mwait(void*); int i8042auxcmd(int); diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c index e68220d5f..17a766137 100644 --- a/sys/src/9/pc64/main.c +++ b/sys/src/9/pc64/main.c @@ -183,10 +183,11 @@ main(void) quotefmtinstall(); screeninit(); print("\nPlan 9\n"); - i8253init(); cpuidentify(); meminit0(); archinit(); + if(arch->clockinit) + arch->clockinit(); meminit(); ramdiskinit(); confinit(); diff --git a/sys/src/9/pc64/pc64 b/sys/src/9/pc64/pc64 index ed3c76e7a..3250e9a45 100644 --- a/sys/src/9/pc64/pc64 +++ b/sys/src/9/pc64/pc64 @@ -94,7 +94,7 @@ link misc pci pcipc archgeneric devkbd i8259 i8253 - archacpi mp apic squidboy ec + archacpi mp apic squidboy ec hpet archmp mp apic squidboy mtrr diff --git a/sys/src/9/pc64/squidboy.c b/sys/src/9/pc64/squidboy.c index dda4f257f..f7882820b 100644 --- a/sys/src/9/pc64/squidboy.c +++ b/sys/src/9/pc64/squidboy.c @@ -16,6 +16,8 @@ squidboy(Apic* apic) machinit(); mmuinit(); cpuidentify(); + if(arch->clockinit) + arch->clockinit(); cpuidprint(); syncclock(); active.machs[m->machno] = 1; -- cgit v1.2.3