FreeBSD/sys/contrib/dev/acpica/components/hardware/hwesleep.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiHwExtendedSleep
 *
 * PARAMETERS:  SleepState          - Which sleep state to enter
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Enter a system sleep state via the extended FADT sleep
 *              registers (V5 FADT).
 *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
 *
 ******************************************************************************/
AcpiHwExtendedSleep
PARAMETERS:  SleepState          - Which sleep state to enter

Status

Enter a system sleep state via the extended FADT sleep
registers (V5 FADT).
THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
AcpiHwExtendedSleep PARAMETERS : SleepState - Which sleep state to enter Status Enter a system sleep state via the extended FADT sleep registers ( V5 FADT ) . THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
ACPI_STATUS
AcpiHwExtendedSleep (
    UINT8                   SleepState)
{
    ACPI_STATUS             Status;
    UINT8                   SleepTypeValue;
    UINT64                  SleepStatus;
    ACPI_FUNCTION_TRACE (HwExtendedSleep);
    if (!AcpiGbl_FADT.SleepControl.Address ||
        !AcpiGbl_FADT.SleepStatus.Address)
    {
        return_ACPI_STATUS (AE_NOT_EXIST);
    }
    Status = AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS,
        &AcpiGbl_FADT.SleepStatus);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    AcpiGbl_SystemAwakeAndRunning = FALSE;
    ACPI_FLUSH_CPU_CACHE ();
    ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
        "Entering sleep state [S%u]\n", SleepState));
    SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) &
        ACPI_X_SLEEP_TYPE_MASK);
    Status = AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE),
        &AcpiGbl_FADT.SleepControl);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    do
    {
        Status = AcpiRead (&SleepStatus, &AcpiGbl_FADT.SleepStatus);
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
        }
    } while (!(((UINT8) SleepStatus) & ACPI_X_WAKE_STATUS));
    return_ACPI_STATUS (AE_OK);
}
ACPI_STATUS AcpiHwExtendedSleep ( UINT8 SleepState ) { ACPI_STATUS Status ; UINT8 SleepTypeValue ; UINT64 SleepStatus ; ACPI_FUNCTION_TRACE ( HwExtendedSleep ) ; if ( ! AcpiGbl_FADT . SleepControl . Address || ! AcpiGbl_FADT . SleepStatus . Address ) { return_ACPI_STATUS ( AE_NOT_EXIST ) ; } Status = AcpiWrite ( ( UINT64 ) ACPI_X_WAKE_STATUS , & AcpiGbl_FADT . SleepStatus ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } AcpiGbl_SystemAwakeAndRunning = FALSE ; ACPI_FLUSH_CPU_CACHE ( ) ; ACPI_DEBUG_PRINT ( ( ACPI_DB_INIT , " \n " , SleepState ) ) ; SleepTypeValue = ( ( AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION ) & ACPI_X_SLEEP_TYPE_MASK ) ; Status = AcpiWrite ( ( UINT64 ) ( SleepTypeValue | ACPI_X_SLEEP_ENABLE ) , & AcpiGbl_FADT . SleepControl ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } do { Status = AcpiRead ( & SleepStatus , & AcpiGbl_FADT . SleepStatus ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } } while ( ! ( ( ( UINT8 ) SleepStatus ) & ACPI_X_WAKE_STATUS ) ) ; return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiHwExtendedSleep
 PARAMETERS:  SleepState          - Which sleep state to enter
FUNCTION : AcpiHwExtendedSleep PARAMETERS : SleepState - Which sleep state to enter
/* Extended sleep registers must be valid */ /* Clear wake status (WAK_STS) */ /* Flush caches, as per ACPI specification */ /*
     * Set the SLP_TYP and SLP_EN bits.
     *
     * Note: We only use the first value returned by the \_Sx method
     * (AcpiGbl_SleepTypeA) - As per ACPI specification.
     */ /* Wait for transition back to Working State */