ReactOS 0.4.17-dev-1190-g4c812f4
uacpi.c File Reference
Include dependency graph for uacpi.c:

Go to the source code of this file.

Classes

struct  table_load_stats
 
struct  ns_init_context
 

Macros

#define TRACE_BAD_RET(path_fmt, type, ...)
 
#define TRACE_NO_RET(path_fmt, ...)
 

Enumerations

enum  hw_mode { HW_MODE_ACPI = 0 , HW_MODE_LEGACY = 1 }
 

Functions

uacpi_status uacpi_is_platform_reduced_hardware (uacpi_bool *out_value)
 
void uacpi_context_set_log_level (uacpi_log_level lvl)
 
void uacpi_logger_initialize (void)
 
void uacpi_context_set_proactive_table_checksum (uacpi_bool setting)
 
const uacpi_char * uacpi_status_to_string (uacpi_status st)
 
void uacpi_state_reset (void)
 
void uacpi_context_set_loop_timeout (uacpi_u32 seconds)
 
void uacpi_context_set_max_call_stack_depth (uacpi_u32 depth)
 
uacpi_u32 uacpi_context_get_loop_timeout (void)
 
static enum hw_mode read_mode (void)
 
static uacpi_status set_mode (enum hw_mode mode)
 
static uacpi_status enter_mode (enum hw_mode mode, uacpi_bool *did_change)
 
uacpi_status uacpi_enter_acpi_mode (void)
 
uacpi_status uacpi_leave_acpi_mode (void)
 
static void enter_acpi_mode_initial (void)
 
uacpi_init_level uacpi_get_current_init_level (void)
 
uacpi_status uacpi_initialize (uacpi_u64 flags)
 
static void trace_table_load_failure (struct acpi_sdt_hdr *tbl, uacpi_log_level lvl, uacpi_status ret)
 
static uacpi_bool match_ssdt_or_psdt (struct uacpi_installed_table *tbl)
 
static uacpi_u64 elapsed_ms (uacpi_u64 begin_ns, uacpi_u64 end_ns)
 
static uacpi_bool warn_on_bad_timesource (uacpi_u64 begin_ts, uacpi_u64 end_ts)
 
uacpi_status uacpi_namespace_load (void)
 
static void ini_eval (struct ns_init_context *ctx, uacpi_namespace_node *node)
 
static uacpi_status sta_eval (struct ns_init_context *ctx, uacpi_namespace_node *node, uacpi_u32 *value)
 
static uacpi_iteration_decision do_sta_ini (void *opaque, uacpi_namespace_node *node, uacpi_u32 depth)
 
uacpi_status uacpi_namespace_initialize (void)
 
uacpi_status uacpi_eval (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **out_obj)
 
uacpi_status uacpi_eval_simple (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
 
uacpi_status uacpi_execute (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args)
 
uacpi_status uacpi_execute_simple (uacpi_namespace_node *parent, const uacpi_char *path)
 
static void trace_invalid_return_type (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object_type_bits expected_mask, uacpi_object_type actual_type)
 
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 **out_obj)
 
uacpi_status uacpi_eval_simple_typed (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object_type_bits ret_mask, uacpi_object **ret)
 
uacpi_status uacpi_eval_integer (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_u64 *out_value)
 
uacpi_status uacpi_eval_simple_integer (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_u64 *out_value)
 
