ReactOS 0.4.17-dev-684-ga6524ef
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_charuacpi_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:51
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Definition at line 809 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 816 of file uacpi.c.

Enumeration Type Documentation

◆ hw_mode

Enumerator
HW_MODE_ACPI 
HW_MODE_LEGACY 

Definition at line 194 of file uacpi.c.

194 {
195 HW_MODE_ACPI = 0,
196 HW_MODE_LEGACY = 1,
197};
@ HW_MODE_LEGACY
Definition: uacpi.c:196
@ HW_MODE_ACPI
Definition: uacpi.c:195

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 566 of file uacpi.c.

569{
570 struct ns_init_context *ctx = opaque;
573 uacpi_u32 sta_ret;
574
576
577 // We don't care about aliases
580
582 switch (type) {
585 ctx->devices++;
586 break;
588 ctx->thermal_zones++;
589 break;
590 default:
593 }
594
595 ret = sta_eval(ctx, node, &sta_ret);
598
599 if (!(sta_ret & ACPI_STA_RESULT_DEVICE_PRESENT)) {
600 if (!(sta_ret & ACPI_STA_RESULT_DEVICE_FUNCTIONING))
602
603 /*
604 * ACPI 6.5 specification:
605 * _STA may return bit 0 clear (not present) with bit [3] set (device
606 * is functional). This case is used to indicate a valid device for
607 * which no device driver should be loaded (for example, a bridge
608 * device.) Children of this device may be present and valid. OSPM
609 * should continue enumeration below a device whose _STA returns this
610 * bit combination.
611 */
613 }
614
615 ini_eval(ctx, node);
616
618}
#define ACPI_STA_RESULT_DEVICE_PRESENT
Definition: acpi.h:991
#define ACPI_STA_RESULT_DEVICE_FUNCTIONING
Definition: acpi.h:994
#define UACPI_UNUSED(x)
Definition: helpers.h:7
uacpi_bool uacpi_namespace_node_is_alias(uacpi_namespace_node *node)
Definition: namespace.c:328
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:774
@ UACPI_PREDEFINED_NAMESPACE_TZ
Definition: namespace.h:22
uint32_t uacpi_u32
Definition: types.h:21
#define uacpi_unlikely_error(expr)
Definition: status.h:49
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:535
static uacpi_status sta_eval(struct ns_init_context *ctx, uacpi_namespace_node *node, uacpi_u32 *value)
Definition: uacpi.c:548
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 406 of file uacpi.c.

407{
408 return (end_ns - begin_ns) / (1000ull * 1000ull);
409}

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 302 of file uacpi.c.

303{
304 enter_mode(HW_MODE_ACPI, &g_uacpi_rt_ctx.was_in_legacy_mode);
305}
static uacpi_status enter_mode(enum hw_mode mode, uacpi_bool *did_change)
Definition: uacpi.c:259
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:17

Referenced by uacpi_initialize().

◆ enter_mode()

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

Definition at line 259 of file uacpi.c.

260{
262 const uacpi_char *mode_str;
263
265
267 return UACPI_STATUS_OK;
268
269 mode_str = mode == HW_MODE_LEGACY ? "legacy" : "acpi";
270
271 if (read_mode() == mode) {
272 uacpi_trace("%s mode already enabled", mode_str);
273 return UACPI_STATUS_OK;
274 }
275
276 ret = set_mode(mode);
279 "unable to enter %s mode: %s",
280 mode_str, uacpi_status_to_string(ret)
281 );
282 return ret;
283 }
284
285 uacpi_trace("entered %s mode", mode_str);
286 if (did_change != UACPI_NULL)
288
289 return ret;
290}
#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:199
static uacpi_status set_mode(enum hw_mode mode)
Definition: uacpi.c:215
const uacpi_char * uacpi_status_to_string(uacpi_status st)
Definition: uacpi.c:60

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 535 of file uacpi.c.

536{
538
541 return;
542
543 ctx->ini_executed++;
545 ctx->ini_errors++;
546}
@ 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:709

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 397 of file uacpi.c.

