ReactOS 0.4.17-dev-684-ga6524ef
sleep.h File Reference
#include <uacpi/types.h>
#include <uacpi/status.h>
#include <uacpi/uacpi.h>
Include dependency graph for sleep.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE (uacpi_status uacpi_set_waking_vector(uacpi_phys_addr addr32, uacpi_phys_addr addr64)) typedef enum uacpi_sleep_state
 
uacpi_status uacpi_prepare_for_sleep_state (uacpi_sleep_state)
 
uacpi_status uacpi_enter_sleep_state (uacpi_sleep_state)
 
uacpi_status uacpi_enter_sleep_state_simple (uacpi_sleep_state)
 
uacpi_status uacpi_prepare_for_wake_from_sleep_state (uacpi_sleep_state)
 
uacpi_status uacpi_wake_from_sleep_state (uacpi_sleep_state)
 
uacpi_status uacpi_reboot (void)
 

Variables

 uacpi_sleep_state
 

Function Documentation

◆ UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE()

UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE ( uacpi_status   uacpi_set_waking_vector uacpi_phys_addr addr32, uacpi_phys_addr addr64)

Set the firmware waking vector in FACS.

'addr32' is the real mode entry-point address 'addr64' is the protected mode entry-point address

Definition at line 19 of file sleep.h.

24 {
25 UACPI_SLEEP_STATE_S0 = 0,
26 UACPI_SLEEP_STATE_S1,
27 UACPI_SLEEP_STATE_S2,
28 UACPI_SLEEP_STATE_S3,
29 UACPI_SLEEP_STATE_S4,
30 UACPI_SLEEP_STATE_S5,
31 UACPI_SLEEP_STATE_MAX = UACPI_SLEEP_STATE_S5,
uacpi_sleep_state
Definition: sleep.h:32

◆ uacpi_enter_sleep_state()

uacpi_status uacpi_enter_sleep_state ( uacpi_sleep_state  state_enum)

Enter the given sleep state after preparation.

Definition at line 497 of file sleep.c.

498{
499 uacpi_u8 state = state_enum;
500
502
503 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_MAX))
505
506 if (uacpi_unlikely(g_uacpi_rt_ctx.last_sleep_typ_a > ACPI_SLP_TYP_MAX ||
507 g_uacpi_rt_ctx.last_sleep_typ_b > ACPI_SLP_TYP_MAX)) {
508 uacpi_error("invalid SLP_TYP values: 0x%02X:0x%02X",
509 g_uacpi_rt_ctx.last_sleep_typ_a,
510 g_uacpi_rt_ctx.last_sleep_typ_b);
512 }
513
514 return CALL_SLEEP_FN(enter_sleep_state, state);
515}
static int state
Definition: maze.c:121
#define ACPI_SLP_TYP_MAX
Definition: acpi.h:911
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:17
#define uacpi_error(...)
Definition: log.h:36
#define uacpi_unlikely(expr)
Definition: compiler.h:88
uint8_t uacpi_u8
Definition: types.h:19
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_AML_BAD_ENCODING
Definition: status.h:39
@ UACPI_INIT_LEVEL_NAMESPACE_INITIALIZED
Definition: types.h:84
#define CALL_SLEEP_FN(name, state)
Definition: sleep.c:12

Referenced by uacpi_enter_sleep_state_simple().

◆ uacpi_enter_sleep_state_simple()

uacpi_status uacpi_enter_sleep_state_simple ( uacpi_sleep_state  state)

Prepare & enter a given sleep state May be used as a shortcut if the kernel doesn't have any other work to do inbetween calling the two separate helpers

Definition at line 517 of file sleep.c.

518{
520
523 return ret;
524
526}
#define uacpi_unlikely_error(expr)
Definition: status.h:49
uacpi_status
Definition: status.h:10
return ret
Definition: mutex.c:147
uacpi_status uacpi_enter_sleep_state(enum uacpi_sleep_state state_enum)
Definition: sleep.c:497
uacpi_status uacpi_prepare_for_sleep_state(enum uacpi_sleep_state state_enum)
Definition: sleep.c:362

◆ uacpi_prepare_for_sleep_state()

uacpi_status uacpi_prepare_for_sleep_state ( uacpi_sleep_state  state_enum)

Prepare for a given sleep state.

Definition at line 362 of file sleep.c.

363{
364 uacpi_u8 state = state_enum;
366
368
369 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_S5))
371
373 state,
374 &g_uacpi_rt_ctx.last_sleep_typ_a,
375 &g_uacpi_rt_ctx.last_sleep_typ_b
376 );
377 if (ret != UACPI_STATUS_OK)
378 return ret;
379
381 0,
382 &g_uacpi_rt_ctx.s0_sleep_typ_a,
383 &g_uacpi_rt_ctx.s0_sleep_typ_b
384 );
385
386 ret = eval_pts(state);
388 return ret;
389
391 return UACPI_STATUS_OK;
392}
@ UACPI_STATUS_OK
Definition: status.h:11
static uacpi_status get_slp_type_for_state(uacpi_u8 state, uacpi_u8 *a, uacpi_u8 *b)
Definition: sleep.c:198
static uacpi_status eval_pts(uacpi_u8 state)
Definition: sleep.c:307
static uacpi_status eval_sst_for_state(enum uacpi_sleep_state state)
Definition: sleep.c:325