uacpi_status uacpi_eval_string_or_buffer (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
 
uacpi_status uacpi_eval_simple_string_or_buffer (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
 
uacpi_status uacpi_eval_string (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
 
uacpi_status uacpi_eval_simple_string (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
 
uacpi_status uacpi_eval_buffer (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
 
uacpi_status uacpi_eval_simple_buffer (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
 
uacpi_status uacpi_eval_package (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
 
uacpi_status uacpi_eval_simple_package (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
 
uacpi_status uacpi_get_aml_bitness (uacpi_u8 *out_bitness)
 

Variables

struct uacpi_runtime_context g_uacpi_rt_ctx = { 0 }
 

Macro Definition Documentation

◆ TRACE_BAD_RET

#define TRACE_BAD_RET (   path_fmt,
  type,
  ... 
)
Value:
"unexpected '%s' object returned by method "path_fmt \
", expected type mask: %08X", uacpi_object_type_to_string(type), \
__VA_ARGS__ \
)
#define uacpi_warn(...)
Definition: log.h:35
const uacpi_char * uacpi_object_type_to_string(uacpi_object_type)
Definition: types.c:52
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Definition at line 821 of file uacpi.c.

◆ TRACE_NO_RET

#define TRACE_NO_RET (   path_fmt,
  ... 
)
Value:
"no value returned from method "path_fmt", expected type mask: " \
"%08X", __VA_ARGS__ \
)

Definition at line 828 of file uacpi.c.

Enumeration Type Documentation

◆ hw_mode

Enumerator
HW_MODE_ACPI 
HW_MODE_LEGACY 

Definition at line 206 of file uacpi.c.

206 {
207 HW_MODE_ACPI = 0,
208 HW_MODE_LEGACY = 1,
209};
@ HW_MODE_LEGACY
Definition: uacpi.c:208
@ HW_MODE_ACPI
Definition: uacpi.c:207

Function Documentation

◆ do_sta_ini()

static uacpi_iteration_decision do_sta_ini ( void *  opaque,
uacpi_namespace_node *  node,
uacpi_u32  depth 
)
static

Definition at line 578 of file uacpi.c.

581{
582 struct ns_init_context *ctx = opaque;
585 uacpi_u32 sta_ret;
586
588
589 // We don't care about aliases
592
594 switch (type) {
597 ctx->devices++;
598 break;
600 ctx->thermal_zones++;
601 break;
602 default:
605 }
606
607 ret = sta_eval(ctx, node, &sta_ret);
610
611 if (!(sta_ret & ACPI_STA_RESULT_DEVICE_PRESENT)) {
612 if (!(sta_ret & ACPI_STA_RESULT_DEVICE_FUNCTIONING))
614
615 /*
616 * ACPI 6.5 specification:
617 * _STA may return bit 0 clear (not present) with bit [3] set (device
618 * is functional). This case is used to indicate a valid device for
619 * which no device driver should be loaded (for example, a bridge
620 * device.) Children of this device may be present and valid. OSPM
621 * should continue enumeration below a device whose _STA returns this
622 * bit combination.
623 */
625 }
626
627 ini_eval(ctx, node);
628
630}
#define ACPI_STA_RESULT_DEVICE_PRESENT
Definition: acpi.h:992
#define ACPI_STA_RESULT_DEVICE_FUNCTIONING
Definition: acpi.h:995
#define UACPI_UNUSED(x)
Definition: helpers.h:7
uacpi_bool uacpi_namespace_node_is_alias(uacpi_namespace_node *node)
Definition: namespace.c:335
uacpi_namespace_node * uacpi_namespace_get_predefined(uacpi_predefined_namespace)
Definition: namespace.c:269
uacpi_status uacpi_namespace_node_type(const uacpi_namespace_node *node, uacpi_object_type *out_type)
Definition: namespace.c:781
@ UACPI_PREDEFINED_NAMESPACE_TZ
Definition: namespace.h:22
uint32_t uacpi_u32
Definition: types.h:21
#define uacpi_unlikely_error(expr)
Definition: status.h:50
uacpi_status
Definition: status.h:10
@ UACPI_ITERATION_DECISION_NEXT_PEER
Definition: types.h:39
@ UACPI_ITERATION_DECISION_CONTINUE
Definition: types.h:29
uacpi_object_type
Definition: types.h:110
@ UACPI_OBJECT_PROCESSOR
Definition: types.h:123
@ UACPI_OBJECT_DEVICE
Definition: types.h:117
@ UACPI_OBJECT_UNINITIALIZED
Definition: types.h:111
@ UACPI_OBJECT_THERMAL_ZONE
Definition: types.h:124
return ret
Definition: mutex.c:147
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
static void ini_eval(struct ns_init_context *ctx, uacpi_namespace_node *node)
Definition: uacpi.c:547
static uacpi_status sta_eval(struct ns_init_context *ctx, uacpi_namespace_node *node, uacpi_u32 *value)
Definition: uacpi.c:560
Definition: dlist.c:348

Referenced by uacpi_namespace_initialize().

◆ elapsed_ms()

static uacpi_u64 elapsed_ms ( uacpi_u64  begin_ns,
uacpi_u64  end_ns 
)
static

Definition at line 418 of file uacpi.c.

419{
420 return (end_ns - begin_ns) / (1000ull * 1000ull);
421}

Referenced by taskdialog_callback_proc_timer(), uacpi_namespace_initialize(), and uacpi_namespace_load().

◆ enter_acpi_mode_initial()

static void enter_acpi_mode_initial ( void  )
static

Definition at line 314 of file uacpi.c.

315{
316 enter_mode(HW_MODE_ACPI, &g_uacpi_rt_ctx.was_in_legacy_mode);
317}
static uacpi_status enter_mode(enum hw_mode mode, uacpi_bool *did_change)
Definition: uacpi.c:271
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:18

Referenced by uacpi_initialize().

◆ enter_mode()

static uacpi_status enter_mode ( enum hw_mode  mode,
uacpi_bool *  did_change 
)
static

Definition at line 271 of file uacpi.c.

272{
274 const uacpi_char *mode_str;
275
277
279 return UACPI_STATUS_OK;
280
281 mode_str = mode == HW_MODE_LEGACY ? "legacy" : "acpi";
282
283 if (read_mode() == mode) {
284 uacpi_trace("%s mode already enabled", mode_str);
285 return UACPI_STATUS_OK;
286 }
287
288 ret = set_mode(mode);
291 "unable to enter %s mode: %s",
292 mode_str, uacpi_status_to_string(ret)
293 );
294 return ret;
295 }
296
297 uacpi_trace("entered %s mode", mode_str);
298 if (did_change != UACPI_NULL)
300
301 return ret;
302}
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
static uacpi_bool uacpi_is_hardware_reduced(void)
Definition: context.h:100
#define uacpi_trace(...)
Definition: log.h:33
char uacpi_char
Definition: types.h:44
#define UACPI_NULL
Definition: types.h:33
#define UACPI_TRUE
Definition: types.h:29
@ UACPI_STATUS_OK
Definition: status.h:11
@ UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED
Definition: types.h:72
GLenum mode
Definition: glext.h:6217
static int did_change
Definition: io.c:51
static enum hw_mode read_mode(void)
Definition: uacpi.c:211
static uacpi_status set_mode(enum hw_mode mode)
Definition: uacpi.c:227
const uacpi_char * uacpi_status_to_string(uacpi_status st)
Definition: uacpi.c:61

Referenced by enter_acpi_mode_initial(), uacpi_enter_acpi_mode(), and uacpi_leave_acpi_mode().

◆ ini_eval()

static void ini_eval ( struct ns_init_context *  ctx,
uacpi_namespace_node *  node 
)
static

Definition at line 547 of file uacpi.c.

548{
550
553 return;
554
555 ctx->ini_executed++;
557 ctx->ini_errors++;
558}
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
uacpi_status uacpi_eval(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **out_obj)
Definition: uacpi.c:721

Referenced by do_sta_ini(), and uacpi_namespace_initialize().

◆ match_ssdt_or_psdt()

static uacpi_bool match_ssdt_or_psdt ( struct uacpi_installed_table *  tbl)
static

Definition at line 409 of file uacpi.c.

410{
411 if (tbl->flags & UACPI_TABLE_LOADED)
412 return UACPI_FALSE;
413
414 return uacpi_signatures_match(tbl->hdr.signature, ACPI_SSDT_SIGNATURE) ||
416}
#define ACPI_PSDT_SIGNATURE
Definition: acpi.h:25
#define ACPI_SSDT_SIGNATURE
Definition: acpi.h:24
#define UACPI_FALSE
Definition: types.h:30
uacpi_bool uacpi_signatures_match(const void *const lhs, const void *const rhs)
Definition: tables.c:464
uacpi_u8 flags
Definition: tables.h:16
struct acpi_sdt_hdr hdr
Definition: tables.h:11
#define UACPI_TABLE_LOADED
Definition: tables.h:243

Referenced by uacpi_namespace_load().

◆ read_mode()

static enum hw_mode read_mode ( void  )
static

Definition at line 211 of file uacpi.c.

212{
214 uacpi_u64 raw_value;
215 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
216
217 if (!fadt->smi_cmd)
218 return HW_MODE_ACPI;
219
222 return HW_MODE_LEGACY;
223
224 return raw_value ? HW_MODE_ACPI : HW_MODE_LEGACY;
225}
uint64_t uacpi_u64
Definition: types.h:22
@ UACPI_REGISTER_FIELD_SCI_EN
Definition: registers.h:72
uacpi_status uacpi_read_register_field(uacpi_register_field, uacpi_u64 *)
Definition: registers.c:487

Referenced by enter_mode(), and set_mode().

◆ set_mode()

static uacpi_status set_mode ( enum hw_mode  mode)
static

Definition at line 227 of file uacpi.c.

228{
230 uacpi_u64 raw_value, stalled_time = 0;
231 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
232
233 if (uacpi_unlikely(!fadt->smi_cmd)) {
234 uacpi_error("SMI_CMD is not implemented by the firmware");
236 }
237
238 if (uacpi_unlikely(!fadt->acpi_enable && !fadt->acpi_disable)) {
239 uacpi_error("mode transition is not implemented by the hardware");
241 }
242
243 switch (mode) {
244 case HW_MODE_ACPI:
245 raw_value = fadt->acpi_enable;
246 break;
247 case HW_MODE_LEGACY:
248 raw_value = fadt->acpi_disable;
249 break;
250 default:
252 }
253
256 return ret;
257
258 // Allow up to 5 seconds for the hardware to enter the desired mode
259 while (stalled_time < (5 * 1000 * 1000)) {
260 if (read_mode() == mode)
261 return UACPI_STATUS_OK;
262
264 stalled_time += 100;
265 }
266
267 uacpi_error("hardware time out while changing modes");
269}
#define uacpi_error(...)
Definition: log.h:36
#define uacpi_unlikely(expr)
Definition: compiler.h:88
uacpi_status uacpi_write_register(uacpi_register, uacpi_u64)
Definition: registers.c:286
@ UACPI_REGISTER_SMI_CMD
Definition: registers.h:25
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_HARDWARE_TIMEOUT
Definition: status.h:28
void uacpi_kernel_stall(uacpi_u8 usec)
Definition: uacpiosl.c:42

Referenced by enter_mode(), and FT_Set_Renderer().

◆ sta_eval()

static uacpi_status sta_eval ( struct ns_init_context *  ctx,
uacpi_namespace_node *  node,
uacpi_u32 *  value 
)
static

Definition at line 560 of file uacpi.c.

564{
566
568 if (*value == 0xFFFFFFFF)
569 return ret;
570
571 ctx->sta_executed++;
573 ctx->sta_errors++;
574
575 return ret;
576}
Definition: pdh_main.c:64
uacpi_status uacpi_eval_sta(uacpi_namespace_node *, uacpi_u32 *flags)
Definition: utilities.c:577

Referenced by do_sta_ini().

◆ trace_invalid_return_type()

static void trace_invalid_return_type ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object_type_bits  expected_mask,
uacpi_object_type  actual_type 
)
static

Definition at line 834 of file uacpi.c.

838{
839 const uacpi_char *abs_path;
840 uacpi_bool dynamic_abs_path = UACPI_FALSE;
841
842 if (parent == UACPI_NULL || (path != UACPI_NULL && path[0] == '\\')) {
843 abs_path = path;
844 } else {
846 dynamic_abs_path = UACPI_TRUE;
847 }
848
849 if (dynamic_abs_path && path != UACPI_NULL) {
850 if (actual_type == UACPI_OBJECT_UNINITIALIZED)
851 TRACE_NO_RET("%s.%s", abs_path, path, expected_mask);
852 else
853 TRACE_BAD_RET("%s.%s", actual_type, abs_path, path, expected_mask);
854 } else {
855 if (actual_type == UACPI_OBJECT_UNINITIALIZED) {
856 TRACE_NO_RET("%s", abs_path, expected_mask);
857 } else {
858 TRACE_BAD_RET("%s", actual_type, abs_path, expected_mask);
859 }
860 }
861
862 if (dynamic_abs_path)
864}
const uacpi_char * uacpi_namespace_node_generate_absolute_path(const uacpi_namespace_node *node)
Definition: namespace.c:1053
bool uacpi_bool
Definition: types.h:31
r parent
Definition: btrfs.c:3010
void uacpi_free_dynamic_string(const uacpi_char *str)
Definition: utilities.c:1148
#define TRACE_BAD_RET(path_fmt, type,...)
Definition: uacpi.c:821
#define TRACE_NO_RET(path_fmt,...)
Definition: uacpi.c:828

Referenced by uacpi_eval_typed().

◆ trace_table_load_failure()

static void trace_table_load_failure ( struct acpi_sdt_hdr *  tbl,
uacpi_log_level  lvl,
uacpi_status  ret 
)
static

Definition at line 398 of file uacpi.c.

401{
403 lvl,
404 "failed to load "UACPI_PRI_TBL_HDR": %s",
406 );
407}
#define uacpi_log_lvl(lvl, fmt,...)
Definition: log.h:22
#define UACPI_PRI_TBL_HDR
Definition: tables.h:58
#define UACPI_FMT_TBL_HDR(hdr)
Definition: tables.h:59