398{
399 if (tbl->flags & UACPI_TABLE_LOADED)
400 return UACPI_FALSE;
401
402 return uacpi_signatures_match(tbl->hdr.signature, ACPI_SSDT_SIGNATURE) ||
404}
#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 199 of file uacpi.c.

200{
202 uacpi_u64 raw_value;
203 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
204
205 if (!fadt->smi_cmd)
206 return HW_MODE_ACPI;
207
210 return HW_MODE_LEGACY;
211
212 return raw_value ? HW_MODE_ACPI : HW_MODE_LEGACY;
213}
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 215 of file uacpi.c.

216{
218 uacpi_u64 raw_value, stalled_time = 0;
219 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
220
221 if (uacpi_unlikely(!fadt->smi_cmd)) {
222 uacpi_error("SMI_CMD is not implemented by the firmware");
224 }
225
226 if (uacpi_unlikely(!fadt->acpi_enable && !fadt->acpi_disable)) {
227 uacpi_error("mode transition is not implemented by the hardware");
229 }
230
231 switch (mode) {
232 case HW_MODE_ACPI:
233 raw_value = fadt->acpi_enable;
234 break;
235 case HW_MODE_LEGACY:
236 raw_value = fadt->acpi_disable;
237 break;
238 default:
240 }
241
244 return ret;
245
246 // Allow up to 5 seconds for the hardware to enter the desired mode
247 while (stalled_time < (5 * 1000 * 1000)) {
248 if (read_mode() == mode)
249 return UACPI_STATUS_OK;
250
252 stalled_time += 100;
253 }
254
255 uacpi_error("hardware time out while changing modes");
257}
#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 548 of file uacpi.c.

552{
554
556 if (*value == 0xFFFFFFFF)
557 return ret;
558
559 ctx->sta_executed++;
561 ctx->sta_errors++;
562
563 return ret;
564}
Definition: pdh_main.c:96
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 822 of file uacpi.c.

826{
827 const uacpi_char *abs_path;
828 uacpi_bool dynamic_abs_path = UACPI_FALSE;
829
830 if (parent == UACPI_NULL || (path != UACPI_NULL && path[0] == '\\')) {
831 abs_path = path;
832 } else {
834 dynamic_abs_path = UACPI_TRUE;
835 }
836
837 if (dynamic_abs_path && path != UACPI_NULL) {
838 if (actual_type == UACPI_OBJECT_UNINITIALIZED)
839 TRACE_NO_RET("%s.%s", abs_path, path, expected_mask);
840 else
841 TRACE_BAD_RET("%s.%s", actual_type, abs_path, path, expected_mask);
842 } else {
843 if (actual_type == UACPI_OBJECT_UNINITIALIZED) {
844 TRACE_NO_RET("%s", abs_path, expected_mask);
845 } else {
846 TRACE_BAD_RET("%s", actual_type, abs_path, expected_mask);
847 }
848 }
849
850 if (dynamic_abs_path)
852}
const uacpi_char * uacpi_namespace_node_generate_absolute_path(const uacpi_namespace_node *node)
Definition: namespace.c:1034
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:809
#define TRACE_NO_RET(path_fmt,...)
Definition: uacpi.c:816

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 386 of file uacpi.c.

389{
391 lvl,
392 "failed to load "UACPI_PRI_TBL_HDR": %s",
394 );
395}
#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 188 of file uacpi.c.

189{
190 return g_uacpi_rt_ctx.loop_timeout_seconds;
191}

◆ 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 28 of file uacpi.c.

29{
30 if (lvl == 0)
32
33 g_uacpi_rt_ctx.log_level = lvl;
34}
#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 172 of file uacpi.c.

173{
174 if (seconds == 0)
176
177 g_uacpi_rt_ctx.loop_timeout_seconds = seconds;
178}
#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 180 of file uacpi.c.

181{
182 if (depth == 0)
184
185 g_uacpi_rt_ctx.max_call_stack_depth = depth;
186}
#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 52 of file uacpi.c.

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

◆ uacpi_enter_acpi_mode()

uacpi_status uacpi_enter_acpi_mode ( void  )

Definition at line 292 of file uacpi.c.

293{
295}

◆ 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 709 of file uacpi.c.

