ReactOS 0.4.17-dev-683-g0dafdc5
sleep.c File Reference
Include dependency graph for sleep.c:

Go to the source code of this file.

Macros

#define CALL_SLEEP_FN(name, state)
 

Functions

static uacpi_status eval_wak (uacpi_u8 state)
 
static uacpi_status eval_sst (uacpi_u8 value)
 
uacpi_status uacpi_set_waking_vector (uacpi_phys_addr addr32, uacpi_phys_addr addr64)
 
static uacpi_status enter_sleep_state_hw_full (uacpi_u8 state)
 
static uacpi_status prepare_for_wake_from_sleep_state_hw_full (uacpi_u8 state)
 
static uacpi_status wake_from_sleep_state_hw_full (uacpi_u8 state)
 
static uacpi_status get_slp_type_for_state (uacpi_u8 state, uacpi_u8 *a, uacpi_u8 *b)
 
static uacpi_status eval_sleep_helper (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_u8 value)
 
static uacpi_status eval_pts (uacpi_u8 state)
 
static uacpi_status eval_sst_for_state (enum uacpi_sleep_state state)
 
uacpi_status uacpi_prepare_for_sleep_state (enum uacpi_sleep_state state_enum)
 
static uacpi_u8 make_hw_reduced_sleep_control (uacpi_u8 slp_typ)
 
static uacpi_status enter_sleep_state_hw_reduced (uacpi_u8 state)
 
static uacpi_status prepare_for_wake_from_sleep_state_hw_reduced (uacpi_u8 state)
 
static uacpi_status wake_from_sleep_state_hw_reduced (uacpi_u8 state)
 
uacpi_status uacpi_enter_sleep_state (enum uacpi_sleep_state state_enum)
 
uacpi_status uacpi_enter_sleep_state_simple (uacpi_sleep_state state)
 
uacpi_status uacpi_prepare_for_wake_from_sleep_state (uacpi_sleep_state state_enum)
 
uacpi_status uacpi_wake_from_sleep_state (uacpi_sleep_state state_enum)
 
uacpi_status uacpi_reboot (void)
 

Macro Definition Documentation

◆ CALL_SLEEP_FN

#define CALL_SLEEP_FN (   name,
  state 
)
Value:
name##_hw_reduced(state) : name##_hw_full(state))
static int state
Definition: maze.c:121
static uacpi_bool uacpi_is_hardware_reduced(void)
Definition: context.h:100
Definition: name.c:39

Definition at line 12 of file sleep.c.

Function Documentation

◆ enter_sleep_state_hw_full()

static uacpi_status enter_sleep_state_hw_full ( uacpi_u8  state)
static

Definition at line 47 of file sleep.c.

