Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/oea Split set_timebase() into get_timebase_...
details: https://anonhg.NetBSD.org/src/rev/502559fbe4d8
branches: trunk
changeset: 1019261:502559fbe4d8
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri Mar 05 02:58:13 2021 +0000
description:
Split set_timebase() into get_timebase_frequency() and init_decrementer().
Call get_timebase_frequency() much earlier.
diffstat:
sys/arch/powerpc/oea/ofwoea_machdep.c | 40 ++++++++++++++++++++++------------
1 files changed, 26 insertions(+), 14 deletions(-)
diffs (118 lines):
diff -r bfba8a991ad5 -r 502559fbe4d8 sys/arch/powerpc/oea/ofwoea_machdep.c
--- a/sys/arch/powerpc/oea/ofwoea_machdep.c Fri Mar 05 01:33:33 2021 +0000
+++ b/sys/arch/powerpc/oea/ofwoea_machdep.c Fri Mar 05 02:58:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.57 2021/03/05 01:33:33 thorpej Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.58 2021/03/05 02:58:13 thorpej Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.57 2021/03/05 01:33:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.58 2021/03/05 02:58:13 thorpej Exp $");
#include "ksyms.h"
#include "wsdisplay.h"
@@ -136,8 +136,10 @@
extern uint32_t ns_per_tick;
extern uint32_t ticks_per_intr;
+static void get_timebase_frequency(void);
+static void init_decrementer(void);
+
static void restore_ofmap(void);
-static void set_timebase(void);
void
ofwoea_initppc(u_int startkernel, u_int endkernel, char *args)
@@ -172,6 +174,9 @@
bootpath[len] = 0;
}
+ /* Get the timebase frequency from the firmware. */
+ get_timebase_frequency();
+
/* Initialize bus_space */
ofwoea_bus_space_init();
@@ -267,8 +272,8 @@
ksyms_addsyms_elf((int)((uintptr_t)endsym - (uintptr_t)startsym), startsym, endsym);
#endif
- /* CPU clock stuff */
- set_timebase();
+ /* Kick off the clock. */
+ init_decrementer();
#ifdef DDB
if (boothowto & RB_KDB)
@@ -276,22 +281,22 @@
#endif
}
-void
-set_timebase(void)
+static void
+get_timebase_frequency(void)
{
- int qhandle, phandle, msr, scratch, node;
+ int qhandle, phandle, node;
char type[32];
if (timebase_freq != 0) {
ticks_per_sec = timebase_freq;
- goto found;
+ return;
}
node = OF_finddevice("/cpus/@0");
if (node != -1 &&
OF_getprop(node, "timebase-frequency", &ticks_per_sec,
sizeof ticks_per_sec) > 0) {
- goto found;
+ return;
}
node = OF_finddevice("/");
@@ -300,7 +305,7 @@
&& strcmp(type, "cpu") == 0
&& OF_getprop(qhandle, "timebase-frequency",
&ticks_per_sec, sizeof ticks_per_sec) > 0) {
- goto found;
+ return;
}
if ((phandle = OF_child(qhandle)))
continue;
@@ -311,8 +316,15 @@
}
}
panic("no cpu node");
+}
-found:
+static void
+init_decrementer(void)
+{
+ int scratch, msr;
+
+ KASSERT(ticks_per_sec != 0);
+
__asm volatile ("mfmsr %0; andi. %1,%0,%2; mtmsr %1"
: "=r"(msr), "=r"(scratch) : "K"((u_short)~PSL_EE));
ns_per_tick = 1000000000 / ticks_per_sec;
@@ -321,10 +333,10 @@
#ifdef PPC_OEA601
if ((mfpvr() >> 16) == MPC601)
- curcpu()->ci_lasttb = rtc_nanosecs();
+ curcpu()->ci_lasttb = rtc_nanosecs();
else
#endif
- curcpu()->ci_lasttb = mftbl();
+ curcpu()->ci_lasttb = mftbl();
mtspr(SPR_DEC, ticks_per_intr);
mtmsr(msr);
Home |
Main Index |
Thread Index |
Old Index