-/* $OpenBSD: clock.c,v 1.25 2021/02/23 04:44:30 cheloha Exp $ */
+/* $OpenBSD: clock.c,v 1.26 2022/12/10 15:02:29 cheloha Exp $ */
/* $NetBSD: clock.c,v 1.29 2000/06/05 21:47:10 thorpej Exp $ */
/*
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/clockintr.h>
#include <sys/device.h>
#include <sys/evcount.h>
+#include <sys/sched.h>
#include <sys/timetc.h>
#include <dev/clock_subr.h>
#include <alpha/alpha/clockvar.h>
-extern int schedhz;
-
struct device *clockdev;
const struct clockfns *clockfns;
*/
/*
- * Start the real-time and statistics clocks. Leave stathz 0 since there
- * are no other timers available.
+ * Start the real-time and statistics clocks.
*/
void
cpu_initclocks(void)
panic("cpu_initclocks: no clock attached");
tick = 1000000 / hz; /* number of microseconds between interrupts */
-
- /*
- * Establish the clock interrupt; it's a special case.
- *
- * We establish the clock interrupt this late because if
- * we do it at clock attach time, we may have never been at
- * spl0() since taking over the system. Some versions of
- * PALcode save a clock interrupt, which would get delivered
- * when we spl0() in autoconf.c. If established the clock
- * interrupt handler earlier, that interrupt would go to
- * hardclock, which would then fall over because the pointer
- * to the virtual timers wasn't set at that time.
- */
- platform.clockintr = hardclock;
- schedhz = 16;
+ tick_nsec = 1000000000 / hz;
evcount_attach(&clk_count, "clock", &clk_irq);
rpcc_timecounter.tc_frequency = cycles_per_sec;
tc_init(&rpcc_timecounter);
+ schedhz = 16;
+ stathz = hz;
+ profhz = stathz;
+ clockintr_init(0);
+
+ clockintr_cpu_init(NULL);
+
+ /*
+ * Establish the clock interrupt; it's a special case.
+ *
+ * We establish the clock interrupt this late because if
+ * we do it at clock attach time, we may have never been at
+ * spl0() since taking over the system. Some versions of
+ * PALcode save a clock interrupt, which would get delivered
+ * when we spl0() in autoconf.c. If established the clock
+ * interrupt handler earlier, that interrupt would go to
+ * hardclock, which would then fall over because the pointer
+ * to the virtual timers wasn't set at that time.
+ */
+ platform.clockintr = clockintr_dispatch;
+
rtc_todr.todr_gettime = rtc_gettime;
rtc_todr.todr_settime = rtc_settime;
todr_handle = &rtc_todr;
}
-/*
- * We assume newhz is either stathz or profhz, and that neither will
- * change after being set up above. Could recalculate intervals here
- * but that would be a drag.
- */
void
-setstatclockrate(newhz)
- int newhz;
+setstatclockrate(int newhz)
{
-
- /* nothing we can do */
+ clockintr_setstatclockrate(newhz);
}
u_int
-/* $OpenBSD: cpu.c,v 1.45 2022/03/13 08:04:13 mpi Exp $ */
+/* $OpenBSD: cpu.c,v 1.46 2022/12/10 15:02:29 cheloha Exp $ */
/* $NetBSD: cpu.c,v 1.44 2000/05/23 05:12:53 thorpej Exp $ */
/*-
#include <sys/param.h>
+#include <sys/clockintr.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/proc.h>
ci->ci_randseed = (arc4random() & 0x7fffffff) + 1;
KERNEL_UNLOCK();
+ clockintr_cpu_init(NULL);
+
(void) alpha_pal_swpipl(ALPHA_PSL_IPL_0);
SCHED_LOCK(s);
cpu_switchto(NULL, sched_chooseproc());
-/* $OpenBSD: interrupt.c,v 1.40 2017/01/21 05:42:03 guenther Exp $ */
+/* $OpenBSD: interrupt.c,v 1.41 2022/12/10 15:02:29 cheloha Exp $ */
/* $NetBSD: interrupt.c,v 1.46 2000/06/03 20:47:36 thorpej Exp $ */
/*-
struct trapframe *framep)
{
struct cpu_info *ci = curcpu();
- extern int schedhz;
switch (a0) {
case ALPHA_INTR_XPROC: /* interprocessor interrupt */
atomic_add_int(&uvmexp.intrs, 1);
if (CPU_IS_PRIMARY(ci))
clk_count.ec_count++;
- if (platform.clockintr) {
- /*
- * Call hardclock(). This will also call
- * statclock(). On the primary CPU, it
- * will also deal with time-of-day stuff.
- */
- (*platform.clockintr)((struct clockframe *)framep);
-
- /*
- * If it's time to call the scheduler clock,
- * do so.
- */
- if ((++ci->ci_schedstate.spc_schedticks & 0x3f) == 0 &&
- schedhz != 0)
- schedclock(ci->ci_curproc);
- }
+ if (platform.clockintr)
+ (*platform.clockintr)(framep);
break;
case ALPHA_INTR_ERROR: /* Machine Check or Correctable Error */
-/* $OpenBSD: _types.h,v 1.24 2018/03/05 01:15:24 deraadt Exp $ */
+/* $OpenBSD: _types.h,v 1.25 2022/12/10 15:02:29 cheloha Exp $ */
/*-
* Copyright (c) 1990, 1993
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+#define __HAVE_CLOCKINTR
+
#if defined(_KERNEL)
typedef struct label_t {
long val[10];
-/* $OpenBSD: cpu.h,v 1.67 2022/10/25 15:15:38 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.68 2022/12/10 15:02:29 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
#include <machine/bus.h>
#include <machine/intr.h>
#include <sys/cdefs.h>
+#include <sys/clockintr.h>
#include <sys/device.h>
#include <sys/sched.h>
#include <sys/srp.h>
#ifdef GPROF
struct gmonparam *ci_gmon;
#endif
+ struct clockintr_queue ci_queue;
char ci_panicbuf[512];
};
-/* $OpenBSD: cpuconf.h,v 1.6 2011/03/23 16:54:34 pirofti Exp $ */
+/* $OpenBSD: cpuconf.h,v 1.7 2022/12/10 15:02:29 cheloha Exp $ */
/* $NetBSD: cpuconf.h,v 1.12 2000/06/08 03:10:06 thorpej Exp $ */
/*
*/
void (*cons_init)(void);
void (*device_register)(struct device *, void *);
- void (*clockintr)(struct clockframe *);
+ int (*clockintr)(void *);
void (*mcheck_handler)(unsigned long, struct trapframe *,
unsigned long, unsigned long);
void (*powerdown)(void);