Page MenuHomeFreeBSD

D61260.1794070390.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D61260.1794070390.diff

diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -40,11 +40,13 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/endian.h>
+#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/reboot.h>
#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -70,6 +72,7 @@
static int asmc_attach(device_t dev);
static int asmc_detach(device_t dev);
static int asmc_resume(device_t dev);
+static void asmc_shutdown(void *arg, int howto);
/*
* Backlight interface.
@@ -736,6 +739,10 @@
"Apple security chip generation (RGEN; 3=T2)");
}
+ if (asmc_key_getinfo(dev, ASMC_KEY_MBSS, NULL, NULL) == 0)
+ sc->sc_shutdown_tag = EVENTHANDLER_REGISTER(shutdown_pre_sync,
+ asmc_shutdown, dev, SHUTDOWN_PRI_FIRST);
+
if (!sc->sc_has_sms)
goto nosms;
@@ -821,6 +828,11 @@
{
struct asmc_softc *sc = device_get_softc(dev);
+ if (sc->sc_shutdown_tag != NULL) {
+ EVENTHANDLER_DEREGISTER(shutdown_pre_sync, sc->sc_shutdown_tag);
+ sc->sc_shutdown_tag = NULL;
+ }
+
if (sc->sc_kbd_bkl != NULL)
backlight_destroy(sc->sc_kbd_bkl);
@@ -877,6 +889,17 @@
return (0);
}
+static void
+asmc_shutdown(void *arg, int howto)
+{
+ device_t dev = (device_t)arg;
+ uint8_t buf[2];
+
+ be16enc(buf, (howto & (RB_POWEROFF | RB_HALT)) != 0 ?
+ ASMC_MBSS_POWEROFF : ASMC_MBSS_RESTART);
+ asmc_key_write(dev, ASMC_KEY_MBSS, buf, sizeof(buf));
+}
+
#ifdef ASMC_DEBUG
void
asmc_dumpall(device_t dev)
diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h
--- a/sys/dev/asmc/asmcvar.h
+++ b/sys/dev/asmc/asmcvar.h
@@ -90,6 +90,7 @@
int sc_light_len; /* ASMC_LIGHT_{SHORT,LONG}LEN */
int sc_has_safespeed;
int sc_has_alsl; /* ALSL interrupt source */
+ eventhandler_tag sc_shutdown_tag;
};
/*
@@ -197,6 +198,12 @@
*/
#define ASMC_KEY_AUPO "AUPO" /* RW; 1 byte */
+/* Mac Boot State Status. */
+#define ASMC_KEY_MBSS "MBSS" /* RW; 2 bytes */
+
+#define ASMC_MBSS_POWEROFF 0x0001
+#define ASMC_MBSS_RESTART 0x0003
+
/*
* Interrupt keys.
*/

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 7, 4:53 PM (2 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41548503
Default Alt Text
D61260.1794070390.diff (2 KB)

Event Timeline