713{
718
720 return ret;
721
724 return ret;
725
726 if (path != UACPI_NULL) {
730 &node
731 );
733 goto out_read_unlock;
734 } else {
735 node = parent;
736 }
737
739 if (uacpi_unlikely(obj == UACPI_NULL)) {
741 goto out_read_unlock;
742 }
743
744 if (obj->type != UACPI_OBJECT_METHOD) {
745 uacpi_object *new_obj;
746
747 if (uacpi_unlikely(out_obj == UACPI_NULL))
748 goto out_read_unlock;
749
751 if (uacpi_unlikely(new_obj == UACPI_NULL)) {
753 goto out_read_unlock;
754 }
755
758 );
760 uacpi_object_unref(new_obj);
761 goto out_read_unlock;
762 }
763 *out_obj = new_obj;
764
765 out_read_unlock:
767 return ret;
768 }
769
770 method = obj->method;
773
774 // Upgrade to a write-lock since we're about to run a method
777 goto out_no_write_lock;
778
781
782out_no_write_lock:
784 return ret;
785}
method
Definition: dragdrop.c:54
uacpi_status uacpi_namespace_write_unlock(void)
Definition: namespace.c:51
@ UACPI_PERMANENT_ONLY_YES
Definition: namespace.h:90
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:646
uacpi_status uacpi_namespace_read_lock(void)
Definition: namespace.c:36
@ UACPI_SHOULD_LOCK_NO
Definition: namespace.h:94
uacpi_status uacpi_namespace_write_lock(void)
Definition: namespace.c:46
@ UACPI_MAY_SEARCH_ABOVE_PARENT_NO
Definition: namespace.h:84
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:491
uacpi_object * uacpi_create_object(uacpi_object_type type)
Definition: types.c:327
uacpi_status uacpi_object_assign(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior)
Definition: types.c:1372
void uacpi_method_unref(uacpi_control_method *)
Definition: types.c:655
@ UACPI_ASSIGN_BEHAVIOR_DEEP_COPY
Definition: types.h:276
@ 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:762
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:6150
uacpi_u32 uacpi_shareable_ref(uacpi_handle)
Definition: shareable.c:31
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 961 of file uacpi.c.

965{
966 return uacpi_eval_typed(
968 );
969}
@ 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:854

◆ 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 892 of file uacpi.c.

896{
897 uacpi_object *int_obj;
899
902 );
904 return ret;
905
906 *out_value = int_obj->integer;
907 uacpi_object_unref(int_obj);
908
909 return UACPI_STATUS_OK;
910}
@ UACPI_OBJECT_INTEGER_BIT
Definition: types.h:135
uacpi_u64 integer
Definition: types.h:253

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 980 of file uacpi.c.

984{
985 return uacpi_eval_typed(
987 );
988}
@ 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 787 of file uacpi.c.

790{
792}

◆ uacpi_eval_simple_buffer()

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

Definition at line 971 of file uacpi.c.

974{
975 return uacpi_eval_typed(
977 );
978}

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 912 of file uacpi.c.

915{
916 return uacpi_eval_integer(parent, path, UACPI_NULL, out_value);
917}
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:892

Referenced by pci_region_attach().

◆ uacpi_eval_simple_package()

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

Definition at line 990 of file uacpi.c.

993{
994 return uacpi_eval_typed(
996 );
997}

◆ uacpi_eval_simple_string()

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

Definition at line 952 of file uacpi.c.

955{
956 return uacpi_eval_typed(
958 );
959}
@ 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 931 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 884 of file uacpi.c.

888{
889 return uacpi_eval_typed(parent, path, UACPI_NULL, ret_mask, ret);
890}

◆ 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 942 of file uacpi.c.

946{
947 return uacpi_eval_typed(
949 );
950}

◆ 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 919 of file uacpi.c.

923{
924 return uacpi_eval_typed(
925 parent, path, args,
927 ret
928 );
929}

◆ 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 854 of file uacpi.c.

