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

Go to the source code of this file.

Macros

#define UACPI_MAJOR   7
 
#define UACPI_MINOR   0
 
#define UACPI_PATCH   0
 
#define UACPI_STUB_IF_REDUCED_HARDWARE(fn)   fn;
 
#define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(fn)   fn;
 
#define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE(fn)   fn;
 
#define UACPI_FLAG_BAD_CSUM_FATAL   (1ull << 0)
 
#define UACPI_FLAG_BAD_TBL_SIGNATURE_FATAL   (1ull << 1)
 
#define UACPI_FLAG_BAD_XSDT   (1ull << 2)
 
#define UACPI_FLAG_NO_ACPI_MODE   (1ull << 3)
 
#define UACPI_FLAG_NO_OSI   (1ull << 4)
 
#define UACPI_FLAG_PROACTIVE_TBL_CSUM   (1ull << 5)
 

Functions

uacpi_status uacpi_setup_early_table_access (void *temporary_buffer, uacpi_size buffer_size)
 
uacpi_bool uacpi_table_subsystem_available (void)
 
uacpi_status uacpi_is_platform_reduced_hardware (uacpi_bool *out_value)
 
uacpi_status uacpi_initialize (uacpi_u64 flags)
 
uacpi_status uacpi_namespace_load (void)
 
uacpi_status uacpi_namespace_initialize (void)
 
uacpi_init_level uacpi_get_current_init_level (void)
 
uacpi_status uacpi_eval (uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
 
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)
 
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)
 
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)
 
 UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE (uacpi_status uacpi_enter_acpi_mode(void)) UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(uacpi_status uacpi_leave_acpi_mode(void)) uacpi_status uacpi_acquire_global_lock(uacpi_u16 timeout
 
uacpi_status uacpi_release_global_lock (uacpi_u32 seq)
 
void uacpi_state_reset (void)
 

Variables

uacpi_u32 * out_seq
 

Macro Definition Documentation

◆ UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE

#define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE (   fn )    fn;

Definition at line 27 of file uacpi.h.

◆ UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE

#define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE (   fn )    fn;

Definition at line 28 of file uacpi.h.

◆ UACPI_FLAG_BAD_CSUM_FATAL

#define UACPI_FLAG_BAD_CSUM_FATAL   (1ull << 0)

Bad table checksum should be considered a fatal error (table load is fully aborted in this case)

Definition at line 75 of file uacpi.h.

◆ UACPI_FLAG_BAD_TBL_SIGNATURE_FATAL

#define UACPI_FLAG_BAD_TBL_SIGNATURE_FATAL   (1ull << 1)

Unexpected table signature should be considered a fatal error (table load is fully aborted in this case)

Definition at line 81 of file uacpi.h.

◆ UACPI_FLAG_BAD_XSDT

#define UACPI_FLAG_BAD_XSDT   (1ull << 2)

Force uACPI to use RSDT even for later revisions

Definition at line 86 of file uacpi.h.

◆ UACPI_FLAG_NO_ACPI_MODE

#define UACPI_FLAG_NO_ACPI_MODE   (1ull << 3)

If this is set, ACPI mode is not entered during the call to uacpi_initialize. The caller is expected to enter it later at their own discretion by using uacpi_enter_acpi_mode().

Definition at line 93 of file uacpi.h.

◆ UACPI_FLAG_NO_OSI

#define UACPI_FLAG_NO_OSI   (1ull << 4)

Don't create the _OSI method when building the namespace. Only enable this if you're certain that having this method breaks your AML blob, a more atomic/granular interface management is available via osi.h

Definition at line 100 of file uacpi.h.

◆ UACPI_FLAG_PROACTIVE_TBL_CSUM

#define UACPI_FLAG_PROACTIVE_TBL_CSUM   (1ull << 5)

Validate table checksums 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 107 of file uacpi.h.

◆ UACPI_MAJOR

#define UACPI_MAJOR   7

Definition at line 8 of file uacpi.h.

◆ UACPI_MINOR

#define UACPI_MINOR   0

Definition at line 9 of file uacpi.h.

◆ UACPI_PATCH

#define UACPI_PATCH   0

Definition at line 10 of file uacpi.h.

◆ UACPI_STUB_IF_REDUCED_HARDWARE

#define UACPI_STUB_IF_REDUCED_HARDWARE (   fn)    fn;

Definition at line 26 of file uacpi.h.

Function Documentation

◆ UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE()

UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE ( uacpi_status   uacpi_enter_acpi_modevoid)

Helpers for entering & leaving ACPI mode. Note that ACPI mode is entered automatically during the call to uacpi_initialize(). Attempt to acquire the global lock for 'timeout' milliseconds. 0xFFFF implies infinite wait.

On success, 'out_seq' is set to a unique sequence number for the current acquire transaction. This number is used for validation during release.

◆ 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
#define uacpi_unlikely(expr)
Definition: compiler.h:88
#define UACPI_NULL
Definition: types.h:33
#define uacpi_unlikely_error(expr)
Definition: status.h:50
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
@ UACPI_OBJECT_METHOD
Definition: types.h:119
@ UACPI_OBJECT_UNINITIALIZED
Definition: types.h:111
void uacpi_object_unref(uacpi_object *obj)
Definition: types.c:761
return ret
Definition: mutex.c:147
r parent
Definition: btrfs.c:3010
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
Definition: dlist.c:348

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_STATUS_OK
Definition: status.h:11
@ 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_status uacpi_eval(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **out_obj)
Definition: uacpi.c:721

◆ 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
uacpi_object_type
Definition: types.h:110
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}
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
@ UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED
Definition: types.h:72
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:18

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
#define UACPI_DEFAULT_MAX_CALL_STACK_DEPTH
Definition: config.h:48
#define UACPI_DEFAULT_LOOP_TIMEOUT_SECONDS
Definition: config.h:39
@ 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}
static uacpi_bool uacpi_is_hardware_reduced(void)
Definition: context.h:100
@ UACPI_STATUS_INIT_LEVEL_MISMATCH
Definition: status.h:23
uacpi_bool uacpi_table_subsystem_available(void)

