1 /* $NetBSD: clock.c,v 1.24 2011/02/20 07:59:51 matt Exp $ */ 2 3 /* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * the Systems Programming Group of the University of Utah Computer 10 * Science Department, Ralph Campbell, and Kazumasa Utashiro of 11 * Software Research Associates, Inc. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: Utah $Hdr: clock.c 1.18 91/01/21$ 38 * 39 * @(#)clock.c 8.1 (Berkeley) 6/11/93 40 */ 41 42 #include <sys/cdefs.h> 43 __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.24 2011/02/20 07:59:51 matt Exp $"); 44 45 #include <sys/param.h> 46 #include <sys/device.h> 47 #include <sys/kernel.h> 48 #include <sys/systm.h> 49 #include <sys/cpu.h> 50 #include <machine/sysconf.h> 51 52 #include <mips/locore.h> 53 #include <mips/mips3_clock.h> 54 #include <dev/clock_subr.h> 55 #include <dev/ic/i8253reg.h> 56 57 #include <machine/machtype.h> 58 #include <sgimips/sgimips/clockvar.h> 59 60 uint32_t next_clk_intr; 61 uint32_t missed_clk_intrs; 62 63 void mips3_clock_intr(vaddr_t, uint32_t, uint32_t); 64 65 /* 66 * Machine-dependent clock routines. 67 */ 68 69 /* 70 * We assume newhz is either stathz or profhz, and that neither will 71 * change after being set up above. Could recalculate intervals here 72 * but that would be a drag. 73 */ 74 void 75 setstatclockrate(int newhz) 76 { 77 78 /* do something? */ 79 } 80 81 /* 82 * Set up the real-time and statistics clocks. Leave stathz 0 only if 83 * no alternative timer is available. 84 */ 85 void 86 cpu_initclocks(void) 87 { 88 89 switch (mach_type) { 90 #if defined(MIPS1) 91 case MACH_SGI_IP6 | MACH_SGI_IP10: 92 case MACH_SGI_IP12: 93 /* int(4) will take care of our clocks */ 94 /* enable hardware interrupts including hardclock(9) */ 95 spl0(); 96 break; 97 #endif /* MIPS1 */ 98 #if defined(MIPS3) 99 case MACH_SGI_IP20: 100 case MACH_SGI_IP22: 101 case MACH_SGI_IP30: 102 case MACH_SGI_IP32: 103 mips3_initclocks(); 104 break; 105 #endif /* MIPS3 */ 106 default: 107 panic("cpu_initclocks(): unknown mach_type IP%d", mach_type); 108 break; 109 } 110 } 111 112 #if defined(MIPS3) 113 void 114 mips3_clock_intr(vaddr_t pc, uint32_t status, uint32_t pending) 115 { 116 struct clockframe cf; 117 118 cf.pc = pc; 119 cf.sr = status; 120 cf.intr = (curcpu()->ci_idepth > 1); 121 mips3_clockintr(&cf); 122 } 123 124 #endif /* MIPS3 */ 125