Deleted Added
full compact
clock.c (1442) clock.c (1549)
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

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

45#include "time.h"
46#include "kernel.h"
47#include "machine/segments.h"
48#include "machine/frame.h"
49#include "i386/isa/icu.h"
50#include "i386/isa/isa.h"
51#include "i386/isa/rtc.h"
52#include "i386/isa/timerreg.h"
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

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

45#include "time.h"
46#include "kernel.h"
47#include "machine/segments.h"
48#include "machine/frame.h"
49#include "i386/isa/icu.h"
50#include "i386/isa/isa.h"
51#include "i386/isa/rtc.h"
52#include "i386/isa/timerreg.h"
53#include <machine/cpu.h>
53
54/* X-tals being what they are, it's nice to be able to fudge this one... */
55/* Note, the name changed here from XTALSPEED to TIMER_FREQ rgrimes 4/26/93 */
56#ifndef TIMER_FREQ
57#define TIMER_FREQ 1193182 /* XXX - should be in isa.h */
58#endif
59#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
60

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

66static char timer0_reprogram = 0;
67static void (*timer_func)() = hardclock;
68static void (*new_function)();
69static u_int new_rate;
70static u_int hardclock_divisor;
71
72
73void
54
55/* X-tals being what they are, it's nice to be able to fudge this one... */
56/* Note, the name changed here from XTALSPEED to TIMER_FREQ rgrimes 4/26/93 */
57#ifndef TIMER_FREQ
58#define TIMER_FREQ 1193182 /* XXX - should be in isa.h */
59#endif
60#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
61

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

67static char timer0_reprogram = 0;
68static void (*timer_func)() = hardclock;
69static void (*new_function)();
70static u_int new_rate;
71static u_int hardclock_divisor;
72
73
74void
74timerintr(struct intrframe frame)
75clkintr(frame)
76 struct clockframe frame;
75{
77{
76 timer_func(frame);
78 hardclock(&frame);
79}
80
81#if 0
82void
83timerintr(struct clockframe frame)
84{
85 timer_func(&frame);
77 switch (timer0_state) {
78 case 0:
79 break;
80 case 1:
81 if ((timer0_prescale+=timer0_divisor) >= hardclock_divisor) {
86 switch (timer0_state) {
87 case 0:
88 break;
89 case 1:
90 if ((timer0_prescale+=timer0_divisor) >= hardclock_divisor) {
82 hardclock(frame);
91 hardclock(&frame);
83 timer0_prescale = 0;
84 }
85 break;
86 case 2:
87 disable_intr();
88 outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
89 outb(TIMER_CNTR0, TIMER_DIV(new_rate)%256);
90 outb(TIMER_CNTR0, TIMER_DIV(new_rate)/256);
91 enable_intr();
92 timer0_divisor = TIMER_DIV(new_rate);
93 timer0_prescale = 0;
94 timer_func = new_function;
95 timer0_state = 1;
96 break;
97 case 3:
98 if ((timer0_prescale+=timer0_divisor) >= hardclock_divisor) {
92 timer0_prescale = 0;
93 }
94 break;
95 case 2:
96 disable_intr();
97 outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
98 outb(TIMER_CNTR0, TIMER_DIV(new_rate)%256);
99 outb(TIMER_CNTR0, TIMER_DIV(new_rate)/256);
100 enable_intr();
101 timer0_divisor = TIMER_DIV(new_rate);
102 timer0_prescale = 0;
103 timer_func = new_function;
104 timer0_state = 1;
105 break;
106 case 3:
107 if ((timer0_prescale+=timer0_divisor) >= hardclock_divisor) {
99 hardclock(frame);
108 hardclock(&frame);
100 disable_intr();
101 outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
102 outb(TIMER_CNTR0, TIMER_DIV(hz)%256);
103 outb(TIMER_CNTR0, TIMER_DIV(hz)/256);
104 enable_intr();
105 timer0_divisor = TIMER_DIV(hz);
106 timer0_prescale = 0;
107 timer_func = hardclock;;
108 timer0_state = 0;
109 }
110 break;
111 }
112}
113
109 disable_intr();
110 outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
111 outb(TIMER_CNTR0, TIMER_DIV(hz)%256);
112 outb(TIMER_CNTR0, TIMER_DIV(hz)/256);
113 enable_intr();
114 timer0_divisor = TIMER_DIV(hz);
115 timer0_prescale = 0;
116 timer_func = hardclock;;
117 timer0_state = 0;
118 }
119 break;
120 }
121}
122
123#endif
114
115int
116acquire_timer0(int rate, void (*function)() )
117{
118 if (timer0_state || !function)
119 return -1;
120
121 new_function = function;

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

390 printf("%d ",bcd(inb(IO_RTC+1)));
391 outb(IO_RTC,0); /* seconds */
392 printf("%d\n",bcd(inb(IO_RTC+1)));
393
394 time.tv_sec = base;
395}
396#endif
397
124
125int
126acquire_timer0(int rate, void (*function)() )
127{
128 if (timer0_state || !function)
129 return -1;
130
131 new_function = function;

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

400 printf("%d ",bcd(inb(IO_RTC+1)));
401 outb(IO_RTC,0); /* seconds */
402 printf("%d\n",bcd(inb(IO_RTC+1)));
403
404 time.tv_sec = base;
405}
406#endif
407
398
399/*
408/*
400 * Restart the clock.
401 */
402void
403resettodr()
404{
405}
406
407
408/*
409 * Wire clock interrupt in.
410 */
411#define V(s) __CONCAT(V, s)
412extern void V(clk)();
413
414
415void
416enablertclock()

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

423/*
424 * Delay for some number of milliseconds.
425 */
426void
427spinwait(int millisecs)
428{
429 DELAY(1000 * millisecs);
430}
409 * Wire clock interrupt in.
410 */
411#define V(s) __CONCAT(V, s)
412extern void V(clk)();
413
414
415void
416enablertclock()

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

423/*
424 * Delay for some number of milliseconds.
425 */
426void
427spinwait(int millisecs)
428{
429 DELAY(1000 * millisecs);
430}
431
432void
433cpu_initclocks()
434{
435 startrtclock();
436 enablertclock();
437}
438
439void
440setstatclockrate(int newhz)
441{
442}