859{
863
864 if (uacpi_unlikely(out_obj == UACPI_NULL))
866
869 return ret;
870
871 if (obj != UACPI_NULL)
872 returned_type = obj->type;
873
874 if (ret_mask && (ret_mask & (1 << returned_type)) == 0) {
875 trace_invalid_return_type(parent, path, ret_mask, returned_type);
878 }
879
880 *out_obj = obj;
881 return UACPI_STATUS_OK;
882}
@ 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:822

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 794 of file uacpi.c.

798{
800}

◆ uacpi_execute_simple()

uacpi_status uacpi_execute_simple ( uacpi_namespace_node parent,
const uacpi_char path 
)

Definition at line 802 of file uacpi.c.

805{
807}

◆ 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 999 of file uacpi.c.

1000{
1002
1003 *out_bitness = g_uacpi_rt_ctx.is_rev1 ? 32 : 64;
1004 return UACPI_STATUS_OK;
1005}

Referenced by uacpi_object_create_integer_safe().

◆ uacpi_get_current_init_level()

uacpi_init_level uacpi_get_current_init_level ( void  )

Definition at line 310 of file uacpi.c.

311{
312 return g_uacpi_rt_ctx.init_level;
313}

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 315 of file uacpi.c.

316{
318
320
321#ifdef UACPI_KERNEL_INITIALIZATION
322 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_EARLY);
324 return ret;
325#endif
326
328 g_uacpi_rt_ctx.last_sleep_typ_a = UACPI_SLEEP_TYP_INVALID;
329 g_uacpi_rt_ctx.last_sleep_typ_b = UACPI_SLEEP_TYP_INVALID;
332 g_uacpi_rt_ctx.flags = flags;
333
335
336 if (g_uacpi_rt_ctx.loop_timeout_seconds == 0)
338 if (g_uacpi_rt_ctx.max_call_stack_depth == 0)
340
343 goto out_fatal_error;
344
347 goto out_fatal_error;
348
351 goto out_fatal_error;
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
370
373
374 return UACPI_STATUS_OK;
375
376out_fatal_error:
378 return ret;
379}
#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:2173
GLbitfield flags
Definition: glext.h:7161
uacpi_status uacpi_initialize_notify(void)
Definition: notify.c:14
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:133
void uacpi_logger_initialize(void)
Definition: uacpi.c:36
void uacpi_context_set_max_call_stack_depth(uacpi_u32 depth)
Definition: uacpi.c:180
static void enter_acpi_mode_initial(void)
Definition: uacpi.c:302
void uacpi_context_set_loop_timeout(uacpi_u32 seconds)
Definition: uacpi.c:172
#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 19 of file uacpi.c.

20{
23
24 *out_value = uacpi_is_hardware_reduced();
25 return UACPI_STATUS_OK;
26}
@ 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 297 of file uacpi.c.

298{
300}

Referenced by uacpi_state_reset().

◆ uacpi_logger_initialize()

void uacpi_logger_initialize ( void  )

Definition at line 36 of file uacpi.c.

37{
38 static uacpi_bool version_printed = UACPI_FALSE;
39
40 if (g_uacpi_rt_ctx.log_level == 0)
42
43 if (!version_printed) {
44 version_printed = UACPI_TRUE;
46 "starting uACPI, version %d.%d.%d",
48 );
49 }
50}
#define uacpi_info(...)
Definition: log.h:34
void uacpi_context_set_log_level(uacpi_log_level lvl)
Definition: uacpi.c:28
#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 620 of file uacpi.c.