Referenced by uacpi_namespace_load().

◆ uacpi_context_get_loop_timeout()

uacpi_u32 uacpi_context_get_loop_timeout ( void  )

Definition at line 200 of file uacpi.c.

201{
202 return g_uacpi_rt_ctx.loop_timeout_seconds;
203}

◆ uacpi_context_set_log_level()

void uacpi_context_set_log_level ( uacpi_log_level  lvl)

Set the minimum log level to be accepted by the logging facilities. Any logs below this level are discarded and not passed to uacpi_kernel_log, etc.

0 is treated as a special value that resets the setting to the default value.

E.g. for a log level of UACPI_LOG_INFO: UACPI_LOG_DEBUG -> discarded UACPI_LOG_TRACE -> discarded UACPI_LOG_INFO -> allowed UACPI_LOG_WARN -> allowed UACPI_LOG_ERROR -> allowed

Definition at line 29 of file uacpi.c.

30{
31 if (lvl == 0)
33
34 g_uacpi_rt_ctx.log_level = lvl;
35}
#define UACPI_DEFAULT_LOG_LEVEL
Definition: config.h:29

Referenced by uacpi_logger_initialize().

◆ uacpi_context_set_loop_timeout()

void uacpi_context_set_loop_timeout ( uacpi_u32  seconds)

Set the maximum number of seconds a While loop is allowed to run for before getting timed out.

0 is treated a special value that resets the setting to the default value.

Definition at line 184 of file uacpi.c.

185{
186 if (seconds == 0)
188
189 g_uacpi_rt_ctx.loop_timeout_seconds = seconds;
190}
#define UACPI_DEFAULT_LOOP_TIMEOUT_SECONDS
Definition: config.h:39

Referenced by uacpi_initialize().

◆ uacpi_context_set_max_call_stack_depth()

void uacpi_context_set_max_call_stack_depth ( uacpi_u32  depth)

Set the maximum call stack depth AML can reach before getting aborted.

0 is treated as a special value that resets the setting to the default value.

Definition at line 192 of file uacpi.c.

193{
194 if (depth == 0)
196
197 g_uacpi_rt_ctx.max_call_stack_depth = depth;
198}
#define UACPI_DEFAULT_MAX_CALL_STACK_DEPTH
Definition: config.h:48

Referenced by uacpi_initialize().

◆ uacpi_context_set_proactive_table_checksum()

void uacpi_context_set_proactive_table_checksum ( uacpi_bool  setting)

Enables table checksum validation at installation time instead of first use. Note that this makes uACPI map the entire table at once, which not all hosts are able to handle at early init.

Definition at line 53 of file uacpi.c.

54{
55 if (setting)
57 else
58 g_uacpi_rt_ctx.flags &= ~UACPI_FLAG_PROACTIVE_TBL_CSUM;
59}
#define UACPI_FLAG_PROACTIVE_TBL_CSUM
Definition: uacpi.h:107

◆ uacpi_enter_acpi_mode()

uacpi_status uacpi_enter_acpi_mode ( void  )

Definition at line 304 of file uacpi.c.

305{
307}

◆ uacpi_eval()

uacpi_status uacpi_eval ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args,
uacpi_object **  ret 
)

