summaryrefslogtreecommitdiff
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
parentb63233435dd37169d9c0b9e875ca311a1e4bfd59 (diff)
Implement cnbell(), an optional entrypoint that rings the console bell; from
NetBSD. deraadt@ ok
-rw-r--r--sys/arch/alpha/alpha/prom.c4
-rw-r--r--sys/arch/alpha/tc/scc.c4
-rw-r--r--sys/arch/mvme68k/mvme68k/machdep.c3
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c4
-rw-r--r--sys/arch/pmax/dev/dz.c4
-rw-r--r--sys/arch/pmax/pmax/cons.c1
-rw-r--r--sys/arch/pmax/pmax/cpu_cons.c3
-rw-r--r--sys/arch/pmax/tc/scc.c2
-rw-r--r--sys/arch/sun3/dev/kd.c3
-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
16 files changed, 100 insertions, 35 deletions
diff --git a/sys/arch/alpha/alpha/prom.c b/sys/arch/alpha/alpha/prom.c
index 026598b97f9..d91487ee7c1 100644
--- a/sys/arch/alpha/alpha/prom.c
+++ b/sys/arch/alpha/alpha/prom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: prom.c,v 1.10 2001/04/06 04:42:05 csapuntz Exp $ */
+/* $OpenBSD: prom.c,v 1.11 2001/04/17 04:30:45 aaron Exp $ */
/* $NetBSD: prom.c,v 1.39 2000/03/06 21:36:05 thorpej Exp $ */
/*
@@ -42,7 +42,7 @@
/* XXX this is to fake out the console routines, while booting. */
struct consdev promcons = { NULL, NULL, promcngetc, promcnputc,
- nullcnpollc, makedev(23,0), 1 };
+ nullcnpollc, NULL, makedev(23,0), 1 };
struct rpb *hwrpb;
int alpha_console;
diff --git a/sys/arch/alpha/tc/scc.c b/sys/arch/alpha/tc/scc.c
index c3058f6911a..25ef5b983a4 100644
--- a/sys/arch/alpha/tc/scc.c
+++ b/sys/arch/alpha/tc/scc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scc.c,v 1.7 1997/01/24 19:58:15 niklas Exp $ */
+/* $OpenBSD: scc.c,v 1.8 2001/04/17 04:30:46 aaron Exp $ */
/* $NetBSD: scc.c,v 1.28 1996/12/05 01:39:43 cgd Exp $ */
/*
@@ -236,7 +236,7 @@ extern int cold;
scc_regmap_t *scc_cons_addr = 0;
static struct scc_softc coldcons_softc;
static struct consdev scccons = {
- NULL, NULL, sccGetc, sccPutc, sccPollc, NODEV, 0
+ NULL, NULL, sccGetc, sccPutc, sccPollc, NULL, NODEV, 0
};
void scc_consinit __P((dev_t dev, scc_regmap_t *sccaddr));
void scc_oconsinit __P((struct scc_softc *, dev_t));
diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c
index fd8820d2443..bb8d00ea6e0 100644
--- a/sys/arch/mvme68k/mvme68k/machdep.c
+++ b/sys/arch/mvme68k/mvme68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.35 2001/04/05 20:39:39 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.36 2001/04/17 04:30:46 aaron Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -173,6 +173,7 @@ static struct consdev bootcons = {
bootcngetc,
bootcnputc,
bootcnpollc,
+ NULL,
makedev(14,0),
1};
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index a740ed5317f..f35866f44a7 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.30 2001/03/16 00:08:28 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.31 2001/04/17 04:30:47 aaron Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -292,7 +292,7 @@ static struct consdev bootcons = {
(void (*))NULL,
bootcngetc,
(void (*))bootcnputc,
- bootcnpollc, makedev(14,0), 1};
+ bootcnpollc, NULL, makedev(14,0), 1};
void cmmu_init(void);
/*
* Console initialization: called early on from main,
diff --git a/sys/arch/pmax/dev/dz.c b/sys/arch/pmax/dev/dz.c
index bd66fa8e9e6..4ecdc0c4168 100644
--- a/sys/arch/pmax/dev/dz.c
+++ b/sys/arch/pmax/dev/dz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dz.c,v 1.1 2000/08/19 18:36:18 maja Exp $ */
+/* $OpenBSD: dz.c,v 1.2 2001/04/17 04:30:47 aaron Exp $ */
/* $NetBSD: dc.c,v 1.30 1996/10/16 02:10:33 jonathan Exp $ */
/*-
@@ -218,7 +218,7 @@ raster_console()
/* XXX move back into dz_consinit when debugged */
static struct consdev dzcons = {
- NULL, NULL, dzGetc, dzPutc, dzPollc, NODEV, CN_REMOTE
+ NULL, NULL, dzGetc, dzPutc, dzPollc, NULL, NODEV, CN_REMOTE
};
/*
diff --git a/sys/arch/pmax/pmax/cons.c b/sys/arch/pmax/pmax/cons.c
index 5de8e786963..bd724a9b3f9 100644
--- a/sys/arch/pmax/pmax/cons.c
+++ b/sys/arch/pmax/pmax/cons.c
@@ -69,6 +69,7 @@ struct consdev cn_tab = {
(int (*)())0,
(int (*)())0,
(void (*)())0,
+ NULL,
(struct tty *)0,
};
diff --git a/sys/arch/pmax/pmax/cpu_cons.c b/sys/arch/pmax/pmax/cpu_cons.c
index b2d305e5708..637a2a61896 100644
--- a/sys/arch/pmax/pmax/cpu_cons.c
+++ b/sys/arch/pmax/pmax/cpu_cons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu_cons.c,v 1.7 2000/08/19 18:43:31 maja Exp $ */
+/* $OpenBSD: cpu_cons.c,v 1.8 2001/04/17 04:30:48 aaron Exp $ */
/* $NetBSD: cpu_cons.c,v 1.17 1997/05/24 08:19:48 jonathan Exp $ */
/*
@@ -142,6 +142,7 @@ struct consdev cd = {
(int (*)(dev_t)) romgetc, /* getc */
(void (*)(dev_t, int))romputc, /* putc */
(void (*)(dev_t, int))rompollc, /* pollc */
+ NULL,
makedev (0, 0),
CN_DEAD,
};
diff --git a/sys/arch/pmax/tc/scc.c b/sys/arch/pmax/tc/scc.c
index c9eda15cc88..20f11485e16 100644
--- a/sys/arch/pmax/tc/scc.c
+++ b/sys/arch/pmax/tc/scc.c
@@ -312,7 +312,7 @@ extern int cold;
scc_regmap_t *scc_cons_addr = 0;
static struct scc_softc coldcons_softc;
static struct consdev scccons = {
- NULL, NULL, sccGetc, sccPutc, sccPollc, NODEV, 0
+ NULL, NULL, sccGetc, sccPutc, sccPollc, NULL, NODEV, 0
};
void scc_consinit __P((dev_t dev, scc_regmap_t *sccaddr));
void scc_oconsinit __P((struct scc_softc *sc, dev_t dev));
diff --git a/sys/arch/sun3/dev/kd.c b/sys/arch/sun3/dev/kd.c
index d5425c260fe..a5f1aee358c 100644
--- a/sys/arch/sun3/dev/kd.c
+++ b/sys/arch/sun3/dev/kd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kd.c,v 1.8 2000/07/06 15:42:49 ho Exp $ */
+/* $OpenBSD: kd.c,v 1.9 2001/04/17 04:30:49 aaron Exp $ */
/* $NetBSD: kd.c,v 1.21 1996/11/20 18:56:55 gwr Exp $ */
/*-
@@ -488,6 +488,7 @@ struct consdev consdev_kd = {
kdcngetc,
kdcnputc,
kdcnpollc,
+ NULL,
makedev(KDMAJOR, 0),
CN_INTERNAL
};
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;
}