48{
50 uacpi_interrupt_state int_state;
51 uacpi_u64 wake_status, pm1a, pm1b;
52
55 );
57 return ret;
58
61 return ret;
62
65 return ret;
66
69 return ret;
70
73 return ret;
74
76 pm1b = pm1a;
77
78 pm1a |= g_uacpi_rt_ctx.last_sleep_typ_a << ACPI_PM1_CNT_SLP_TYP_IDX;
79 pm1b |= g_uacpi_rt_ctx.last_sleep_typ_b << ACPI_PM1_CNT_SLP_TYP_IDX;
80
82
83 /*
84 * Just like ACPICA, split writing SLP_TYP and SLP_EN to work around
85 * buggy firmware that can't handle both written at the same time.
86 */
89 goto out;
90
93
94 if (state < UACPI_SLEEP_STATE_S4)
96
99 goto out;
100
101 if (state > UACPI_SLEEP_STATE_S3) {
102 /*
103 * We're still here, this is a bug or very slow firmware.
104 * Just try spinning for a bit.
105 */
106 uacpi_u64 stalled_time = 0;
107
108 // 10 seconds max
109 while (stalled_time < (10 * 1000 * 1000)) {
111 stalled_time += 100;
112 }
113
114 // Try one more time
117 goto out;
118
119 // Nothing we can do here, give up
121 goto out;
122 }
123
124 do {
126 UACPI_REGISTER_FIELD_WAK_STS, &wake_status
127 );
129 goto out;
130 } while (wake_status != 1);
131
132out:
134 return ret;
135}
#define UACPI_ARCH_FLUSH_CPU_CACHE()
Definition: arch_helpers.h:10
unsigned long uacpi_interrupt_state
Definition: arch_helpers.h:14
#define ACPI_PM1_CNT_SLP_TYP_MASK
Definition: acpi.h:916
#define ACPI_PM1_STS_CLEAR
Definition: acpi.h:878
#define ACPI_PM1_CNT_SLP_EN_MASK
Definition: acpi.h:917
#define ACPI_PM1_CNT_SLP_TYP_IDX
Definition: acpi.h:906
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:17
uint64_t uacpi_u64
Definition: types.h:22
@ UACPI_REGISTER_FIELD_WAK_STS
Definition: registers.h:65
uacpi_status uacpi_read_register_field(uacpi_register_field, uacpi_u64 *)
Definition: registers.c:487
uacpi_status uacpi_read_register(uacpi_register, uacpi_u64 *)
Definition: registers.c:227
uacpi_status uacpi_write_registers(uacpi_register, uacpi_u64, uacpi_u64)
Definition: registers.c:307
uacpi_status uacpi_write_register_field(uacpi_register_field, uacpi_u64)
Definition: registers.c:518
@ UACPI_REGISTER_PM1_CNT
Definition: registers.h:19
#define uacpi_unlikely_error(expr)
Definition: status.h:49
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_HARDWARE_TIMEOUT
Definition: status.h:28
uacpi_status uacpi_enable_all_wake_gpes(void)
Definition: event.c:1998
uacpi_status uacpi_disable_all_gpes(void)
Definition: event.c:1982
uacpi_status uacpi_clear_all_events(void)
Definition: event.c:2475
return ret
Definition: mutex.c:147
void uacpi_kernel_restore_interrupts(uacpi_interrupt_state state)
void uacpi_kernel_stall(uacpi_u8 usec)
Definition: uacpiosl.c:42
uacpi_interrupt_state uacpi_kernel_disable_interrupts(void)
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ enter_sleep_state_hw_reduced()

static uacpi_status enter_sleep_state_hw_reduced ( uacpi_u8  state)
static

Definition at line 405 of file sleep.c.

406{
408 uacpi_u8 sleep_control;
409 uacpi_u64 wake_status;
410 uacpi_interrupt_state int_state;
411 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
412
413 if (!fadt->sleep_control_reg.address || !fadt->sleep_status_reg.address)
415
417
421 );
423 goto out;
424
425 sleep_control = make_hw_reduced_sleep_control(
426 g_uacpi_rt_ctx.last_sleep_typ_a
427 );
428
429 if (state < UACPI_SLEEP_STATE_S4)
431
432 /*
433 * To put the system into a sleep state, software will write the HW-reduced
434 * Sleep Type value (obtained from the \_Sx object in the DSDT) and the
435 * SLP_EN bit to the sleep control register.
436 */
439 goto out;
440
441 /*
442 * The OSPM then polls the WAK_STS bit of the SLEEP_STATUS_REG waiting for
443 * it to be one (1), indicating that the system has been transitioned
444 * back to the Working state.
445 */
446 do {
449 );
451 goto out;
452 } while (wake_status != 1);
453
454out:
456 return ret;
457}
#define ACPI_SLP_STS_CLEAR
Definition: acpi.h:970
uint8_t uacpi_u8
Definition: types.h:19
@ UACPI_REGISTER_FIELD_HWR_WAK_STS
Definition: registers.h:64
uacpi_status uacpi_write_register(uacpi_register, uacpi_u64)
Definition: registers.c:286
@ UACPI_REGISTER_SLP_CNT
Definition: registers.h:22
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
static uacpi_u8 make_hw_reduced_sleep_control(uacpi_u8 slp_typ)
Definition: sleep.c:394

◆ eval_pts()

static uacpi_status eval_pts ( uacpi_u8  state)
static

Definition at line 307 of file sleep.c.