◆ 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_trace(...)
Definition: log.h:33
#define uacpi_info(...)
Definition: log.h:34
uacpi_namespace_node * uacpi_namespace_get_predefined(uacpi_predefined_namespace)
Definition: namespace.c:269
#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
uint64_t uacpi_u64
Definition: types.h:22
#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 void ini_eval(struct ns_init_context *ctx, uacpi_namespace_node *node)
Definition: uacpi.c:547
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
#define uacpi_error(...)
Definition: log.h:36
@ UACPI_LOG_ERROR
Definition: log.h:35
@ UACPI_LOG_WARN
Definition: log.h:29
size_t uacpi_size
Definition: types.h:37
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
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
const uacpi_char * uacpi_status_to_string(uacpi_status st)
Definition: uacpi.c:61

◆ uacpi_release_global_lock()

uacpi_status uacpi_release_global_lock ( uacpi_u32  seq)

Definition at line 176 of file mutex.c.

177{
179
180 if (uacpi_unlikely(!g_uacpi_rt_ctx.global_lock_acquired ||
181 seq != g_uacpi_rt_ctx.global_lock_seq_num))
183
184 g_uacpi_rt_ctx.global_lock_acquired = UACPI_FALSE;
186 uacpi_release_native_mutex(g_uacpi_rt_ctx.global_lock_mutex->handle);
187
188 return UACPI_STATUS_OK;
189}
static uacpi_status uacpi_release_native_mutex(uacpi_handle mtx)
Definition: mutex.h:44
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:18
#define UACPI_FALSE
Definition: types.h:30
static void uacpi_release_global_lock_to_firmware(void)
Definition: mutex.c:106