Evaluate an object within the namespace and get back its value. Either root or path must be valid. A value of NULL for 'parent' implies uacpi_namespace_root() relative lookups, unless 'path' is already absolute.

Definition at line 721 of file uacpi.c.

725{
730
732 return ret;
733
736 return ret;
737
738 if (path != UACPI_NULL) {
742 &node
743 );
745 goto out_read_unlock;
746 } else {
747 node = parent;
748 }
749
751 if (uacpi_unlikely(obj == UACPI_NULL)) {
753 goto out_read_unlock;
754 }
755
756 if (obj->type != UACPI_OBJECT_METHOD) {
757 uacpi_object *new_obj;
758
759 if (uacpi_unlikely(out_obj == UACPI_NULL))
760 goto out_read_unlock;
761
763 if (uacpi_unlikely(new_obj == UACPI_NULL)) {
765 goto out_read_unlock;
766 }
767
770 );
772 uacpi_object_unref(new_obj);
773 goto out_read_unlock;
774 }
775 *out_obj = new_obj;
776
777 out_read_unlock:
779 return ret;
780 }
781
782 method = obj->method;
785
786 // Upgrade to a write-lock since we're about to run a method
789 goto out_no_write_lock;
790
793
794out_no_write_lock:
796 return ret;
797}
method
Definition: dragdrop.c:54
uacpi_status uacpi_namespace_write_unlock(void)
Definition: namespace.c:51
@ UACPI_PERMANENT_ONLY_YES
Definition: namespace.h:94
uacpi_status uacpi_namespace_read_unlock(void)
Definition: namespace.c:41
uacpi_object * uacpi_namespace_node_get_object(const uacpi_namespace_node *node)
Definition: namespace.c:653
uacpi_status uacpi_namespace_read_lock(void)
Definition: namespace.c:36
@ UACPI_SHOULD_LOCK_NO
Definition: namespace.h:98
uacpi_status uacpi_namespace_write_lock(void)
Definition: namespace.c:46
@ UACPI_MAY_SEARCH_ABOVE_PARENT_NO
Definition: namespace.h:88
uacpi_status uacpi_namespace_node_resolve(uacpi_namespace_node *scope, const uacpi_char *path, enum uacpi_should_lock, enum uacpi_may_search_above_parent, enum uacpi_permanent_only, uacpi_namespace_node **out_node)
Definition: namespace.c:498
uacpi_object * uacpi_create_object(uacpi_object_type type)
Definition: types.c:328
uacpi_status uacpi_object_assign(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior)
Definition: types.c:1371
void uacpi_method_unref(uacpi_control_method *)
Definition: types.c:650
@ UACPI_ASSIGN_BEHAVIOR_DEEP_COPY
Definition: types.h:286
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
@ UACPI_OBJECT_METHOD
Definition: types.h:119
void uacpi_object_unref(uacpi_object *obj)
Definition: types.c:761
uacpi_status uacpi_execute_control_method(uacpi_namespace_node *scope, uacpi_control_method *method, const uacpi_object_array *args, uacpi_object **ret)
Definition: interpreter.c:6479
static uacpi_u32 uacpi_shareable_ref(uacpi_handle handle)
Definition: shareable.h:40
Definition: match.c:390

Referenced by eval_sleep_helper(), ini_eval(), uacpi_eval_simple(), uacpi_eval_typed(), uacpi_execute(), uacpi_execute_simple(), uacpi_set_interrupt_model(), and uacpi_set_resources().

◆ uacpi_eval_buffer()

uacpi_status uacpi_eval_buffer ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args,
uacpi_object **  ret 
)

A shorthand for uacpi_eval_typed with UACPI_OBJECT_BUFFER_BIT.

Use uacpi_object_get_buffer to retrieve the resulting buffer data.

Definition at line 973 of file uacpi.c.

977{
978 return uacpi_eval_typed(
980 );
981}
@ UACPI_OBJECT_BUFFER_BIT
Definition: types.h:137
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 **out_obj)
Definition: uacpi.c:866

◆ uacpi_eval_integer()

uacpi_status uacpi_eval_integer ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args,
uacpi_u64 *  out_value 
)

A shorthand for uacpi_eval_typed with UACPI_OBJECT_INTEGER_BIT.

Definition at line 904 of file uacpi.c.

908{
909 uacpi_object *int_obj;
911
914 );
916 return ret;
917
918 *out_value = int_obj->integer;
919 uacpi_object_unref(int_obj);
920
921 return UACPI_STATUS_OK;
922}
@ UACPI_OBJECT_INTEGER_BIT
Definition: types.h:135
uacpi_u64 integer
Definition: types.h:263

Referenced by uacpi_eval_adr(), uacpi_eval_simple_integer(), and uacpi_eval_sta().

◆ uacpi_eval_package()

uacpi_status uacpi_eval_package ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args,
uacpi_object **  ret 
)

A shorthand for uacpi_eval_typed with UACPI_OBJECT_PACKAGE_BIT.

Use uacpi_object_get_package to retrieve the resulting object array.

Definition at line 992 of file uacpi.c.

996{
997 return uacpi_eval_typed(
999 );
1000}
@ UACPI_OBJECT_PACKAGE_BIT
Definition: types.h:138

◆ uacpi_eval_simple()

uacpi_status uacpi_eval_simple ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object **  ret 
)

Definition at line 799 of file uacpi.c.

802{
804}

◆ uacpi_eval_simple_buffer()

uacpi_status uacpi_eval_simple_buffer ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object **  ret 
)

Definition at line 983 of file uacpi.c.

986{
987 return uacpi_eval_typed(
989 );
990}

Referenced by eval_resource_helper().

◆ uacpi_eval_simple_integer()

uacpi_status uacpi_eval_simple_integer ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_u64 *  out_value 
)

Definition at line 924 of file uacpi.c.

927{
928 return uacpi_eval_integer(parent, path, UACPI_NULL, out_value);
929}
uacpi_status uacpi_eval_integer(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_u64 *out_value)
Definition: uacpi.c:904

Referenced by pci_region_attach(), pci_region_collect_devices(), and pci_region_find_devices().

◆ uacpi_eval_simple_package()

uacpi_status uacpi_eval_simple_package ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object **  ret 
)

Definition at line 1002 of file uacpi.c.

1005{
1006 return uacpi_eval_typed(
1008 );
1009}

◆ uacpi_eval_simple_string()

uacpi_status uacpi_eval_simple_string ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object **  ret 
)

Definition at line 964 of file uacpi.c.

967{
968 return uacpi_eval_typed(
970 );
971}
@ UACPI_OBJECT_STRING_BIT
Definition: types.h:136

◆ uacpi_eval_simple_string_or_buffer()

uacpi_status uacpi_eval_simple_string_or_buffer ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object **  ret 
)

Definition at line 943 of file uacpi.c.

◆ uacpi_eval_simple_typed()

uacpi_status uacpi_eval_simple_typed ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_object_type_bits  ret_mask,
uacpi_object **  ret 
)