308{
310}
uacpi_namespace_node * uacpi_namespace_root(void)
Definition: namespace.c:264
static uacpi_status eval_sleep_helper(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_u8 value)
Definition: sleep.c:274

Referenced by uacpi_prepare_for_sleep_state().

◆ eval_sleep_helper()

static uacpi_status eval_sleep_helper ( uacpi_namespace_node parent,
const uacpi_char path,
uacpi_u8  value 
)
static

Definition at line 274 of file sleep.c.

277{
281
285
286 arg->integer = value;
287 args.objects = &arg;
288 args.count = 1;
289
291 switch (ret) {
292 case UACPI_STATUS_OK:
293 break;
296 break;
297 default:
298 uacpi_error("error while evaluating %s: %s",
300 break;
301 }
302
304 return ret;
305}
#define uacpi_error(...)
Definition: log.h:36
uacpi_object * uacpi_create_object(uacpi_object_type type)
Definition: types.c:327
#define uacpi_unlikely(expr)
Definition: compiler.h:88
#define UACPI_NULL
Definition: types.h:33
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
@ UACPI_STATUS_OK
Definition: status.h:11
const uacpi_char * uacpi_status_to_string(uacpi_status)
Definition: uacpi.c:60
@ UACPI_OBJECT_INTEGER
Definition: types.h:112
void uacpi_object_unref(uacpi_object *obj)
Definition: types.c:762
r parent
Definition: btrfs.c:3010
#define args
Definition: format.c:66
Definition: match.c:390
uacpi_status uacpi_eval(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
Definition: uacpi.c:709
Definition: pdh_main.c:96
void * arg
Definition: msvc.h:10

Referenced by eval_pts(), eval_sst(), and eval_wak().

◆ eval_sst()

static uacpi_status eval_sst ( uacpi_u8  value)
static

Definition at line 317 of file sleep.c.

318{
319 return eval_sleep_helper(
321 "_SST", value
322 );
323}
uacpi_namespace_node * uacpi_namespace_get_predefined(uacpi_predefined_namespace)
Definition: namespace.c:269
@ UACPI_PREDEFINED_NAMESPACE_SI
Definition: namespace.h:21

Referenced by eval_sst_for_state(), wake_from_sleep_state_hw_full(), and wake_from_sleep_state_hw_reduced().

◆ eval_sst_for_state()

static uacpi_status eval_sst_for_state ( enum uacpi_sleep_state  state)
static

Definition at line 325 of file sleep.c.

326{
328
329 /*
330 * This optional object is a control method that OSPM invokes to set the
331 * system status indicator as desired.
332 * Arguments:(1)
333 * Arg0 - An Integer containing the system status indicator identifier:
334 * 0 - No system state indication. Indicator off
335 * 1 - Working
336 * 2 - Waking
337 * 3 - Sleeping. Used to indicate system state S1, S2, or S3
338 * 4 - Sleeping with context saved to non-volatile storage
339 */
340 switch (state) {
341 case UACPI_SLEEP_STATE_S0:
342 arg = 1;
343 break;
344 case UACPI_SLEEP_STATE_S1:
345 case UACPI_SLEEP_STATE_S2:
346 case UACPI_SLEEP_STATE_S3:
347 arg = 3;
348 break;
349 case UACPI_SLEEP_STATE_S4:
350 arg = 4;
351 break;
352 case UACPI_SLEEP_STATE_S5:
353 arg = 0;
354 break;
355 default:
357 }
358
359 return eval_sst(arg);
360}
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
static uacpi_status eval_sst(uacpi_u8 value)
Definition: sleep.c:317

Referenced by uacpi_prepare_for_sleep_state().

◆ eval_wak()

static uacpi_status eval_wak ( uacpi_u8  state)
static

Definition at line 312 of file sleep.c.

313{
315}

Referenced by wake_from_sleep_state_hw_full(), and wake_from_sleep_state_hw_reduced().

◆ get_slp_type_for_state()

static uacpi_status get_slp_type_for_state ( uacpi_u8  state,
uacpi_u8 a,
uacpi_u8 b 
)
static

Definition at line 198 of file sleep.c.

201{
202 uacpi_char path[] = "_S0";
204 uacpi_object *obj0, *obj1, *ret_obj = UACPI_NULL;
205
206 path[2] += state;
207
211 );
212 if (ret != UACPI_STATUS_OK) {
214 uacpi_warn("error while evaluating %s: %s", path,
216 } else {
217 uacpi_trace("sleep state %d is not supported as %s was not found",
218 state, path);
219 }
220 goto out;
221 }
222
223 switch (ret_obj->package->count) {
224 case 0:
225 uacpi_error("empty package while evaluating %s!", path);
227 goto out;
228
229 case 1:
230 obj0 = ret_obj->package->objects[0];
233 "invalid object type at pkg[0] => %s when evaluating %s",
235 );
236 goto out;
237 }
238
239 *a = obj0->integer;
240 *b = obj0->integer >> 8;
241 break;
242
243 default:
244 obj0 = ret_obj->package->objects[0];
245 obj1 = ret_obj->package->objects[1];
246
248 obj1->type != UACPI_OBJECT_INTEGER)) {
250 "invalid object type when evaluating %s: "
251 "pkg[0] => %s, pkg[1] => %s", path,
254 );
256 goto out;
257 }
258
259 *a = obj0->integer;
260 *b = obj1->integer;
261 break;
262 }
263
264out:
265 if (ret != UACPI_STATUS_OK) {
268 }
269
270 uacpi_object_unref(ret_obj);
271 return ret;
272}
#define UACPI_SLEEP_TYP_INVALID
Definition: context.h:34
#define uacpi_trace(...)
Definition: log.h:33
#define uacpi_warn(...)
Definition: log.h:35
char uacpi_char
Definition: types.h:44
@ UACPI_STATUS_AML_INCOMPATIBLE_OBJECT_TYPE
Definition: status.h:38
@ UACPI_OBJECT_PACKAGE_BIT
Definition: types.h:138
const uacpi_char * uacpi_object_type_to_string(uacpi_object_type)
Definition: types.c:51
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
uacpi_u8 type
Definition: types.h:249
uacpi_package * package
Definition: types.h:254
uacpi_u64 integer
Definition: types.h:253
uacpi_object ** objects
Definition: types.h:36
uacpi_size count
Definition: types.h:37
uacpi_status uacpi_eval_typed(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object_type_bits ret_mask, uacpi_object **ret)
Definition: uacpi.c:854

