summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>1999-11-07 17:39:16 +0000
committerNiels Provos <provos@cvs.openbsd.org>1999-11-07 17:39:16 +0000
commitb29bc74d7071cb537a794a618a897ebbc6ab3423 (patch)
tree4f31c9b385ac21c835bc0da8c8ace75a8635c8bd /sys/arch
parentbab8bf2167fab743a4dee7d1a8a597458858ab5d (diff)
add APM powerhooks.
from NetBSD, Sat Jun 26 08:25:25 1999 UTC by augustss: Add powerhooks, i.e., the ability to register a function that will be called when the machine does a suspend or resume. XXX Will go away when Jason's kevents come to life.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/i386/apm.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c
index d1825fa5c8f..d3d18c79de7 100644
--- a/sys/arch/i386/i386/apm.c
+++ b/sys/arch/i386/i386/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.26 1999/02/28 05:53:13 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.27 1999/11/07 17:39:15 provos Exp $ */
/*-
* Copyright (c) 1995 John T. Kohl. All rights reserved.
@@ -155,8 +155,9 @@ STATIC const char *apm_err_translate __P((int code));
#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 void apm_standby __P((void));
+STATIC void apm_suspend __P((void));
+STATIC void apm_resume __P((struct apm_softc *, struct apmregs *));
STATIC const char *
apm_err_translate(code)
@@ -284,6 +285,32 @@ apm_power_print (sc, regs)
#endif
}
+STATIC void
+apm_suspend()
+{
+ dopowerhooks(PWR_SUSPEND);
+
+ (void)apm_set_powstate(APM_DEV_ALLDEVS, APM_SYS_SUSPEND);
+}
+
+STATIC void
+apm_standby()
+{
+ dopowerhooks(PWR_STANDBY);
+
+ (void)apm_set_powstate(APM_DEV_ALLDEVS, APM_SYS_STANDBY);
+}
+
+STATIC void
+apm_resume(sc, regs)
+ struct apm_softc *sc;
+ struct apmregs *regs;
+{
+ inittodr(time.tv_sec);
+ dopowerhooks(PWR_RESUME);
+ apm_record_event(sc, regs->bx);
+}
+
/*
* call the APM protected mode bios function FUNCTION for BIOS selection
* WHICHBIOS.
@@ -411,23 +438,19 @@ apm_event_handle(sc, regs)
break;
case APM_NORMAL_RESUME:
DPRINTF(("system resumed\n"));
- inittodr(time.tv_sec);
- apm_record_event(sc, regs->bx);
+ apm_resume(sc, regs);
break;
case APM_CRIT_RESUME:
DPRINTF(("system resumed without us!\n"));
- inittodr(time.tv_sec);
- apm_record_event(sc, regs->bx);
+ apm_resume(sc, regs);
break;
case APM_SYS_STANDBY_RESUME:
DPRINTF(("system standby resume\n"));
- inittodr(time.tv_sec);
- apm_record_event(sc, regs->bx);
+ apm_resume(sc, regs);
break;
case APM_UPDATE_TIME:
DPRINTF(("update time, please\n"));
- inittodr(time.tv_sec);
- apm_record_event(sc, regs->bx);
+ apm_resume(sc, regs);
break;
case APM_CRIT_SUSPEND_REQ:
DPRINTF(("suspend required immediately\n"));