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.
This commit is contained in:
parent
ff3d0079a9
commit
1611ea8727
@ -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));
|
||||
|
@ -241,6 +241,15 @@ accf_http_load="NO" # Wait for full HTTP request accept filter
|
||||
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 ##########################
|
||||
##############################################################
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
@ -391,6 +408,9 @@ acpi_attach(device_t dev)
|
||||
SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
|
||||
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");
|
||||
|
142
sys/dev/acpica/acpica_support.c
Normal file
142
sys/dev/acpica/acpica_support.c
Normal file
@ -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);
|
||||
}
|
||||
|
38
sys/dev/acpica/acpica_support.h
Normal file
38
sys/dev/acpica/acpica_support.h
Normal file
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user