summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2010-04-09 19:24:18 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2010-04-09 19:24:18 +0000
commited16ce09757f8870141a9ac9478f9b0f2f3a2bb6 (patch)
tree44102c9bdc3cd1bd5e9247f8571ea8f1ca3b0d2a
parentdf119c11fc40aa20a4756b2e38466864ff9313c3 (diff)
- add and enable pgs(4), a driver for the Programmers Switch found on
recent-ish macs with macgpio(4). Basically dropping one to DDB when pushed. ...and not to be confused by the "reset" button ;-) feedback and ok drahn@
-rw-r--r--sys/arch/macppc/conf/GENERIC3
-rw-r--r--sys/arch/macppc/conf/files.macppc6
-rw-r--r--sys/arch/macppc/dev/openpic.c26
-rw-r--r--sys/arch/macppc/dev/pgs.c93
4 files changed, 103 insertions, 25 deletions
diff --git a/sys/arch/macppc/conf/GENERIC b/sys/arch/macppc/conf/GENERIC
index 2d84daf47ab..baee5825df9 100644
--- a/sys/arch/macppc/conf/GENERIC
+++ b/sys/arch/macppc/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.195 2010/03/03 20:57:28 mk Exp $g
+# $OpenBSD: GENERIC,v 1.196 2010/04/09 19:24:17 jasper Exp $g
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -154,6 +154,7 @@ wi* at macobio? # airport
macgpio* at macobio? # GPIO, PMU interrupt router.
macgpio* at macgpio? # GPIO, PMU interrupt router.
sysbutton* at macgpio? # Xserve system id button.
+pgs* at macgpio? # Programmer Switch.
akbd* at adb? # ADB keyboard
wskbd* at akbd? mux 1
ams* at adb? # ADB mouse
diff --git a/sys/arch/macppc/conf/files.macppc b/sys/arch/macppc/conf/files.macppc
index 9f2c6d29f01..117478a97ab 100644
--- a/sys/arch/macppc/conf/files.macppc
+++ b/sys/arch/macppc/conf/files.macppc
@@ -1,4 +1,4 @@
-# $OpenBSD: files.macppc,v 1.61 2009/09/07 19:29:29 miod Exp $
+# $OpenBSD: files.macppc,v 1.62 2010/04/09 19:24:17 jasper Exp $
#
# macppc-specific configuration info
@@ -233,6 +233,10 @@ device sysbutton {}
attach sysbutton at macgpio
file arch/macppc/dev/sysbutton.c
+device pgs {}
+attach pgs at macgpio
+file arch/macppc/dev/pgs.c
+
attach wdc at mediabay, macobio, kauaiata with wdc_obio
file arch/macppc/dev/wdc_obio.c wdc_obio
diff --git a/sys/arch/macppc/dev/openpic.c b/sys/arch/macppc/dev/openpic.c
index 7f64854ad01..acc3e126a97 100644
--- a/sys/arch/macppc/dev/openpic.c
+++ b/sys/arch/macppc/dev/openpic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openpic.c,v 1.59 2009/11/08 21:05:18 kettenis Exp $ */
+/* $OpenBSD: openpic.c,v 1.60 2010/04/09 19:24:17 jasper Exp $ */
/*-
* Copyright (c) 1995 Per Fogelstrom
@@ -68,7 +68,6 @@ static char *intr_typename(int type);
void openpic_calc_mask(void);
static __inline int cntlzw(int x);
static int mapirq(int irq);
-int openpic_prog_button(void *arg);
void openpic_enable_irq_mask(int irq_mask);
#define HWIRQ_MAX (31 - (SI_NQUEUES + 1))
@@ -187,16 +186,13 @@ openpic_attach(struct device *parent, struct device *self, void *aux)
openpic_collect_preconf_intr();
#endif
-#if 1
- mac_intr_establish(parent, 0x37, IST_LEVEL,
- IPL_HIGH, openpic_prog_button, (void *)0x37, "progbutton");
-#endif
-
ppc_intr_enable(1);
printf("\n");
}
+
+
void
openpic_collect_preconf_intr()
{
@@ -818,22 +814,6 @@ openpic_init()
install_extint(ext_intr_openpic);
}
-/*
- * programmer_button function to fix args to Debugger.
- * deal with any enables/disables, if necessary.
- */
-int
-openpic_prog_button (void *arg)
-{
-#ifdef DDB
- if (db_console)
- Debugger();
-#else
- printf("programmer button pressed, debugger not available\n");
-#endif
- return 1;
-}
-
void
openpic_ipi_ddb(void)
diff --git a/sys/arch/macppc/dev/pgs.c b/sys/arch/macppc/dev/pgs.c
new file mode 100644
index 00000000000..cedb1bf265c
--- /dev/null
+++ b/sys/arch/macppc/dev/pgs.c
@@ -0,0 +1,93 @@
+/* $OpenBSD: pgs.c,v 1.1 2010/04/09 19:24:17 jasper Exp $ */
+/*
+ * Copyright (c) 2010 Jasper Lievisse Adriaanse <jasper@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This driver allows entering DDB by pushing the "Programmers Switch",
+ * which can be found on most any modern world MacPPC.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/device.h>
+
+#include <ddb/db_var.h>
+#include <dev/ofw/openfirm.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
+
+struct pgs_softc {
+ struct device sc_dev;
+ int sc_node;
+ int sc_intr;
+};
+
+void pgs_attach(struct device *, struct device *, void *);
+int pgs_match(struct device *, void *, void *);
+int pgs_intr(void *);
+
+struct cfattach pgs_ca = {
+ sizeof(struct pgs_softc), pgs_match, pgs_attach
+};
+
+struct cfdriver pgs_cd = {
+ NULL, "pgs", DV_DULL
+};
+
+int
+pgs_match(struct device *parent, void *arg, void *aux)
+{
+ struct confargs *ca = aux;
+
+ if (strcmp(ca->ca_name, "programmer-switch") == 0)
+ return 1;
+
+ return 0;
+}
+
+void
+pgs_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct pgs_softc *sc = (struct pgs_softc *)self;
+ struct confargs *ca = aux;
+ int intr[2];
+
+ sc->sc_node = ca->ca_node;
+
+ OF_getprop(sc->sc_node, "interrupts", intr, sizeof(intr));
+ sc->sc_intr = intr[0];
+
+ printf(": irq %d\n", sc->sc_intr);
+
+ mac_intr_establish(parent, sc->sc_intr, IST_LEVEL,
+ IPL_HIGH, pgs_intr, sc, sc->sc_dev.dv_xname);
+}
+
+int
+pgs_intr(void *v)
+{
+#ifdef DDB
+ if (db_console)
+ Debugger();
+#else
+ printf("programmer-switch pressed, debugger not available.\n");
+#endif
+
+ return 1;
+}