1 /* $NetBSD: timer_hb.c,v 1.15 2008/04/28 20:23:30 martin Exp $ */
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: timer_hb.c,v 1.15 2008/04/28 20:23:30 martin Exp $");
35 #include <sys/param.h>
36 #include <sys/kernel.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
41 #include <uvm/uvm_extern.h>
43 #include <machine/cpu.h>
44 #include <machine/bus.h>
46 #include <dev/clock_subr.h>
48 #include <news68k/news68k/isr.h>
49 #include <news68k/news68k/clockvar.h>
51 #include <news68k/dev/hbvar.h>
56 * interrupt level for clock
60 #define TIMER_SIZE 8 /* XXX */
62 static int timer_hb_match(device_t
, cfdata_t
, void *);
63 static void timer_hb_attach(device_t
, device_t
, void *);
64 static void timer_hb_initclocks(int, int);
65 void clock_intr(struct clockframe
*);
67 static inline void leds_intr(void);
69 extern void _isr_clock(void); /* locore.s */
71 CFATTACH_DECL_NEW(timer_hb
, 0,
72 timer_hb_match
, timer_hb_attach
, NULL
, NULL
);
74 static volatile uint8_t *ctrl_timer
; /* XXX */
76 extern volatile u_char
*ctrl_led
; /* XXX */
79 timer_hb_match(device_t parent
, cfdata_t cf
, void *aux
)
81 struct hb_attach_args
*ha
= aux
;
82 static int timer_hb_matched
;
84 /* Only one timer, please. */
88 if (strcmp(ha
->ha_name
, timer_cd
.cd_name
))
92 ha
->ha_ipl
= TIMER_LEVEL
;
94 ha
->ha_size
= TIMER_SIZE
;
102 timer_hb_attach(device_t parent
, device_t self
, void *aux
)
104 struct hb_attach_args
*ha
= aux
;
106 if (ha
->ha_ipl
!= TIMER_LEVEL
)
107 panic("clock_hb_attach: wrong interrupt level");
109 ctrl_timer
= (uint8_t *)IIOV(ha
->ha_address
); /* XXX needs bus_space */
113 timer_config(timer_hb_initclocks
);
115 #if 0 /* XXX this will be done in timer_hb_initclocks() */
116 isrlink_custom(ha
->ha_ipl
, (void *)_isr_clock
);
121 * Set up the interval timer (enable clock interrupts).
122 * Leave stathz 0 since there is no secondary clock available.
123 * Note that clock interrupts MUST STAY DISABLED until here.
126 timer_hb_initclocks(int prof
, int stat
)
132 /* Install isr (in locore.s) that calls clock_intr(). */
133 isrlink_custom(TIMER_LEVEL
, (void *)_isr_clock
);
135 /* enable the clock */
141 * Clock interrupt handler.
142 * This is is called by the "custom" interrupt handler.
144 * from sun3/sun3x/clock.c -tsutsui
147 clock_intr(struct clockframe
*cf
)
149 #ifdef LED_IDLE_CHECK
150 extern char _Idle
[]; /* locore.s */
153 /* Pulse the clock intr. enable low. */
156 intrcnt
[TIMER_LEVEL
]++;
159 #ifdef LED_IDLE_CHECK
160 if (cf
.cf_pc
== (long)_Idle
)
164 /* Call common clock interrupt handler. */
176 static u_char led_countdown
, led_stat
;