Definition at line 896 of file uacpi.c.

900{
901 return uacpi_eval_typed(parent, path, UACPI_NULL, ret_mask, ret);
902}

◆ uacpi_eval_string()

uacpi_status uacpi_eval_string ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args,
uacpi_object **  ret 
)

A shorthand for uacpi_eval_typed with UACPI_OBJECT_STRING_BIT.

Use uacpi_object_get_string to retrieve the resulting buffer data.

Definition at line 954 of file uacpi.c.

958{
959 return uacpi_eval_typed(
961 );
962}

◆ uacpi_eval_string_or_buffer()

uacpi_status uacpi_eval_string_or_buffer ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args,
uacpi_object **  ret 
)

A shorthand for uacpi_eval_typed with UACPI_OBJECT_BUFFER_BIT | UACPI_OBJECT_STRING_BIT

Use uacpi_object_get_string_or_buffer to retrieve the resulting buffer data.

Definition at line 931 of file uacpi.c.

935{
936 return uacpi_eval_typed(
937 parent, path, args,
939 ret
940 );
941}

◆ uacpi_eval_typed()

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 
)

Same as uacpi_eval, but the return value type is validated against the 'ret_mask'. UACPI_STATUS_TYPE_MISMATCH is returned on error.

Definition at line 866 of file uacpi.c.

871{
875
876 if (uacpi_unlikely(out_obj == UACPI_NULL))
878
881 return ret;
882
883 if (obj != UACPI_NULL)
884 returned_type = obj->type;
885
886 if (ret_mask && (ret_mask & (1 << returned_type)) == 0) {
887 trace_invalid_return_type(parent, path, ret_mask, returned_type);
890 }
891
892 *out_obj = obj;
893 return UACPI_STATUS_OK;
894}
@ UACPI_STATUS_TYPE_MISMATCH
Definition: status.h:22
static void trace_invalid_return_type(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object_type_bits expected_mask, uacpi_object_type actual_type)
Definition: uacpi.c:834

Referenced by get_slp_type_for_state(), uacpi_eval_buffer(), uacpi_eval_cid(), uacpi_eval_cls(), uacpi_eval_dstate_method_template(), uacpi_eval_hid(), uacpi_eval_integer(), uacpi_eval_package(), uacpi_eval_simple_buffer(), uacpi_eval_simple_package(), uacpi_eval_simple_string(), uacpi_eval_simple_string_or_buffer(), uacpi_eval_simple_typed(), uacpi_eval_string(), uacpi_eval_string_or_buffer(), uacpi_eval_uid(), and uacpi_get_pci_routing_table().

◆ uacpi_execute()

uacpi_status uacpi_execute ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
const uacpi_object_array *  args 
)

Same as uacpi_eval() but without a return value.

Definition at line 806 of file uacpi.c.

810{
812}

◆ uacpi_execute_simple()

uacpi_status uacpi_execute_simple ( uacpi_namespace_node *  parent,
const uacpi_char *  path 
)

Definition at line 814 of file uacpi.c.

817{
819}

◆ uacpi_get_aml_bitness()

uacpi_status uacpi_get_aml_bitness ( uacpi_u8 *  out_bitness)

Get the bitness of the currently loaded AML code according to the DSDT.

Returns either 32 or 64.

Definition at line 1011 of file uacpi.c.

1012{
1014
1015 *out_bitness = g_uacpi_rt_ctx.is_rev1 ? 32 : 64;
1016 return UACPI_STATUS_OK;
1017}

Referenced by uacpi_object_create_integer_safe().

◆ uacpi_get_current_init_level()

uacpi_init_level uacpi_get_current_init_level ( void  )

Definition at line 322 of file uacpi.c.

323{
324 return g_uacpi_rt_ctx.init_level;
325}

Referenced by uacpi_initialize_opregion_node().

◆ uacpi_initialize()

uacpi_status uacpi_initialize ( uacpi_u64  flags)

Initializes the uACPI subsystem, iterates & records all relevant RSDT/XSDT tables. Enters ACPI mode.

'flags' is any combination of UACPI_FLAG_* above

Definition at line 327 of file uacpi.c.

328{
330
332
333#ifdef UACPI_KERNEL_INITIALIZATION
334 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_EARLY);
336 return ret;
337#endif
338
340 g_uacpi_rt_ctx.last_sleep_typ_a = UACPI_SLEEP_TYP_INVALID;
341 g_uacpi_rt_ctx.last_sleep_typ_b = UACPI_SLEEP_TYP_INVALID;
344 g_uacpi_rt_ctx.flags = flags;
345
347
348 if (g_uacpi_rt_ctx.loop_timeout_seconds == 0)
350 if (g_uacpi_rt_ctx.max_call_stack_depth == 0)
352
355 goto out_fatal_error;
356
359 goto out_fatal_error;
360
363 goto out_fatal_error;
364
367 goto out_fatal_error;
368
371 goto out_fatal_error;
372
375 goto out_fatal_error;
376
379 goto out_fatal_error;
380
382
385
386 return UACPI_STATUS_OK;
387
388out_fatal_error:
390 return ret;
391}
#define UACPI_ENSURE_INIT_LEVEL_IS(lvl)
Definition: context.h:141
static uacpi_bool uacpi_check_flag(uacpi_u64 flag)
Definition: context.h:90
#define UACPI_SLEEP_TYP_INVALID
Definition: context.h:34
uacpi_status uacpi_initialize_namespace(void)
Definition: namespace.c:156
uacpi_status uacpi_initialize_registers(void)
Definition: registers.c:456
@ UACPI_INIT_LEVEL_EARLY
Definition: types.h:66
uacpi_status uacpi_initialize_events_early(void)
Definition: event.c:3027
GLbitfield flags
Definition: glext.h:7161
uacpi_status uacpi_initialize_notify(void)
Definition: notify.c:15
uacpi_status uacpi_initialize_opregion(void)
Definition: opregion.c:15
void uacpi_install_default_address_space_handlers(void)
uacpi_status uacpi_initialize_interfaces(void)
Definition: osi.c:90
uacpi_status uacpi_initialize_tables(void)
Definition: tables.c:279
void uacpi_state_reset(void)
Definition: uacpi.c:136
void uacpi_logger_initialize(void)
Definition: uacpi.c:37
void uacpi_context_set_max_call_stack_depth(uacpi_u32 depth)
Definition: uacpi.c:192
static void enter_acpi_mode_initial(void)
Definition: uacpi.c:314
void uacpi_context_set_loop_timeout(uacpi_u32 seconds)
Definition: uacpi.c:184
#define UACPI_FLAG_NO_ACPI_MODE
Definition: uacpi.h:93

Referenced by ACPIInitUACPI().

◆ uacpi_is_platform_reduced_hardware()

uacpi_status uacpi_is_platform_reduced_hardware ( uacpi_bool *  out_value)

Returns UACPI_TRUE via 'out_value' if the current platform is reduced ACPI hardware, UACPI_FALSE otherwise.

