diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/include/clock.h | 8 | ||||
-rw-r--r-- | sys/amd64/include/timerreg.h | 11 | ||||
-rw-r--r-- | sys/amd64/isa/clock.c | 54 | ||||
-rw-r--r-- | sys/dev/speaker/spkr.c | 5 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 4 | ||||
-rw-r--r-- | sys/i386/include/clock.h | 8 | ||||
-rw-r--r-- | sys/i386/include/timerreg.h | 11 | ||||
-rw-r--r-- | sys/i386/isa/clock.c | 55 | ||||
-rw-r--r-- | sys/ia64/ia64/machdep.c | 6 | ||||
-rw-r--r-- | sys/ia64/include/clock.h | 2 | ||||
-rw-r--r-- | sys/isa/atrtc.c | 55 | ||||
-rw-r--r-- | sys/isa/syscons_isa.c | 2 | ||||
-rw-r--r-- | sys/kern/tty_cons.c | 51 | ||||
-rw-r--r-- | sys/pc98/cbus/clock.c | 77 | ||||
-rw-r--r-- | sys/pc98/cbus/pcrtc.c | 77 | ||||
-rw-r--r-- | sys/pc98/cbus/syscons_cbus.c | 2 | ||||
-rw-r--r-- | sys/pc98/include/clock.h | 5 | ||||
-rw-r--r-- | sys/pc98/include/timerreg.h | 11 | ||||
-rw-r--r-- | sys/powerpc/aim/clock.c | 10 | ||||
-rw-r--r-- | sys/powerpc/booke/clock.c | 10 | ||||
-rw-r--r-- | sys/powerpc/include/clock.h | 4 | ||||
-rw-r--r-- | sys/sparc64/include/clock.h | 2 | ||||
-rw-r--r-- | sys/sparc64/sparc64/clock.c | 9 | ||||
-rw-r--r-- | sys/sun4v/include/clock.h | 2 | ||||
-rw-r--r-- | sys/sys/systm.h | 2 |
26 files changed, 153 insertions, 332 deletions
diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index 09cf697..c1f3029 100644 --- a/sys/amd64/include/clock.h +++ b/sys/amd64/include/clock.h @@ -27,14 +27,16 @@ void i8254_init(void); * Driver to clock driver interface. */ -int acquire_timer2(int mode); -int release_timer2(void); int rtcin(int reg); void writertc(int reg, unsigned char val); -int sysbeep(int pitch, int period); void init_TSC(void); void init_TSC_tc(void); +#define HAS_TIMER_SPKR 1 +int timer_spkr_acquire(void); +int timer_spkr_release(void); +void timer_spkr_setfreq(int freq); + #endif /* _KERNEL */ #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/amd64/include/timerreg.h b/sys/amd64/include/timerreg.h index 0ab7d40..cf5f281 100644 --- a/sys/amd64/include/timerreg.h +++ b/sys/amd64/include/timerreg.h @@ -49,17 +49,6 @@ #define TIMER_CNTR2 (IO_TIMER1 + TIMER_REG_CNTR2) #define TIMER_MODE (IO_TIMER1 + TIMER_REG_MODE) -#define timer_spkr_acquire() \ - acquire_timer2(TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT) -#define timer_spkr_release() \ - release_timer2() - -#define spkr_set_pitch(pitch) \ - do { \ - outb(TIMER_CNTR2, (pitch) & 0xff); \ - outb(TIMER_CNTR2, (pitch) >> 8); \ - } while(0) - #endif /* _KERNEL */ #endif /* _MACHINE_TIMERREG_H_ */ diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 31ec862..d7978a0 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -110,7 +110,6 @@ static int i8254_real_max_count; #define RTC_LOCK mtx_lock_spin(&clock_lock) #define RTC_UNLOCK mtx_unlock_spin(&clock_lock) -static int beeping = 0; static struct mtx clock_lock; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; static struct intsrc *i8254_intsrc; @@ -165,8 +164,11 @@ clkintr(struct trapframe *frame) } int -acquire_timer2(int mode) +timer_spkr_acquire(void) { + int mode; + + mode = TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT; if (timer2_state != RELEASED) return (-1); @@ -180,21 +182,33 @@ acquire_timer2(int mode) * careful with it as with timer0. */ outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f)); - + ppi_spkr_on(); /* enable counter2 output to speaker */ return (0); } int -release_timer2() +timer_spkr_release(void) { if (timer2_state != ACQUIRED) return (-1); timer2_state = RELEASED; outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT); + ppi_spkr_off(); /* disable counter2 output to speaker */ return (0); } +void +timer_spkr_setfreq(int freq) +{ + + freq = i8254_freq / freq; + mtx_lock_spin(&clock_lock); + outb(TIMER_CNTR2, freq & 0xff); + outb(TIMER_CNTR2, freq >> 8); + mtx_unlock_spin(&clock_lock); +} + /* * This routine receives statistical clock interrupts from the RTC. * As explained above, these occur at 128 interrupts per second. @@ -381,38 +395,6 @@ DELAY(int n) #endif } -static void -sysbeepstop(void *chan) -{ - ppi_spkr_off(); /* disable counter2 output to speaker */ - timer_spkr_release(); - beeping = 0; -} - -int -sysbeep(int pitch, int period) -{ - int x = splclock(); - - if (timer_spkr_acquire()) - if (!beeping) { - /* Something else owns it. */ - splx(x); - return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */ - } - mtx_lock_spin(&clock_lock); - spkr_set_pitch(pitch); - mtx_unlock_spin(&clock_lock); - if (!beeping) { - /* enable counter2 output to speaker */ - ppi_spkr_on(); - beeping = period; - timeout(sysbeepstop, (void *)NULL, period); - } - splx(x); - return (0); -} - /* * RTC support routines */ diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index f2f4989..f21732b 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -74,14 +74,11 @@ static void tone(thz, centisecs) unsigned int thz, centisecs; { - unsigned int divisor; int sps, timo; if (thz <= 0) return; - divisor = i8254_freq / thz; - #ifdef DEBUG (void) printf("tone: thz=%d centisecs=%d\n", thz, centisecs); #endif /* DEBUG */ @@ -96,7 +93,7 @@ tone(thz, centisecs) } splx(sps); disable_intr(); - spkr_set_pitch(divisor); + timer_spkr_setfreq(thz); enable_intr(); /* turn the speaker on */ diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 9fc443b..4abf4c4 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -3613,7 +3613,7 @@ sc_bell(scr_stat *scp, int pitch, int duration) } else if (duration != 0 && pitch != 0) { if (scp != scp->sc->cur_scp) pitch *= 2; - sysbeep(pitch, duration); + sysbeep(1193182 / pitch, duration); } } diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 88750d4..acc972e 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -417,7 +417,7 @@ trap(struct trapframe *frame) mtx_lock(&Giant); if (time_second - lastalert > 10) { log(LOG_WARNING, "NMI: power fail\n"); - sysbeep(TIMER_FREQ/880, hz); + sysbeep(880, hz); lastalert = time_second; } mtx_unlock(&Giant); @@ -651,7 +651,7 @@ trap(struct trapframe *frame) mtx_lock(&Giant); if (time_second - lastalert > 10) { log(LOG_WARNING, "NMI: power fail\n"); - sysbeep(TIMER_FREQ/880, hz); + sysbeep(880, hz); lastalert = time_second; } mtx_unlock(&Giant); diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h index 11d89a4..f938e58 100644 --- a/sys/i386/include/clock.h +++ b/sys/i386/include/clock.h @@ -27,15 +27,17 @@ void i8254_init(void); * Driver to clock driver interface. */ -int acquire_timer2(int mode); -int release_timer2(void); int rtcin(int reg); void writertc(int reg, unsigned char val); -int sysbeep(int pitch, int period); void timer_restore(void); void init_TSC(void); void init_TSC_tc(void); +#define HAS_TIMER_SPKR 1 +int timer_spkr_acquire(void); +int timer_spkr_release(void); +void timer_spkr_setfreq(int freq); + #endif /* _KERNEL */ #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/i386/include/timerreg.h b/sys/i386/include/timerreg.h index 0ab7d40..cf5f281 100644 --- a/sys/i386/include/timerreg.h +++ b/sys/i386/include/timerreg.h @@ -49,17 +49,6 @@ #define TIMER_CNTR2 (IO_TIMER1 + TIMER_REG_CNTR2) #define TIMER_MODE (IO_TIMER1 + TIMER_REG_MODE) -#define timer_spkr_acquire() \ - acquire_timer2(TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT) -#define timer_spkr_release() \ - release_timer2() - -#define spkr_set_pitch(pitch) \ - do { \ - outb(TIMER_CNTR2, (pitch) & 0xff); \ - outb(TIMER_CNTR2, (pitch) >> 8); \ - } while(0) - #endif /* _KERNEL */ #endif /* _MACHINE_TIMERREG_H_ */ diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 76a6549..d5aa118 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -113,7 +113,6 @@ static int i8254_real_max_count; #define RTC_LOCK mtx_lock_spin(&clock_lock) #define RTC_UNLOCK mtx_unlock_spin(&clock_lock) -static int beeping = 0; static struct mtx clock_lock; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; @@ -172,8 +171,11 @@ clkintr(struct trapframe *frame) } int -acquire_timer2(int mode) +timer_spkr_acquire(void) { + int mode; + + mode = TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT; if (timer2_state != RELEASED) return (-1); @@ -187,21 +189,34 @@ acquire_timer2(int mode) * careful with it as with timer0. */ outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f)); - + ppi_spkr_on(); /* enable counter2 output to speaker */ return (0); } int -release_timer2() +timer_spkr_release(void) { if (timer2_state != ACQUIRED) return (-1); timer2_state = RELEASED; outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT); + ppi_spkr_off(); /* disable counter2 output to speaker */ return (0); } +void +timer_spkr_setfreq(int freq) +{ + + freq = i8254_freq / freq; + mtx_lock_spin(&clock_lock); + outb(TIMER_CNTR2, freq & 0xff); + outb(TIMER_CNTR2, freq >> 8); + mtx_unlock_spin(&clock_lock); +} + + /* * This routine receives statistical clock interrupts from the RTC. * As explained above, these occur at 128 interrupts per second. @@ -386,38 +401,6 @@ DELAY(int n) #endif } -static void -sysbeepstop(void *chan) -{ - ppi_spkr_off(); /* disable counter2 output to speaker */ - timer_spkr_release(); - beeping = 0; -} - -int -sysbeep(int pitch, int period) -{ - int x = splclock(); - - if (timer_spkr_acquire()) - if (!beeping) { - /* Something else owns it. */ - splx(x); - return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */ - } - mtx_lock_spin(&clock_lock); - spkr_set_pitch(pitch); - mtx_unlock_spin(&clock_lock); - if (!beeping) { - /* enable counter2 output to speaker */ - ppi_spkr_on(); - beeping = period; - timeout(sysbeepstop, (void *)NULL, period); - } - splx(x); - return (0); -} - /* * RTC support routines */ diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 98f2812..4bc743a 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -1513,9 +1513,3 @@ ia64_highfp_save(struct thread *td) KASSERT(thr == td, ("Inconsistent high FP state")); return (1); } - -int -sysbeep(int pitch, int period) -{ - return (ENODEV); -} diff --git a/sys/ia64/include/clock.h b/sys/ia64/include/clock.h index 31a8ed2..aa4220a 100644 --- a/sys/ia64/include/clock.h +++ b/sys/ia64/include/clock.h @@ -16,8 +16,6 @@ extern uint64_t ia64_clock_reload; extern uint64_t itc_frequency; -int sysbeep(int pitch, int period); - #endif #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 76a6549..d5aa118 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -113,7 +113,6 @@ static int i8254_real_max_count; #define RTC_LOCK mtx_lock_spin(&clock_lock) #define RTC_UNLOCK mtx_unlock_spin(&clock_lock) -static int beeping = 0; static struct mtx clock_lock; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; @@ -172,8 +171,11 @@ clkintr(struct trapframe *frame) } int -acquire_timer2(int mode) +timer_spkr_acquire(void) { + int mode; + + mode = TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT; if (timer2_state != RELEASED) return (-1); @@ -187,21 +189,34 @@ acquire_timer2(int mode) * careful with it as with timer0. */ outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f)); - + ppi_spkr_on(); /* enable counter2 output to speaker */ return (0); } int -release_timer2() +timer_spkr_release(void) { if (timer2_state != ACQUIRED) return (-1); timer2_state = RELEASED; outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT); + ppi_spkr_off(); /* disable counter2 output to speaker */ return (0); } +void +timer_spkr_setfreq(int freq) +{ + + freq = i8254_freq / freq; + mtx_lock_spin(&clock_lock); + outb(TIMER_CNTR2, freq & 0xff); + outb(TIMER_CNTR2, freq >> 8); + mtx_unlock_spin(&clock_lock); +} + + /* * This routine receives statistical clock interrupts from the RTC. * As explained above, these occur at 128 interrupts per second. @@ -386,38 +401,6 @@ DELAY(int n) #endif } -static void -sysbeepstop(void *chan) -{ - ppi_spkr_off(); /* disable counter2 output to speaker */ - timer_spkr_release(); - beeping = 0; -} - -int -sysbeep(int pitch, int period) -{ - int x = splclock(); - - if (timer_spkr_acquire()) - if (!beeping) { - /* Something else owns it. */ - splx(x); - return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */ - } - mtx_lock_spin(&clock_lock); - spkr_set_pitch(pitch); - mtx_unlock_spin(&clock_lock); - if (!beeping) { - /* enable counter2 output to speaker */ - ppi_spkr_on(); - beeping = period; - timeout(sysbeepstop, (void *)NULL, period); - } - splx(x); - return (0); -} - /* * RTC support routines */ diff --git a/sys/isa/syscons_isa.c b/sys/isa/syscons_isa.c index 50ed27d..035280f 100644 --- a/sys/isa/syscons_isa.c +++ b/sys/isa/syscons_isa.c @@ -278,7 +278,7 @@ sc_tone(int herz) if (timer_spkr_acquire()) return EBUSY; /* set pitch */ - spkr_set_pitch(i8254_freq / herz); + timer_spkr_setfreq(herz); /* enable counter 2 output to speaker */ ppi_spkr_on(); } else { diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index 624ae85..99f6f51 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include <ddb/ddb.h> #include <machine/cpu.h> +#include <machine/clock.h> static d_open_t cnopen; static d_close_t cnclose; @@ -732,3 +733,53 @@ cn_drvinit(void *unused) } SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, cn_drvinit, NULL); + +/* + * Sysbeep(), if we have hardware for it + */ + +#ifdef HAS_TIMER_SPKR + +static int beeping; + +static void +sysbeepstop(void *chan) +{ + + timer_spkr_release(); + beeping = 0; +} + +int +sysbeep(int pitch, int period) +{ + + if (timer_spkr_acquire()) { + if (!beeping) { + /* Something else owns it. */ + return (EBUSY); + } + } + timer_spkr_setfreq(pitch); + if (!beeping) { + beeping = period; + timeout(sysbeepstop, (void *)NULL, period); + } + return (0); +} + +#else + +/* + * No hardware, no sound + */ + +int +sysbeep(int pitch __unused, int period __unused) +{ + + return (ENODEV); +} + +#endif + diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index fcacda5..38f9854 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -105,7 +105,6 @@ TUNABLE_INT("hw.i8254.freq", &i8254_freq); int i8254_max_count; static int i8254_real_max_count; -static int beeping = 0; static struct mtx clock_lock; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; @@ -121,7 +120,6 @@ static int using_lapic_timer; #define ACQUIRE_PENDING 3 static u_char timer1_state; -static u_char timer2_state; static void rtc_serialcombit(int); static void rtc_serialcom(int); static int rtc_inb(void); @@ -161,8 +159,11 @@ clkintr(struct trapframe *frame) } int -acquire_timer1(int mode) +timer_spkr_acquire(void) { + int mode; + + mode = TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT; if (timer1_state != RELEASED) return (-1); @@ -176,50 +177,32 @@ acquire_timer1(int mode) * careful with it as with timer0. */ outb(TIMER_MODE, TIMER_SEL1 | (mode & 0x3f)); + ppi_spkr_on(); /* enable counter1 output to speaker */ return (0); } int -acquire_timer2(int mode) -{ - - if (timer2_state != RELEASED) - return (-1); - timer2_state = ACQUIRED; - - /* - * This access to the timer registers is as atomic as possible - * because it is a single instruction. We could do better if we - * knew the rate. Use of splclock() limits glitches to 10-100us, - * and this is probably good enough for timer2, so we aren't as - * careful with it as with timer0. - */ - outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f)); - - return (0); -} - -int -release_timer1() +timer_spkr_release(void) { if (timer1_state != ACQUIRED) return (-1); timer1_state = RELEASED; outb(TIMER_MODE, TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT); + ppi_spkr_off(); /* disable counter1 output to speaker */ return (0); } -int -release_timer2() +void +timer_spkr_setfreq(int freq) { - if (timer2_state != ACQUIRED) - return (-1); - timer2_state = RELEASED; - outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT); - return (0); + freq = i8254_freq / freq; + mtx_lock_spin(&clock_lock); + outb(TIMER_CNTR1, (freq) & 0xff); + outb(TIMER_CNTR1, (freq) >> 8); + mtx_unlock_spin(&clock_lock); } @@ -342,38 +325,6 @@ DELAY(int n) #endif } -static void -sysbeepstop(void *chan) -{ - ppi_spkr_off(); /* disable counter1 output to speaker */ - timer_spkr_release(); - beeping = 0; -} - -int -sysbeep(int pitch, int period) -{ - int x = splclock(); - - if (timer_spkr_acquire()) - if (!beeping) { - /* Something else owns it. */ - splx(x); - return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */ - } - mtx_lock_spin(&clock_lock); - spkr_set_pitch(pitch); - mtx_unlock_spin(&clock_lock); - if (!beeping) { - /* enable counter1 output to speaker */ - ppi_spkr_on(); - beeping = period; - timeout(sysbeepstop, (void *)NULL, period); - } - splx(x); - return (0); -} - static u_int calibrate_clocks(void) { diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index fcacda5..38f9854 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -105,7 +105,6 @@ TUNABLE_INT("hw.i8254.freq", &i8254_freq); int i8254_max_count; static int i8254_real_max_count; -static int beeping = 0; static struct mtx clock_lock; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; @@ -121,7 +120,6 @@ static int using_lapic_timer; #define ACQUIRE_PENDING 3 static u_char timer1_state; -static u_char timer2_state; static void rtc_serialcombit(int); static void rtc_serialcom(int); static int rtc_inb(void); @@ -161,8 +159,11 @@ clkintr(struct trapframe *frame) } int -acquire_timer1(int mode) +timer_spkr_acquire(void) { + int mode; + + mode = TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT; if (timer1_state != RELEASED) return (-1); @@ -176,50 +177,32 @@ acquire_timer1(int mode) * careful with it as with timer0. */ outb(TIMER_MODE, TIMER_SEL1 | (mode & 0x3f)); + ppi_spkr_on(); /* enable counter1 output to speaker */ return (0); } int -acquire_timer2(int mode) -{ - - if (timer2_state != RELEASED) - return (-1); - timer2_state = ACQUIRED; - - /* - * This access to the timer registers is as atomic as possible - * because it is a single instruction. We could do better if we - * knew the rate. Use of splclock() limits glitches to 10-100us, - * and this is probably good enough for timer2, so we aren't as - * careful with it as with timer0. - */ - outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f)); - - return (0); -} - -int -release_timer1() +timer_spkr_release(void) { if (timer1_state != ACQUIRED) return (-1); timer1_state = RELEASED; outb(TIMER_MODE, TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT); + ppi_spkr_off(); /* disable counter1 output to speaker */ return (0); } -int -release_timer2() +void +timer_spkr_setfreq(int freq) { - if (timer2_state != ACQUIRED) - return (-1); - timer2_state = RELEASED; - outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT); - return (0); + freq = i8254_freq / freq; + mtx_lock_spin(&clock_lock); + outb(TIMER_CNTR1, (freq) & 0xff); + outb(TIMER_CNTR1, (freq) >> 8); + mtx_unlock_spin(&clock_lock); } @@ -342,38 +325,6 @@ DELAY(int n) #endif } -static void -sysbeepstop(void *chan) -{ - ppi_spkr_off(); /* disable counter1 output to speaker */ - timer_spkr_release(); - beeping = 0; -} - -int -sysbeep(int pitch, int period) -{ - int x = splclock(); - - if (timer_spkr_acquire()) - if (!beeping) { - /* Something else owns it. */ - splx(x); - return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */ - } - mtx_lock_spin(&clock_lock); - spkr_set_pitch(pitch); - mtx_unlock_spin(&clock_lock); - if (!beeping) { - /* enable counter1 output to speaker */ - ppi_spkr_on(); - beeping = period; - timeout(sysbeepstop, (void *)NULL, period); - } - splx(x); - return (0); -} - static u_int calibrate_clocks(void) { diff --git a/sys/pc98/cbus/syscons_cbus.c b/sys/pc98/cbus/syscons_cbus.c index 19415a2..c23fbc4 100644 --- a/sys/pc98/cbus/syscons_cbus.c +++ b/sys/pc98/cbus/syscons_cbus.c @@ -233,7 +233,7 @@ sc_tone(int herz) if (timer_spkr_acquire()) return EBUSY; /* set pitch */ - spkr_set_pitch(i8254_freq / herz); + timer_spkr_setfreq(herz); } else { /* disable counter 1 */ ppi_spkr_off(); diff --git a/sys/pc98/include/clock.h b/sys/pc98/include/clock.h index a2a654a..86251a5 100644 --- a/sys/pc98/include/clock.h +++ b/sys/pc98/include/clock.h @@ -30,9 +30,4 @@ #include <i386/clock.h> -#ifdef _KERNEL -int acquire_timer1(int); -int release_timer1(void); -#endif - #endif /* _PC98_INCLUDE_CLOCK_H_ */ diff --git a/sys/pc98/include/timerreg.h b/sys/pc98/include/timerreg.h index 59c223c..f232581 100644 --- a/sys/pc98/include/timerreg.h +++ b/sys/pc98/include/timerreg.h @@ -49,17 +49,6 @@ #define TIMER_CNTR2 (IO_TIMER1 + TIMER_REG_CNTR2 * 2) #define TIMER_MODE (IO_TIMER1 + TIMER_REG_MODE * 2) -#define timer_spkr_acquire() \ - acquire_timer1(TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT) -#define timer_spkr_release() \ - release_timer1() - -#define spkr_set_pitch(pitch) \ - do { \ - outb(TIMER_CNTR1, (pitch) & 0xff); \ - outb(TIMER_CNTR1, (pitch) >> 8); \ - } while(0) - #endif /* _KERNEL */ #endif /* _MACHINE_TIMERREG_H_ */ diff --git a/sys/powerpc/aim/clock.c b/sys/powerpc/aim/clock.c index 0c01cf0..1b3de58 100644 --- a/sys/powerpc/aim/clock.c +++ b/sys/powerpc/aim/clock.c @@ -306,13 +306,3 @@ void cpu_stopprofclock(void) { } - -/* - * XXX Needed by syscons - */ -int -sysbeep(int pitch, int period) -{ - - return (0); -} diff --git a/sys/powerpc/booke/clock.c b/sys/powerpc/booke/clock.c index a54c85a..c05e1d1 100644 --- a/sys/powerpc/booke/clock.c +++ b/sys/powerpc/booke/clock.c @@ -264,13 +264,3 @@ cpu_stopprofclock(void) { } - -/* - * XXX Needed by syscons - */ -int -sysbeep(int pitch, int period) -{ - - return (0); -} diff --git a/sys/powerpc/include/clock.h b/sys/powerpc/include/clock.h index ead37ac1..b3cee9c 100644 --- a/sys/powerpc/include/clock.h +++ b/sys/powerpc/include/clock.h @@ -13,10 +13,6 @@ struct trapframe; -int sysbeep(int pitch, int period); -int acquire_timer2(int mode); -int release_timer2(void); - void decr_intr(struct trapframe *); #endif diff --git a/sys/sparc64/include/clock.h b/sys/sparc64/include/clock.h index c98b024..b0e4c0b 100644 --- a/sys/sparc64/include/clock.h +++ b/sys/sparc64/include/clock.h @@ -33,6 +33,4 @@ extern u_long tick_increment; extern u_long tick_freq; extern u_long tick_MHz; -int sysbeep(int, int); - #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/sparc64/sparc64/clock.c b/sys/sparc64/sparc64/clock.c index 37341fd..a73ed35 100644 --- a/sys/sparc64/sparc64/clock.c +++ b/sys/sparc64/sparc64/clock.c @@ -56,12 +56,3 @@ void cpu_stopprofclock(void) { } - -int -sysbeep(int pitch, int period) -{ - /* - * XXX: function exists to enable RAID drivers to compile at the moment. - */ - return (0); -} diff --git a/sys/sun4v/include/clock.h b/sys/sun4v/include/clock.h index fbedfea..992b629 100644 --- a/sys/sun4v/include/clock.h +++ b/sys/sun4v/include/clock.h @@ -36,6 +36,4 @@ extern u_long tick_MHz; extern int adjkerntz; extern int wall_cmos_clock; -int sysbeep(int, int); - #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 0e5f820..1863fb7 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -212,6 +212,8 @@ u_long casuword(volatile u_long *p, u_long oldval, u_long newval); void realitexpire(void *); +int sysbeep(int hertz, int period); + /* * Cyclic clock function type definition used to hook the cyclic * subsystem into the appropriate timer interrupt. |