Home | History | Annotate | Line # | Download | only in sun3x
clock.c revision 1.40.42.1
      1  1.40.42.1  thorpej /*	$NetBSD: clock.c,v 1.40.42.1 2021/04/03 22:28:40 thorpej Exp $	*/
      2       1.25      agc 
      3       1.25      agc /*
      4       1.25      agc  * Copyright (c) 1982, 1990, 1993
      5       1.25      agc  *	The Regents of the University of California.  All rights reserved.
      6       1.25      agc  *
      7       1.25      agc  * This code is derived from software contributed to Berkeley by
      8       1.25      agc  * the Systems Programming Group of the University of Utah Computer
      9       1.25      agc  * Science Department.
     10       1.25      agc  *
     11       1.25      agc  * Redistribution and use in source and binary forms, with or without
     12       1.25      agc  * modification, are permitted provided that the following conditions
     13       1.25      agc  * are met:
     14       1.25      agc  * 1. Redistributions of source code must retain the above copyright
     15       1.25      agc  *    notice, this list of conditions and the following disclaimer.
     16       1.25      agc  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.25      agc  *    notice, this list of conditions and the following disclaimer in the
     18       1.25      agc  *    documentation and/or other materials provided with the distribution.
     19       1.25      agc  * 3. Neither the name of the University nor the names of its contributors
     20       1.25      agc  *    may be used to endorse or promote products derived from this software
     21       1.25      agc  *    without specific prior written permission.
     22       1.25      agc  *
     23       1.25      agc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24       1.25      agc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25       1.25      agc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26       1.25      agc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27       1.25      agc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28       1.25      agc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29       1.25      agc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30       1.25      agc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31       1.25      agc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32       1.25      agc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33       1.25      agc  * SUCH DAMAGE.
     34       1.25      agc  *
     35       1.25      agc  *	from: Utah Hdr: clock.c 1.18 91/01/21$
     36       1.25      agc  *	from: @(#)clock.c	8.2 (Berkeley) 1/12/94
     37       1.25      agc  */
     38        1.1      gwr 
     39        1.1      gwr /*
     40        1.1      gwr  * Copyright (c) 1994 Gordon W. Ross
     41        1.1      gwr  * Copyright (c) 1993 Adam Glass
     42        1.1      gwr  * Copyright (c) 1988 University of Utah.
     43        1.1      gwr  *
     44        1.1      gwr  * This code is derived from software contributed to Berkeley by
     45        1.1      gwr  * the Systems Programming Group of the University of Utah Computer
     46        1.1      gwr  * Science Department.
     47        1.1      gwr  *
     48        1.1      gwr  * Redistribution and use in source and binary forms, with or without
     49        1.1      gwr  * modification, are permitted provided that the following conditions
     50        1.1      gwr  * are met:
     51        1.1      gwr  * 1. Redistributions of source code must retain the above copyright
     52        1.1      gwr  *    notice, this list of conditions and the following disclaimer.
     53        1.1      gwr  * 2. Redistributions in binary form must reproduce the above copyright
     54        1.1      gwr  *    notice, this list of conditions and the following disclaimer in the
     55        1.1      gwr  *    documentation and/or other materials provided with the distribution.
     56        1.1      gwr  * 3. All advertising materials mentioning features or use of this software
     57        1.1      gwr  *    must display the following acknowledgement:
     58        1.1      gwr  *	This product includes software developed by the University of
     59        1.1      gwr  *	California, Berkeley and its contributors.
     60        1.1      gwr  * 4. Neither the name of the University nor the names of its contributors
     61        1.1      gwr  *    may be used to endorse or promote products derived from this software
     62        1.1      gwr  *    without specific prior written permission.
     63        1.1      gwr  *
     64        1.1      gwr  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     65        1.1      gwr  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     66        1.1      gwr  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     67        1.1      gwr  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     68        1.1      gwr  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     69        1.1      gwr  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     70        1.1      gwr  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     71        1.1      gwr  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     72        1.1      gwr  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     73        1.1      gwr  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     74        1.1      gwr  * SUCH DAMAGE.
     75        1.1      gwr  *
     76        1.1      gwr  *	from: Utah Hdr: clock.c 1.18 91/01/21$
     77        1.1      gwr  *	from: @(#)clock.c	8.2 (Berkeley) 1/12/94
     78        1.1      gwr  */
     79        1.1      gwr 
     80        1.1      gwr /*
     81       1.10      gwr  * Machine-dependent clock routines.  Sun3X machines may have
     82       1.10      gwr  * either the Mostek 48T02 or the Intersil 7170 clock.
     83       1.10      gwr  *
     84       1.10      gwr  * It is tricky to determine which you have, because there is
     85       1.10      gwr  * always something responding at the address where the Mostek
     86       1.10      gwr  * clock might be found: either a Mostek or plain-old EEPROM.
     87       1.10      gwr  * Therefore, we cheat.  If we find an Intersil clock, assume
     88       1.10      gwr  * that what responds at the end of the EEPROM space is just
     89       1.10      gwr  * plain-old EEPROM (not a Mostek clock).  Worse, there are
     90       1.10      gwr  * H/W problems with probing for an Intersil on the 3/80, so
     91       1.10      gwr  * on that machine we "know" there is a Mostek clock.
     92       1.10      gwr  *
     93       1.10      gwr  * Note that the probing algorithm described above requires
     94       1.10      gwr  * that we probe the intersil before we probe the mostek!
     95        1.1      gwr  */
     96       1.24    lukem 
     97       1.24    lukem #include <sys/cdefs.h>
     98  1.40.42.1  thorpej __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.40.42.1 2021/04/03 22:28:40 thorpej Exp $");
     99        1.1      gwr 
    100        1.1      gwr #include <sys/param.h>
    101        1.1      gwr #include <sys/systm.h>
    102        1.1      gwr #include <sys/time.h>
    103        1.1      gwr #include <sys/kernel.h>
    104        1.1      gwr #include <sys/device.h>
    105        1.1      gwr 
    106       1.27  tsutsui #include <uvm/uvm_extern.h>
    107       1.27  tsutsui 
    108        1.9      gwr #include <m68k/asm_single.h>
    109        1.9      gwr 
    110        1.1      gwr #include <machine/autoconf.h>
    111       1.32  tsutsui #include <machine/bus.h>
    112        1.1      gwr #include <machine/cpu.h>
    113       1.10      gwr #include <machine/idprom.h>
    114       1.10      gwr #include <machine/leds.h>
    115       1.10      gwr 
    116       1.15      gwr #include <dev/clock_subr.h>
    117       1.32  tsutsui #include <dev/ic/intersil7170reg.h>
    118       1.32  tsutsui #include <dev/ic/intersil7170var.h>
    119       1.32  tsutsui #include <dev/ic/mk48txxreg.h>
    120       1.32  tsutsui #include <dev/ic/mk48txxvar.h>
    121       1.15      gwr 
    122       1.15      gwr #include <sun3/sun3/machdep.h>
    123       1.10      gwr #include <sun3/sun3/interreg.h>
    124        1.1      gwr 
    125  1.40.42.1  thorpej extern u_int intrcnt[];
    126       1.27  tsutsui 
    127       1.10      gwr #define SUN3_470	Yes
    128        1.1      gwr 
    129        1.1      gwr #define	CLOCK_PRI	5
    130        1.9      gwr #define IREG_CLK_BITS	(IREG_CLOCK_ENAB_7 | IREG_CLOCK_ENAB_5)
    131        1.1      gwr 
    132       1.32  tsutsui #define MKCLOCK_REG_OFFSET	(MK48T02_CLKOFF + MK48TXX_ICSR)
    133       1.32  tsutsui 
    134       1.10      gwr /*
    135       1.10      gwr  * Only one of these two variables should be non-zero after
    136       1.10      gwr  * autoconfiguration determines which clock we have.
    137       1.10      gwr  */
    138       1.10      gwr static volatile void *intersil_va;
    139       1.10      gwr static volatile void *mostek_clk_va;
    140       1.10      gwr 
    141       1.28      chs void _isr_clock(void);	/* in locore.s */
    142       1.28      chs void clock_intr(struct clockframe);
    143        1.1      gwr 
    144        1.1      gwr 
    145       1.36  tsutsui static int  clock_match(device_t, cfdata_t, void *);
    146       1.36  tsutsui static void clock_attach(device_t, device_t, void *);
    147        1.1      gwr 
    148       1.36  tsutsui CFATTACH_DECL_NEW(clock, sizeof(struct mk48txx_softc),
    149       1.23  thorpej     clock_match, clock_attach, NULL, NULL);
    150        1.1      gwr 
    151       1.10      gwr #ifdef	SUN3_470
    152       1.10      gwr 
    153       1.32  tsutsui #define intersil_clock ((volatile struct intersil7170 *)intersil_va)
    154       1.10      gwr 
    155       1.10      gwr #define intersil_clear() (void)intersil_clock->clk_intr_reg
    156       1.10      gwr 
    157       1.36  tsutsui static int  oclock_match(device_t, cfdata_t, void *);
    158       1.36  tsutsui static void oclock_attach(device_t, device_t, void *);
    159       1.10      gwr 
    160       1.36  tsutsui CFATTACH_DECL_NEW(oclock, sizeof(struct intersil7170_softc),
    161       1.23  thorpej     oclock_match, oclock_attach, NULL, NULL);
    162       1.10      gwr 
    163       1.31  gdamore 
    164        1.9      gwr /*
    165       1.10      gwr  * Is there an intersil clock?
    166        1.9      gwr  */
    167       1.40  tsutsui static int
    168       1.36  tsutsui oclock_match(device_t parent, cfdata_t cf, void *aux)
    169       1.10      gwr {
    170       1.32  tsutsui 	struct confargs *ca = aux;
    171       1.10      gwr 
    172       1.10      gwr 	/* This driver only supports one unit. */
    173       1.18  tsutsui 	if (intersil_va)
    174       1.32  tsutsui 		return 0;
    175       1.10      gwr 
    176       1.10      gwr 	/*
    177       1.10      gwr 	 * The 3/80 can not probe the Intersil absent,
    178       1.10      gwr 	 * but it never has one, so "just say no."
    179       1.10      gwr 	 */
    180       1.29  thorpej 	if (cpu_machine_id == ID_SUN3X_80)
    181       1.32  tsutsui 		return 0;
    182       1.10      gwr 
    183       1.10      gwr 	/* OK, really probe for the Intersil. */
    184       1.10      gwr 	if (bus_peek(ca->ca_bustype, ca->ca_paddr, 1) == -1)
    185       1.32  tsutsui 		return 0;
    186       1.10      gwr 
    187       1.16      gwr 	/* Default interrupt priority. */
    188       1.16      gwr 	if (ca->ca_intpri == -1)
    189       1.16      gwr 		ca->ca_intpri = CLOCK_PRI;
    190       1.16      gwr 
    191       1.32  tsutsui 	return 1;
    192       1.10      gwr }
    193       1.10      gwr 
    194       1.10      gwr /*
    195       1.10      gwr  * Attach the intersil clock.
    196       1.10      gwr  */
    197       1.40  tsutsui static void
    198       1.36  tsutsui oclock_attach(device_t parent, device_t self, void *aux)
    199        1.9      gwr {
    200       1.36  tsutsui 	struct intersil7170_softc *sc = device_private(self);
    201       1.32  tsutsui 	struct confargs *ca = aux;
    202       1.10      gwr 
    203       1.37  tsutsui 	sc->sc_dev = self;
    204       1.37  tsutsui 
    205       1.32  tsutsui 	/* Get a mapping for it. */
    206       1.32  tsutsui 	sc->sc_bst = ca->ca_bustag;
    207       1.32  tsutsui 	if (bus_space_map(sc->sc_bst, ca->ca_paddr, sizeof(struct intersil7170),
    208       1.32  tsutsui 	    0, &sc->sc_bsh) != 0) {
    209       1.36  tsutsui 		aprint_error(": can't map registers\n");
    210       1.32  tsutsui 		return;
    211       1.32  tsutsui 	}
    212       1.10      gwr 
    213       1.32  tsutsui 	intersil_va = bus_space_vaddr(sc->sc_bst, sc->sc_bsh);
    214       1.10      gwr 
    215       1.10      gwr #ifdef	DIAGNOSTIC
    216       1.10      gwr 	/* Verify correct probe order... */
    217       1.10      gwr 	if (mostek_clk_va) {
    218       1.32  tsutsui 		mostek_clk_va = NULL;
    219       1.36  tsutsui 		aprint_normal("\n");
    220       1.36  tsutsui 		aprint_error_dev(self, "warning - mostek found also!\n");
    221        1.9      gwr 	}
    222       1.10      gwr #endif
    223       1.10      gwr 
    224       1.10      gwr 	/*
    225       1.10      gwr 	 * Set the clock to the correct interrupt rate, but
    226       1.10      gwr 	 * do not enable the interrupt until cpu_initclocks.
    227       1.10      gwr 	 * XXX: Actually, the interrupt_reg should be zero
    228       1.10      gwr 	 * at this point, so the clock interrupts should not
    229       1.10      gwr 	 * affect us, but we need to set the rate...
    230       1.10      gwr 	 */
    231       1.32  tsutsui 	bus_space_write_1(sc->sc_bst, sc->sc_bsh, INTERSIL_ICMD,
    232       1.32  tsutsui 	    INTERSIL_COMMAND(INTERSIL_CMD_RUN, INTERSIL_CMD_IDISABLE));
    233       1.32  tsutsui 	(void)bus_space_read_1(sc->sc_bst, sc->sc_bsh, INTERSIL_IINTR);
    234       1.10      gwr 
    235       1.10      gwr 	/* Set the clock to 100 Hz, but do not enable it yet. */
    236       1.32  tsutsui 	bus_space_write_1(sc->sc_bst, sc->sc_bsh,
    237       1.32  tsutsui 	    INTERSIL_IINTR, INTERSIL_INTER_CSECONDS);
    238       1.32  tsutsui 
    239       1.32  tsutsui 	sc->sc_year0 = 1968;
    240       1.32  tsutsui 	intersil7170_attach(sc);
    241       1.32  tsutsui 
    242       1.36  tsutsui 	aprint_normal("\n");
    243       1.32  tsutsui 
    244       1.10      gwr 	/*
    245       1.10      gwr 	 * Can not hook up the ISR until cpu_initclocks()
    246       1.10      gwr 	 * because hardclock is not ready until then.
    247       1.10      gwr 	 * For now, the handler is _isr_autovec(), which
    248       1.10      gwr 	 * will complain if it gets clock interrupts.
    249       1.10      gwr 	 */
    250        1.9      gwr }
    251       1.10      gwr #endif	/* SUN3_470 */
    252       1.10      gwr 
    253        1.9      gwr 
    254        1.1      gwr /*
    255       1.10      gwr  * Is there a Mostek clock?  Hard to tell...
    256       1.10      gwr  * (See comment at top of this file.)
    257        1.1      gwr  */
    258       1.40  tsutsui static int
    259       1.36  tsutsui clock_match(device_t parent, cfdata_t cf, void *args)
    260        1.1      gwr {
    261       1.16      gwr 	struct confargs *ca = args;
    262        1.1      gwr 
    263        1.1      gwr 	/* This driver only supports one unit. */
    264       1.18  tsutsui 	if (mostek_clk_va)
    265       1.32  tsutsui 		return 0;
    266       1.11      gwr 
    267       1.10      gwr 	/* If intersil was found, use that. */
    268       1.10      gwr 	if (intersil_va)
    269       1.32  tsutsui 		return 0;
    270       1.16      gwr 	/* Else assume a Mostek is there... */
    271       1.16      gwr 
    272       1.16      gwr 	/* Default interrupt priority. */
    273       1.16      gwr 	if (ca->ca_intpri == -1)
    274       1.16      gwr 		ca->ca_intpri = CLOCK_PRI;
    275        1.1      gwr 
    276       1.32  tsutsui 	return 1;
    277        1.1      gwr }
    278        1.1      gwr 
    279       1.10      gwr /*
    280       1.10      gwr  * Attach the mostek clock.
    281       1.10      gwr  */
    282       1.40  tsutsui static void
    283       1.36  tsutsui clock_attach(device_t parent, device_t self, void *aux)
    284        1.1      gwr {
    285       1.36  tsutsui 	struct mk48txx_softc *sc = device_private(self);
    286       1.32  tsutsui 	struct confargs *ca = aux;
    287       1.32  tsutsui 
    288       1.37  tsutsui 	sc->sc_dev = self;
    289       1.32  tsutsui 	sc->sc_bst = ca->ca_bustag;
    290       1.32  tsutsui 	if (bus_space_map(sc->sc_bst, ca->ca_paddr - MKCLOCK_REG_OFFSET,
    291       1.32  tsutsui 	    MK48T02_CLKSZ, 0, &sc->sc_bsh) != 0) {
    292       1.36  tsutsui 		aprint_error(": can't map device space\n");
    293       1.32  tsutsui 		return;
    294       1.32  tsutsui 	}
    295       1.32  tsutsui 
    296       1.36  tsutsui 	mostek_clk_va = bus_space_vaddr(sc->sc_bst, sc->sc_bsh);
    297        1.1      gwr 
    298       1.32  tsutsui 	sc->sc_model = "mk48t02";
    299       1.32  tsutsui 	sc->sc_year0 = 1968;
    300        1.1      gwr 
    301       1.32  tsutsui 	mk48txx_attach(sc);
    302       1.13      gwr 
    303       1.36  tsutsui 	aprint_normal("\n");
    304        1.1      gwr }
    305        1.1      gwr 
    306        1.1      gwr /*
    307        1.1      gwr  * Set and/or clear the desired clock bits in the interrupt
    308        1.1      gwr  * register.  We have to be extremely careful that we do it
    309        1.1      gwr  * in such a manner that we don't get ourselves lost.
    310        1.9      gwr  * XXX:  Watch out!  It's really easy to break this!
    311        1.1      gwr  */
    312        1.1      gwr void
    313       1.28      chs set_clk_mode(u_char on, u_char off, int enable_clk)
    314        1.1      gwr {
    315       1.19  tsutsui 	u_char interreg;
    316        1.1      gwr 
    317        1.9      gwr 	/*
    318        1.9      gwr 	 * If we have not yet mapped the register,
    319        1.9      gwr 	 * then we do not want to do any of this...
    320        1.9      gwr 	 */
    321        1.5      gwr 	if (!interrupt_reg)
    322        1.4      gwr 		return;
    323        1.4      gwr 
    324        1.9      gwr #ifdef	DIAGNOSTIC
    325        1.9      gwr 	/* Assertion: were are at splhigh! */
    326        1.9      gwr 	if ((getsr() & PSL_IPL) < PSL_IPL7)
    327        1.9      gwr 		panic("set_clk_mode: bad ipl");
    328        1.9      gwr #endif
    329        1.1      gwr 
    330        1.1      gwr 	/*
    331        1.1      gwr 	 * make sure that we are only playing w/
    332        1.1      gwr 	 * clock interrupt register bits
    333        1.1      gwr 	 */
    334        1.9      gwr 	on  &= IREG_CLK_BITS;
    335        1.9      gwr 	off &= IREG_CLK_BITS;
    336        1.1      gwr 
    337        1.9      gwr 	/* First, turn off the "master" enable bit. */
    338        1.9      gwr 	single_inst_bclr_b(*interrupt_reg, IREG_ALL_ENAB);
    339        1.1      gwr 
    340        1.1      gwr 	/*
    341        1.9      gwr 	 * Save the current interrupt register clock bits,
    342        1.9      gwr 	 * and turn off/on the requested bits in the copy.
    343        1.1      gwr 	 */
    344        1.9      gwr 	interreg = *interrupt_reg & IREG_CLK_BITS;
    345        1.9      gwr 	interreg &= ~off;
    346        1.9      gwr 	interreg |= on;
    347        1.9      gwr 
    348        1.9      gwr 	/* Clear the CLK5 and CLK7 bits to clear the flip-flops. */
    349        1.9      gwr 	single_inst_bclr_b(*interrupt_reg, IREG_CLK_BITS);
    350        1.9      gwr 
    351        1.9      gwr #ifdef	SUN3_470
    352        1.9      gwr 	if (intersil_va) {
    353        1.9      gwr 		/*
    354        1.9      gwr 		 * Then disable clock interrupts, and read the clock's
    355        1.9      gwr 		 * interrupt register to clear any pending signals there.
    356        1.9      gwr 		 */
    357        1.9      gwr 		intersil_clock->clk_cmd_reg =
    358       1.32  tsutsui 		    INTERSIL_COMMAND(INTERSIL_CMD_RUN, INTERSIL_CMD_IDISABLE);
    359        1.9      gwr 		intersil_clear();
    360        1.9      gwr 	}
    361        1.9      gwr #endif	/* SUN3_470 */
    362        1.3      gwr 
    363        1.9      gwr 	/* Set the requested bits in the interrupt register. */
    364        1.9      gwr 	single_inst_bset_b(*interrupt_reg, interreg);
    365        1.1      gwr 
    366        1.9      gwr #ifdef	SUN3_470
    367        1.9      gwr 	/* Turn the clock back on (maybe) */
    368        1.9      gwr 	if (intersil_va && enable_clk)
    369        1.9      gwr 		intersil_clock->clk_cmd_reg =
    370       1.32  tsutsui 		    INTERSIL_COMMAND(INTERSIL_CMD_RUN, INTERSIL_CMD_IENABLE);
    371        1.9      gwr #endif	/* SUN3_470 */
    372        1.1      gwr 
    373        1.9      gwr 	/* Finally, turn the "master" enable back on. */
    374        1.9      gwr 	single_inst_bset_b(*interrupt_reg, IREG_ALL_ENAB);
    375        1.1      gwr }
    376        1.1      gwr 
    377        1.1      gwr /*
    378        1.1      gwr  * Set up the real-time clock (enable clock interrupts).
    379        1.1      gwr  * Leave stathz 0 since there is no secondary clock available.
    380        1.1      gwr  * Note that clock interrupts MUST STAY DISABLED until here.
    381        1.1      gwr  */
    382        1.1      gwr void
    383        1.1      gwr cpu_initclocks(void)
    384        1.1      gwr {
    385        1.1      gwr 	int s;
    386        1.1      gwr 
    387        1.1      gwr 	s = splhigh();
    388        1.1      gwr 
    389        1.1      gwr 	/* Install isr (in locore.s) that calls clock_intr(). */
    390       1.26  tsutsui 	isr_add_custom(CLOCK_PRI, (void *)_isr_clock);
    391        1.1      gwr 
    392        1.9      gwr 	/* Now enable the clock at level 5 in the interrupt reg. */
    393        1.9      gwr 	set_clk_mode(IREG_CLOCK_ENAB_5, 0, 1);
    394        1.3      gwr 
    395        1.1      gwr 	splx(s);
    396        1.1      gwr }
    397        1.1      gwr 
    398        1.1      gwr /*
    399        1.1      gwr  * This doesn't need to do anything, as we have only one timer and
    400        1.1      gwr  * profhz==stathz==hz.
    401        1.1      gwr  */
    402       1.40  tsutsui void
    403       1.28      chs setstatclockrate(int newhz)
    404        1.1      gwr {
    405       1.26  tsutsui 
    406        1.1      gwr 	/* nothing */
    407        1.1      gwr }
    408        1.1      gwr 
    409        1.1      gwr /*
    410       1.10      gwr  * Clock interrupt handler (for both Intersil and Mostek).
    411       1.10      gwr  * XXX - Is it worth the trouble to save a few cycles here
    412       1.10      gwr  * by making two separate interrupt handlers?
    413       1.10      gwr  *
    414       1.38  mbalmer  * This is called by the "custom" interrupt handler.
    415        1.9      gwr  * Note that we can get ZS interrupts while this runs,
    416        1.9      gwr  * and zshard may touch the interrupt_reg, so we must
    417        1.9      gwr  * be careful to use the single_inst_* macros to modify
    418        1.9      gwr  * the interrupt register atomically.
    419        1.1      gwr  */
    420        1.1      gwr void
    421       1.28      chs clock_intr(struct clockframe cf)
    422        1.1      gwr {
    423       1.10      gwr 	extern char _Idle[];	/* locore.s */
    424       1.10      gwr 
    425       1.35  tsutsui 	idepth++;
    426       1.35  tsutsui 
    427       1.10      gwr #ifdef	SUN3_470
    428       1.10      gwr 	if (intersil_va) {
    429       1.10      gwr 		/* Read the clock interrupt register. */
    430       1.10      gwr 		intersil_clear();
    431       1.10      gwr 	}
    432       1.10      gwr #endif	/* SUN3_470 */
    433        1.1      gwr 
    434        1.1      gwr 	/* Pulse the clock intr. enable low. */
    435        1.9      gwr 	single_inst_bclr_b(*interrupt_reg, IREG_CLOCK_ENAB_5);
    436        1.9      gwr 	single_inst_bset_b(*interrupt_reg, IREG_CLOCK_ENAB_5);
    437        1.1      gwr 
    438       1.10      gwr #ifdef	SUN3_470
    439       1.10      gwr 	if (intersil_va) {
    440       1.10      gwr 		/* Read the clock intr. reg. AGAIN! */
    441       1.10      gwr 		intersil_clear();
    442       1.10      gwr 	}
    443       1.10      gwr #endif	/* SUN3_470 */
    444       1.27  tsutsui 
    445       1.27  tsutsui 	intrcnt[CLOCK_PRI]++;
    446       1.39     matt 	curcpu()->ci_data.cpu_nintr++;
    447       1.13      gwr 
    448       1.13      gwr 	/* Entertainment! */
    449       1.13      gwr 	if (cf.cf_pc == (long)_Idle)
    450       1.13      gwr 		leds_intr();
    451       1.10      gwr 
    452        1.9      gwr 	/* Call common clock interrupt handler. */
    453        1.1      gwr 	hardclock(&cf);
    454       1.35  tsutsui 
    455       1.35  tsutsui 	idepth--;
    456        1.1      gwr }
    457