summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authoriwasaki <iwasaki@FreeBSD.org>2000-09-30 22:37:24 +0000
committeriwasaki <iwasaki@FreeBSD.org>2000-09-30 22:37:24 +0000
commite50592ac572d97a1ad258f180a94a57db5e06052 (patch)
tree84a6f7396e3b43119ffdf76245a8b21e10aaa4c8 /sys/dev/acpi
parent017c58324c4e1ec2f7ba068f6d99153cb68860eb (diff)
downloadFreeBSD-src-e50592ac572d97a1ad258f180a94a57db5e06052.zip
FreeBSD-src-e50592ac572d97a1ad258f180a94a57db5e06052.tar.gz
- Add acpi_disable_events() and set it with EVENTHANDLER_REGISTER in order to
avoid power on again problem after acpi_soft_off() calling. - Implement SleepOp/StallOp in AML interpreter. Also provide ACPICA compatibility. - Minor changes on __inline function declaration in acpica_osd.h (obtained from NetBSD porting).
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpi.c41
-rw-r--r--sys/dev/acpi/acpi_event.c13
-rw-r--r--sys/dev/acpi/acpireg.h3
-rw-r--r--sys/dev/acpi/acpivar.h7
-rw-r--r--sys/dev/acpi/aml/aml_common.h4
-rw-r--r--sys/dev/acpi/aml/aml_parse.c20
6 files changed, 83 insertions, 5 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index c78a39f..994b320 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -831,7 +831,10 @@ acpi_attach(device_t dev)
acpi_powerres_debug(sc);
}
- EVENTHANDLER_REGISTER(shutdown_final, acpi_soft_off, sc, SHUTDOWN_PRI_LAST);
+ EVENTHANDLER_REGISTER(shutdown_pre_sync, acpi_disable_events,
+ sc, SHUTDOWN_PRI_LAST);
+ EVENTHANDLER_REGISTER(shutdown_final, acpi_soft_off,
+ sc, SHUTDOWN_PRI_LAST);
sc->dev_t = make_dev(&acpi_cdevsw, 0, 0, 5, 0660, "acpi");
sc->dev_t->si_drv1 = sc;
@@ -962,3 +965,39 @@ acpi_attach_resource(acpi_softc_t *sc, int type, int *wantidx, u_long start, u_l
return(ENXIO);
}
}
+
+/*
+ * System service interface
+ */
+
+#include <sys/proc.h>
+
+int
+acpi_sleep(u_int32_t micro)
+{
+ static u_int8_t count = 0;
+ int x, error;
+ u_int32_t timo;
+
+ x = error = 0;
+
+ if (micro == 0) {
+ return (1);
+ }
+
+ if (curproc == NULL) {
+ return (2);
+ }
+
+ timo = ((hz * micro) / 1000000L) ? ((hz * micro) / 1000000L) : 1;
+ error = tsleep((caddr_t)acpi_sleep + count, PWAIT, "acpislp", timo);
+ if (error != 0 && error != EWOULDBLOCK) {
+ return (2);
+ }
+ x = splhigh();
+ count++;
+ splx(x);
+
+ return (0);
+}
+
diff --git a/sys/dev/acpi/acpi_event.c b/sys/dev/acpi/acpi_event.c
index a66ec23..5f965df 100644
--- a/sys/dev/acpi/acpi_event.c
+++ b/sys/dev/acpi/acpi_event.c
@@ -298,6 +298,19 @@ acpi_enable_events(acpi_softc_t *sc)
}
void
+acpi_disable_events(acpi_softc_t *sc)
+{
+ u_int32_t zero;
+
+ if (sc->enabled) {
+ zero = 0;
+ acpi_io_pm1_enable(sc, ACPI_REGISTER_OUTPUT, &zero);
+ acpi_io_gpe0_enable(sc, ACPI_REGISTER_OUTPUT, &zero);
+ acpi_io_gpe1_enable(sc, ACPI_REGISTER_OUTPUT, &zero);
+ }
+}
+
+void
acpi_clear_ignore_events(void *arg)
{
((acpi_softc_t *)arg)->ignore_events = 0;
diff --git a/sys/dev/acpi/acpireg.h b/sys/dev/acpi/acpireg.h
index 635c2b7..1d64e92 100644
--- a/sys/dev/acpi/acpireg.h
+++ b/sys/dev/acpi/acpireg.h
@@ -328,6 +328,9 @@ ACPI_STATUS OsdReadPciCfgDword(UINT32, UINT32 , UINT32 , UINT32 *);
ACPI_STATUS OsdWritePciCfgByte(UINT32, UINT32 , UINT32 , UINT8);
ACPI_STATUS OsdWritePciCfgWord(UINT32, UINT32 , UINT32 , UINT16);
ACPI_STATUS OsdWritePciCfgDword(UINT32, UINT32 , UINT32 , UINT32);
+
+ACPI_STATUS OsdSleep(UINT32, UINT32);
+ACPI_STATUS OsdSleepUsec(UINT32);
#endif /* ACPI_NO_OSDFUNC_INLINE */
#else /* !_KERNEL */
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h
index d06794d..011a6b1 100644
--- a/sys/dev/acpi/acpivar.h
+++ b/sys/dev/acpi/acpivar.h
@@ -202,6 +202,7 @@ extern void acpi_intr(void *data);
extern void acpi_queue_event(acpi_softc_t *sc, int type, int arg);
extern int acpi_send_pm_event(acpi_softc_t *sc, u_int8_t state);
extern void acpi_enable_events(acpi_softc_t *sc);
+extern void acpi_disable_events(acpi_softc_t *sc);
extern void acpi_clear_ignore_events(void *arg);
extern void acpi_event_thread(void *arg);
@@ -244,3 +245,9 @@ extern void acpi_mapmem(void);
extern int acpi_debug;
#define ACPI_DEVPRINTF(args...) printf("acpi0: " args)
#define ACPI_DEBUGPRINT(args...) do { if (acpi_debug) ACPI_DEVPRINTF(args);} while(0)
+
+/*
+ * System service interface
+ */
+extern int acpi_sleep(u_int32_t micro);
+
diff --git a/sys/dev/acpi/aml/aml_common.h b/sys/dev/acpi/aml/aml_common.h
index 4988385..827c324 100644
--- a/sys/dev/acpi/aml/aml_common.h
+++ b/sys/dev/acpi/aml/aml_common.h
@@ -47,11 +47,15 @@
printf(fmt, args); \
} while(0)
#define AML_DEBUGGER(x, y) /* no debugger in kernel */
+#define AML_STALL(micro) DELAY(micro)
+#define AML_SLEEP(sec, milli) OsdSleep(sec, milli)
#else /* !_KERNEL */
#define AML_SYSASSERT(x) assert(x)
#define AML_SYSABORT() abort()
#define AML_SYSERRX(eval, fmt, args...) errx(eval, fmt, args)
#define AML_DEBUGGER(x, y) aml_dbgr(x, y)
+#define AML_STALL(micro) /* not required in userland */
+#define AML_SLEEP(sec, milli) /* not required in userland */
#endif /* _KERNEL */
union aml_object;
diff --git a/sys/dev/acpi/aml/aml_parse.c b/sys/dev/acpi/aml/aml_parse.c
index f98977d..ce40e64 100644
--- a/sys/dev/acpi/aml/aml_parse.c
+++ b/sys/dev/acpi/aml/aml_parse.c
@@ -55,6 +55,14 @@
#include "debug.h"
#else /* _KERNEL */
#include <sys/systm.h>
+#include <sys/bus.h>
+#include <machine/bus.h>
+#include <machine/clock.h>
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#ifndef ACPI_NO_OSDFUNC_INLINE
+#include <machine/acpica_osd.h>
+#endif
#endif /* !_KERNEL */
static int findsetleftbit(int num);
@@ -1484,14 +1492,18 @@ aml_parse_termobj(struct aml_environ *env, int indent)
aml_parse_termobj(env, indent);
AML_DEBUGPRINT(")");
break;
- case 0x21: /* StallOp *//* XXX Not yet */
+ case 0x21: /* StallOp */
AML_DEBUGPRINT("Stall(");
- aml_parse_termobj(env, indent);
+ num1 = aml_objtonum(env, aml_eval_name(env,
+ aml_parse_termobj(env, indent)));
AML_DEBUGPRINT(")");
+ AML_STALL(num1);
break;
- case 0x22: /* SleepOp *//* XXX Not yet */
+ case 0x22: /* SleepOp */
AML_DEBUGPRINT("Sleep(");
- aml_parse_termobj(env, indent);
+ num1 = aml_objtonum(env, aml_eval_name(env,
+ aml_parse_termobj(env, indent)));
+ AML_SLEEP(0, num1);
AML_DEBUGPRINT(")");
break;
case 0x23: /* AcquireOp *//* XXX Not yet */
OpenPOWER on IntegriCloud