This getter becomes available along with the table subsystem, use uacpi_table_subsystem_available() to check.

Definition at line 20 of file uacpi.c.

21{
24
25 *out_value = uacpi_is_hardware_reduced();
26 return UACPI_STATUS_OK;
27}
@ UACPI_STATUS_INIT_LEVEL_MISMATCH
Definition: status.h:23
uacpi_bool uacpi_table_subsystem_available(void)

◆ uacpi_leave_acpi_mode()

uacpi_status uacpi_leave_acpi_mode ( void  )

Definition at line 309 of file uacpi.c.

310{
312}

Referenced by uacpi_state_reset().

◆ uacpi_logger_initialize()

void uacpi_logger_initialize ( void  )

Definition at line 37 of file uacpi.c.

38{
39 static uacpi_bool version_printed = UACPI_FALSE;
40
41 if (g_uacpi_rt_ctx.log_level == 0)
43
44 if (!version_printed) {
45 version_printed = UACPI_TRUE;
47 "starting uACPI, version %d.%d.%d",
49 );
50 }
51}
#define uacpi_info(...)
Definition: log.h:34
void uacpi_context_set_log_level(uacpi_log_level lvl)
Definition: uacpi.c:29
#define UACPI_PATCH
Definition: uacpi.h:10
#define UACPI_MINOR
Definition: uacpi.h:9
#define UACPI_MAJOR
Definition: uacpi.h:8

Referenced by uacpi_initialize(), and uacpi_setup_early_table_access().

◆ uacpi_namespace_initialize()

uacpi_status uacpi_namespace_initialize ( void  )

Initializes all the necessary objects in the namespaces by calling _STA/_INI etc.

Definition at line 632 of file uacpi.c.

633{
634 struct ns_init_context ctx = { 0 };
636 uacpi_u64 begin_ts, end_ts;
640
642
643#ifdef UACPI_KERNEL_INITIALIZATION
644 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_NAMESPACE_LOADED);
646 goto out;
647#endif
648
649 /*
650 * Initialization order here is identical to ACPICA because ACPI
651 * specification doesn't really have any detailed steps that explain
652 * how to do it.
653 */
654
656
658
659 // Step 1 - Execute \_INI
660 ini_eval(&ctx, root);
661
662 // Step 2 - Execute \_SB._INI
663 ini_eval(
665 );
666
667 /*
668 * Step 3 - Run _REG methods for all globally installed
669 * address space handlers.
670 */
672 if (handlers) {
673 handler = handlers->head;
674
675 while (handler) {
678
679 handler = handler->next;
680 }
681 }
682
683 // Step 4 - Run all other _STA and _INI methods
687 );
688
690
691 if (uacpi_likely(!g_uacpi_rt_ctx.bad_timesource)) {
693 "namespace initialization done in %"UACPI_PRIu64"ms: "
694 "%zu devices, %zu thermal zones",
695 UACPI_FMT64(elapsed_ms(begin_ts, end_ts)),
696 ctx.devices, ctx.thermal_zones
697 );
698 } else {
700 "namespace initialization done: %zu devices, %zu thermal zones",
701 ctx.devices, ctx.thermal_zones
702 );
703 }
704
706 "_STA calls: %zu (%zu errors), _INI calls: %zu (%zu errors)",
707 ctx.sta_executed, ctx.sta_errors, ctx.ini_executed,
708 ctx.ini_errors
709 );
710
712#ifdef UACPI_KERNEL_INITIALIZATION
713 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_NAMESPACE_INITIALIZED);
714out:
717#endif
718 return ret;
719}
struct _root root
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7708
#define UACPI_MAX_DEPTH_ANY
Definition: namespace.h:102
@ UACPI_PREDEFINED_NAMESPACE_SB
Definition: namespace.h:20
uacpi_namespace_node * uacpi_namespace_root(void)
Definition: namespace.c:264
uacpi_status uacpi_namespace_for_each_child(uacpi_namespace_node *parent, uacpi_iteration_callback descending_callback, uacpi_iteration_callback ascending_callback, uacpi_object_type_bits type_mask, uacpi_u32 max_depth, void *user)
Definition: namespace.c:955
#define uacpi_likely(expr)
Definition: compiler.h:89
#define UACPI_FMT64(val)
Definition: types.h:62
#define UACPI_PRIu64
Definition: types.h:59
@ UACPI_OBJECT_ANY_BIT
Definition: types.h:152
@ UACPI_INIT_LEVEL_NAMESPACE_INITIALIZED
Definition: types.h:84
@ UACPI_INIT_LEVEL_NAMESPACE_LOADED
Definition: types.h:78
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1380
uacpi_address_space_handlers * uacpi_node_get_address_space_handlers(uacpi_namespace_node *node)
Definition: opregion.c:179
uacpi_bool uacpi_address_space_handler_is_default(uacpi_address_space_handler *handler)
Definition: opregion.c:502
uacpi_u64 uacpi_kernel_get_nanoseconds_since_boot(void)
Definition: uacpiosl.c:35
uacpi_status uacpi_reg_all_opregions(uacpi_namespace_node *device_node, enum uacpi_address_space space)
Definition: opregion.c:847
static uacpi_u64 elapsed_ms(uacpi_u64 begin_ns, uacpi_u64 end_ns)
Definition: uacpi.c:418
static uacpi_iteration_decision do_sta_ini(void *opaque, uacpi_namespace_node *node, uacpi_u32 depth)
Definition: uacpi.c:578
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ uacpi_namespace_load()

uacpi_status uacpi_namespace_load ( void  )

Parses & executes all of the DSDT/SSDT tables. Initializes the event subsystem.

Definition at line 449 of file uacpi.c.

