summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2001-10-03 14:45:38 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2001-10-03 14:45:38 +0000
commit5919548fd8581cb4f12acc4d89ab2ad1dc8989f5 (patch)
tree9d8a92c49d79311c2b2e3dc09c10ec18d9492336
parentd06ec46e13639684c063927640650c3c355dfd3e (diff)
apm support for macppc. This is not fully implemented, sleep modes
and power event are not handled, however it is enough support to poll the battery/AC/charging states of the system. Code by Alexander Guy.
-rw-r--r--sys/arch/macppc/conf/GENERIC3
-rw-r--r--sys/arch/macppc/conf/files.macppc6
-rw-r--r--sys/arch/macppc/dev/adb.c27
-rw-r--r--sys/arch/macppc/dev/adbvar.h4
-rw-r--r--sys/arch/macppc/dev/apm.c362
-rw-r--r--sys/arch/macppc/dev/pm_direct.c49
-rw-r--r--sys/arch/macppc/dev/pm_direct.h24
-rw-r--r--sys/arch/macppc/include/adbsys.h4
-rw-r--r--sys/arch/macppc/include/conf.h10
-rw-r--r--sys/arch/macppc/macppc/conf.c7
10 files changed, 482 insertions, 14 deletions
diff --git a/sys/arch/macppc/conf/GENERIC b/sys/arch/macppc/conf/GENERIC
index 2ac43a177a3..cd63483ec2f 100644
--- a/sys/arch/macppc/conf/GENERIC
+++ b/sys/arch/macppc/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.4 2001/09/28 04:41:50 drahn Exp $
+# $OpenBSD: GENERIC,v 1.5 2001/10/03 14:45:37 drahn Exp $
#
# PPC GENERIC config file
#
@@ -83,6 +83,7 @@ bm* at macobio? # BMAC ethernet
#mesh* at macobio? flags 0xffff # MESH SCSI
#nvram* at macobio? # nvram
adb* at macobio? # Apple Desktop Bus
+apm0 at adb? # APM emulation
wi* at macobio? # airport
gpio* at macobio? # GPIO, PMU interrupt router.
gpio* at gpio? # GPIO, PMU interrupt router.
diff --git a/sys/arch/macppc/conf/files.macppc b/sys/arch/macppc/conf/files.macppc
index 85c002291fd..22183d95809 100644
--- a/sys/arch/macppc/conf/files.macppc
+++ b/sys/arch/macppc/conf/files.macppc
@@ -1,4 +1,4 @@
-# $OpenBSD: files.macppc,v 1.3 2001/09/16 03:19:30 drahn Exp $
+# $OpenBSD: files.macppc,v 1.4 2001/10/03 14:45:37 drahn Exp $
#
# macppc-specific configuration info
@@ -158,6 +158,10 @@ file arch/macppc/dev/adb.c adb needs-flag
file arch/macppc/dev/adb_direct.c adb
file arch/macppc/dev/pm_direct.c adb
+device apm
+attach apm at adb
+file arch/macppc/dev/apm.c apm needs-count
+
device aed
attach aed at adb
file arch/macppc/dev/aed.c aed needs-flag
diff --git a/sys/arch/macppc/dev/adb.c b/sys/arch/macppc/dev/adb.c
index 439cda2063a..d7ddcc277ab 100644
--- a/sys/arch/macppc/dev/adb.c
+++ b/sys/arch/macppc/dev/adb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: adb.c,v 1.2 2001/09/01 17:43:08 drahn Exp $ */
+/* $OpenBSD: adb.c,v 1.3 2001/10/03 14:45:37 drahn Exp $ */
/* $NetBSD: adb.c,v 1.6 1999/08/16 06:28:09 tsubai Exp $ */
/*-
@@ -47,6 +47,7 @@
#include <macppc/dev/viareg.h>
#include "aed.h"
+#include "apm.h"
/*
* Function declarations.
@@ -74,8 +75,6 @@ struct cfdriver adb_cd = {
NULL, "adb", DV_DULL
};
-extern int adbHardware;
-
static int
adbmatch(parent, cf, aux)
struct device *parent;
@@ -156,7 +155,18 @@ adbattach(parent, self, aux)
totaladbs = CountADBs();
printf(" irq %d", ca->ca_intr[0]);
- printf(": %d targets\n", totaladbs);
+
+ switch (adbHardware) {
+ case ADB_HW_CUDA:
+ printf(": via-cuda ");
+ break;
+ case ADB_HW_PB:
+ printf(": via-pmu ");
+ break;
+ }
+
+ printf("%d targets\n", totaladbs);
+
#if NAED > 0
/* ADB event device for compatibility */
@@ -178,6 +188,15 @@ adbattach(parent, self, aux)
(void)config_found(self, &aa_args, adbprint);
}
+#if NAPM > 0
+ /* Magic for signalling the apm driver to match. */
+ aa_args.origaddr = ADBADDR_APM;
+ aa_args.adbaddr = ADBADDR_APM;
+ aa_args.handler_id = ADBADDR_APM;
+
+ (void)config_found(self, &aa_args, NULL);
+#endif
+
if (adbHardware == ADB_HW_CUDA)
adb_cuda_autopoll();
adb_polling = 0;
diff --git a/sys/arch/macppc/dev/adbvar.h b/sys/arch/macppc/dev/adbvar.h
index 04bd6dc9f70..b84babcc68c 100644
--- a/sys/arch/macppc/dev/adbvar.h
+++ b/sys/arch/macppc/dev/adbvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: adbvar.h,v 1.1 2001/09/01 15:50:00 drahn Exp $ */
+/* $OpenBSD: adbvar.h,v 1.2 2001/10/03 14:45:37 drahn Exp $ */
/* $NetBSD: adbvar.h,v 1.3 2000/06/08 22:10:46 tsubai Exp $ */
/*-
@@ -113,6 +113,8 @@ void extdms_complete __P((caddr_t, caddr_t, int));
#define ADB_HW_PB 0x04 /* PowerBook series */
#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */
+extern int adbHardware; /* in adb_direct.c */
+
#define ADB_CMDADDR(cmd) ((u_int8_t)((cmd) & 0xf0) >> 4)
#define ADBFLUSH(dev) ((((u_int8_t)(dev) & 0x0f) << 4) | 0x01)
#define ADBLISTEN(dev, reg) ((((u_int8_t)(dev) & 0x0f) << 4) | 0x08 | (reg))
diff --git a/sys/arch/macppc/dev/apm.c b/sys/arch/macppc/dev/apm.c
new file mode 100644
index 00000000000..9331788ade4
--- /dev/null
+++ b/sys/arch/macppc/dev/apm.c
@@ -0,0 +1,362 @@
+/*-
+ * Copyright (c) 2001 Alexander Guy. All rights reserved.
+ * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved.
+ * Copyright (c) 1995 John T. Kohl. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "apm.h"
+
+#if NAPM > 1
+#error only one APM emulation device may be configured
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/device.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/event.h>
+
+#include <machine/conf.h>
+#include <machine/cpu.h>
+#include <machine/apmvar.h>
+
+#include <macppc/dev/adbvar.h>
+#include <macppc/dev/pm_direct.h>
+
+#if defined(APMDEBUG)
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x) /**/
+#endif
+
+struct apm_softc {
+ struct device sc_dev;
+ struct klist sc_note;
+ int sc_flags;
+};
+
+int apmmatch __P((struct device *, void *, void *));
+void apmattach __P((struct device *, struct device *, void *));
+
+struct cfattach apm_ca = {
+ sizeof(struct apm_softc), apmmatch, apmattach
+};
+
+int apmopen __P((dev_t dev, int flag, int mode, struct proc *p));
+int apmclose __P((dev_t dev, int flag, int mode, struct proc *p));
+int apmioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p));
+
+struct cfdriver apm_cd = {
+ NULL, "apm", DV_DULL
+};
+
+#define APMUNIT(dev) (minor(dev)&0xf0)
+#define APMDEV(dev) (minor(dev)&0x0f)
+#define APMDEV_NORMAL 0
+#define APMDEV_CTL 8
+
+void filt_apmrdetach __P((struct knote *kn));
+int filt_apmread __P((struct knote *kn, long hint));
+int apmkqfilter __P((dev_t dev, struct knote *kn));
+
+struct filterops apmread_filtops =
+ { 1, NULL, filt_apmrdetach, filt_apmread};
+
+/*
+ * Flags to control kernel display
+ * SCFLAG_NOPRINT: do not output APM power messages due to
+ * a power change event.
+ *
+ * SCFLAG_PCTPRINT: do not output APM power messages due to
+ * to a power change event unless the battery
+ * percentage changes.
+ */
+
+#define SCFLAG_NOPRINT 0x0008000
+#define SCFLAG_PCTPRINT 0x0004000
+#define SCFLAG_PRINT (SCFLAG_NOPRINT|SCFLAG_PCTPRINT)
+
+#define SCFLAG_OREAD (1 << 0)
+#define SCFLAG_OWRITE (1 << 1)
+#define SCFLAG_OPEN (SCFLAG_OREAD|SCFLAG_OWRITE)
+
+
+int
+apmmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct adb_attach_args *aa = (void *)aux;
+ if (aa->origaddr != ADBADDR_APM ||
+ aa->handler_id != ADBADDR_APM ||
+ aa->adbaddr != ADBADDR_APM)
+ return 0;
+
+ if (adbHardware != ADB_HW_PB)
+ return 0;
+
+ return 1;
+}
+
+void
+apmattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct pmu_battery_info info;
+
+ pm_battery_info(0, &info);
+
+ printf(": battery flags 0x%X, ", info.flags);
+ printf("%d%% charged\n", ((info.cur_charge * 100) / info.max_charge));
+}
+
+int
+apmopen(dev, flag, mode, p)
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
+{
+ struct apm_softc *sc;
+ int error = 0;
+
+ /* apm0 only */
+ if (!apm_cd.cd_ndevs || APMUNIT(dev) != 0 ||
+ !(sc = apm_cd.cd_devs[APMUNIT(dev)]))
+ return ENXIO;
+
+ DPRINTF(("apmopen: dev %d pid %d flag %x mode %x\n",
+ APMDEV(dev), p->p_pid, flag, mode));
+
+ switch (APMDEV(dev)) {
+ case APMDEV_CTL:
+ if (!(flag & FWRITE)) {
+ error = EINVAL;
+ break;
+ }
+ if (sc->sc_flags & SCFLAG_OWRITE) {
+ error = EBUSY;
+ break;
+ }
+ sc->sc_flags |= SCFLAG_OWRITE;
+ break;
+ case APMDEV_NORMAL:
+ if (!(flag & FREAD) || (flag & FWRITE)) {
+ error = EINVAL;
+ break;
+ }
+ sc->sc_flags |= SCFLAG_OREAD;
+ break;
+ default:
+ error = ENXIO;
+ break;
+ }
+ return error;
+}
+
+int
+apmclose(dev, flag, mode, p)
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
+{
+ struct apm_softc *sc;
+
+ /* apm0 only */
+ if (!apm_cd.cd_ndevs || APMUNIT(dev) != 0 ||
+ !(sc = apm_cd.cd_devs[APMUNIT(dev)]))
+ return ENXIO;
+
+ DPRINTF(("apmclose: pid %d flag %x mode %x\n", p->p_pid, flag, mode));
+
+ switch (APMDEV(dev)) {
+ case APMDEV_CTL:
+ sc->sc_flags &= ~SCFLAG_OWRITE;
+ break;
+ case APMDEV_NORMAL:
+ sc->sc_flags &= ~SCFLAG_OREAD;
+ break;
+ }
+ return 0;
+}
+
+int
+apmioctl(dev, cmd, data, flag, p)
+ dev_t dev;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+ struct apm_softc *sc;
+ struct pmu_battery_info batt;
+ struct apm_power_info *power;
+ int error = 0;
+
+ /* apm0 only */
+ if (!apm_cd.cd_ndevs || APMUNIT(dev) != 0 ||
+ !(sc = apm_cd.cd_devs[APMUNIT(dev)]))
+ return ENXIO;
+
+ switch (cmd) {
+ /* some ioctl names from linux */
+ case APM_IOC_STANDBY:
+ if ((flag & FWRITE) == 0)
+ error = EBADF;
+ case APM_IOC_SUSPEND:
+ if ((flag & FWRITE) == 0)
+ error = EBADF;
+ break;
+ case APM_IOC_PRN_CTL:
+ if ((flag & FWRITE) == 0)
+ error = EBADF;
+ else {
+ int flag = *(int*)data;
+ DPRINTF(( "APM_IOC_PRN_CTL: %d\n", flag ));
+ switch (flag) {
+ case APM_PRINT_ON: /* enable printing */
+ sc->sc_flags &= ~SCFLAG_PRINT;
+ break;
+ case APM_PRINT_OFF: /* disable printing */
+ sc->sc_flags &= ~SCFLAG_PRINT;
+ sc->sc_flags |= SCFLAG_NOPRINT;
+ break;
+ case APM_PRINT_PCT: /* disable some printing */
+ sc->sc_flags &= ~SCFLAG_PRINT;
+ sc->sc_flags |= SCFLAG_PCTPRINT;
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+ }
+ break;
+ case APM_IOC_DEV_CTL:
+ if ((flag & FWRITE) == 0)
+ error = EBADF;
+ break;
+ case APM_IOC_GETPOWER:
+ power = (struct apm_power_info *)data;
+
+ pm_battery_info(0, &batt);
+
+ power->ac_state = ((batt.flags & PMU_PWR_AC_PRESENT) ? APM_AC_ON : APM_AC_OFF);
+ power->battery_life = ((batt.cur_charge * 100) / batt.max_charge);
+
+ /* XXX - If the battery is charging, return the minutes left until
+ * charging is complete. This might cause problems as I don't
+ * think APM does this.. I don't have a machine to test with.
+ */
+
+
+ if (!(batt.flags & PMU_PWR_BATT_PRESENT)) {
+ power->battery_state = APM_BATT_UNKNOWN;
+ power->minutes_left = 0;
+ power->battery_life = 0;
+ } else if ((power->ac_state == APM_AC_ON) &&
+ (batt.draw > 0)) {
+ power->minutes_left =
+ (((batt.max_charge - batt.cur_charge) * 3600) / batt.draw) / 60;
+ power->battery_state = APM_BATT_CHARGING;
+ } else {
+ power->minutes_left =
+ ((batt.cur_charge * 3600) / (-batt.draw)) / 60;
+
+ /* XXX - Arbitrary */
+ if (power->battery_life > 60) {
+ power->battery_state = APM_BATT_HIGH;
+ } else if (power->battery_life < 10) {
+ power->battery_state = APM_BATT_CRITICAL;
+ } else {
+ power->battery_state = APM_BATT_LOW;
+ }
+ }
+
+ break;
+
+
+ default:
+ error = ENOTTY;
+ }
+
+ return error;
+}
+
+void
+filt_apmrdetach(kn)
+ struct knote *kn;
+{
+ struct apm_softc *sc = (struct apm_softc *)kn->kn_hook;
+
+ SLIST_REMOVE(&sc->sc_note, kn, knote, kn_selnext);
+}
+
+int
+filt_apmread(kn, hint)
+ struct knote *kn;
+ long hint;
+{
+ /* XXX weird kqueue_scan() semantics */
+ if (hint && !kn->kn_data)
+ kn->kn_data = (int)hint;
+
+ return (1);
+}
+
+int
+apmkqfilter(dev, kn)
+ dev_t dev;
+ struct knote *kn;
+{
+ struct apm_softc *sc;
+
+ /* apm0 only */
+ if (!apm_cd.cd_ndevs || APMUNIT(dev) != 0 ||
+ !(sc = apm_cd.cd_devs[APMUNIT(dev)]))
+ return ENXIO;
+
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ kn->kn_fop = &apmread_filtops;
+ break;
+ default:
+ return (1);
+ }
+
+ kn->kn_hook = (caddr_t)sc;
+ SLIST_INSERT_HEAD(&sc->sc_note, kn, kn_selnext);
+
+ return (0);
+}
diff --git a/sys/arch/macppc/dev/pm_direct.c b/sys/arch/macppc/dev/pm_direct.c
index 6b596eec9fc..45612b48cb9 100644
--- a/sys/arch/macppc/dev/pm_direct.c
+++ b/sys/arch/macppc/dev/pm_direct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pm_direct.c,v 1.3 2001/09/20 17:02:30 mpech Exp $ */
+/* $OpenBSD: pm_direct.c,v 1.4 2001/10/03 14:45:37 drahn Exp $ */
/* $NetBSD: pm_direct.c,v 1.9 2000/06/08 22:10:46 tsubai Exp $ */
/*
@@ -1282,6 +1282,53 @@ pm_eject_pcmcia(slot)
pmgrop(&p);
}
+
+/*
+ * Thanks to Paul Mackerras and Fabio Riccardi's Linux implementation
+ * for a clear description of the PMU results.
+ */
+
+int
+pm_battery_info(int battery, struct pmu_battery_info *info)
+{
+ PMData p;
+
+ p.command = PMU_SMART_BATTERY_STATE;
+ p.num_data = 1;
+ p.s_buf = p.r_buf = p.data;
+ p.data[0] = battery + 1;
+ pmgrop(&p);
+
+ info->flags = p.data[1];
+
+ switch (p.data[0]) {
+ case 3:
+ case 4:
+ info->cur_charge = p.data[2];
+ info->max_charge = p.data[3];
+ info->draw = *((signed char *)&p.data[4]);
+ info->voltage = p.data[5];
+ break;
+ case 5:
+ info->cur_charge = ((p.data[2] << 8) | (p.data[3]));
+ info->max_charge = ((p.data[4] << 8) | (p.data[5]));
+ info->draw = *((signed short *)&p.data[6]);
+ info->voltage = ((p.data[8] << 8) | (p.data[7]));
+ break;
+ default:
+ /* XXX - Error condition */
+ info->cur_charge = 0;
+ info->max_charge = 0;
+ info->draw = 0;
+ info->voltage = 0;
+ break;
+ }
+
+ return 1;
+}
+
+
+
int
pm_read_nvram(addr)
int addr;
diff --git a/sys/arch/macppc/dev/pm_direct.h b/sys/arch/macppc/dev/pm_direct.h
index f84d7f66b11..b77edff5300 100644
--- a/sys/arch/macppc/dev/pm_direct.h
+++ b/sys/arch/macppc/dev/pm_direct.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pm_direct.h,v 1.1 2001/09/01 15:50:00 drahn Exp $ */
+/* $OpenBSD: pm_direct.h,v 1.2 2001/10/03 14:45:37 drahn Exp $ */
/* $NetBSD: pm_direct.h,v 1.5 1999/07/12 15:54:55 tsubai Exp $ */
/*
@@ -31,6 +31,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* From: pm_direct.h 1.0 01/02/97 Takashi Hamada */
+#ifndef _PM_DIRECT_H_
+#define _PM_DIRECT_H_
/*
* Public declarations that other routines may need.
@@ -50,6 +52,18 @@ void pm_adb_restart __P((void));
void pm_adb_poweroff __P((void));
void pm_read_date_time __P((u_long *));
void pm_set_date_time __P((u_long));
+
+struct pmu_battery_info
+{
+ unsigned int flags;
+ unsigned int cur_charge;
+ unsigned int max_charge;
+ signed int draw;
+ unsigned int voltage;
+};
+
+int pm_battery_info __P((int, struct pmu_battery_info *));
+
int pm_read_nvram __P((int));
void pm_write_nvram __P((int, int));
int pm_read_brightness __P((void));
@@ -78,6 +92,8 @@ void pm_eject_pcmcia __P((int));
#define PMU_POWER_EVENTS 0x8f /* Send power-event commands to PMU */
#define PMU_SYSTEM_READY 0xdf /* tell PMU we are awake */
+#define PMU_SMART_BATTERY_STATE 0x6f /* Read battery state */
+
/* Bits in PMU interrupt and interrupt mask bytes */
#define PMU_INT_ADB_AUTO 0x04 /* ADB autopoll, when PMU_INT_ADB */
#define PMU_INT_PCEJECT 0x04 /* PC-card eject buttons */
@@ -109,3 +125,9 @@ enum {
PMU_PWR_CLR_WAKEUP_EVENTS = 0x05,
};
+/* PMU Power Information */
+
+#define PMU_PWR_AC_PRESENT (1 << 0)
+#define PMU_PWR_BATT_PRESENT (1 << 2)
+
+#endif
diff --git a/sys/arch/macppc/include/adbsys.h b/sys/arch/macppc/include/adbsys.h
index c06fadaef87..4457e598a7a 100644
--- a/sys/arch/macppc/include/adbsys.h
+++ b/sys/arch/macppc/include/adbsys.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: adbsys.h,v 1.1 2001/09/01 15:49:06 drahn Exp $ */
+/* $OpenBSD: adbsys.h,v 1.2 2001/10/03 14:45:37 drahn Exp $ */
/* $NetBSD: adbsys.h,v 1.4 2000/12/19 02:59:24 tsubai Exp $ */
/*-
@@ -100,6 +100,8 @@ typedef struct adb_dev_s{
#define ADBADDR_TABLET ADBADDR_ABS
#define ADBADDR_MODEM ADBADDR_DATATX
+#define ADBADDR_APM 0xac0ff /* A faux-addr for the APM driver to
+ latch onto */
/* Interesting keyboard handler IDs */
#define ADB_STDKBD 1
diff --git a/sys/arch/macppc/include/conf.h b/sys/arch/macppc/include/conf.h
index 1a3f8ef04d1..eca8335c75a 100644
--- a/sys/arch/macppc/include/conf.h
+++ b/sys/arch/macppc/include/conf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.h,v 1.2 2001/09/28 03:14:21 mickey Exp $ */
+/* $OpenBSD: conf.h,v 1.3 2001/10/03 14:45:37 drahn Exp $ */
/* $NetBSD: conf.h,v 1.2 1996/05/05 19:28:34 christos Exp $ */
/*
@@ -36,6 +36,12 @@
#define mmwrite mmrw
cdev_decl(mm);
-cdev_decl(apm);
+/* open, close, write, ioctl, kqueue */
+#define cdev_apm_init(c,n) { \
+ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
+ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
+ (dev_type_stop((*))) enodev, 0, (dev_type_select((*))) enodev, \
+ (dev_type_mmap((*))) enodev, D_KQFILTER, dev_init(c,n,kqfilter) }
+
cdev_decl(zs);
diff --git a/sys/arch/macppc/macppc/conf.c b/sys/arch/macppc/macppc/conf.c
index 90de887db2a..7f8b2a2ffee 100644
--- a/sys/arch/macppc/macppc/conf.c
+++ b/sys/arch/macppc/macppc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.4 2001/09/28 03:14:20 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.5 2001/10/03 14:45:37 drahn Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -133,6 +133,9 @@ cdev_decl(urio);
#include "ucom.h"
cdev_decl(ucom);
+#include "apm.h"
+cdev_decl(apm);
+
#include "wsmux.h"
#ifdef USER_PCICONF
@@ -172,7 +175,7 @@ struct cdevsw cdevsw[] = {
cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */
cdev_bpftun_init(NTUN,tun), /* 23: network tunnel */
cdev_lkm_init(NLKM,lkm), /* 24: loadable module driver */
- cdev_notdef(), /* 25 */
+ cdev_apm_init(NAPM,apm), /* 25: APM interface */
cdev_notdef(), /* 26 */
cdev_notdef(), /* 27 */
cdev_notdef(), /* 28 */