Referenced by uacpi_prepare_for_sleep_state().

◆ make_hw_reduced_sleep_control()

static uacpi_u8 make_hw_reduced_sleep_control ( uacpi_u8  slp_typ)
static

Definition at line 394 of file sleep.c.

395{
397
398 value = (slp_typ << ACPI_SLP_CNT_SLP_TYP_IDX);
401
402 return value;
403}
#define ACPI_SLP_CNT_SLP_EN_MASK
Definition: acpi.h:953
#define ACPI_SLP_CNT_SLP_TYP_IDX
Definition: acpi.h:947
#define ACPI_SLP_CNT_SLP_TYP_MASK
Definition: acpi.h:952

Referenced by enter_sleep_state_hw_reduced(), and prepare_for_wake_from_sleep_state_hw_reduced().

◆ prepare_for_wake_from_sleep_state_hw_full()

static uacpi_status prepare_for_wake_from_sleep_state_hw_full ( uacpi_u8  state)
static

Definition at line 137 of file sleep.c.

138{
140 uacpi_u64 pm1a, pm1b;
142
143 /*
144 * Some hardware apparently relies on S0 values being written to the PM1
145 * control register on wake, so do this here.
146 */
147
148 if (g_uacpi_rt_ctx.s0_sleep_typ_a == UACPI_SLEEP_TYP_INVALID)
149 goto out;
150
153 goto out;
154
156 pm1b = pm1a;
157
158 pm1a |= g_uacpi_rt_ctx.s0_sleep_typ_a << ACPI_PM1_CNT_SLP_TYP_IDX;
159 pm1b |= g_uacpi_rt_ctx.s0_sleep_typ_b << ACPI_PM1_CNT_SLP_TYP_IDX;
160
162out:
163 // Errors ignored intentionally, we don't want to abort because of this
164 return UACPI_STATUS_OK;
165}
#define UACPI_UNUSED(x)
Definition: helpers.h:7

