summaryrefslogtreecommitdiffstats
path: root/sys/isa/atrtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/isa/atrtc.c')
-rw-r--r--sys/isa/atrtc.c55
1 files changed, 19 insertions, 36 deletions
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
*/
OpenPOWER on IntegriCloud