621{
622 struct ns_init_context ctx = { 0 };
624 uacpi_u64 begin_ts, end_ts;
628
630
631#ifdef UACPI_KERNEL_INITIALIZATION
632 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_NAMESPACE_LOADED);
634 goto out;
635#endif
636
637 /*
638 * Initialization order here is identical to ACPICA because ACPI
639 * specification doesn't really have any detailed steps that explain
640 * how to do it.
641 */
642
644
646
647 // Step 1 - Execute \_INI
648 ini_eval(&ctx, root);
649
650 // Step 2 - Execute \_SB._INI
651 ini_eval(
653 );
654
655 /*
656 * Step 3 - Run _REG methods for all globally installed
657 * address space handlers.
658 */
660 if (handlers) {
661 handler = handlers->head;
662
663 while (handler) {
666
667 handler = handler->next;
668 }
669 }
670
671 // Step 4 - Run all other _STA and _INI methods
675 );
676
678
679 if (uacpi_likely(!g_uacpi_rt_ctx.bad_timesource)) {
681 "namespace initialization done in %"UACPI_PRIu64"ms: "
682 "%zu devices, %zu thermal zones",
683 UACPI_FMT64(elapsed_ms(begin_ts, end_ts)),
684 ctx.devices, ctx.thermal_zones
685 );
686 } else {
688 "namespace initialization done: %zu devices, %zu thermal zones",
689 ctx.devices, ctx.thermal_zones
690 );
691 }
692
694 "_STA calls: %zu (%zu errors), _INI calls: %zu (%zu errors)",
695 ctx.sta_executed, ctx.sta_errors, ctx.ini_executed,
696 ctx.ini_errors
697 );
698
700#ifdef UACPI_KERNEL_INITIALIZATION
701 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_NAMESPACE_INITIALIZED);
702out:
705#endif
706 return ret;
707}
struct _root root
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
#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:948
#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:170
uacpi_bool uacpi_address_space_handler_is_default(uacpi_address_space_handler *handler)
Definition: opregion.c:413
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:590
static uacpi_u64 elapsed_ms(uacpi_u64 begin_ns, uacpi_u64 end_ns)
Definition: uacpi.c:406
static uacpi_iteration_decision do_sta_ini(void *opaque, uacpi_namespace_node *node, uacpi_u32 depth)
Definition: uacpi.c:566
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 437 of file uacpi.c.

438{
439 struct uacpi_table tbl;
441 uacpi_u64 begin_ts, end_ts;
442 struct table_load_stats st = { 0 };
443 uacpi_size cur_index;
444
446
447#ifdef UACPI_KERNEL_INITIALIZATION
448 ret = uacpi_kernel_initialize(UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED);
450 goto out_fatal_error;
451#endif
452
454
457 uacpi_error("unable to find DSDT: %s", uacpi_status_to_string(ret));
458 goto out_fatal_error;
459 }
460
464 st.failure_counter++;
465 }
466 st.load_counter++;
467 uacpi_table_unref(&tbl);
468
469 for (cur_index = 0;; cur_index = tbl.index + 1) {
470 ret = uacpi_table_match(cur_index, match_ssdt_or_psdt, &tbl);
471 if (ret != UACPI_STATUS_OK) {
473 goto out_fatal_error;
474
475 break;
476 }
477
481 st.failure_counter++;
482 }
483 st.load_counter++;
484 uacpi_table_unref(&tbl);
485 }
486
488 g_uacpi_rt_ctx.bad_timesource = warn_on_bad_timesource(begin_ts, end_ts);
489
490 if (uacpi_unlikely(st.failure_counter != 0 || g_uacpi_rt_ctx.bad_timesource)) {
492 "loaded %u AML blob%s (%u error%s)",
493 st.load_counter, st.load_counter > 1 ? "s" : "", st.failure_counter,
494 st.failure_counter == 1 ? "" : "s"
495 );
496 } else {
497 uacpi_u64 ops = g_uacpi_rt_ctx.opcodes_executed;
498 uacpi_u64 ops_per_sec = ops * UACPI_NANOSECONDS_PER_SEC;
499
500 ops_per_sec /= end_ts - begin_ts;
501
503 "successfully loaded %u AML blob%s, %"UACPI_PRIu64" ops in "
504 "%"UACPI_PRIu64"ms (avg %"UACPI_PRIu64"/s)",
505 st.load_counter, st.load_counter > 1 ? "s" : "",
506 UACPI_FMT64(ops), UACPI_FMT64(elapsed_ms(begin_ts, end_ts)),
507 UACPI_FMT64(ops_per_sec)
508 );
509 }
510
513 uacpi_error("event initialization failed: %s",
515 goto out_fatal_error;
516 }
517
519 return UACPI_STATUS_OK;
520
521out_fatal_error:
523 return ret;
524}
#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:2195
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:383
uacpi_u32 load_counter
Definition: uacpi.c:382
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:397
static void trace_table_load_failure(struct acpi_sdt_hdr *tbl, uacpi_log_level lvl, uacpi_status ret)
Definition: uacpi.c:386
static uacpi_bool warn_on_bad_timesource(uacpi_u64 begin_ts, uacpi_u64 end_ts)
Definition: uacpi.c:411

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

