summaryrefslogtreecommitdiff
path: root/sys/dev/isa
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2001-04-17 04:30:52 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2001-04-17 04:30:52 +0000
commitd471bc85066a41148d5a902c01901d37503aef8e (patch)
tree5aad893f43fec1ffb45e2e7732cf5e2bbdd7e3fd /sys/dev/isa
parentb63233435dd37169d9c0b9e875ca311a1e4bfd59 (diff)
Implement cnbell(), an optional entrypoint that rings the console bell; from
NetBSD. deraadt@ ok
Diffstat (limited to 'sys/dev/isa')
-rw-r--r--sys/dev/isa/pcppi.c61
-rw-r--r--sys/dev/isa/pcppivar.h5
-rw-r--r--sys/dev/isa/spkr.c4
3 files changed, 58 insertions, 12 deletions
diff --git a/sys/dev/isa/pcppi.c b/sys/dev/isa/pcppi.c
index 6bb451d66d1..f8e71d388db 100644
--- a/sys/dev/isa/pcppi.c
+++ b/sys/dev/isa/pcppi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcppi.c,v 1.2 2000/06/30 06:55:53 art Exp $ */
+/* $OpenBSD: pcppi.c,v 1.3 2001/04/17 04:30:50 aaron Exp $ */
/* $NetBSD: pcppi.c,v 1.1 1998/04/15 20:26:18 drochner Exp $ */
/*
@@ -44,15 +44,25 @@
#include <dev/ic/i8253reg.h>
+#include "pckbd.h"
+#if NPCKBD > 0
+#include <dev/ic/pckbcvar.h>
+#include <dev/pckbc/pckbdvar.h>
+
+void pcppi_pckbd_bell __P((void *, u_int, u_int, u_int, int));
+#endif
+
struct pcppi_softc {
struct device sc_dv;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ppi_ioh, sc_pit1_ioh;
+ struct timeout sc_bell_timeout;
+
int sc_bellactive, sc_bellpitch;
int sc_slp;
- struct timeout sc_bell_timeout;
+ int sc_timeout;
};
#define __BROKEN_INDIRECT_CONFIG /* XXX */
@@ -156,6 +166,8 @@ pcppi_attach(parent, self, aux)
bus_space_tag_t iot;
struct pcppi_attach_args pa;
+ timeout_set(&sc->sc_bell_timeout, pcppi_bell_stop, sc);
+
sc->sc_iot = iot = ia->ia_iot;
if (bus_space_map(iot, IO_TIMER1, 4, 0, &sc->sc_pit1_ioh) ||
@@ -165,7 +177,11 @@ pcppi_attach(parent, self, aux)
printf("\n");
sc->sc_bellactive = sc->sc_bellpitch = sc->sc_slp = 0;
- timeout_set(&sc->sc_bell_timeout, pcppi_bell_stop, sc);
+
+#if NPCKBD > 0
+ /* Provide a beeper for the PC Keyboard, if there isn't one already. */
+ pckbd_hookup_bell(pcppi_pckbd_bell, sc);
+#endif
pa.pa_cookie = sc;
while (config_found(self, &pa, 0));
@@ -182,7 +198,10 @@ pcppi_bell(self, pitch, period, slp)
s1 = spltty(); /* ??? */
if (sc->sc_bellactive) {
- timeout_del(&sc->sc_bell_timeout);
+ if (sc->sc_timeout) {
+ sc->sc_timeout = 0;
+ timeout_del(&sc->sc_bell_timeout);
+ }
if (sc->sc_slp)
wakeup(pcppi_bell_stop);
}
@@ -209,11 +228,18 @@ pcppi_bell(self, pitch, period, slp)
sc->sc_bellpitch = pitch;
sc->sc_bellactive = 1;
- timeout_add(&sc->sc_bell_timeout, period);
- if (slp) {
- sc->sc_slp = 1;
- tsleep(pcppi_bell_stop, PCPPIPRI | PCATCH, "bell", 0);
- sc->sc_slp = 0;
+
+ if (slp & PCPPI_BELL_POLL) {
+ delay((period * 1000000) / hz);
+ pcppi_bell_stop(sc);
+ } else {
+ sc->sc_timeout = 1;
+ timeout_add(&sc->sc_bell_timeout, period);
+ if (slp & PCPPI_BELL_SLEEP) {
+ sc->sc_slp = 1;
+ tsleep(pcppi_bell_stop, PCPPIPRI | PCATCH, "bell", 0);
+ sc->sc_slp = 0;
+ }
}
splx(s1);
}
@@ -226,6 +252,8 @@ pcppi_bell_stop(arg)
int s;
s = spltty(); /* ??? */
+ sc->sc_timeout = 0;
+
/* disable bell */
bus_space_write_1(sc->sc_iot, sc->sc_ppi_ioh, 0,
bus_space_read_1(sc->sc_iot, sc->sc_ppi_ioh, 0)
@@ -235,3 +263,18 @@ pcppi_bell_stop(arg)
wakeup(pcppi_bell_stop);
splx(s);
}
+
+#if NPCKBD > 0
+void
+pcppi_pckbd_bell(arg, pitch, period, volume, poll)
+ void *arg;
+ u_int pitch, period, volume;
+ int poll;
+{
+ /*
+ * Comes in as ms, goes out as ticks; volume ignored.
+ */
+ pcppi_bell(arg, pitch, (period * hz) / 1000,
+ poll ? PCPPI_BELL_POLL : 0);
+}
+#endif /* NPCKBD > 0 */
diff --git a/sys/dev/isa/pcppivar.h b/sys/dev/isa/pcppivar.h
index fb61b38e9fa..9d705616070 100644
--- a/sys/dev/isa/pcppivar.h
+++ b/sys/dev/isa/pcppivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcppivar.h,v 1.1 1999/01/02 00:02:45 niklas Exp $ */
+/* $OpenBSD: pcppivar.h,v 1.2 2001/04/17 04:30:50 aaron Exp $ */
/* $NetBSD: pcppivar.h,v 1.1 1998/04/15 20:26:18 drochner Exp $ */
/*
@@ -34,4 +34,7 @@ struct pcppi_attach_args {
pcppi_tag_t pa_cookie;
};
+#define PCPPI_BELL_SLEEP 0x01 /* synchronous; sleep for complete */
+#define PCPPI_BELL_POLL 0x02 /* synchronous; poll for complete */
+
void pcppi_bell __P((pcppi_tag_t, int, int, int));
diff --git a/sys/dev/isa/spkr.c b/sys/dev/isa/spkr.c
index 466c8d3e19f..79e99bfdd22 100644
--- a/sys/dev/isa/spkr.c
+++ b/sys/dev/isa/spkr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spkr.c,v 1.4 2000/09/29 23:39:08 miod Exp $ */
+/* $OpenBSD: spkr.c,v 1.5 2001/04/17 04:30:50 aaron Exp $ */
/* $NetBSD: spkr.c,v 1.1 1998/04/15 20:26:18 drochner Exp $ */
/*
@@ -62,7 +62,7 @@ void tone(hz, ticks)
/* emit tone of frequency hz for given number of ticks */
u_int hz, ticks;
{
- pcppi_bell(ppicookie, hz, ticks, 1);
+ pcppi_bell(ppicookie, hz, ticks, PCPPI_BELL_SLEEP);
}
static void