Deleted Added
full compact
pcrtc.c (90007) pcrtc.c (92793)
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz and Don Ahn.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz and Don Ahn.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
37 * $FreeBSD: head/sys/pc98/cbus/pcrtc.c 90007 2002-01-31 04:28:52Z nyan $
37 * $FreeBSD: head/sys/pc98/cbus/pcrtc.c 92793 2002-03-20 12:22:31Z kato $
38 */
39
40/*
41 * Routines to handle clock hardware.
42 */
43
44/*
45 * inittodr, settodr and support routines written

--- 58 unchanged lines hidden (view full) ---

104#ifdef DEV_MCA
105#include <i386/isa/mca_machdep.h>
106#endif
107
108#ifdef APIC_IO
109#include <i386/isa/intr_machdep.h>
110/* The interrupt triggered by the 8254 (timer) chip */
111int apic_8254_intr;
38 */
39
40/*
41 * Routines to handle clock hardware.
42 */
43
44/*
45 * inittodr, settodr and support routines written

--- 58 unchanged lines hidden (view full) ---

104#ifdef DEV_MCA
105#include <i386/isa/mca_machdep.h>
106#endif
107
108#ifdef APIC_IO
109#include <i386/isa/intr_machdep.h>
110/* The interrupt triggered by the 8254 (timer) chip */
111int apic_8254_intr;
112static u_long read_intr_count __P((int vec));
113static void setup_8254_mixed_mode __P((void));
112static u_long read_intr_count(int vec);
113static void setup_8254_mixed_mode(void);
114#endif
115
116/*
117 * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
118 * can use a simple formula for leap years.
119 */
120#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
121#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)

--- 42 unchanged lines hidden (view full) ---

164static u_int32_t i8254_offset;
165static int i8254_ticked;
166/*
167 * XXX new_function and timer_func should not handle clockframes, but
168 * timer_func currently needs to hold hardclock to handle the
169 * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
170 * to switch between clkintr() and a slightly different timerintr().
171 */
114#endif
115
116/*
117 * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
118 * can use a simple formula for leap years.
119 */
120#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
121#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)

--- 42 unchanged lines hidden (view full) ---

164static u_int32_t i8254_offset;
165static int i8254_ticked;
166/*
167 * XXX new_function and timer_func should not handle clockframes, but
168 * timer_func currently needs to hold hardclock to handle the
169 * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
170 * to switch between clkintr() and a slightly different timerintr().
171 */
172static void (*new_function) __P((struct clockframe *frame));
172static void (*new_function)(struct clockframe *frame);
173static u_int new_rate;
174#ifndef PC98
175static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
176static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
177#endif
178static u_int timer0_prescaler_count;
179
180/* Values for timerX_state: */
181#define RELEASED 0
182#define RELEASE_PENDING 1
183#define ACQUIRED 2
184#define ACQUIRE_PENDING 3
185
186static u_char timer0_state;
187#ifdef PC98
188static u_char timer1_state;
189#endif
190static u_char timer2_state;
173static u_int new_rate;
174#ifndef PC98
175static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
176static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
177#endif
178static u_int timer0_prescaler_count;
179
180/* Values for timerX_state: */
181#define RELEASED 0
182#define RELEASE_PENDING 1
183#define ACQUIRED 2
184#define ACQUIRE_PENDING 3
185
186static u_char timer0_state;
187#ifdef PC98
188static u_char timer1_state;
189#endif
190static u_char timer2_state;
191static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
191static void (*timer_func)(struct clockframe *frame) = hardclock;
192#ifdef PC98
192#ifdef PC98
193static void rtc_serialcombit __P((int));
194static void rtc_serialcom __P((int));
195static int rtc_inb __P((void));
196static void rtc_outb __P((int));
193static void rtc_serialcombit(int);
194static void rtc_serialcom(int);
195static int rtc_inb(void);
196static void rtc_outb(int);
197#endif
198
197#endif
198
199static unsigned i8254_get_timecount __P((struct timecounter *tc));
200static unsigned tsc_get_timecount __P((struct timecounter *tc));
199static unsigned i8254_get_timecount(struct timecounter *tc);
200static unsigned tsc_get_timecount(struct timecounter *tc);
201static void set_timer_freq(u_int freq, int intr_freq);
202
203static struct timecounter tsc_timecounter = {
204 tsc_get_timecount, /* get_timecount */
205 0, /* no poll_pps */
206 ~0u, /* counter_mask */
207 0, /* frequency */
208 "TSC" /* name */

--- 90 unchanged lines hidden (view full) ---

299 outb(0x61, inb(0x61) | 0x80);
300#endif
301}
302
303/*
304 * The acquire and release functions must be called at ipl >= splclock().
305 */
306int
201static void set_timer_freq(u_int freq, int intr_freq);
202
203static struct timecounter tsc_timecounter = {
204 tsc_get_timecount, /* get_timecount */
205 0, /* no poll_pps */
206 ~0u, /* counter_mask */
207 0, /* frequency */
208 "TSC" /* name */

--- 90 unchanged lines hidden (view full) ---

299 outb(0x61, inb(0x61) | 0x80);
300#endif
301}
302
303/*
304 * The acquire and release functions must be called at ipl >= splclock().
305 */
306int
307acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
307acquire_timer0(int rate, void (*function)(struct clockframe *frame))
308{
309 static int old_rate;
310
311 if (rate <= 0 || rate > TIMER0_MAX_FREQ)
312 return (-1);
313 switch (timer0_state) {
314
315 case RELEASED:

--- 1351 unchanged lines hidden ---
308{
309 static int old_rate;
310
311 if (rate <= 0 || rate > TIMER0_MAX_FREQ)
312 return (-1);
313 switch (timer0_state) {
314
315 case RELEASED:

--- 1351 unchanged lines hidden ---