From 99f1b222339d6eee1c65e04ad1def3c866f155b0 Mon Sep 17 00:00:00 2001 From: nyan Date: Sat, 14 May 2005 09:10:02 +0000 Subject: - Move timerreg.h to /include and split i8253 specific defines into i8253reg.h, and add some defines to control a speaker. - Move PPI related defines from i386/isa/spkr.c into ppireg.h and use them. - Move IO_{PPI,TIMER} defines into ppireg.h and timerreg.h respectively. - Use isa/isareg.h rather than /isa/isa.h. Tested on: i386, pc98 --- sys/isa/atrtc.c | 16 ++++++++-------- sys/isa/isareg.h | 3 --- sys/isa/syscons_isa.c | 19 +++++++------------ 3 files changed, 15 insertions(+), 23 deletions(-) (limited to 'sys/isa') diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index eb8f282..5350c79 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -77,13 +77,14 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include +#include -#include #include #ifdef DEV_ISA +#include #include #endif -#include #ifdef DEV_MCA #include @@ -379,8 +380,8 @@ DELAY(int n) static void sysbeepstop(void *chan) { - outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */ - release_timer2(); + ppi_spkr_off(); /* disable counter2 output to speaker */ + timer_spkr_release(); beeping = 0; } @@ -389,19 +390,18 @@ sysbeep(int pitch, int period) { int x = splclock(); - if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT)) + 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); - outb(TIMER_CNTR2, pitch); - outb(TIMER_CNTR2, (pitch>>8)); + spkr_set_pitch(pitch); mtx_unlock_spin(&clock_lock); if (!beeping) { /* enable counter2 output to speaker */ - outb(IO_PPI, inb(IO_PPI) | 3); + ppi_spkr_on(); beeping = period; timeout(sysbeepstop, (void *)NULL, period); } diff --git a/sys/isa/isareg.h b/sys/isa/isareg.h index 05f21bfb..8be7443 100644 --- a/sys/isa/isareg.h +++ b/sys/isa/isareg.h @@ -56,10 +56,7 @@ #define IO_DMA1 0x000 /* 8237A DMA Controller #1 */ #define IO_ICU1 0x020 /* 8259A Interrupt Controller #1 */ #define IO_PMP1 0x026 /* 82347 Power Management Peripheral */ -#define IO_TIMER1 0x040 /* 8253 Timer #1 */ -#define IO_TIMER2 0x048 /* 8253 Timer #2 */ #define IO_KBD 0x060 /* 8042 Keyboard */ -#define IO_PPI 0x061 /* Programmable Peripheral Interface */ #define IO_RTC 0x070 /* RTC */ #define IO_NMI IO_RTC /* NMI Control */ #define IO_DMAPG 0x080 /* DMA Page Registers */ diff --git a/sys/isa/syscons_isa.c b/sys/isa/syscons_isa.c index d271d09..3f750ef 100644 --- a/sys/isa/syscons_isa.c +++ b/sys/isa/syscons_isa.c @@ -43,14 +43,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include #include -#include - #define BIOS_CLKED (1 << 6) #define BIOS_NLKED (1 << 5) #define BIOS_SLKED (1 << 4) @@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include static devclass_t sc_devclass; @@ -256,22 +255,18 @@ int sc_tone(int herz) { #if defined(__i386__) || defined(__amd64__) - int pitch; - if (herz) { /* set command for counter 2, 2 byte write */ - if (acquire_timer2(TIMER_16BIT | TIMER_SQWAVE)) + if (timer_spkr_acquire()) return EBUSY; /* set pitch */ - pitch = timer_freq/herz; - outb(TIMER_CNTR2, pitch); - outb(TIMER_CNTR2, pitch >> 8); + spkr_set_pitch(timer_freq / herz); /* enable counter 2 output to speaker */ - outb(IO_PPI, inb(IO_PPI) | 3); + ppi_spkr_on(); } else { /* disable counter 2 output to speaker */ - outb(IO_PPI, inb(IO_PPI) & 0xFC); - release_timer2(); + ppi_spkr_off(); + timer_spkr_release(); } #endif -- cgit v1.1