summaryrefslogtreecommitdiff
path: root/sys/dev
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
parentb63233435dd37169d9c0b9e875ca311a1e4bfd59 (diff)
Implement cnbell(), an optional entrypoint that rings the console bell; from
NetBSD. deraadt@ ok
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/cons.c13
-rw-r--r--sys/dev/cons.h12
-rw-r--r--sys/dev/ic/com.c4
-rw-r--r--sys/dev/isa/pcppi.c61
-rw-r--r--sys/dev/isa/pcppivar.h5
-rw-r--r--sys/dev/isa/spkr.c4
-rw-r--r--sys/dev/wscons/wsdisplay.c8
7 files changed, 84 insertions, 23 deletions
diff --git a/sys/dev/cons.c b/sys/dev/cons.c
index 78700bfa8ed..16020e8af48 100644
--- a/sys/dev/cons.c
+++ b/sys/dev/cons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.c,v 1.9 2001/03/01 20:54:32 provos Exp $ */
+/* $OpenBSD: cons.c,v 1.10 2001/04/17 04:30:49 aaron Exp $ */
/* $NetBSD: cons.c,v 1.30 1996/04/08 19:57:30 jonathan Exp $ */
/*
@@ -291,3 +291,14 @@ nullcnpollc(dev, on)
{
}
+
+void
+cnbell(pitch, period, volume)
+ u_int pitch, period, volume;
+{
+ if (cn_tab == NULL || cn_tab->cn_bell == NULL)
+ return;
+
+ (*cn_tab->cn_bell)(cn_tab->cn_dev, pitch, period, volume);
+}
+
diff --git a/sys/dev/cons.h b/sys/dev/cons.h
index 14adef8e9ae..8dcd7d11de2 100644
--- a/sys/dev/cons.h
+++ b/sys/dev/cons.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.h,v 1.7 2001/03/01 20:54:33 provos Exp $ */
+/* $OpenBSD: cons.h,v 1.8 2001/04/17 04:30:49 aaron Exp $ */
/* $NetBSD: cons.h,v 1.14 1996/03/14 19:08:35 christos Exp $ */
/*
@@ -54,6 +54,8 @@ struct consdev {
__P((dev_t, int));
void (*cn_pollc) /* turn on and off polling */
__P((dev_t, int));
+ void (*cn_bell) /* ring bell */
+ __P((dev_t, u_int, u_int, u_int));
dev_t cn_dev; /* major/minor of device */
int cn_pri; /* pecking order; the higher the better */
};
@@ -86,6 +88,7 @@ int cnkqfilter __P((dev_t, struct knote *));
int cngetc __P((void));
void cnputc __P((int));
void cnpollc __P((int));
+void cnbell __P((u_int, u_int, u_int));
void cnrint __P((void));
void nullcnpollc __P((dev_t, int));
@@ -95,13 +98,18 @@ void nullcnpollc __P((dev_t, int));
#define dev_type_cngetc(n) int n __P((dev_t))
#define dev_type_cnputc(n) void n __P((dev_t, int))
#define dev_type_cnpollc(n) void n __P((dev_t, int))
+#define dev_type_cnbell(n) void n __P((dev_t, u_int, u_int, u_int))
#define cons_decl(n) \
dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \
- dev_decl(n,cnputc); dev_decl(n,cnpollc)
+ dev_decl(n,cnputc); dev_decl(n,cnpollc); dev_decl(n,cnbell);
#define cons_init(n) { \
dev_init(1,n,cnprobe), dev_init(1,n,cninit), dev_init(1,n,cngetc), \
dev_init(1,n,cnputc), dev_init(1,n,cnpollc) }
+#define cons_init_bell(n) { \
+ dev_init(1,n,cnprobe), dev_init(1,n,cninit), dev_init(1,n,cngetc), \
+ dev_init(1,n,cnputc), dev_init(1,n,cnpollc), dev_init(1,n,cnbell) }
+
#endif
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 511b7964abb..b19d23c1956 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.62 2001/03/15 21:09:17 art Exp $ */
+/* $OpenBSD: com.c,v 1.63 2001/04/17 04:30:49 aaron Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*
@@ -1960,7 +1960,7 @@ comcnattach(iot, iobase, rate, frequency, cflag)
tcflag_t cflag;
{
static struct consdev comcons = {
- NULL, NULL, comcngetc, comcnputc, comcnpollc,
+ NULL, NULL, comcngetc, comcnputc, comcnpollc, NULL,
NODEV, CN_NORMAL
};
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
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index 1f49627e85c..80055c0a71f 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.22 2001/04/16 15:00:49 jbm Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.23 2001/04/17 04:30:51 aaron Exp $ */
/* $NetBSD: wsdisplay.c,v 1.37.4.1 2000/06/30 16:27:53 simonb Exp $ */
/*
@@ -233,7 +233,7 @@ void (*wsdisplay_cons_kbd_pollc) __P((dev_t, int));
static struct consdev wsdisplay_cons = {
NULL, NULL, wsdisplay_getc_dummy, wsdisplay_cnputc,
- wsdisplay_pollc, /* NULL, */ NODEV, CN_NORMAL
+ wsdisplay_pollc, NULL, NODEV, CN_NORMAL
};
#ifndef WSDISPLAY_DEFAULTSCREENS
@@ -1877,9 +1877,7 @@ wsdisplay_set_cons_kbd(get, poll, bell)
void (*bell) __P((dev_t, u_int, u_int, u_int));
{
wsdisplay_cons.cn_getc = get;
-#if 0
wsdisplay_cons.cn_bell = bell;
-#endif
wsdisplay_cons_kbd_pollc = poll;
}
@@ -1887,9 +1885,7 @@ void
wsdisplay_unset_cons_kbd()
{
wsdisplay_cons.cn_getc = wsdisplay_getc_dummy;
-#if 0
wsdisplay_cons.cn_bell = NULL;
-#endif
wsdisplay_cons_kbd_pollc = 0;
}