ReactOS 0.4.16-dev-1946-g52006dd
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_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)

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)

Definition at line 486 of file sleep.c.

487{
488 uacpi_u8 state = state_enum;
489
491
492 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_MAX))
494
495 if (uacpi_unlikely(g_uacpi_rt_ctx.last_sleep_typ_a > ACPI_SLP_TYP_MAX ||
496 g_uacpi_rt_ctx.last_sleep_typ_b > ACPI_SLP_TYP_MAX)) {
497 uacpi_error("invalid SLP_TYP values: 0x%02X:0x%02X\n",
498 g_uacpi_rt_ctx.last_sleep_typ_a,
499 g_uacpi_rt_ctx.last_sleep_typ_b);
501 }
502
503 return CALL_SLEEP_FN(enter_sleep_state, state);
504}
static int state
Definition: maze.c:121
#define ACPI_SLP_TYP_MAX
Definition: acpi.h:907
#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:21
#define uacpi_unlikely(expr)
Definition: compiler.h:58
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:78
#define CALL_SLEEP_FN(name, state)
Definition: sleep.c:12

◆ uacpi_prepare_for_sleep_state()

uacpi_status uacpi_prepare_for_sleep_state ( uacpi_sleep_state  state_enum)

Definition at line 356 of file sleep.c.

357{
358 uacpi_u8 state = state_enum;
360
362
363 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_S5))
365
367 state,
368 &g_uacpi_rt_ctx.last_sleep_typ_a,
369 &g_uacpi_rt_ctx.last_sleep_typ_b
370 );
371 if (ret != UACPI_STATUS_OK)
372 return ret;
373
375 0,
376 &g_uacpi_rt_ctx.s0_sleep_typ_a,
377 &g_uacpi_rt_ctx.s0_sleep_typ_b
378 );
379
380 ret = eval_pts(state);
382 return ret;
383
385 return UACPI_STATUS_OK;
386}
#define uacpi_unlikely_error(expr)
Definition: status.h:49
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_OK
Definition: status.h:11
return ret
Definition: mutex.c:146
static uacpi_status get_slp_type_for_state(uacpi_u8 state, uacpi_u8 *a, uacpi_u8 *b)
Definition: sleep.c:192
static uacpi_status eval_pts(uacpi_u8 state)
Definition: sleep.c:301
static uacpi_status eval_sst_for_state(enum uacpi_sleep_state state)
Definition: sleep.c:319

◆ uacpi_prepare_for_wake_from_sleep_state()

uacpi_status uacpi_prepare_for_wake_from_sleep_state ( uacpi_sleep_state  state_enum)

Definition at line 506 of file sleep.c.

509{
510 uacpi_u8 state = state_enum;
511
513
514 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_MAX))
516
517 return CALL_SLEEP_FN(prepare_for_wake_from_sleep_state, state);
518}

◆ uacpi_reboot()

uacpi_status uacpi_reboot ( void  )

Definition at line 534 of file sleep.c.

535{
537 uacpi_handle pci_dev = UACPI_NULL, io_handle = UACPI_NULL;
538 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
539 struct acpi_gas *reset_reg = &fadt->reset_reg;
540
541 /*
542 * Allow restarting earlier than namespace load so that the kernel can
543 * use this in case of some initialization error.
544 */
546
547 if (!(fadt->flags & ACPI_RESET_REG_SUP) || !reset_reg->address)
549
550 switch (reset_reg->address_space_id) {
552 /*
553 * For SystemIO we don't do any checking, and we ignore bit width
554 * because that's what NT does.
555 */
556 ret = uacpi_kernel_io_map(reset_reg->address, 1, &io_handle);
558 return ret;
559
560 ret = uacpi_kernel_io_write8(io_handle, 0, fadt->reset_value);
561 break;
563 ret = uacpi_write_register(UACPI_REGISTER_RESET, fadt->reset_value);
564 break;
566 // Bus is assumed to be 0 here
568 .segment = 0,
569 .bus = 0,
570 .device = (reset_reg->address >> 32) & 0xFF,
571 .function = (reset_reg->address >> 16) & 0xFF,
572 };
573
576 break;
577
579 pci_dev, reset_reg->address & 0xFFFF, fadt->reset_value
580 );
581 break;
582 }
583 default:
585 "unable to perform a reset: unsupported address space '%s' (%d)\n",
586 uacpi_address_space_to_string(reset_reg->address_space_id),
587 reset_reg->address_space_id
588 );
590 }
591
592 if (ret == UACPI_STATUS_OK) {
593 /*
594 * This should've worked but we're still here.
595 * Spin for a bit then give up.
596 */
597 uacpi_u64 stalled_time = 0;
598
599 while (stalled_time < (1000 * 1000)) {
601 stalled_time += 100;
602 }
603
604 uacpi_error("reset timeout\n");
606 }
607
608 if (pci_dev != UACPI_NULL)
610 if (io_handle != UACPI_NULL)
611 uacpi_kernel_io_unmap(io_handle);
612
613 return ret;
614}
#define ACPI_RESET_REG_SUP
Definition: acpi.h:714
#define uacpi_warn(...)
Definition: log.h:20
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:66
@ UACPI_ADDRESS_SPACE_SYSTEM_MEMORY
Definition: types.h:37
@ UACPI_ADDRESS_SPACE_PCI_CONFIG
Definition: types.h:39
@ UACPI_ADDRESS_SPACE_SYSTEM_IO
Definition: types.h:38
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:82

◆ uacpi_wake_from_sleep_state()

uacpi_status uacpi_wake_from_sleep_state ( uacpi_sleep_state  state_enum)

Definition at line 520 of file sleep.c.

523{
524 uacpi_u8 state = state_enum;
525
527
528 if (uacpi_unlikely(state > UACPI_SLEEP_STATE_MAX))
530
531 return CALL_SLEEP_FN(wake_from_sleep_state, state);
532}

Variable Documentation

◆ uacpi_sleep_state

uacpi_sleep_state

Definition at line 32 of file sleep.h.