Definition at line 133 of file uacpi.c.

134{
135#ifndef UACPI_BAREBONES_MODE
141#endif
142
144
145#ifndef UACPI_BAREBONES_MODE
146
147#ifndef UACPI_REDUCED_HARDWARE
148 if (g_uacpi_rt_ctx.was_in_legacy_mode)
150#endif
151
153
154#ifndef UACPI_REDUCED_HARDWARE
155 if (g_uacpi_rt_ctx.global_lock_event)
156 uacpi_kernel_free_event(g_uacpi_rt_ctx.global_lock_event);
157 if (g_uacpi_rt_ctx.global_lock_spinlock)
158 uacpi_kernel_free_spinlock(g_uacpi_rt_ctx.global_lock_spinlock);
159#endif
160
161#endif // !UACPI_BAREBONES_MODE
162
164
165#if defined(UACPI_KERNEL_INITIALIZATION) && !defined(UACPI_BAREBONES_MODE)
166 uacpi_kernel_deinitialize();
167#endif
168}
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:2246
void uacpi_deinitialize_notify(void)
Definition: notify.c:23
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
void uacpi_kernel_free_event(uacpi_handle)
Definition: uacpiosl.c:60
void uacpi_kernel_free_spinlock(uacpi_handle)
Definition: uacpiosl.c:92
uacpi_status uacpi_leave_acpi_mode(void)
Definition: uacpi.c:297

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 60 of file uacpi.c.

61{
62 switch (st) {
63 case UACPI_STATUS_OK:
64 return "no error";
66 return "failed to map memory";
68 return "out of memory";
70 return "bad table checksum";
72 return "invalid table signature";
74 return "invalid table length";
76 return "not found";
78 return "invalid argument";
80 return "unimplemented";
82 return "already exists";
84 return "internal error";
86 return "object type mismatch";
88 return "init level too low/high for this action";
90 return "attempting to use a dangling namespace node";
92 return "no handler found";
94 return "resource template without an end tag";
96 return "this functionality has been compiled out of this build";
98 return "timed out waiting for hardware response";
100 return "wait timed out";
102 return "the requested action has been overridden";
104 return "the requested action has been denied";
105
107 return "AML referenced an undefined object";
109 return "invalid AML name string";
111 return "object already exists";
113 return "invalid AML opcode";
115 return "incompatible AML object type";
117 return "bad AML instruction encoding";
119 return "out of bounds AML index";
121 return "AML attempted to acquire a mutex with a lower sync level";
123 return "invalid resource template encoding or type";
125 return "hanging AML while loop";
127 return "reached maximum AML call stack depth";
128 default:
129 return "<invalid status>";
130 }
131}
@ 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_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(), enter_mode(), eval_sleep_helper(), get_slp_type_for_state(), initialize_gpes(), report_table_id_find_error(), 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(), uacpi_notify_all(), 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 411 of file uacpi.c.

412{
413 const uacpi_char *reason;
414
415 if (uacpi_unlikely(begin_ts == 0 && end_ts == 0)) {
416 reason = "uacpi_kernel_get_nanoseconds_since_boot() appears to be a stub";
417 goto out_bad_timesource;
418 }
419
420 if (uacpi_unlikely(begin_ts == end_ts)) {
421 reason = "poor time source precision detected";
422 goto out_bad_timesource;
423 }
424
425 if (uacpi_unlikely(end_ts < begin_ts)) {
426 reason = "time source backwards drift detected";
427 goto out_bad_timesource;
428 }
429
430 return UACPI_FALSE;
431
432out_bad_timesource:
433 uacpi_warn("%s, this may cause problems", reason);
434 return UACPI_TRUE;
435}
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 17 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(), unlock_field_unit_transaction(), verify_and_install_table(), wake_from_sleep_state_hw_full(), and wake_from_sleep_state_hw_reduced().