Referenced by uacpi_enter_sleep_state_simple().

◆ uacpi_prepare_for_wake_from_sleep_state()

uacpi_status uacpi_prepare_for_wake_from_sleep_state ( uacpi_sleep_state  state_enum)

Prepare to leave the given sleep state.

Definition at line 528 of file sleep.c.

531{
532 uacpi_u8 state = state_enum;
533
535
536 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_MAX))
538
539 return CALL_SLEEP_FN(prepare_for_wake_from_sleep_state, state);
540}

◆ uacpi_reboot()

uacpi_status uacpi_reboot ( void  )

Attempt reset via the FADT reset register.

Definition at line 556 of file sleep.c.

557{
559 uacpi_handle pci_dev = UACPI_NULL, io_handle = UACPI_NULL;
560 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
561 struct acpi_gas *reset_reg = &fadt->reset_reg;
562
563 /*
564 * Allow restarting earlier than namespace load so that the kernel can
565 * use this in case of some initialization error.
566 */
568
569 if (!(fadt->flags & ACPI_RESET_REG_SUP) || !reset_reg->address)
571
572 switch (reset_reg->address_space_id) {
574 /*
575 * For SystemIO we don't do any checking, and we ignore bit width
576 * because that's what NT does.
577 */
578 ret = uacpi_kernel_io_map(reset_reg->address, 1, &io_handle);
580 return ret;
581
582 ret = uacpi_kernel_io_write8(io_handle, 0, fadt->reset_value);
583 break;
585 ret = uacpi_write_register(UACPI_REGISTER_RESET, fadt->reset_value);
586 break;
589
590 // Bus is assumed to be 0 here
591 address.segment = 0;
592 address.bus = 0;
593 address.device = (reset_reg->address >> 32) & 0xFF;
594 address.function = (reset_reg->address >> 16) & 0xFF;
595
598 break;
599
601 pci_dev, reset_reg->address & 0xFFFF, fadt->reset_value
602 );
603 break;
604 }
605 default:
607 "unable to perform a reset: unsupported address space '%s' (%d)",
608 uacpi_address_space_to_string(reset_reg->address_space_id),
609 reset_reg->address_space_id
610 );
612 }
613
614 if (ret == UACPI_STATUS_OK) {
615 /*
616 * This should've worked but we're still here.
617 * Spin for a bit then give up.
618 */
619 uacpi_u64 stalled_time = 0;
620
621 while (stalled_time < (1000 * 1000)) {
623 stalled_time += 100;
624 }
625
626 uacpi_error("reset timeout");
628 }
629
630 if (pci_dev != UACPI_NULL)
632 if (io_handle != UACPI_NULL)
633 uacpi_kernel_io_unmap(io_handle);
634
635 return ret;
636}
#define ACPI_RESET_REG_SUP
Definition: acpi.h:718
#define uacpi_warn(...)
Definition: log.h:35
uint64_t uacpi_u64
Definition: types.h:22
#define UACPI_NULL
Definition: types.h:33
uacpi_status uacpi_write_register(uacpi_register, uacpi_u64)
Definition: registers.c:286
@ UACPI_REGISTER_RESET
Definition: registers.h:24
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
@ UACPI_STATUS_UNIMPLEMENTED
Definition: status.h:19
@ UACPI_STATUS_HARDWARE_TIMEOUT
Definition: status.h:28
const uacpi_char * uacpi_address_space_to_string(uacpi_address_space space)
Definition: types.c:11
@ UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED
Definition: types.h:72
@ UACPI_ADDRESS_SPACE_SYSTEM_MEMORY
Definition: types.h:43
@ UACPI_ADDRESS_SPACE_PCI_CONFIG
Definition: types.h:45
@ UACPI_ADDRESS_SPACE_SYSTEM_IO
Definition: types.h:44
GLuint address
Definition: glext.h:9393
uacpi_status uacpi_kernel_io_map(uacpi_io_addr base, uacpi_size len, uacpi_handle *out_handle)
Definition: uacpiosl.c:165
void uacpi_kernel_pci_device_close(uacpi_handle)
Definition: uacpiosl.c:251
uacpi_status uacpi_kernel_io_write8(uacpi_handle, uacpi_size offset, uacpi_u8 in_value)
Definition: uacpiosl.c:320
void uacpi_kernel_stall(uacpi_u8 usec)
Definition: uacpiosl.c:42
uacpi_status uacpi_kernel_pci_device_open(uacpi_pci_address address, uacpi_handle *out_handle)
Definition: uacpiosl.c:242
uacpi_status uacpi_kernel_pci_write8(uacpi_handle device, uacpi_size offset, uacpi_u8 value)
Definition: uacpiosl.c:278
void uacpi_kernel_io_unmap(uacpi_handle handle)
Definition: uacpiosl.c:171
uacpi_u16 segment
Definition: types.h:88

◆ uacpi_wake_from_sleep_state()

uacpi_status uacpi_wake_from_sleep_state ( uacpi_sleep_state  state_enum)

Wake from the given sleep state.

Definition at line 542 of file sleep.c.

545{
546 uacpi_u8 state = state_enum;
547
549
550 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_MAX))
552
553 return CALL_SLEEP_FN(wake_from_sleep_state, state);
554}

Variable Documentation

◆ uacpi_sleep_state

uacpi_sleep_state

Definition at line 32 of file sleep.h.