summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/i386/conf/GENERIC4
-rw-r--r--sys/arch/i386/conf/RAMDISK5
-rw-r--r--sys/arch/i386/i386/apm.c316
-rw-r--r--sys/arch/i386/i386/bios.c49
-rw-r--r--sys/arch/i386/i386/genassym.cf20
-rw-r--r--sys/arch/i386/i386/locore.s70
-rw-r--r--sys/arch/i386/i386/mainbus.c16
-rw-r--r--sys/arch/i386/include/apmvar.h106
-rw-r--r--sys/arch/i386/include/biosvar.h188
9 files changed, 293 insertions, 481 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 0aa640a7896..de7e9444655 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.49 1997/09/24 18:19:45 niklas Exp $
+# $OpenBSD: GENERIC,v 1.50 1997/09/29 03:42:23 mickey Exp $
# $NetBSD: GENERIC,v 1.48 1996/05/20 18:17:23 mrg Exp $
#
# GENERIC -- everything that's currently supported
@@ -36,7 +36,7 @@ config bsd swap generic
mainbus0 at root
bios0 at mainbus0
-apm0 at mainbus0
+apm0 at bios0
option APM_NOIDLE
isa0 at mainbus0
eisa0 at mainbus0
diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK
index 11b1ffb974f..0c77e6a5c56 100644
--- a/sys/arch/i386/conf/RAMDISK
+++ b/sys/arch/i386/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.15 1997/09/24 18:19:46 niklas Exp $
+# $OpenBSD: RAMDISK,v 1.16 1997/09/29 03:42:23 mickey Exp $
# from: OpenBSD: INST,v 1.19 1996/11/05 03:49:13 tholo Exp
#
# Install kernels no longer support X.
@@ -51,8 +51,9 @@ config bsd root on rd0a swap on rd0b
mainbus0 at root
bios0 at mainbus0
-apm0 at mainbus0
+apm0 at bios0
option APM_NOIDLE
+option APMDEBUG
isa0 at mainbus0
eisa0 at mainbus0
pci0 at mainbus0
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c
index f15842bc0e4..e7ac9e3042f 100644
--- a/sys/arch/i386/i386/apm.c
+++ b/sys/arch/i386/i386/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.10 1997/09/24 22:18:12 mickey Exp $ */
+/* $OpenBSD: apm.c,v 1.11 1997/09/29 03:42:24 mickey Exp $ */
/*-
* Copyright (c) 1995 John T. Kohl. All rights reserved.
@@ -34,7 +34,6 @@
*/
#include "apm.h"
-#if NAPM > 0
#if NAPM > 1
#error only one APM device may be configured
@@ -63,6 +62,7 @@
#include <i386/isa/nvram.h>
#include <dev/isa/isavar.h>
+#include <machine/biosvar.h>
#include <machine/apmvar.h>
#if defined(DEBUG) || defined(APMDEBUG)
@@ -104,16 +104,27 @@ struct cfdriver apm_cd = {
NULL, "apm", DV_DULL
};
-struct apm_connect_info apminfo = { 0 };
-u_char apm_majver;
-u_char apm_minver;
-u_short apminited;
+STATIC u_int apm_flags;
+STATIC u_char apm_majver;
+STATIC u_char apm_minver;
+STATIC u_short apminited;
int apm_dobusy;
+STATIC struct {
+ u_int32_t entry;
+ u_int16_t seg;
+ u_int16_t pad;
+} apm_ep;
+
+struct apmregs {
+ u_int32_t ax;
+ u_int32_t bx;
+ u_int32_t cx;
+ u_int32_t dx;
+};
-STATIC int apm_get_powstat __P((struct apmregs *));
+STATIC int apmcall __P((u_int, u_int, struct apmregs *));
STATIC void apm_power_print __P((struct apm_softc *, struct apmregs *));
STATIC void apm_event_handle __P((struct apm_softc *, struct apmregs *));
-STATIC int apm_get_event __P((struct apmregs *));
STATIC void apm_set_ver __P((struct apm_softc *));
STATIC void apm_periodic_check __P((void *));
/* STATIC void apm_disconnect __P((void *)); */
@@ -121,15 +132,17 @@ STATIC void apm_perror __P((const char *, struct apmregs *));
/* STATIC void apm_powmgt_enable __P((int onoff)); */
STATIC void apm_powmgt_engage __P((int onoff, u_int devid));
/* STATIC void apm_devpowmgt_enable __P((int onoff, u_int devid)); */
-STATIC void apm_suspend __P((void));
-STATIC void apm_standby __P((void));
STATIC int apm_record_event __P((struct apm_softc *sc, u_int event_type));
STATIC const char *apm_err_translate __P((int code));
-STATIC void apm_get_powstate __P((u_int dev));
+
+#define apm_get_powstat(r) apmcall(APM_POWER_STATUS, APM_DEV_ALLDEVS, &r)
+#define apm_get_event(r) apmcall(APM_GET_PM_EVENT, 0, &r)
+#define apm_suspend() apm_set_powstate(APM_DEV_ALLDEVS, APM_SYS_SUSPEND)
+#define apm_standby() apm_set_powstate(APM_DEV_ALLDEVS, APM_SYS_STANDBY)
STATIC const char *
apm_err_translate(code)
-int code;
+ int code;
{
switch(code) {
case APM_ERR_PM_DISABLED:
@@ -165,8 +178,8 @@ int code;
STATIC void
apm_perror(str, regs)
-const char *str;
-struct apmregs *regs;
+ const char *str;
+ struct apmregs *regs;
{
printf("APM %s: %s (%d)\n", str,
apm_err_translate(APM_ERR_CODE(regs)),
@@ -175,8 +188,8 @@ struct apmregs *regs;
STATIC void
apm_power_print (sc, regs)
-struct apm_softc *sc;
-struct apmregs *regs;
+ struct apm_softc *sc;
+ struct apmregs *regs;
{
if (BATT_LIFE(regs) != APM_BATT_LIFE_UNKNOWN) {
printf("%s: battery life expectancy %d%%\n",
@@ -244,43 +257,57 @@ struct apmregs *regs;
return;
}
-int apm_standbys = 0;
-int apm_userstandbys = 0;
-int apm_suspends = 0;
-int apm_battlow = 0;
-
-STATIC void
-apm_get_powstate(dev)
-u_int dev;
+/*
+ * call the APM protected mode bios function FUNCTION for BIOS selection
+ * WHICHBIOS.
+ * Fills in *regs with registers as returned by APM.
+ * returns nonzero if error returned by APM.
+ */
+STATIC int
+apmcall(f, dev, r)
+ u_int f, dev;
+ struct apmregs *r;
{
- struct apmregs regs;
- int rval;
+ register int rv;
+
+ /* todo: do something with %edi? */
+ __asm __volatile(
+#if defined(DEBUG) || defined(DIAGNOSTIC)
+ "pushl %%ds; pushl %%es; pushl %%fs; pushl %%gs\n\t"
+ "pushfl; cli\n\t"
+ "xorl %0, %0\n\t"
+ "movl %0, %%ds\n\t"
+ "movl %0, %%es\n\t"
+ "movl %0, %%fs\n\t"
+ "movl %0, %%gs\n\t"
+#endif
+ "movl %5, %%eax\n\t"
+ "lcall %%cs:(%9)\n\t"
+ "pushl %1; setc %b1; movzbl %b1, %0; popl %1\n\t"
- regs.bx = dev;
- rval = apmcall(APM_GET_POWER_STATE, &regs);
- if (rval == 0) {
- printf("apm dev %04x state %04x\n", dev, regs.cx);
- }
+#if defined(DEBUG) || defined(DIAGNOSTIC)
+ "popfl; popl %%gs; popl %%fs; popl %%es; popl %%ds"
+#endif
+ : "=r" (rv),
+ "=a" (r->ax), "=b" (r->bx), "=c" (r->cx), "=d" (r->dx)
+ : "m" (f), "2" (dev), "3" (r->cx), "4" (r->dx),
+ "m" (apm_ep)
+ : "cc", "memory");
+ return rv;
}
-STATIC void
-apm_suspend()
-{
- (void) apm_set_powstate(APM_DEV_ALLDEVS, APM_SYS_SUSPEND);
-}
-STATIC void
-apm_standby()
-{
- (void) apm_set_powstate(APM_DEV_ALLDEVS, APM_SYS_STANDBY);
-}
+int apm_standbys = 0;
+int apm_userstandbys = 0;
+int apm_suspends = 0;
+int apm_battlow = 0;
static int apm_evindex = 0;
STATIC int
apm_record_event(sc, event_type)
-struct apm_softc *sc;
-u_int event_type;
+ struct apm_softc *sc;
+ u_int event_type;
{
struct apm_event_info *evp;
@@ -300,8 +327,8 @@ u_int event_type;
STATIC void
apm_event_handle(sc, regs)
-struct apm_softc *sc;
-struct apmregs *regs;
+ struct apm_softc *sc;
+ struct apmregs *regs;
{
int error;
struct apmregs nregs;
@@ -346,7 +373,7 @@ struct apmregs *regs;
break;
case APM_POWER_CHANGE:
DPRINTF(("power status change\n"));
- error = apm_get_powstat(&nregs);
+ error = apm_get_powstat(nregs);
if (error == 0)
apm_power_print(sc, &nregs);
apm_record_event(sc, regs->bx);
@@ -386,22 +413,16 @@ struct apmregs *regs;
}
}
-STATIC int
-apm_get_event(regs)
-struct apmregs *regs;
-{
- return apmcall(APM_GET_PM_EVENT, regs);
-}
-
STATIC void
apm_periodic_check(arg)
-void *arg;
+ void *arg;
{
+ register struct apm_softc *sc = arg;
struct apmregs regs;
- struct apm_softc *sc = arg;
- while (apm_get_event(&regs) == 0) {
+
+ while (apm_get_event(regs) == 0)
apm_event_handle(sc, &regs);
- };
+
if (APM_ERR_CODE(&regs) != APM_ERR_NOEVENTS)
apm_perror("get event", &regs);
if (apm_suspends /*|| (apm_battlow && apm_userstandbys)*/) {
@@ -417,27 +438,26 @@ void *arg;
#ifdef notused
STATIC void
apm_powmgt_enable(onoff)
-int onoff;
+ int onoff;
{
struct apmregs regs;
- regs.bx = apm_minver == 0 ? APM_MGT_ALL : APM_DEV_APM_BIOS;
regs.cx = onoff ? APM_MGT_ENABLE : APM_MGT_DISABLE;
- if (apmcall(APM_PWR_MGT_ENABLE, &regs) != 0)
+ if (apmcall(APM_PWR_MGT_ENABLE,
+ (apm_minver? APM_DEV_APM_BIOS : APM_MGT_ALL), &regs) != 0)
apm_perror("power management enable", &regs);
}
#endif
STATIC void
apm_powmgt_engage(onoff, dev)
-int onoff;
-u_int dev;
+ int onoff;
+ u_int dev;
{
struct apmregs regs;
if (apm_minver == 0)
return;
- regs.bx = dev;
regs.cx = onoff ? APM_MGT_ENGAGE : APM_MGT_DISENGAGE;
- if (apmcall(APM_PWR_MGT_ENGAGE, &regs) != 0)
+ if (apmcall(APM_PWR_MGT_ENGAGE, dev, &regs) != 0)
printf("APM power mgmt engage (device %x): %s (%d)\n",
dev, apm_err_translate(APM_ERR_CODE(&regs)),
APM_ERR_CODE(&regs));
@@ -446,18 +466,17 @@ u_int dev;
#ifdef notused
STATIC void
apm_devpowmgt_enable(onoff, dev)
-int onoff;
-u_int dev;
+ int onoff;
+ u_int dev;
{
struct apmregs regs;
if (apm_minver == 0)
return;
- regs.bx = dev;
/* enable is auto BIOS managment.
* disable is program control.
*/
regs.cx = onoff ? APM_MGT_ENABLE : APM_MGT_DISABLE;
- if (apmcall(APM_DEVICE_MGMT_ENABLE, &regs) != 0)
+ if (apmcall(APM_DEVICE_MGMT_ENABLE, dev, &regs) != 0)
printf("APM device engage (device %x): %s (%d)\n",
dev, apm_err_translate(APM_ERR_CODE(&regs)),
APM_ERR_CODE(&regs));
@@ -466,14 +485,13 @@ u_int dev;
int
apm_set_powstate(dev, state)
-u_int dev, state;
+ u_int dev, state;
{
struct apmregs regs;
if (!apminited || (apm_minver == 0 && state > APM_SYS_OFF))
return EINVAL;
- regs.bx = dev;
regs.cx = state;
- if (apmcall(APM_SET_PWR_STATE, &regs) != 0) {
+ if (apmcall(APM_SET_PWR_STATE, dev, &regs) != 0) {
apm_perror("set power state", &regs);
return EIO;
}
@@ -492,8 +510,8 @@ apm_cpu_busy()
struct apmregs regs;
if (!apminited || !apmidleon)
return;
- if ((apminfo.apm_detail & APM_IDLE_SLOWS) &&
- apmcall(APM_CPU_BUSY, &regs) != 0)
+ if ((apm_flags & APM_IDLE_SLOWS) &&
+ apmcall(APM_CPU_BUSY, 0, &regs) != 0)
apm_perror("set CPU busy", &regs);
}
@@ -503,12 +521,10 @@ apm_cpu_idle()
struct apmregs regs;
if (!apminited || !apmidleon)
return;
- if (apmcall(APM_CPU_IDLE, &regs) != 0)
+ if (apmcall(APM_CPU_IDLE, 0, &regs) != 0)
apm_perror("set CPU idle", &regs);
}
-void *apm_sh;
-
#ifdef APM_V10_ONLY
int apm_v11_enabled = 0;
#else
@@ -517,26 +533,24 @@ int apm_v11_enabled = 1;
STATIC void
apm_set_ver(self)
-struct apm_softc *self;
+ struct apm_softc *self;
{
struct apmregs regs;
int error;
regs.cx = 0x0101; /* APM Version 1.1 */
- regs.bx = APM_DEV_APM_BIOS;
- if (apm_v11_enabled &&
- (error = apmcall(APM_DRIVER_VERSION, &regs)) == 0) {
+ if (apm_v11_enabled && (error =
+ apmcall(APM_DRIVER_VERSION, APM_DEV_APM_BIOS, &regs)) == 0) {
apm_majver = APM_CONN_MAJOR(&regs);
apm_minver = APM_CONN_MINOR(&regs);
} else {
apm_majver = 1;
apm_minver = 0;
}
- printf(": Power Management spec V%d.%d",
- apm_majver, apm_minver);
+ printf(": Power Management spec V%d.%d", apm_majver, apm_minver);
apminited = 1;
- if (apminfo.apm_detail & APM_IDLE_SLOWS) {
+ if (apm_flags & APM_IDLE_SLOWS) {
#ifdef DEBUG
/* not relevant much */
printf(" (slowidle)");
@@ -545,34 +559,25 @@ struct apm_softc *self;
} else
apm_dobusy = 0;
#ifdef DIAGNOSTIC
- if (apminfo.apm_detail & APM_BIOS_PM_DISABLED)
+ if (apm_flags & APM_BIOS_PM_DISABLED)
printf(" (BIOS mgmt disabled)");
- if (apminfo.apm_detail & APM_BIOS_PM_DISENGAGED)
+ if (apm_flags & APM_BIOS_PM_DISENGAGED)
printf(" (BIOS managing devices)");
#endif
printf("\n");
}
-STATIC int
-apm_get_powstat(regs)
-struct apmregs *regs;
-{
- regs->bx = APM_DEV_ALLDEVS;
- return apmcall(APM_POWER_STATUS, regs);
-}
-
#ifdef notused
STATIC void
apm_disconnect(xxx)
-void *xxx;
+ void *xxx;
{
struct apmregs regs;
- regs.bx = apm_minver == 1 ? APM_DEV_ALLDEVS : APM_DEFAULTS_ALL;
- if (apmcall(APM_SYSTEM_DEFAULTS, &regs))
+ if (apmcall(APM_SYSTEM_DEFAULTS,
+ (apm_minver == 1 ? APM_DEV_ALLDEVS : APM_DEFAULTS_ALL), &regs))
apm_perror("system defaults failed", &regs);
- regs.bx = APM_DEV_APM_BIOS;
- if (apmcall(APM_DISCONNECT, &regs))
+ if (apmcall(APM_DISCONNECT, APM_DEV_APM_BIOS, &regs))
apm_perror("disconnect failed", &regs);
else
printf("APM disconnected\n");
@@ -584,12 +589,14 @@ apmprobe(parent, match, aux)
struct device *parent;
void *match, *aux;
{
- struct apm_attach_args *aaa = aux;
+ struct bios_attach_args *ba = aux;
if (apminited)
return 0;
- if ((apminfo.apm_detail & APM_32BIT_SUPPORTED) &&
- strcmp(aaa->aaa_busname, "apm") == 0) {
+ if (!(ba->apm_detail & APM_BIOS_PM_DISABLED) &&
+ !(ba->apm_detail & APM_BIOS_PM_DISENGAGED) &&
+ (ba->apm_detail & APM_32BIT_SUPPORTED) &&
+ strcmp(ba->bios_dev, "apm") == 0) {
return 1;
}
return 0;
@@ -601,43 +608,39 @@ apmattach(parent, self, aux)
void *aux;
{
extern union descriptor *dynamic_gdt;
- struct apm_softc *apmsc = (void *)self;
+ register struct bios_attach_args *ba = aux;
+ struct apm_softc *sc = (void *)self;
struct apmregs regs;
- int error;
+
/*
* set up GDT descriptors for APM
*/
- if (apminfo.apm_detail & APM_32BIT_SUPPORTED) {
- apminfo.apm_segsel = GSEL(GAPM32CODE_SEL,SEL_KPL);
+ if (ba->apm_detail & APM_32BIT_SUPPORTED) {
+ apm_flags = ba->apm_detail;
+ apm_ep.seg = GSEL(GAPM32CODE_SEL,SEL_KPL);
+ apm_ep.entry = ba->apm_entry;
setsegment(&dynamic_gdt[GAPM32CODE_SEL].sd,
- (void *)ISA_HOLE_VADDR(apminfo.apm_code32_seg_base),
- apminfo.apm_code32_seg_len-1,
- SDT_MEMERA, SEL_KPL, 1, 0);
+ (void *)ISA_HOLE_VADDR(ba->apm_code32_base),
+ ba->apm_code_len-1, SDT_MEMERA, SEL_KPL, 1, 0);
setsegment(&dynamic_gdt[GAPM16CODE_SEL].sd,
- (void *)ISA_HOLE_VADDR(apminfo.apm_code16_seg_base),
- apminfo.apm_code32_seg_len-1,
- SDT_MEMERA, SEL_KPL, 0, 0);
+ (void *)ISA_HOLE_VADDR(ba->apm_code16_base),
+ ba->apm_code_len-1, SDT_MEMERA, SEL_KPL, 0, 0);
setsegment(&dynamic_gdt[GAPMDATA_SEL].sd,
- (void *)ISA_HOLE_VADDR(apminfo.apm_data_seg_base),
- apminfo.apm_data_seg_len-1,
- SDT_MEMRWA, SEL_KPL, 1, 0);
+ (void *)ISA_HOLE_VADDR(ba->apm_data_base),
+ ba->apm_data_len-1, SDT_MEMRWA, SEL_KPL, 1, 0);
#if defined(DEBUG) || defined(APMDEBUG)
- printf(": detail %x 32b:%x/%x/%x 16b:%x/%x data %x/%x/%x ep %x (%x:%x)\n%s",
- apminfo.apm_detail,
- apminfo.apm_code32_seg_base,
- ISA_HOLE_VADDR(apminfo.apm_code32_seg_base),
- apminfo.apm_code32_seg_len,
- apminfo.apm_code16_seg_base,
- ISA_HOLE_VADDR(apminfo.apm_code16_seg_base),
- apminfo.apm_data_seg_base,
- ISA_HOLE_VADDR(apminfo.apm_data_seg_base),
- apminfo.apm_data_seg_len,
- apminfo.apm_entrypt,
- apminfo.apm_segsel,
- apminfo.apm_entrypt+ISA_HOLE_VADDR(apminfo.apm_code32_seg_base),
- apmsc->sc_dev.dv_xname);
+ printf(": flags %x code 32:%x/%x 16:%x/%x %x "
+ "data %x/%x/%x ep %x (%x:%x)\n%s", apm_flags,
+ ba->apm_code32_base, ISA_HOLE_VADDR(ba->apm_code32_base),
+ ba->apm_code16_base, ISA_HOLE_VADDR(ba->apm_code16_base),
+ ba->apm_code_len,
+ ba->apm_data_base, ISA_HOLE_VADDR(ba->apm_data_base),
+ ba->apm_data_len,
+ ba->apm_entry, apm_ep.seg,
+ ba->apm_entry+ISA_HOLE_VADDR(ba->apm_code32_base),
+ sc->sc_dev.dv_xname);
#endif
- apm_set_ver(apmsc);
+ apm_set_ver(sc);
/*
* Engage cooperative power mgt (we get to do it)
* on all devices (v1.1).
@@ -651,13 +654,13 @@ apmattach(parent, self, aux)
apm_powmgt_engage(1, APM_DEV_NETWORK(APM_DEV_ALLUNITS));
apm_powmgt_engage(1, APM_DEV_PCMCIA(APM_DEV_ALLUNITS));
#endif
- error = apm_get_powstat(&regs);
- if (error == 0) {
- apm_power_print(apmsc, &regs);
+
+ if (apm_get_powstat(regs) == 0) {
+ apm_power_print(sc, &regs);
} else
apm_perror("get power status", &regs);
apm_cpu_busy();
- apm_periodic_check(apmsc);
+ apm_periodic_check(sc);
} else {
dynamic_gdt[GAPM32CODE_SEL] = dynamic_gdt[GNULL_SEL];
dynamic_gdt[GAPM16CODE_SEL] = dynamic_gdt[GNULL_SEL];
@@ -671,17 +674,13 @@ apmopen(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
- int unit = APMUNIT(dev);
- int ctl = APMDEV(dev);
- struct apm_softc *sc;
+ struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)];
- if (unit >= apm_cd.cd_ndevs)
- return ENXIO;
- sc = apm_cd.cd_devs[unit];
- if (!sc)
+ /* apm0 only */
+ if (APMUNIT(dev) != 0 || sc == NULL)
return ENXIO;
- switch (ctl) {
+ switch (APMDEV(dev)) {
case APMDEV_CTL:
if (!(flag & FWRITE))
return EINVAL;
@@ -708,10 +707,14 @@ apmclose(dev, flag, mode, p)
struct proc *p;
{
struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)];
- int ctl = APMDEV(dev);
+ /* apm0 only */
+ if (APMUNIT(dev) != 0 || sc == NULL)
+ return ENXIO;
+
DPRINTF(("apmclose: pid %d flag %x mode %x\n", p->p_pid, flag, mode));
- switch (ctl) {
+
+ switch (APMDEV(dev)) {
case APMDEV_CTL:
sc->sc_flags &= ~SCFLAG_OWRITE;
break;
@@ -734,7 +737,6 @@ apmioctl(dev, cmd, data, flag, p)
int flag;
struct proc *p;
{
- int error;
struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)];
struct apm_power_info *powerp;
struct apm_event_info *evp;
@@ -742,6 +744,10 @@ apmioctl(dev, cmd, data, flag, p)
register int i;
struct apm_ctl *actl;
+ /* apm0 only */
+ if (APMUNIT(dev) != 0 || sc == NULL)
+ return ENXIO;
+
switch (cmd) {
/* some ioctl names from linux */
case APM_IOC_STANDBY:
@@ -758,7 +764,13 @@ apmioctl(dev, cmd, data, flag, p)
actl = (struct apm_ctl *)data;
if ((flag & FWRITE) == 0)
return EBADF;
- apm_get_powstate(actl->dev); /* XXX */
+ {
+ struct apmregs regs;
+
+ if (!apmcall(APM_GET_POWER_STATE, actl->dev, &regs))
+ printf("%s: dev %04x state %04x\n",
+ sc->sc_dev.dv_xname, dev, regs.cx);
+ }
return apm_set_powstate(actl->dev, actl->mode);
case APM_IOC_NEXTEVENT:
if (sc->event_count) {
@@ -772,8 +784,7 @@ apmioctl(dev, cmd, data, flag, p)
return EAGAIN;
case APM_IOC_GETPOWER:
powerp = (struct apm_power_info *)data;
- error = apm_get_powstat(&regs);
- if (error == 0) {
+ if (apm_get_powstat(regs) == 0) {
bzero(powerp, sizeof(*powerp));
if (BATT_LIFE(&regs) != APM_BATT_LIFE_UNKNOWN)
powerp->battery_life = BATT_LIFE(&regs);
@@ -800,13 +811,14 @@ apmioctl(dev, cmd, data, flag, p)
}
} else {
apm_perror("ioctl get power status", &regs);
- error = EIO;
+ return (EIO);
}
break;
default:
- return ENOTTY;
+ return (ENOTTY);
}
+
return 0;
}
@@ -818,6 +830,10 @@ apmselect(dev, rw, p)
{
struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)];
+ /* apm0 only */
+ if (APMUNIT(dev) != 0 || sc == NULL)
+ return ENXIO;
+
switch (rw) {
case FREAD:
if (sc->event_count)
@@ -830,5 +846,3 @@ apmselect(dev, rw, p)
}
return 0;
}
-
-#endif /* NAPM > 0 */
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c
index 948ec5317df..227ac592c24 100644
--- a/sys/arch/i386/i386/bios.c
+++ b/sys/arch/i386/i386/bios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bios.c,v 1.7 1997/09/24 23:00:01 mickey Exp $ */
+/* $OpenBSD: bios.c,v 1.8 1997/09/29 03:42:25 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -72,6 +72,7 @@ struct bios_softc {
int biosprobe __P((struct device *, void *, void *));
void biosattach __P((struct device *, struct device *, void *));
void bios_init __P((bus_space_handle_t));
+int bios_print __P((void *, const char *));
static __inline int bios_call __P((u_int cmd, u_int arg));
struct cfattach bios_ca = {
@@ -154,7 +155,7 @@ biosprobe(parent, match, aux)
bus_space_unmap(bia->bios_memt, hsp, LMVAS);
}
#endif
- return !bios_cd.cd_ndevs && !strcmp(bia->bios_busname, "bios");
+ return !bios_cd.cd_ndevs && !strcmp(bia->bios_dev, "bios");
}
void
@@ -170,15 +171,6 @@ biosattach(parent, self, aux)
sc->bt = bia->bios_memt;
/* bios_init(sc->bt); */
-#if NAPM > 0
- apminfo.apm_detail = BIOS_vars.apm_detail;
- apminfo.apm_code32_seg_base = BIOS_vars.apm_code32_base;
- apminfo.apm_code16_seg_base = BIOS_vars.apm_code16_base;
- apminfo.apm_code32_seg_len = BIOS_vars.apm_code_len;
- apminfo.apm_data_seg_base = BIOS_vars.apm_data_base;
- apminfo.apm_data_seg_len = BIOS_vars.apm_data_len;
- apminfo.apm_entrypt = BIOS_vars.apm_entry;
-#endif
switch (va[14]) {
default:
case 0xff: p = "PC"; break;
@@ -194,14 +186,41 @@ biosattach(parent, self, aux)
p, va[15], va[5], va[6], va[8], va[9], va[11], va[12]);
#ifdef DEBUG
printf("apminfo: %x, code %x/%x[%x], data %x[%x], entry %x\n",
- BIOS_vars.apm_detail, BIOS_vars.apm_code32_base,
- BIOS_vars.apm_code16_base, BIOS_vars.apm_code_len,
- BIOS_vars.apm_data_base, BIOS_vars.apm_data_len,
- BIOS_vars.apm_entry);
+ BIOS_vars.bios_apm_detail, BIOS_vars.bios_apm_code32_base,
+ BIOS_vars.bios_apm_code16_base, BIOS_vars.bios_apm_code_len,
+ BIOS_vars.bios_apm_data_base, BIOS_vars.bios_apm_data_len,
+ BIOS_vars.bios_apm_entry);
+#endif
+#if NAPM > 0
+ {
+ struct bios_attach_args ba;
+
+ ba.apm_detail = BIOS_vars.bios_apm_detail;
+ ba.apm_code32_base = BIOS_vars.bios_apm_code32_base;
+ ba.apm_code16_base = BIOS_vars.bios_apm_code16_base;
+ ba.apm_code_len = BIOS_vars.bios_apm_code_len;
+ ba.apm_data_base = BIOS_vars.bios_apm_data_base;
+ ba.apm_data_len = BIOS_vars.bios_apm_data_len;
+ ba.apm_entry = BIOS_vars.bios_apm_entry;
+ ba.bios_dev = "apm";
+ config_found(self, &ba, bios_print);
+ }
#endif
}
int
+bios_print(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct bios_attach_args *ba = aux;
+
+ if (pnp)
+ printf("%s at %s", ba->bios_dev, pnp);
+ return (UNCONF);
+}
+
+int
biosopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
diff --git a/sys/arch/i386/i386/genassym.cf b/sys/arch/i386/i386/genassym.cf
index 80760498058..977f15831da 100644
--- a/sys/arch/i386/i386/genassym.cf
+++ b/sys/arch/i386/i386/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.2 1997/09/21 04:27:54 mickey Exp $
+# $OpenBSD: genassym.cf,v 1.3 1997/09/29 03:42:26 mickey Exp $
#
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@@ -49,16 +49,6 @@ include <machine/trap.h>
include <machine/pmap.h>
include <machine/vmparam.h>
-include "apm.h"
-if NAPM > 0
-include <machine/apmvar.h>
-endif
-
-include "bios.h"
-if NBIOS > 0
-include <machine/biosvar.h>
-endif
-
if COMPAT_SVR4 > 0
include <compat/svr4/svr4_ucontext.h>
endif
@@ -167,11 +157,3 @@ define IH_COUNT offsetof(struct intrhand, ih_count)
define IH_NEXT offsetof(struct intrhand, ih_next)
endif
-# Advanced Power Management information
-if NAPM > 0
-define APM_CALL offsetof(struct apm_connect_info, apm_entrypt)
-define APMREG_AX offsetof(struct apmregs, ax)
-define APMREG_BX offsetof(struct apmregs, bx)
-define APMREG_CX offsetof(struct apmregs, cx)
-define APMREG_DX offsetof(struct apmregs, dx)
-endif
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s
index 79ba2b67bb3..1811f215a8a 100644
--- a/sys/arch/i386/i386/locore.s
+++ b/sys/arch/i386/i386/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.32 1997/09/25 00:13:54 mickey Exp $ */
+/* $OpenBSD: locore.s,v 1.33 1997/09/29 03:42:26 mickey Exp $ */
/* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */
/*-
@@ -212,7 +212,7 @@ start: movw $0x1234,0x472 # warm boot
cld
rep; movsb
1:
-#endif /* APM */
+#endif /* NBIOS */
/* First, reset the PSL. */
pushl $PSL_MBO
@@ -2165,69 +2165,3 @@ ENTRY(bzero)
popl %edi
ret
-
-#if NAPM > 0
-/*
- * int apmcall(int function, struct apmregs *regs):
- * call the APM protected mode bios function FUNCTION for BIOS selection
- * WHICHBIOS.
- * Fills in *regs with registers as returned by APM.
- * returns nonzero if error returned by APM.
- */
- .globl _apminfo
-ENTRY(apmcall)
- pushl %ebp
- movl %esp,%ebp
- pushl %esi
- pushl %edi
- pushl %ebx
-
-#if defined(DEBUG) || defined(DIAGNOSTIC)
- pushl %ds
- pushl %es
- pushl %fs
- pushl %gs
- pushfl
- cli
- pushl %ds
- xorl %ax,%ax
- movl %ax,%ds
- movl %ax,%es
- movl %ax,%fs
- movl %ax,%gs
-#endif
- movb %cs:8(%ebp),%al
- movb $0x53,%ah
- movl %cs:12(%ebp),%ebx
- movw %cs:APMREG_CX(%ebx),%cx
- movw %cs:APMREG_DX(%ebx),%dx
- movw %cs:APMREG_BX(%ebx),%bx
- lcall %cs:(_apminfo+APM_CALL)
-#if defined(DEBUG) || defined(DIAGNOSTIC)
- popl %ds
-#endif
- movl 12(%ebp),%esi
- movw %ax,APMREG_AX(%esi)
- movw %bx,APMREG_BX(%esi)
- movw %cx,APMREG_CX(%esi)
- movw %dx,APMREG_DX(%esi)
- /* todo: do something with %edi? */
- setc %al
- movzbl %al, %eax
-
-#if defined(DEBUG) || defined(DIAGNOSTIC)
- popfl
- popl %gs
- popl %fs
- popl %es
- popl %ds
-#endif
-
- popl %ebx
- popl %edi
- popl %esi
- popl %ebp
- ret
-#endif /* APM */
-
-
diff --git a/sys/arch/i386/i386/mainbus.c b/sys/arch/i386/i386/mainbus.c
index 0aaea20903a..278874db789 100644
--- a/sys/arch/i386/i386/mainbus.c
+++ b/sys/arch/i386/i386/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.9 1997/09/21 04:27:56 mickey Exp $ */
+/* $OpenBSD: mainbus.c,v 1.10 1997/09/29 03:42:27 mickey Exp $ */
/* $NetBSD: mainbus.c,v 1.8 1996/04/11 22:13:37 cgd Exp $ */
/*
@@ -48,9 +48,6 @@
#include "apm.h"
#include "bios.h"
-#if NAPM > 0
-#include <machine/apmvar.h>
-#endif
#if NBIOS > 0
#include <machine/biosvar.h>
#endif
@@ -73,9 +70,6 @@ union mainbus_attach_args {
struct pcibus_attach_args mba_pba;
struct eisabus_attach_args mba_eba;
struct isabus_attach_args mba_iba;
-#if NAPM > 0
- struct apm_attach_args mba_aaa;
-#endif
#if NBIOS > 0
struct bios_attach_args mba_bios;
#endif
@@ -107,18 +101,12 @@ mainbus_attach(parent, self, aux)
#if NBIOS > 0
{
- mba.mba_bios.bios_busname = "bios";
+ mba.mba_bios.bios_dev = "bios";
mba.mba_bios.bios_iot = I386_BUS_SPACE_IO;
mba.mba_bios.bios_memt = I386_BUS_SPACE_MEM;
config_found(self, &mba.mba_bios, mainbus_print);
}
#endif
-#if NAPM > 0
- {
- mba.mba_aaa.aaa_busname = "apm";
- config_found(self, &mba.mba_aaa, mainbus_print);
- }
-#endif
if (1 /* XXX ISA NOT YET SEEN */) {
mba.mba_iba.iba_busname = "isa";
mba.mba_iba.iba_iot = I386_BUS_SPACE_IO;
diff --git a/sys/arch/i386/include/apmvar.h b/sys/arch/i386/include/apmvar.h
index b960bb3ad5e..30286cbeb07 100644
--- a/sys/arch/i386/include/apmvar.h
+++ b/sys/arch/i386/include/apmvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD$ */
+/* $OpenBSD: apmvar.h,v 1.4 1997/09/29 03:42:28 mickey Exp $ */
/*
* Copyright (c) 1995 John T. Kohl
@@ -28,28 +28,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*
*/
-#ifndef __I386_APM_H__
-#define __I386_APM_H__
+#ifndef _I386_APMVAR_H_
+#define _I386_APMVAR_H_
#include <sys/ioccom.h>
/* Advanced Power Management (v1.0 and v1.1 specification)
* functions/defines/etc.
*/
-#define APM_BIOS_FNCODE (0x53)
-#define APM_SYSTEM_BIOS (0x15)
-#define APM_BIOS_FN(x) ((APM_BIOS_FNCODE<<8)|(x))
+
/*
* APM info word from boot loader
*/
-#define APM_MAJOR_VERS(info) (((info)&0xff00)>>8)
-#define APM_MINOR_VERS(info) ((info)&0xff)
#define APM_16BIT_SUPPORTED 0x00010000
#define APM_32BIT_SUPPORTED 0x00020000
#define APM_IDLE_SLOWS 0x00040000
#define APM_BIOS_PM_DISABLED 0x00080000
#define APM_BIOS_PM_DISENGAGED 0x00100000
+/* APM error codes */
#define APM_ERR_CODE(regs) (((regs)->ax & 0xff00) >> 8)
#define APM_ERR_PM_DISABLED 0x01
#define APM_ERR_REALALREADY 0x02
@@ -76,33 +73,45 @@
#define APM_DEV_PCMCIA(x) (0x0600|((x)&0xff))
#define APM_DEV_ALLUNITS 0xff
-#define APM_INSTALLATION_CHECK 0x00 /* int15 only */
-#define APM_REALMODE_CONNECT 0x01 /* int15 only */
-#define APM_16BIT_CONNECT 0x02 /* int15 only */
-#define APM_32BIT_CONNECT 0x03 /* int15 only */
-#define APM_DISCONNECT 0x04 /* %bx = APM_DEV_APM_BIOS */
-#define APM_CPU_IDLE 0x05
-#define APM_CPU_BUSY 0x06
-#define APM_SET_PWR_STATE 0x07
-#define APM_SYS_READY 0x0000 /* %cx */
-#define APM_SYS_STANDBY 0x0001
-#define APM_SYS_SUSPEND 0x0002
-#define APM_SYS_OFF 0x0003
+#define APM_INSTCHECK 0x5300 /* int15 only */
+#define APM_16BIT_SUPPORT 0x01
+#define APM_32BIT_SUPPORT 0x02
+#define APM_CPUIDLE_SLOW 0x04
+#define APM_DISABLED 0x08
+#define APM_DISENGAGED 0x10
+
+#define APM_REAL_CONNECT 0x5301 /* int15 only */
+#define APM_PROT16_CONNECT 0x5302 /* int15 only */
+#define APM_PROT32_CONNECT 0x5303 /* int15 only */
+#define APM_DISCONNECT 0x5304 /* %bx = APM_DEV_APM_BIOS */
+
+#define APM_CPU_IDLE 0x5305
+#define APM_CPU_BUSY 0x5306
+
+#define APM_SET_PWR_STATE 0x5307
+#define APM_SYS_READY 0x0000 /* %cx */
+#define APM_SYS_STANDBY 0x0001
+#define APM_SYS_SUSPEND 0x0002
+#define APM_SYS_OFF 0x0003
#define APM_LASTREQ_INPROG 0x0004
#define APM_LASTREQ_REJECTED 0x0005
+/* 0x0006 - 0x001f Reserved system states */
+/* 0x0020 - 0x003f OEM-defined system states */
+/* 0x0040 - 0x007f OEM-defined device states */
+/* 0x0080 - 0xffff Reserved device states */
/* system standby is device ID (%bx) 0x0001, APM_SYS_STANDBY */
/* system suspend is device ID (%bx) 0x0001, APM_SYS_SUSPEND */
-#define APM_PWR_MGT_ENABLE 0x08
+#define APM_PWR_MGT_ENABLE 0x5308
#define APM_MGT_ALL 0xffff /* %bx */
#define APM_MGT_DISABLE 0x0 /* %cx */
#define APM_MGT_ENABLE 0x1
-#define APM_SYSTEM_DEFAULTS 0x09
+#define APM_SYSTEM_DEFAULTS 0x5309
#define APM_DEFAULTS_ALL 0xffff /* %bx */
-#define APM_POWER_STATUS 0x0a
+#define APM_POWER_STATUS 0x530a
#define APM_AC_OFF 0x00
#define APM_AC_ON 0x01
#define APM_AC_BACKUP 0x02
@@ -126,7 +135,9 @@
((regp)->dx & 0x7fff)*60 : \
((regp)->dx & 0x7fff))
#define BATT_REM_VALID(regp) (((regp)->dx & 0xffff) != 0xffff)
-#define APM_GET_PM_EVENT 0x0b
+
+#define APM_GET_PM_EVENT 0x530b
+#define APM_NOEVENT 0x0000
#define APM_STANDBY_REQ 0x0001 /* %bx on return */
#define APM_SUSPEND_REQ 0x0002
#define APM_NORMAL_RESUME 0x0003
@@ -139,11 +150,16 @@
#define APM_USER_STANDBY_REQ 0x0009
#define APM_USER_SUSPEND_REQ 0x000A
#define APM_SYS_STANDBY_RESUME 0x000B
+/* 0x000c - 0x00ff Reserved system events */
+/* 0x0100 - 0x01ff Reserved device events */
+/* 0x0200 - 0x02ff OEM-defined APM events */
+/* 0x0300 - 0xffff Reserved */
+#define APM_DEFEVENT 0xffffffff /* for customization */
-#define APM_GET_POWER_STATE 0x0c
-#define APM_DEVICE_MGMT_ENABLE 0x0d
+#define APM_GET_POWER_STATE 0x530c
+#define APM_DEVICE_MGMT_ENABLE 0x530d
-#define APM_DRIVER_VERSION 0x0e
+#define APM_DRIVER_VERSION 0x530e
/* %bx should be DEV value (APM_DEV_APM_BIOS)
%ch = driver major vno
%cl = driver minor vno
@@ -152,13 +168,12 @@
#define APM_CONN_MINOR(regp) ((regp)->ax & 0xff)
#define APM_CONN_MAJOR(regp) (((regp)->ax & 0xff00) >> 8)
-#define APM_PWR_MGT_ENGAGE 0x0F
+#define APM_PWR_MGT_ENGAGE 0x530F
#define APM_MGT_DISENGAGE 0x0 /* %cx */
#define APM_MGT_ENGAGE 0x1
-#define APM_OEM 0x80
+#define APM_OEM 0x5380
-#ifndef _LOCORE
/*
* LP (Laptop Package)
*
@@ -174,26 +189,6 @@
* Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
*/
-/* filled in by apmcall */
-struct apmregs {
- u_short ax;
- u_short bx;
- u_short cx;
- u_short dx;
-};
-
-struct apm_connect_info {
- u_int apm_code32_seg_base; /* real-mode style segment selector */
- u_int apm_code16_seg_base;
- u_int apm_data_seg_base;
- u_int apm_entrypt;
- u_short apm_segsel; /* segment selector for APM */
- u_short _pad1;
- u_int apm_code32_seg_len;
- u_int apm_data_seg_len;
- u_int apm_detail;
-};
-
struct apm_event_info {
u_int type;
u_int index;
@@ -223,18 +218,11 @@ struct apm_ctl {
#define APM_IOC_NEXTEVENT _IOR('A', 4, struct apm_event_info) /* fetch event */
#define APM_IOC_DEV_CTL _IOW('A', 5, struct apm_ctl) /* put device into mode */
-struct apm_attach_args {
- char *aaa_busname;
-};
-
#ifdef _KERNEL
-extern struct apm_connect_info apminfo; /* in locore */
-extern int apmpresent;
-extern int apmcall __P((int function, struct apmregs *regs));
extern void apm_cpu_busy __P((void));
extern void apm_cpu_idle __P((void));
extern void apminit __P((void));
int apm_set_powstate __P((u_int devid, u_int powstate));
#endif /* _KERNEL */
-#endif /* _LOCORE */
-#endif /* __i386_apm_h__ */
+
+#endif /* _I386_APMVAR_H_ */
diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h
index 4e7796565d4..4ff198446ec 100644
--- a/sys/arch/i386/include/biosvar.h
+++ b/sys/arch/i386/include/biosvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosvar.h,v 1.12 1997/09/21 23:00:43 mickey Exp $ */
+/* $OpenBSD: biosvar.h,v 1.13 1997/09/29 03:42:28 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -32,23 +32,11 @@
*
*/
-#ifndef __BIOS_VAR_H__
-#define __BIOS_VAR_H__
+#ifndef _I386_BIOSVAR_H_
+#define _I386_BIOSVAR_H_
#define BOOT_APIVER 0x00000001
-#define BOOTC_CHECK 0x00
-#define BOOTC_BOOT 0x01
-#define BOOTC_GETENV 0x02
-#define BOOTC_SETENV 0x03
-#define BOOTV_BOOTDEV 1
-#define BOOTV_BDGMTRY 2
-#define BOOTV_CONSDEV 3
-#define BOOTV_APMCONN 4
-#define BOOTC_GETC 0x10
-#define BOOTC_PUTC 0x11
-#define BOOTC_POLL 0x12
-
#define BIOSNHEADS(d) (((d)>>24)+1)
#define BIOSNSECTS(d) ((d)&0x3f) /* sectors are 1-based */
#define BIOSNDRIVES(d) ((((d)>>16)&0x0f)+1)
@@ -83,133 +71,8 @@
{ "extmem", CTLTYPE_INT }, \
}
-/*
- * Advanced Power Management (APM) BIOS driver for laptop PCs.
- *
- * Copyright (c) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp>
- *
- * This software may be used, modified, copied, and distributed, in
- * both source and binary form provided that the above copyright and
- * these terms are retained. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with its
- * use.
- *
- * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
- * Oct, 1994 NetBSD port (1.0 BETA 10/2) by ukai
- */
-
#if defined(_KERNEL) || defined (_STANDALONE)
-/* APM flags */
-#define APM_16BIT_SUPPORT 0x01
-#define APM_32BIT_SUPPORT 0x02
-#define APM_CPUIDLE_SLOW 0x04
-#define APM_DISABLED 0x08
-#define APM_DISENGAGED 0x10
-
-/* APM functions */
-#define APM_INSTCHECK 0x5300
-#define APM_REALCONNECT 0x5301
-#define APM_PROT16CONNECT 0x5302
-#define APM_PROT32CONNECT 0x5303
-#define APM_DISCONNECTANY 0x5304
-#define APM_CPUIDLE 0x5305
-#define APM_CPUBUSY 0x5306
-#define APM_SETPWSTATE 0x5307
-#define APM_ENABLEDISABLEPM 0x5308
-#define APM_RESTOREDEFAULT 0x5309
-#define APM_GETPWSTATUS 0x530a
-#define APM_GETPMEVENT 0x530b
-#define APM_GETPWSTATE 0x530c
-#define APM_ENABLEDISABLEDPM 0x530d
-#define APM_DRVVERSION 0x530e
-#define APM_ENGAGEDISENGAGEPM 0x530f
-#define APM_OEMFUNC 0x5380
-
-/* error code */
-#define APME_OK 0x00
-#define APME_PMDISABLED 0x01
-#define APME_REALESTABLISHED 0x02
-#define APME_NOTCONNECTED 0x03
-#define APME_PROT16ESTABLISHED 0x05
-#define APME_PROT16NOTSUPPORTED 0x06
-#define APME_PROT32ESTABLISHED 0x07
-#define APME_PROT32NOTDUPPORTED 0x08
-#define APME_UNKNOWNDEVICEID 0x09
-#define APME_OUTOFRANGE 0x0a
-#define APME_NOTENGAGED 0x0b
-#define APME_CANTENTERSTATE 0x60
-#define APME_NOPMEVENT 0x80
-#define APME_NOAPMPRESENT 0x86
-
-/* device code */
-#define PMDV_APMBIOS 0x0000
-#define PMDV_ALLDEV 0x0001
-#define PMDV_DISP0 0x0100
-#define PMDV_DISP1 0x0101
-#define PMDV_2NDSTORAGE0 0x0200
-#define PMDV_2NDSTORAGE1 0x0201
-#define PMDV_2NDSTORAGE2 0x0202
-#define PMDV_2NDSTORAGE3 0x0203
-#define PMDV_PARALLEL0 0x0300
-#define PMDV_PARALLEL1 0x0301
-#define PMDV_SERIAL0 0x0400
-#define PMDV_SERIAL1 0x0401
-#define PMDV_SERIAL2 0x0402
-#define PMDV_SERIAL3 0x0403
-#define PMDV_SERIAL4 0x0404
-#define PMDV_SERIAL5 0x0405
-#define PMDV_SERIAL6 0x0406
-#define PMDV_SERIAL7 0x0407
-#define PMDV_NET0 0x0500
-#define PMDV_NET1 0x0501
-#define PMDV_NET2 0x0502
-#define PMDV_NET3 0x0503
-#define PMDV_PCMCIA0 0x0600
-#define PMDV_PCMCIA1 0x0601
-#define PMDV_PCMCIA2 0x0602
-#define PMDV_PCMCIA3 0x0603
-/* 0x0700 - 0xdfff Reserved */
-/* 0xe000 - 0xefff OEM-defined power device IDs */
-/* 0xf000 - 0xffff Reserved */
-
-/* Power state */
-#define PMST_APMENABLED 0x0000
-#define PMST_STANDBY 0x0001
-#define PMST_SUSPEND 0x0002
-#define PMST_OFF 0x0003
-#define PMST_LASTREQNOTIFY 0x0004
-#define PMST_LASTREQREJECT 0x0005
-/* 0x0006 - 0x001f Reserved system states */
-/* 0x0020 - 0x003f OEM-defined system states */
-/* 0x0040 - 0x007f OEM-defined device states */
-/* 0x0080 - 0xffff Reserved device states */
-
-#define APM_MIN_ORDER 0x00
-#define APM_MID_ORDER 0x80
-#define APM_MAX_ORDER 0xff
-
-
-/* power management event code */
-#define PMEV_NOEVENT 0x0000
-#define PMEV_STANDBYREQ 0x0001
-#define PMEV_SUSPENDREQ 0x0002
-#define PMEV_NORMRESUME 0x0003
-#define PMEV_CRITRESUME 0x0004
-#define PMEV_BATTERYLOW 0x0005
-#define PMEV_POWERSTATECHANGE 0x0006
-#define PMEV_UPDATETIME 0x0007
-#define PMEV_CRITSUSPEND 0x0008
-#define PMEV_USERSTANDBYREQ 0x0009
-#define PMEV_USERSUSPENDREQ 0x000a
-#define PMEV_STANDBYRESUME 0x000b
-/* 0x000c - 0x00ff Reserved system events */
-/* 0x0100 - 0x01ff Reserved device events */
-/* 0x0200 - 0x02ff OEM-defined APM events */
-/* 0x0300 - 0xffff Reserved */
-#define PMEV_DEFAULT 0xffffffff /* used for customization */
-
#ifdef _LOCORE
#define DOINT(n) int $0x20+(n)
#else
@@ -220,13 +83,13 @@ extern struct BIOS_vars {
int bios_dev;
int bios_geometry;
- u_int apm_detail;
- u_int apm_code32_base;
- u_int apm_code16_base;
- u_int apm_code_len;
- u_int apm_data_base;
- u_int apm_data_len;
- u_int apm_entry;
+ u_int bios_apm_detail;
+ u_int bios_apm_code32_base;
+ u_int bios_apm_code16_base;
+ u_int bios_apm_code_len;
+ u_int bios_apm_data_base;
+ u_int bios_apm_data_len;
+ u_int bios_apm_entry;
} BIOS_vars;
@@ -254,11 +117,34 @@ struct EDD_CB {
#include <machine/bus.h>
struct bios_attach_args {
- char *bios_busname;
- bus_space_tag_t bios_iot;
- bus_space_tag_t bios_memt;
+ char *bios_dev;
+ union {
+ struct {
+ bus_space_tag_t _bios_iot;
+ bus_space_tag_t _bios_memt;
+ } bios;
+ struct {
+ u_int _apm_detail;
+ u_int _apm_code32_base;
+ u_int _apm_code16_base;
+ u_int _apm_code_len;
+ u_int _apm_data_base;
+ u_int _apm_data_len;
+ u_int _apm_entry;
+ } apm;
+ } _;
};
+#define bios_iot _.bios._bios_iot
+#define bios_memt _.bios._bios_memt
+#define apm_detail _.apm._apm_detail
+#define apm_code32_base _.apm._apm_code32_base
+#define apm_code16_base _.apm._apm_code16_base
+#define apm_code_len _.apm._apm_code_len
+#define apm_data_base _.apm._apm_data_base
+#define apm_data_len _.apm._apm_data_len
+#define apm_entry _.apm._apm_entry
+
struct consdev;
struct proc;
@@ -275,4 +161,4 @@ void bioscnpollc __P((dev_t, int));
#endif /* _LOCORE */
#endif /* _KERNEL || _STANDALONE */
-#endif /* __BIOS_VAR_H__ */
+#endif /* _I386_BIOSVAR_H_ */