diff options
author | iwasaki <iwasaki@FreeBSD.org> | 2001-11-06 15:00:30 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 2001-11-06 15:00:30 +0000 |
commit | 37688d63276146108db05e433930ef7f0d572d34 (patch) | |
tree | 048d74e450c6b6eaaa11cab65d2c0a47191e40d2 | |
parent | e2aa5ac96dede4de34aabb975cab9a6ee618a276 (diff) | |
download | FreeBSD-src-37688d63276146108db05e433930ef7f0d572d34.zip FreeBSD-src-37688d63276146108db05e433930ef7f0d572d34.tar.gz |
Add S4BIOS sleep (BIOS hibernation) and DSDT overriding support.
- Add S4BIOS sleep implementation. This will works well if MIB
hw.acpi.s4bios is set (and of course BIOS supports it and hibernation
is enabled correctly).
- Add DSDT overriding support which is submitted by takawata originally.
If loader tunable acpi_dsdt_load="YES" and DSDT file is set to
acpi_dsdt_name (default DSDT file name is /boot/acpi_dsdt.aml),
ACPI CA core loads DSDT from given file rather than BIOS memory block.
DSDT file can be generated by iasl in ports/devel/acpicatools/.
- Add new files so that we can add our proposed additional code to Intel
ACPI CA into these files temporary. They will be removed when
similar code is added into ACPI CA officially.
-rw-r--r-- | sys/amd64/acpica/acpi_wakeup.c | 10 | ||||
-rw-r--r-- | sys/boot/forth/loader.conf | 9 | ||||
-rw-r--r-- | sys/conf/files | 1 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/tbget.c | 4 | ||||
-rw-r--r-- | sys/dev/acpica/acpi.c | 20 | ||||
-rw-r--r-- | sys/dev/acpica/acpica_support.c | 142 | ||||
-rw-r--r-- | sys/dev/acpica/acpica_support.h | 38 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 2 | ||||
-rw-r--r-- | sys/i386/acpica/acpi_wakeup.c | 10 | ||||
-rw-r--r-- | sys/modules/acpi/Makefile | 1 |
10 files changed, 234 insertions, 3 deletions
diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c index ad67313..3ba70b1 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 abbfcc4..cd5bf21 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 aadff78..f099136 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 e30e4bd..a6c3cf5 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 245fa42..cddb898 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 0000000..5904fc1 --- /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 0000000..359d0d0 --- /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 5dd9619..64e8ceb 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 ad67313..3ba70b1 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 15c87b7..4b33d7d 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 |