450{
451 struct uacpi_table tbl;
453 uacpi_u64 begin_ts, end_ts;
454 struct table_load_stats st = { 0 };
455 uacpi_size cur_index;
456
458
459#ifdef UACPI_KERNEL_INITIALIZATION
460 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED);
462 goto out_fatal_error;
463#endif
464
466
469 uacpi_error("unable to find DSDT: %s", uacpi_status_to_string(ret));
470 goto out_fatal_error;
471 }
472
476 st.failure_counter++;
477 }
478 st.load_counter++;
479 uacpi_table_unref(&tbl);
480
481 for (cur_index = 0;; cur_index = tbl.index + 1) {
482 ret = uacpi_table_match(cur_index, match_ssdt_or_psdt, &tbl);
483 if (ret != UACPI_STATUS_OK) {
485 goto out_fatal_error;
486
487 break;
488 }
489
493 st.failure_counter++;
494 }
495 st.load_counter++;
496 uacpi_table_unref(&tbl);
497 }
498
500 g_uacpi_rt_ctx.bad_timesource = warn_on_bad_timesource(begin_ts, end_ts);
501
502 if (uacpi_unlikely(st.failure_counter != 0 || g_uacpi_rt_ctx.bad_timesource)) {
504 "loaded %u AML blob%s (%u error%s)",
505 st.load_counter, st.load_counter > 1 ? "s" : "", st.failure_counter,
506 st.failure_counter == 1 ? "" : "s"
507 );
508 } else {
509 uacpi_u64 ops = g_uacpi_rt_ctx.opcodes_executed;
510 uacpi_u64 ops_per_sec = ops * UACPI_NANOSECONDS_PER_SEC;
511
512 ops_per_sec /= end_ts - begin_ts;
513
515 "successfully loaded %u AML blob%s, %"UACPI_PRIu64" ops in "
516 "%"UACPI_PRIu64"ms (avg %"UACPI_PRIu64"/s)",
517 st.load_counter, st.load_counter > 1 ? "s" : "",
518 UACPI_FMT64(ops), UACPI_FMT64(elapsed_ms(begin_ts, end_ts)),
519 UACPI_FMT64(ops_per_sec)
520 );
521 }
522
525 uacpi_error("event initialization failed: %s",
527 goto out_fatal_error;
528 }
529
531 return UACPI_STATUS_OK;
532
533out_fatal_error:
535 return ret;
536}
#define ACPI_DSDT_SIGNATURE
Definition: acpi.h:23
@ UACPI_LOG_ERROR
Definition: log.h:35
@ UACPI_LOG_WARN
Definition: log.h:29
size_t uacpi_size
Definition: types.h:37
uacpi_status uacpi_initialize_events(void)
Definition: event.c:3057
uacpi_status uacpi_table_load_with_cause(uacpi_size idx, enum uacpi_table_load_cause cause)
Definition: tables.c:1280
uacpi_status uacpi_table_match(uacpi_size base_idx, uacpi_table_match_callback, uacpi_table *out_table)
Definition: tables.c:1081
#define UACPI_NANOSECONDS_PER_SEC
Definition: utilities.h:45
@ UACPI_TABLE_LOAD_CAUSE_INIT
Definition: interpreter.h:12
uacpi_u32 failure_counter
Definition: uacpi.c:395
uacpi_u32 load_counter
Definition: uacpi.c:394
uacpi_status uacpi_table_unref(uacpi_table *)
Definition: tables.c:1357
uacpi_status uacpi_table_find_by_signature(const uacpi_char *signature, uacpi_table *out_table)
Definition: tables.c:1153
static uacpi_bool match_ssdt_or_psdt(struct uacpi_installed_table *tbl)
Definition: uacpi.c:409
static void trace_table_load_failure(struct acpi_sdt_hdr *tbl, uacpi_log_level lvl, uacpi_status ret)
Definition: uacpi.c:398
static uacpi_bool warn_on_bad_timesource(uacpi_u64 begin_ts, uacpi_u64 end_ts)
Definition: uacpi.c:423

◆ uacpi_state_reset()

void uacpi_state_reset ( void  )

Reset the global uACPI state by freeing all internally allocated data structures & resetting any global variables. After this call, uACPI must be re-initialized from scratch to be used again.

This is called by uACPI automatically if a fatal error occurs during a call to uacpi_initialize/uacpi_namespace_load etc. in order to prevent accidental use of partially uninitialized subsystems.

NOTE:

  • This waits for all of the in-flight interrupts & deferred work to complete, see uacpi_kernel_wait_for_work_completion, and therefore must not be called from an interrupt handler, nor from any work that was scheduled via uacpi_kernel_schedule_work
  • That is all it waits for: it's up to the caller to make sure that no other thread is in the middle of a call into uACPI, or is about to make one, as everything that such a call relies on is gone once this returns

Definition at line 136 of file uacpi.c.

137{
138#ifndef UACPI_BAREBONES_MODE
139 /*
140 * Get rid of everything that is able to produce deferred work first, and
141 * then make sure there's none left, be it a GPE handler or a notification.
142 * Neither would survive the namespace being torn down underneath it.
143 */
145
148
153#endif
154
156
157#ifndef UACPI_BAREBONES_MODE
158
159#ifndef UACPI_REDUCED_HARDWARE
160 if (g_uacpi_rt_ctx.was_in_legacy_mode)
162#endif
163
165
166#ifndef UACPI_REDUCED_HARDWARE
167 if (g_uacpi_rt_ctx.global_lock_event)
168 uacpi_free_native_event(g_uacpi_rt_ctx.global_lock_event);
169 if (g_uacpi_rt_ctx.global_lock_spinlock)
170 uacpi_kernel_free_spinlock(g_uacpi_rt_ctx.global_lock_spinlock);
171#endif
172
173#endif // !UACPI_BAREBONES_MODE
174
176
177#if defined(UACPI_KERNEL_INITIALIZATION) && !defined(UACPI_BAREBONES_MODE)
178 uacpi_kernel_deinitialize();
179#endif
180}
static void uacpi_free_native_event(uacpi_handle evt)
Definition: mutex.h:83
void uacpi_deinitialize_namespace(void)
Definition: namespace.c:205
void uacpi_deinitialize_registers(void)
Definition: registers.c:465
#define uacpi_memzero(ptr, size)
Definition: stdlib.h:99
void uacpi_deinitialize_events(void)
Definition: event.c:3120
void uacpi_deinitialize_notify(void)
Definition: notify.c:24
void uacpi_deinitialize_opregion(void)
Definition: opregion.c:20
void uacpi_deinitialize_interfaces(void)
Definition: osi.c:106
void uacpi_deinitialize_tables(void)
Definition: tables.c:351
uacpi_status uacpi_kernel_wait_for_work_completion(void)
Definition: uacpiosl.c:235
void uacpi_kernel_free_spinlock(uacpi_handle)
Definition: uacpiosl.c:92
uacpi_status uacpi_leave_acpi_mode(void)
Definition: uacpi.c:309

Referenced by uacpi_initialize(), uacpi_namespace_initialize(), and uacpi_namespace_load().

◆ uacpi_status_to_string()

const uacpi_char * uacpi_status_to_string ( uacpi_status  st)

Definition at line 61 of file uacpi.c.