◆ prepare_for_wake_from_sleep_state_hw_reduced()

static uacpi_status prepare_for_wake_from_sleep_state_hw_reduced ( uacpi_u8  state)
static

Definition at line 459 of file sleep.c.

460{
461 uacpi_u8 sleep_control;
463
464 if (g_uacpi_rt_ctx.s0_sleep_typ_a == UACPI_SLEEP_TYP_INVALID)
465 goto out;
466
467 sleep_control = make_hw_reduced_sleep_control(
468 g_uacpi_rt_ctx.s0_sleep_typ_a
469 );
471
472out:
473 return UACPI_STATUS_OK;
474}

◆ 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}
#define ACPI_SLP_TYP_MAX
Definition: acpi.h:911
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
@ 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}
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}
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
@ UACPI_REGISTER_RESET
Definition: registers.h:24
@ UACPI_STATUS_UNIMPLEMENTED
Definition: status.h:19
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
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_set_waking_vector()

uacpi_status uacpi_set_waking_vector ( uacpi_phys_addr  addr32,
uacpi_phys_addr  addr64 
)

Definition at line 23 of file sleep.c.

26{
27 struct acpi_facs *facs = g_uacpi_rt_ctx.facs;
28
29 if (facs == UACPI_NULL)
30 return UACPI_STATUS_OK;
31
32 facs->firmware_waking_vector = addr32;
33
34 // The 64-bit wake vector doesn't exist, we're done
35 if (facs->length < 32)
36 return UACPI_STATUS_OK;
37
38 // Only allow 64-bit wake vector on 1.0 and above FACS
39 if (facs->version >= 1)
40 facs->x_firmware_waking_vector = addr64;
41 else
43
44 return UACPI_STATUS_OK;
45}
uacpi_u32 length
Definition: acpi.h:804
uacpi_u64 x_firmware_waking_vector
Definition: acpi.h:809
uacpi_u8 version
Definition: acpi.h:810
uacpi_u32 firmware_waking_vector
Definition: acpi.h:806

◆ 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}

◆ wake_from_sleep_state_hw_full()

static uacpi_status wake_from_sleep_state_hw_full ( uacpi_u8  state)
static

Definition at line 167 of file sleep.c.

168{
170 g_uacpi_rt_ctx.last_sleep_typ_a = UACPI_SLEEP_TYP_INVALID;
171 g_uacpi_rt_ctx.last_sleep_typ_b = UACPI_SLEEP_TYP_INVALID;
172
173 // Set the status to 2 (waking) while we execute the wake method.
174 eval_sst(2);
175
178 return ret;
179
182 return ret;
183
185
186 // Apparently some BIOSes expect us to clear this, so do it
189 );
190
191 // Now that we're awake set the status to 1 (running)
192 eval_sst(1);
193
194 return UACPI_STATUS_OK;
195}
uacpi_status uacpi_enable_all_runtime_gpes(void)
Definition: event.c:1990
static uacpi_status eval_wak(uacpi_u8 state)
Definition: sleep.c:312

◆ wake_from_sleep_state_hw_reduced()

static uacpi_status wake_from_sleep_state_hw_reduced ( uacpi_u8  state)
static

Definition at line 476 of file sleep.c.

477{
478 g_uacpi_rt_ctx.last_sleep_typ_a = UACPI_SLEEP_TYP_INVALID;
479 g_uacpi_rt_ctx.last_sleep_typ_b = UACPI_SLEEP_TYP_INVALID;
480
481 // Set the status to 2 (waking) while we execute the wake method.
482 eval_sst(2);
483
485
486 // Apparently some BIOSes expect us to clear this, so do it
489 );
490
491 // Now that we're awake set the status to 1 (running)
492 eval_sst(1);
493
494 return UACPI_STATUS_OK;
495}