Пример #1
0
status_t
prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size)
{
    ACPI_STATUS acpiStatus;

    TRACE("prepare_sleep_state %d, %p, %ld\n", state, wakeFunc, size);

    if (state != ACPI_POWER_STATE_OFF) {
        physical_entry wakeVector;
        status_t status;

        // Note: The supplied code must already be locked into memory.
        status = get_memory_map((const void*)wakeFunc, size, &wakeVector, 1);
        if (status != B_OK)
            return status;

#	if B_HAIKU_PHYSICAL_BITS > 32
        if (wakeVector.address >= 0x100000000LL) {
            ERROR("prepare_sleep_state(): ACPI 2.0c says use 32 bit "
                  "vector, but we have a physical address >= 4 GB\n");
        }
#	endif
        acpiStatus = AcpiSetFirmwareWakingVector(wakeVector.address,
                     wakeVector.address);
        if (acpiStatus != AE_OK)
            return B_ERROR;
    }

    acpiStatus = AcpiEnterSleepStatePrep(state);
    if (acpiStatus != AE_OK)
        return B_ERROR;

    return B_OK;
}
Пример #2
0
int
acpi_poweroff(void)
{
	extern int acpica_use_safe_delay;
	ACPI_STATUS status;

	PSM_VERBOSE_POWEROFF(("acpi_poweroff: starting poweroff\n"));

	acpica_use_safe_delay = 1;

	status = AcpiEnterSleepStatePrep(5);
	if (status != AE_OK) {
		PSM_VERBOSE_POWEROFF(("acpi_poweroff: failed to prepare for "
		    "poweroff, status=0x%x\n", status));
		return (1);
	}
	ACPI_DISABLE_IRQS();
	status = AcpiEnterSleepState(5);
	ACPI_ENABLE_IRQS();

	/* we should be off; if we get here it's an error */
	PSM_VERBOSE_POWEROFF(("acpi_poweroff: failed to actually power "
	    "off, status=0x%x\n", status));
	return (1);
}
Пример #3
0
uint32_t handlePowerButton(void *context) {
	frigg::infoLogger() << "thor: Preparing for shutdown" << frigg::endLog;

	ACPICA_CHECK(AcpiEnterSleepStatePrep(5));
	ACPICA_CHECK(AcpiEnterSleepState(5));

	return ACPI_INTERRUPT_HANDLED;
}
Пример #4
0
Файл: acpica.c Проект: olsner/os
static void GlobalEventHandler(UINT32 EventType, ACPI_HANDLE Device,
		UINT32 EventNumber, void *Context) {
	if (EventType == ACPI_EVENT_TYPE_FIXED &&
		EventNumber == ACPI_EVENT_POWER_BUTTON) {

		printf("POWER BUTTON! Shutting down.\n");

		AcpiEnterSleepStatePrep(ACPI_STATE_S5);
		AcpiEnterSleepState(ACPI_STATE_S5);
	}
}
Пример #5
0
void acpi_shutdown(void) {
	ACPI_STATUS status;

	status = AcpiEnterSleepStatePrep(ACPI_STATE_S5);
	if (ACPI_FAILURE(status)) {
		printk("ERROR: Unable to prepare to enter the soft off system state\n");
		break;
	}

	status = AcpiEnterSleepState(ACPI_STATE_S5);
	if (ACPI_FAILURE(status)) {
		printk("ERROR: Unable to enter the soft off system state\n");
	}
}
Пример #6
0
ACPI_STATUS
AcpiDbSleep (
    char                    *ObjectArg)
{
    ACPI_STATUS             Status;
    UINT8                   SleepState;


    ACPI_FUNCTION_TRACE (AcpiDbSleep);


    SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);

    AcpiOsPrintf ("**** Prepare to sleep ****\n");
    Status = AcpiEnterSleepStatePrep (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    AcpiOsPrintf ("**** Going to sleep ****\n");
    Status = AcpiEnterSleepState (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    AcpiOsPrintf ("**** Prepare to return from sleep ****\n");
    Status = AcpiLeaveSleepStatePrep (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    AcpiOsPrintf ("**** Returning from sleep ****\n");
    Status = AcpiLeaveSleepState (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    return (Status);


ErrorExit:

    ACPI_EXCEPTION ((AE_INFO, Status, "During sleep test"));
    return (Status);
}
Пример #7
0
errno_t
acpi_powerdown(void)
{
    ACPI_STATUS status;

    t_migrate_to_boot_CPU();

    status = AcpiEnterSleepStatePrep(ACPI_POWER_STATE_OFF);
    if (status != AE_OK)
        return ENXIO;

    status = AcpiEnterSleepState(ACPI_POWER_STATE_OFF);
    if (status != AE_OK)
        return ENXIO;

    return 0;
}
Пример #8
0
static void
AcpiDbDoOneSleepState (
    UINT8                   SleepState)
{
    ACPI_STATUS             Status;
    UINT8                   SleepTypeA;
    UINT8                   SleepTypeB;


    /* Validate parameter */

    if (SleepState > ACPI_S_STATES_MAX)
    {
        AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
            SleepState, ACPI_S_STATES_MAX);
        return;
    }

    AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
        SleepState, AcpiGbl_SleepStateNames[SleepState]);

    /* Get the values for the sleep type registers (for display only) */

    Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
    if (ACPI_FAILURE (Status))
    {
        AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
            AcpiGbl_SleepStateNames[SleepState],
            AcpiFormatException (Status));
        return;
    }

    AcpiOsPrintf (
        "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
        SleepState, SleepTypeA, SleepTypeB);

    /* Invoke the various sleep/wake interfaces */

    AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
        SleepState);
    Status = AcpiEnterSleepStatePrep (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
        SleepState);
    Status = AcpiEnterSleepState (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
        SleepState);
    Status = AcpiLeaveSleepStatePrep (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
        SleepState);
    Status = AcpiLeaveSleepState (SleepState);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    return;


ErrorExit:
    ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
        SleepState));
}