Move definitions of TIMER_FREQ to timerreg.h, and fix value of CF for DELAY().
This commit is contained in:
parent
2a2bde915f
commit
528edf6037
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.7 1993/06/06 04:16:28 cgd Exp $
|
||||
* $Id: clock.c,v 1.8 1993/06/15 21:37:14 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -53,10 +53,6 @@
|
||||
#define DAYST 119
|
||||
#define DAYEN 303
|
||||
|
||||
#ifndef TIMER_FREQ
|
||||
#define TIMER_FREQ 1193182
|
||||
#endif
|
||||
|
||||
startrtclock() {
|
||||
int s;
|
||||
|
||||
@ -66,8 +62,8 @@ startrtclock() {
|
||||
outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
|
||||
|
||||
/* Correct rounding will buy us a better precision in timekeeping */
|
||||
outb (IO_TIMER1, (TIMER_FREQ+hz/2)/hz);
|
||||
outb (IO_TIMER1, ((TIMER_FREQ+hz/2)/hz)/256);
|
||||
outb (IO_TIMER1, TIMER_DIV(hz)%256);
|
||||
outb (IO_TIMER1, TIMER_DIV(hz)/256);
|
||||
|
||||
/* initialize brain-dead battery powered clock */
|
||||
outb (IO_RTC, RTC_STATUSA);
|
||||
@ -103,7 +99,7 @@ findcpuspeed()
|
||||
/* Formula for delaycount is :
|
||||
* (loopcount * timer clock speed)/ (counter ticks * 1000)
|
||||
*/
|
||||
delaycount = (FIRST_GUESS * (TIMER_FREQ/1000)) / (0xffff-remainder);
|
||||
delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff-remainder);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)isa.c 7.2 (Berkeley) 5/13/91
|
||||
* $Id: isa.c,v 1.16 1993/06/15 20:34:54 mycroft Exp $
|
||||
* $Id: isa.c,v 1.17 1993/06/15 21:37:16 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -516,13 +516,12 @@ isa_strayintr(d) {
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
* Relies on timer 1 counting down from (TIMER_FREQ / hz) at
|
||||
* (2 * TIMER_FREQ) Hz.
|
||||
* (1 * TIMER_FREQ) Hz.
|
||||
* Note: timer had better have been programmed before this is first used!
|
||||
* (The standard programming causes the timer to generate a square wave and
|
||||
* the counter is decremented twice every cycle.)
|
||||
* (Note that we use `rate generator' mode, which counts at 1:1; `square
|
||||
* wave' mode counts at 2:1).
|
||||
*/
|
||||
#define CF (2 * TIMER_FREQ)
|
||||
#define TIMER_FREQ 1193182 /* XXX - should be elsewhere */
|
||||
#define CF (1 * TIMER_FREQ)
|
||||
|
||||
extern int hz; /* XXX - should be elsewhere */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* 386bsd only clean version, all SYSV stuff removed
|
||||
* use hz value from param.c
|
||||
*
|
||||
* $Id: spkr.c,v 1.2 1993/05/22 08:01:37 cgd Exp $
|
||||
* $Id: spkr.c,v 1.3 1993/06/15 21:37:18 mycroft Exp $
|
||||
*/
|
||||
|
||||
#include "speaker.h"
|
||||
@ -54,10 +54,7 @@
|
||||
#define PIT_COUNT 0x42 /* PIT count address */
|
||||
#define PIT_MODE 0xB6 /* set timer mode for sound generation */
|
||||
|
||||
/*
|
||||
* Magic numbers for timer control.
|
||||
*/
|
||||
#define TIMER_CLK 1193180L /* corresponds to 18.2 MHz tick rate */
|
||||
#include "timerreg.h"
|
||||
|
||||
static int endtone()
|
||||
/* turn off the speaker, ending current tone */
|
||||
@ -70,7 +67,7 @@ static void tone(hz, ticks)
|
||||
/* emit tone of frequency hz for given number of ticks */
|
||||
unsigned int hz, ticks;
|
||||
{
|
||||
unsigned int divisor = TIMER_CLK / hz;
|
||||
unsigned int divisor = TIMER_DIV(hz);
|
||||
int sps;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: timerreg.h,v 1.2 1993/05/22 08:01:39 cgd Exp $
|
||||
* $Id: timerreg.h,v 1.3 1993/06/15 21:37:19 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -67,6 +67,15 @@
|
||||
* Timer 2 is used to generate console beeps.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Frequency of all three count-down timers; (TIMER_FREQ/freq) is the
|
||||
* appropriate count to generate a frequency of freq hz.
|
||||
*/
|
||||
#ifndef TIMER_FREQ
|
||||
#define TIMER_FREQ 1193182
|
||||
#endif
|
||||
#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
|
||||
|
||||
/*
|
||||
* Macros for specifying values to be written into a mode register.
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: i8253reg.h,v 1.2 1993/05/22 08:01:39 cgd Exp $
|
||||
* $Id: i8253reg.h,v 1.3 1993/06/15 21:37:19 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -67,6 +67,15 @@
|
||||
* Timer 2 is used to generate console beeps.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Frequency of all three count-down timers; (TIMER_FREQ/freq) is the
|
||||
* appropriate count to generate a frequency of freq hz.
|
||||
*/
|
||||
#ifndef TIMER_FREQ
|
||||
#define TIMER_FREQ 1193182
|
||||
#endif
|
||||
#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
|
||||
|
||||
/*
|
||||
* Macros for specifying values to be written into a mode register.
|
||||
*/
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)isa.c 7.2 (Berkeley) 5/13/91
|
||||
* $Id: isa.c,v 1.16 1993/06/15 20:34:54 mycroft Exp $
|
||||
* $Id: isa.c,v 1.17 1993/06/15 21:37:16 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -516,13 +516,12 @@ isa_strayintr(d) {
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
* Relies on timer 1 counting down from (TIMER_FREQ / hz) at
|
||||
* (2 * TIMER_FREQ) Hz.
|
||||
* (1 * TIMER_FREQ) Hz.
|
||||
* Note: timer had better have been programmed before this is first used!
|
||||
* (The standard programming causes the timer to generate a square wave and
|
||||
* the counter is decremented twice every cycle.)
|
||||
* (Note that we use `rate generator' mode, which counts at 1:1; `square
|
||||
* wave' mode counts at 2:1).
|
||||
*/
|
||||
#define CF (2 * TIMER_FREQ)
|
||||
#define TIMER_FREQ 1193182 /* XXX - should be elsewhere */
|
||||
#define CF (1 * TIMER_FREQ)
|
||||
|
||||
extern int hz; /* XXX - should be elsewhere */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user