aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/acpica/acpi_wakeup.c10
-rw-r--r--sys/boot/forth/loader.conf9
-rw-r--r--sys/conf/files1
-rw-r--r--sys/contrib/dev/acpica/tbget.c4
-rw-r--r--sys/dev/acpica/acpi.c20
-rw-r--r--sys/dev/acpica/acpica_support.c142
-rw-r--r--sys/dev/acpica/acpica_support.h38
-rw-r--r--sys/dev/acpica/acpivar.h2
-rw-r--r--sys/i386/acpica/acpi_wakeup.c10
-rw-r--r--sys/modules/acpi/Makefile1
10 files changed, 234 insertions, 3 deletions
diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c
index ad67313469d0..3ba70b1ef330 100644
--- a/sys/amd64/acpica/acpi_wakeup.c
+++ b/sys/amd64/acpica/acpi_wakeup.c
@@ -52,6 +52,8 @@
#include "acpi.h"
+#include <dev/acpica/acpica_support.h>
+
#include <dev/acpica/acpivar.h>
#include "acpi_wakecode.h"
@@ -236,7 +238,13 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
acpi_printcpu();
}
- if ((status = AcpiEnterSleepState(state)) != AE_OK) {
+ if (state == ACPI_STATE_S4 && sc->acpi_s4bios) {
+ status = AcpiEnterSleepStateS4Bios();
+ } else {
+ status = AcpiEnterSleepState(state);
+ }
+
+ if (status != AE_OK) {
device_printf(sc->acpi_dev,
"AcpiEnterSleepState failed - %s\n",
AcpiFormatException(status));
diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf
index abbfcc4e7a35..cd5bf218b922 100644
--- a/sys/boot/forth/loader.conf
+++ b/sys/boot/forth/loader.conf
@@ -242,6 +242,15 @@ random_load="NO" # Random device
atspeaker_load="NO" # AT speaker module
##############################################################
+### ACPI settings ##########################################
+##############################################################
+
+acpi_dsdt_load="NO" # DSDT Overriding
+acpi_dsdt_type="acpi_dsdt" # Don't change this
+acpi_dsdt_name="/boot/acpi_dsdt.aml"
+ # Override DSDT in BIOS by this file
+
+##############################################################
### Module loading syntax example ##########################
##############################################################
diff --git a/sys/conf/files b/sys/conf/files
index aadff7879739..f099136d2db5 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -197,6 +197,7 @@ dev/aac/aac_debug.c optional aac
dev/aac/aac_disk.c optional aac
dev/aac/aac_pci.c optional aac pci
dev/acpica/acpi.c optional acpica
+dev/acpica/acpica_support.c optional acpica
dev/acpica/acpi_acad.c optional acpica
dev/acpica/acpi_battery.c optional acpica
dev/acpica/acpi_button.c optional acpica
diff --git a/sys/contrib/dev/acpica/tbget.c b/sys/contrib/dev/acpica/tbget.c
index e30e4bd38276..a6c3cf576aff 100644
--- a/sys/contrib/dev/acpica/tbget.c
+++ b/sys/contrib/dev/acpica/tbget.c
@@ -439,7 +439,9 @@ AcpiTbGetAllTables (
* Get the DSDT (We know that the FADT is valid now)
*/
Status = AcpiTbGetTable ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt),
- TablePtr, &TableInfo);
+ ((AcpiGbl_DSDT) ?
+ AcpiGbl_DSDT: TablePtr), &TableInfo);
+
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 245fa42ae06a..cddb89819732 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -42,6 +42,7 @@
#include <sys/reboot.h>
#include <sys/sysctl.h>
#include <sys/ctype.h>
+#include <sys/linker.h>
#include <sys/power.h>
#include <machine/clock.h>
@@ -51,6 +52,8 @@
#include "acpi.h"
+#include <dev/acpica/acpica_support.h>
+
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
@@ -205,6 +208,7 @@ acpi_identify(driver_t *driver, device_t parent)
{
device_t child;
int error;
+ caddr_t acpi_dsdt, p;
#ifdef ENABLE_DEBUGGER
char *debugpoint = getenv("debug.acpi.debugger");
#endif
@@ -247,6 +251,19 @@ acpi_identify(driver_t *driver, device_t parent)
if (debugpoint && !strcmp(debugpoint, "tables"))
acpi_EnterDebugger();
#endif
+
+ if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) != NULL) {
+ if ((p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) != NULL) {
+ error = AcpiSetDsdtTablePtr(*(void **)p);
+ if (error != AE_OK) {
+ printf("ACPI: DSDT overriding failed: %s\n",
+ AcpiFormatException(error));
+ } else {
+ printf("ACPI: DSDT was overridden.\n");
+ }
+ }
+ }
+
if ((error = AcpiLoadTables()) != AE_OK) {
printf("ACPI: table load failed: %s\n", AcpiFormatException(error));
return_VOID;
@@ -392,6 +409,9 @@ acpi_attach(device_t dev)
OID_AUTO, "suspend_state", CTLTYPE_STRING | CTLFLAG_RW,
&sc->acpi_suspend_sx, 0, acpi_sleep_state_sysctl, "A", "");
SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
+ OID_AUTO, "s4bios", CTLFLAG_RD | CTLFLAG_RW,
+ &sc->acpi_s4bios, 0, "S4BIOS mode");
+ SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
OID_AUTO, "verbose", CTLFLAG_RD | CTLFLAG_RW,
&sc->acpi_verbose, 0, "verbose mode");
if (bootverbose)
diff --git a/sys/dev/acpica/acpica_support.c b/sys/dev/acpica/acpica_support.c
new file mode 100644
index 000000000000..5904fc16989d
--- /dev/null
+++ b/sys/dev/acpica/acpica_support.c
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2001 Mitsuru IWASAKI
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 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.
+ *
+ * $FreeBSD$
+ */
+
+#include "acpi.h"
+#include <dev/acpica/acpica_support.h>
+
+MODULE_NAME("support")
+
+/*
+ * Implement support code temporary here until officially merged into
+ * Intel ACPI CA release.
+ */
+
+#undef _COMPONENT
+#define _COMPONENT ACPI_HARDWARE
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepStateS4Bios
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter a system sleep state S4BIOS
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepStateS4Bios (
+ void)
+{
+ ACPI_OBJECT_LIST ArgList;
+ ACPI_OBJECT Arg;
+
+
+ FUNCTION_TRACE ("AcpiEnterSleepStateS4Bios");
+
+ /* run the _PTS and _GTS methods */
+
+ MEMSET(&ArgList, 0, sizeof(ArgList));
+ ArgList.Count = 1;
+ ArgList.Pointer = &Arg;
+
+ MEMSET(&Arg, 0, sizeof(Arg));
+ Arg.Type = ACPI_TYPE_INTEGER;
+ Arg.Integer.Value = ACPI_STATE_S4;
+
+ AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL);
+ AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL);
+
+ /* clear wake status */
+
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1);
+
+ disable ();
+
+ AcpiHwDisableNonWakeupGpes();
+
+ /* flush caches */
+
+ wbinvd();
+
+ /* write the value to command port and wait until we enter sleep state */
+ do
+ {
+ AcpiOsStall(1000000);
+ AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, AcpiGbl_FADT->S4BiosReq, 8);
+ }
+ while (!AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, WAK_STS));
+
+ AcpiHwEnableNonWakeupGpes();
+
+ enable ();
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+#undef _COMPONENT
+#define _COMPONENT ACPI_TABLES
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetDsdtTablePtr
+ *
+ * PARAMETERS: TablePtr - pointer to a buffer containing the entire
+ * DSDT table to override
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Set DSDT table ptr for DSDT overriding. This function should
+ * be called perior than AcpiLoadTables().
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetDsdtTablePtr(
+ ACPI_TABLE_HEADER *TablePtr)
+{
+ FUNCTION_TRACE ("AcpiSetDsdtTablePtr");
+
+ if (!TablePtr)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (AcpiGbl_AcpiTables[ACPI_TABLE_DSDT].LoadedIntoNamespace)
+ {
+ return_ACPI_STATUS (AE_EXIST);
+ }
+
+ AcpiGbl_DSDT = TablePtr;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/dev/acpica/acpica_support.h b/sys/dev/acpica/acpica_support.h
new file mode 100644
index 000000000000..359d0d0a1984
--- /dev/null
+++ b/sys/dev/acpica/acpica_support.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2001 Mitsuru IWASAKI
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 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.
+ *
+ * $FreeBSD$
+ */
+
+#include "acpi.h"
+
+ACPI_STATUS
+AcpiEnterSleepStateS4Bios (
+ void);
+
+ACPI_STATUS
+AcpiSetDsdtTablePtr(
+ ACPI_TABLE_HEADER *Ptr);
+
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 5dd9619750a3..64e8ceb8b070 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -60,6 +60,8 @@ struct acpi_softc {
int acpi_standby_sx;
int acpi_suspend_sx;
+ int acpi_s4bios;
+
int acpi_verbose;
bus_dma_tag_t acpi_waketag;
diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c
index ad67313469d0..3ba70b1ef330 100644
--- a/sys/i386/acpica/acpi_wakeup.c
+++ b/sys/i386/acpica/acpi_wakeup.c
@@ -52,6 +52,8 @@
#include "acpi.h"
+#include <dev/acpica/acpica_support.h>
+
#include <dev/acpica/acpivar.h>
#include "acpi_wakecode.h"
@@ -236,7 +238,13 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
acpi_printcpu();
}
- if ((status = AcpiEnterSleepState(state)) != AE_OK) {
+ if (state == ACPI_STATE_S4 && sc->acpi_s4bios) {
+ status = AcpiEnterSleepStateS4Bios();
+ } else {
+ status = AcpiEnterSleepState(state);
+ }
+
+ if (status != AE_OK) {
device_printf(sc->acpi_dev,
"AcpiEnterSleepState failed - %s\n",
AcpiFormatException(status));
diff --git a/sys/modules/acpi/Makefile b/sys/modules/acpi/Makefile
index 15c87b7fafa1..4b33d7d6ac7f 100644
--- a/sys/modules/acpi/Makefile
+++ b/sys/modules/acpi/Makefile
@@ -30,6 +30,7 @@ SRCS+= utglobal.c utinit.c utmath.c utmisc.c utobject.c utxface.c
SRCS+= acpi.c acpi_acad.c acpi_battery.c acpi_button.c acpi_cmbat.c acpi_cpu.c
SRCS+= acpi_ec.c acpi_lid.c acpi_pcib.c acpi_powerprofile.c
SRCS+= acpi_powerres.c acpi_resource.c acpi_thermal.c acpi_timer.c
+SRCS+= acpica_support.c
SRCS+= OsdDebug.c
SRCS+= OsdHardware.c OsdInterrupt.c OsdMemory.c OsdSchedule.c
SRCS+= OsdStream.c OsdSynch.c OsdEnvironment.c