62{
63 switch (st) {
64 case UACPI_STATUS_OK:
65 return "no error";
67 return "failed to map memory";
69 return "out of memory";
71 return "bad table checksum";
73 return "invalid table signature";
75 return "invalid table length";
77 return "not found";
79 return "invalid argument";
81 return "unimplemented";
83 return "already exists";
85 return "internal error";
87 return "object type mismatch";
89 return "init level too low/high for this action";
91 return "attempting to use a dangling namespace node";
93 return "no handler found";
95 return "resource template without an end tag";
97 return "this functionality has been compiled out of this build";
99 return "timed out waiting for hardware response";
101 return "wait timed out";
103 return "the requested action has been overridden";
105 return "the requested action has been denied";
106
108 return "AML referenced an undefined object";
110 return "invalid AML name string";
112 return "object already exists";
114 return "invalid AML opcode";
116 return "incompatible AML object type";
118 return "bad AML instruction encoding";
120 return "out of bounds AML index";
122 return "AML attempted to acquire a mutex with a lower sync level";
124 return "invalid resource template encoding or type";
126 return "hanging AML while loop";
128 return "reached maximum AML call stack depth";
130 return "AML attempted to create a reference cycle";
131 default:
132 return "<invalid status>";
133 }
134}
@ UACPI_STATUS_AML_OBJECT_ALREADY_EXISTS
Definition: status.h:36
@ UACPI_STATUS_AML_OUT_OF_BOUNDS_INDEX
Definition: status.h:40
@ UACPI_STATUS_INTERNAL_ERROR
Definition: status.h:21
@ UACPI_STATUS_AML_INVALID_RESOURCE
Definition: status.h:42
@ UACPI_STATUS_UNIMPLEMENTED
Definition: status.h:19
@ UACPI_STATUS_NAMESPACE_NODE_DANGLING
Definition: status.h:24
@ UACPI_STATUS_AML_REFERENCE_CYCLE
Definition: status.h:45
@ UACPI_STATUS_OVERRIDDEN
Definition: status.h:30
@ UACPI_STATUS_INVALID_TABLE_LENGTH
Definition: status.h:16
@ UACPI_STATUS_AML_INCOMPATIBLE_OBJECT_TYPE
Definition: status.h:38
@ UACPI_STATUS_INVALID_SIGNATURE
Definition: status.h:15
@ UACPI_STATUS_NO_RESOURCE_END_TAG
Definition: status.h:26
@ UACPI_STATUS_ALREADY_EXISTS
Definition: status.h:20
@ UACPI_STATUS_AML_UNDEFINED_REFERENCE
Definition: status.h:34
@ UACPI_STATUS_AML_LOOP_TIMEOUT
Definition: status.h:43
@ UACPI_STATUS_AML_BAD_ENCODING
Definition: status.h:39
@ UACPI_STATUS_AML_INVALID_OPCODE
Definition: status.h:37
@ UACPI_STATUS_MAPPING_FAILED
Definition: status.h:12
@ UACPI_STATUS_COMPILED_OUT
Definition: status.h:27
@ UACPI_STATUS_AML_INVALID_NAMESTRING
Definition: status.h:35
@ UACPI_STATUS_TIMEOUT
Definition: status.h:29
@ UACPI_STATUS_AML_CALL_STACK_DEPTH_LIMIT
Definition: status.h:44
@ UACPI_STATUS_DENIED
Definition: status.h:31
@ UACPI_STATUS_AML_SYNC_LEVEL_TOO_HIGH
Definition: status.h:41
@ UACPI_STATUS_NO_HANDLER
Definition: status.h:25
@ UACPI_STATUS_BAD_CHECKSUM
Definition: status.h:14

Referenced by ACPIInitUACPI(), async_restore_gpe(), async_run_gpe_handler(), dispatch_gpe(), do_initialize_gpe_block(), do_match_gpe_methods(), enter_mode(), eval_sleep_helper(), get_slp_type_for_state(), gpe_mask_and_flush(), initialize_gpes(), report_table_id_find_error(), run_reg(), trace_named_object_lookup_or_creation_failure(), trace_table_load_failure(), uacpi_eval_dstate_method_template(), uacpi_execute_control_method(), uacpi_get_pci_routing_table(), uacpi_initialize_events(), uacpi_namespace_load(), and uacpi_trace_region_error().

◆ warn_on_bad_timesource()

static uacpi_bool warn_on_bad_timesource ( uacpi_u64  begin_ts,
uacpi_u64  end_ts 
)
static

Definition at line 423 of file uacpi.c.

424{
425 const uacpi_char *reason;
426
427 if (uacpi_unlikely(begin_ts == 0 && end_ts == 0)) {
428 reason = "uacpi_kernel_get_nanoseconds_since_boot() appears to be a stub";
429 goto out_bad_timesource;
430 }
431
432 if (uacpi_unlikely(begin_ts == end_ts)) {
433 reason = "poor time source precision detected";
434 goto out_bad_timesource;
435 }
436
437 if (uacpi_unlikely(end_ts < begin_ts)) {
438 reason = "time source backwards drift detected";
439 goto out_bad_timesource;
440 }
441
442 return UACPI_FALSE;
443
444out_bad_timesource:
445 uacpi_warn("%s, this may cause problems", reason);
446 return UACPI_TRUE;
447}
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1971

Referenced by uacpi_namespace_load().

Variable Documentation

◆ g_uacpi_rt_ctx

struct uacpi_runtime_context g_uacpi_rt_ctx = { 0 }

Definition at line 18 of file uacpi.c.

Referenced by begin_block_execution(), buffer_field_get_read_type(), debug_store_no_recurse(), do_binary_math(), do_notify(), DYNAMIC_ARRAY_WITH_INLINE_STORAGE(), enter_acpi_mode_initial(), enter_sleep_state_hw_full(), enter_sleep_state_hw_reduced(), extract_handlers(), fadt_relative(), find_or_create_gpe_interrupt_ctx(), get_op(), handle_global_lock(), initialize_fadt(), initialize_from_rsdp(), initialize_gpes(), lock_field_unit_transaction(), make_object_for_predefined(), ones(), prepare_for_wake_from_sleep_state_hw_full(), prepare_for_wake_from_sleep_state_hw_reduced(), prepare_method_call(), read_mode(), set_mode(), sizeof_int(), split_event_blocks(), truncate_number_if_needed(), uacpi_acquire_aml_mutex(), uacpi_acquire_global_lock(), uacpi_acquire_global_lock_from_firmware(), uacpi_check_flag(), uacpi_context_get_loop_timeout(), uacpi_context_set_log_level(), uacpi_context_set_loop_timeout(), uacpi_context_set_max_call_stack_depth(), uacpi_context_set_proactive_table_checksum(), uacpi_deinitialize_events(), uacpi_deinitialize_namespace(), uacpi_enter_sleep_state(), uacpi_field_unit_get_read_type(), uacpi_get_aml_bitness(), uacpi_get_current_init_level(), uacpi_initialize(), uacpi_initialize_events(), uacpi_initialize_tables(), uacpi_install_address_space_handler_with_flags(), uacpi_install_notify_handler(), uacpi_is_hardware_reduced(), uacpi_logger_initialize(), uacpi_namespace_initialize(), uacpi_namespace_load(), uacpi_node_get_address_space_handlers(), uacpi_notify_all(), uacpi_prepare_for_sleep_state(), uacpi_reboot(), uacpi_release_aml_mutex(), uacpi_release_global_lock(), uacpi_release_global_lock_to_firmware(), uacpi_set_waking_vector(), uacpi_should_log(), uacpi_state_reset(), uacpi_table_fadt(), uacpi_uninstall_notify_handler(), uninstall_gpe_block(), unlink_gpe_interrupt_ctx(), unlock_field_unit_transaction(), verify_and_install_table(), wake_from_sleep_state_hw_full(), and wake_from_sleep_state_hw_reduced().