No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hp700 / dev / clock.c
blob54edeccd9366afdb947be18f9cb3b9c308fa6703
1 /* $NetBSD: clock.c,v 1.6 2006/09/16 15:43:24 skrll Exp $ */
3 /* $OpenBSD: clock.c,v 1.10 2001/08/31 03:13:42 mickey Exp $ */
5 /*
6 * Copyright (c) 1998-2003 Michael Shalayeff
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.6 2006/09/16 15:43:24 skrll Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/time.h>
38 #include <sys/timetc.h>
40 #include <machine/pdc.h>
41 #include <machine/iomod.h>
42 #include <machine/psl.h>
43 #include <machine/intr.h>
44 #include <machine/reg.h>
45 #include <machine/cpufunc.h>
46 #include <machine/autoconf.h>
48 #include <hp700/hp700/machdep.h>
50 #if defined(DDB)
51 #include <machine/db_machdep.h>
52 #include <ddb/db_sym.h>
53 #include <ddb/db_extern.h>
54 #endif
56 static unsigned get_itimer_count(struct timecounter *);
58 void
59 cpu_initclocks(void)
61 static struct timecounter tc = {
62 .tc_get_timecount = get_itimer_count,
63 .tc_name = "itimer",
64 .tc_counter_mask = ~0,
65 .tc_quality = 100,
68 extern u_int cpu_hzticks;
69 u_int time_inval;
71 tc.tc_frequency = cpu_hzticks * hz;
73 /* Start the interval timer. */
74 mfctl(CR_ITMR, time_inval);
75 mtctl(time_inval + cpu_hzticks, CR_ITMR);
77 tc_init(&tc);
80 unsigned
81 get_itimer_count(struct timecounter *tc)
83 uint32_t val;
85 mfctl(CR_ITMR, val);
87 return val;
90 int
91 clock_intr(void *v)
93 struct clockframe *frame = v;
94 extern u_int cpu_hzticks;
95 u_int time_inval;
97 /* Restart the interval timer. */
98 mfctl(CR_ITMR, time_inval);
99 mtctl(time_inval + cpu_hzticks, CR_ITMR);
101 /* printf ("clock int 0x%x @ 0x%x for %p\n", t,
102 CLKF_PC(frame), curproc); */
104 if (!cold)
105 hardclock(frame);
107 #if 0
108 ddb_regs = *frame;
109 db_show_regs(NULL, 0, 0, NULL);
110 #endif
112 /* printf ("clock out 0x%x\n", t); */
114 return 1;
117 void
118 setstatclockrate(int newhz)
120 /* nothing we can do */