◆ uacpi_setup_early_table_access()

uacpi_status uacpi_setup_early_table_access ( void *  temporary_buffer,
uacpi_size  buffer_size 
)

Set up early access to the table subsystem. What this means is:

  • uacpi_table_find() and similar API becomes usable before the call to uacpi_initialize().
  • No kernel API besides logging and map/unmap will be invoked at this stage, allowing for heap and scheduling to still be fully offline.
  • The provided 'temporary_buffer' will be used as a temporary storage for the internal metadata about the tables (list, reference count, addresses, sizes, etc).
  • The 'temporary_buffer' is replaced with a normal heap buffer allocated via uacpi_kernel_alloc() after the call to uacpi_initialize() and can therefore be reclaimed by the kernel.

The 'temporary_buffer' is expected to be aligned on the native pointer size boundary (4 on a 32-bit system, 8 on a 64-bit system), although any misalignment is handled gracefully and does not result in an error.

The approximate overhead per table is 56 bytes, so a buffer of 4096 bytes yields about 73 tables in terms of capacity. uACPI also has an internal static buffer for tables, "UACPI_STATIC_TABLE_ARRAY_LEN", which is configured as 16 descriptors in length by default.

This function is used to initialize the barebones mode, see UACPI_BAREBONES_MODE in config.h for more information.

Definition at line 216 of file tables.c.

219{
221 uacpi_virt_addr buffer_addr, aligned_buffer_addr;
222
223#ifndef UACPI_BAREBONES_MODE
225#endif
226 if (uacpi_unlikely(early_table_access))
228
230
232 aligned_buffer_addr = UACPI_ALIGN_UP(
233 buffer_addr, UACPI_POINTER_SIZE, uacpi_virt_addr
234 );
235 if (buffer_addr != aligned_buffer_addr) {
236 uacpi_size stripped_bytes;
237
238 stripped_bytes = aligned_buffer_addr - buffer_addr;
240 "fixed up misaligned early tables buffer (%zu bytes stripped)",
241 stripped_bytes
242 );
243
244 buffer_size -= UACPI_MIN(stripped_bytes, buffer_size);
245 temporary_buffer = UACPI_VIRT_ADDR_TO_PTR(aligned_buffer_addr);
246 }
247
250
251 tables.dynamic_storage = temporary_buffer;
252 tables.dynamic_capacity = buffer_size / sizeof(struct uacpi_installed_table);
253 early_table_access = UACPI_TRUE;
254
258
259 return ret;
260}
void uacpi_logger_initialize(void)
Definition: uacpi.c:37
#define uacpi_warn(...)
Definition: log.h:35
#define UACPI_ALIGN_UP(x, val, type)
Definition: stdlib.h:106
#define UACPI_MIN(x, y)
Definition: stdlib.h:102
uacpi_uintptr uacpi_virt_addr
Definition: types.h:36
#define UACPI_TRUE
Definition: types.h:29
void uacpi_deinitialize_tables(void)
Definition: tables.c:351
static uacpi_status initialize_from_rsdp(void)
Definition: tables.c:171
struct nls_table * tables
Definition: nls_base.c:22
#define UACPI_PTR_TO_VIRT_ADDR(ptr)
Definition: utilities.h:20
#define UACPI_VIRT_ADDR_TO_PTR(vaddr)
Definition: utilities.h:21
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95

◆ 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_table_subsystem_available()

uacpi_bool uacpi_table_subsystem_available ( void  )

Returns UACPI_TRUE if the table subsystem is available for use by the kernel. This happens after a successful call to either uacpi_initialize(...) or uacpi_setup_early_table_access(...).

Referenced by uacpi_is_platform_reduced_hardware().

Variable Documentation

◆ out_seq

uacpi_u32* out_seq

Definition at line 271 of file uacpi.h.

Referenced by uacpi_acquire_global_lock().