From fc7b72ee1061f5deb11b3a5cc5878681e7b7ae30 Mon Sep 17 00:00:00 2001 From: cgd Date: Sat, 23 Nov 1996 06:31:57 +0000 Subject: [PATCH] move interrupt establishment to just before clock interrupts are enabled (from the attach routine), and add comments as to why. Some PALcode apparently 'saves' a clock interrupt for the kernel, and if the clock interrupt handler is enabled at attach time, it will be run when that interrupt hits, i.e. right after the spl0() at the end of autoconfiguration. That would cause hardclock to be run, but proc0's p_stats isn't set up by then, which would cause hardclock to crash. --- sys/arch/alpha/alpha/clock.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sys/arch/alpha/alpha/clock.c b/sys/arch/alpha/alpha/clock.c index feb42a9235e1..a0ea9309114f 100644 --- a/sys/arch/alpha/alpha/clock.c +++ b/sys/arch/alpha/alpha/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.13 1996/10/13 02:59:25 christos Exp $ */ +/* $NetBSD: clock.c,v 1.14 1996/11/23 06:31:57 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -70,18 +70,17 @@ clockattach(dev, fns) { /* - * establish the clock interrupt; it's a special case + * Just bookkeeping. */ - set_clockintr(); -#ifdef EVCNT_COUNTERS - evcnt_attach(self, "intr", &clock_intr_evcnt); -#endif printf("\n"); if (clockfns != NULL) panic("clockattach: multiple clocks"); clockdev = dev; clockfns = fns; +#ifdef EVCNT_COUNTERS + evcnt_attach(dev, "intr", &clock_intr_evcnt); +#endif } /* @@ -120,6 +119,20 @@ cpu_initclocks() tickfixinterval = hz >> (ftp - 1); } + /* + * 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 p->p_stats + * isn't set at that time. + */ + set_clockintr(); + /* * Get the clock started. */