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

Go to the source code of this file.

Macros

#define UACPI_MAX_DEPTH_ANY   0xFFFFFFFF
 

Typedefs

typedef struct uacpi_namespace_node uacpi_namespace_node
 
typedef enum uacpi_predefined_namespace uacpi_predefined_namespace
 
typedef uacpi_iteration_decision(* uacpi_iteration_callback) (void *user, uacpi_namespace_node *node, uacpi_u32 node_depth)
 

Enumerations

enum  uacpi_predefined_namespace {
  UACPI_PREDEFINED_NAMESPACE_ROOT = 0 , UACPI_PREDEFINED_NAMESPACE_GPE , UACPI_PREDEFINED_NAMESPACE_PR , UACPI_PREDEFINED_NAMESPACE_SB ,
  UACPI_PREDEFINED_NAMESPACE_SI , UACPI_PREDEFINED_NAMESPACE_TZ , UACPI_PREDEFINED_NAMESPACE_GL , UACPI_PREDEFINED_NAMESPACE_OS ,
  UACPI_PREDEFINED_NAMESPACE_OSI , UACPI_PREDEFINED_NAMESPACE_REV , UACPI_PREDEFINED_NAMESPACE_MAX = UACPI_PREDEFINED_NAMESPACE_REV
}
 

Functions

uacpi_namespace_node * uacpi_namespace_root (void)
 
uacpi_namespace_node * uacpi_namespace_get_predefined (uacpi_predefined_namespace)
 
uacpi_bool uacpi_namespace_node_is_alias (uacpi_namespace_node *node)
 
uacpi_object_name uacpi_namespace_node_name (const uacpi_namespace_node *node)
 
uacpi_status uacpi_namespace_node_type (const uacpi_namespace_node *node, uacpi_object_type *out_type)
 
uacpi_status uacpi_namespace_node_is (const uacpi_namespace_node *node, uacpi_object_type type, uacpi_bool *out)
 
uacpi_status uacpi_namespace_node_is_one_of (const uacpi_namespace_node *node, uacpi_object_type_bits type_mask, uacpi_bool *out)
 
uacpi_size uacpi_namespace_node_depth (const uacpi_namespace_node *node)
 
uacpi_namespace_node * uacpi_namespace_node_parent (uacpi_namespace_node *node)
 
uacpi_status uacpi_namespace_node_find (uacpi_namespace_node *parent, const uacpi_char *path, uacpi_namespace_node **out_node)
 
uacpi_status uacpi_namespace_node_resolve_from_aml_namepath (uacpi_namespace_node *scope, const uacpi_char *path, uacpi_namespace_node **out_node)
 
uacpi_status uacpi_namespace_for_each_child_simple (uacpi_namespace_node *parent, uacpi_iteration_callback callback, void *user)
 
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)
 
uacpi_status uacpi_namespace_node_next (uacpi_namespace_node *parent, uacpi_namespace_node **iter)
 
uacpi_status uacpi_namespace_node_next_typed (uacpi_namespace_node *parent, uacpi_namespace_node **iter, uacpi_object_type_bits type_mask)
 
const uacpi_char * uacpi_namespace_node_generate_absolute_path (const uacpi_namespace_node *node)
 
void uacpi_free_absolute_path (const uacpi_char *path)
 

Macro Definition Documentation

◆ UACPI_MAX_DEPTH_ANY

#define UACPI_MAX_DEPTH_ANY   0xFFFFFFFF

Definition at line 102 of file namespace.h.

Typedef Documentation

◆ uacpi_iteration_callback

typedef uacpi_iteration_decision(* uacpi_iteration_callback) (void *user, uacpi_namespace_node *node, uacpi_u32 node_depth)

Definition at line 98 of file namespace.h.

◆ uacpi_namespace_node

Definition at line 12 of file namespace.h.

◆ uacpi_predefined_namespace

Enumeration Type Documentation

◆ uacpi_predefined_namespace

Enumerator
UACPI_PREDEFINED_NAMESPACE_ROOT 
UACPI_PREDEFINED_NAMESPACE_GPE 
UACPI_PREDEFINED_NAMESPACE_PR 
UACPI_PREDEFINED_NAMESPACE_SB 
UACPI_PREDEFINED_NAMESPACE_SI 
UACPI_PREDEFINED_NAMESPACE_TZ 
UACPI_PREDEFINED_NAMESPACE_GL 
UACPI_PREDEFINED_NAMESPACE_OS 
UACPI_PREDEFINED_NAMESPACE_OSI 
UACPI_PREDEFINED_NAMESPACE_REV 
UACPI_PREDEFINED_NAMESPACE_MAX 

Definition at line 16 of file namespace.h.

16 {
uacpi_predefined_namespace
Definition: namespace.h:16
@ UACPI_PREDEFINED_NAMESPACE_GPE
Definition: namespace.h:18
@ UACPI_PREDEFINED_NAMESPACE_PR
Definition: namespace.h:19
@ UACPI_PREDEFINED_NAMESPACE_REV
Definition: namespace.h:26
@ UACPI_PREDEFINED_NAMESPACE_MAX
Definition: namespace.h:27
@ UACPI_PREDEFINED_NAMESPACE_ROOT
Definition: namespace.h:17
@ UACPI_PREDEFINED_NAMESPACE_OSI
Definition: namespace.h:25
@ UACPI_PREDEFINED_NAMESPACE_SB
Definition: namespace.h:20
@ UACPI_PREDEFINED_NAMESPACE_SI
Definition: namespace.h:21
@ UACPI_PREDEFINED_NAMESPACE_GL
Definition: namespace.h:23
@ UACPI_PREDEFINED_NAMESPACE_TZ
Definition: namespace.h:22
@ UACPI_PREDEFINED_NAMESPACE_OS
Definition: namespace.h:24

Function Documentation

◆ uacpi_free_absolute_path()

void uacpi_free_absolute_path ( const uacpi_char *  path)

Definition at line 1093 of file namespace.c.

1094{
1096}
void uacpi_free_dynamic_string(const uacpi_char *str)
Definition: utilities.c:1148

Referenced by exec_op().

◆ uacpi_namespace_for_each_child()

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 
)

Depth-first iterate the namespace starting at the first child of 'parent'.

'descending_callback' is invoked the first time a node is visited when walking down. 'ascending_callback' is invoked the second time a node is visited after we reach the leaf node without children and start walking up. Either of the callbacks may be NULL, but not both at the same time.

Only nodes matching 'type_mask' are passed to the callbacks.

'max_depth' is used to limit the maximum reachable depth from 'parent', where 1 is only direct children of 'parent', 2 is children of first-level children etc. Use UACPI_MAX_DEPTH_ANY or -1 to specify infinite depth.

Definition at line 955 of file namespace.c.

960{
962 parent, descending_callback, ascending_callback, type_mask, max_depth,
964 );
965}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
@ UACPI_PERMANENT_ONLY_YES
Definition: namespace.h:94
@ UACPI_SHOULD_LOCK_YES
Definition: namespace.h:99
uacpi_status uacpi_namespace_do_for_each_child(uacpi_namespace_node *node, uacpi_iteration_callback descending_callback, uacpi_iteration_callback ascending_callback, uacpi_object_type_bits type_mask, uacpi_u32 max_depth, enum uacpi_should_lock should_lock, enum uacpi_permanent_only permanent_only, void *user)
Definition: namespace.c:841
r parent
Definition: btrfs.c:3010

Referenced by uacpi_find_devices_at(), and uacpi_namespace_initialize().

◆ uacpi_namespace_for_each_child_simple()

uacpi_status uacpi_namespace_for_each_child_simple ( uacpi_namespace_node *  parent,
uacpi_iteration_callback  callback,
void *  user 
)

Depth-first iterate the namespace starting at the first child of 'parent'.

Definition at line 945 of file namespace.c.

948{
952 );
953}
#define UACPI_MAX_DEPTH_ANY
Definition: namespace.h:102
#define UACPI_NULL
Definition: types.h:33
@ UACPI_OBJECT_ANY_BIT
Definition: types.h:152
static IPrintDialogCallback callback
Definition: printdlg.c:325

◆ uacpi_namespace_get_predefined()

uacpi_namespace_node * uacpi_namespace_get_predefined ( uacpi_predefined_namespace  ns)

Definition at line 269 of file namespace.c.

272{
274 uacpi_warn("requested invalid predefined namespace %u", ns);
275 return UACPI_NULL;
276 }
277
278 return &predefined_namespaces[ns];
279}
#define uacpi_warn(...)
Definition: log.h:35
#define uacpi_unlikely(expr)
Definition: compiler.h:88
static uacpi_namespace_node predefined_namespaces[UACPI_PREDEFINED_NAMESPACE_MAX+1]
Definition: namespace.c:21
Definition: mxnamespace.c:38

Referenced by do_sta_ini(), eval_sst(), initialize_gpes(), sanitize_device_and_find_gpe(), and uacpi_namespace_initialize().

◆ uacpi_namespace_node_depth()

uacpi_size uacpi_namespace_node_depth ( const uacpi_namespace_node *  node)

Definition at line 1034 of file namespace.c.

1035{
1036 uacpi_size depth = 0;
1037
1038 while (node->parent) {
1039 depth++;
1040 node = node->parent;
1041 }
1042
1043 return depth;
1044}
size_t uacpi_size
Definition: types.h:37
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
Definition: dlist.c:348

Referenced by uacpi_namespace_node_generate_absolute_path().

◆ uacpi_namespace_node_find()

uacpi_status uacpi_namespace_node_find ( uacpi_namespace_node *  parent,
const uacpi_char *  path,
uacpi_namespace_node **  out_node 
)

Definition at line 630 of file namespace.c.

634{
638 );
639}
@ UACPI_MAY_SEARCH_ABOVE_PARENT_NO
Definition: namespace.h:88
uacpi_status uacpi_namespace_node_resolve(uacpi_namespace_node *parent, const uacpi_char *path, enum uacpi_should_lock should_lock, enum uacpi_may_search_above_parent may_search_above_parent, enum uacpi_permanent_only permanent_only, uacpi_namespace_node **out_node)
Definition: namespace.c:498

◆ uacpi_namespace_node_generate_absolute_path()

const uacpi_char * uacpi_namespace_node_generate_absolute_path ( const uacpi_namespace_node *  node)

Definition at line 1053 of file namespace.c.

1056{
1058 uacpi_size bytes_needed;
1060
1062
1063 // \ only needs 1 byte, the rest is 4 bytes
1064 bytes_needed = 1 + (depth - 1) * sizeof(uacpi_object_name);
1065
1066 // \ and the first NAME don't need a '.', every other segment does
1067 bytes_needed += depth > 2 ? depth - 2 : 0;
1068
1069 // Null terminator
1070 bytes_needed += 1;
1071
1072 path = uacpi_kernel_alloc(bytes_needed);
1074 return path;
1075
1076 path[0] = '\\';
1077
1078 offset = bytes_needed - 1;
1079 path[offset] = '\0';
1080
1081 while (node != uacpi_namespace_root()) {
1082 offset -= sizeof(uacpi_object_name);
1083 uacpi_memcpy(&path[offset], node->name.text, sizeof(uacpi_object_name));
1084
1085 node = node->parent;
1086 if (node != uacpi_namespace_root())
1087 path[--offset] = '.';
1088 }
1089
1090 return path;
1091}
#define uacpi_memcpy
Definition: stdlib.h:34
char uacpi_char
Definition: types.h:44
uacpi_size uacpi_namespace_node_depth(const uacpi_namespace_node *node)
Definition: namespace.c:1034
uacpi_namespace_node * uacpi_namespace_root(void)
Definition: namespace.c:264
GLintptr offset
Definition: glext.h:5920
void * uacpi_kernel_alloc(uacpi_size size)
Definition: uacpiosl.c:111

Referenced by exec_op(), handle_notify(), run_reg(), trace_invalid_return_type(), trace_method_abort(), trace_named_object_lookup_or_creation_failure(), trace_region_io(), uacpi_dispatch_opregion_io(), uacpi_eval_dstate_method_template(), and uacpi_trace_region_error().

◆ uacpi_namespace_node_is()

uacpi_status uacpi_namespace_node_is ( const uacpi_namespace_node *  node,
uacpi_object_type  type,
uacpi_bool *  out 
)

Returns UACPI_TRUE via 'out' if the type of the object stored at the namespace node matches the provided value, UACPI_FALSE otherwise.

NOTE: due to the existance of the CopyObject operator in AML, the return value of this function is subject to TOCTOU bugs.

Definition at line 832 of file namespace.c.

835{
837 node, 1u << type, out
838 );
839}
uacpi_status uacpi_namespace_node_is_one_of(const uacpi_namespace_node *node, uacpi_object_type_bits type_mask, uacpi_bool *out)
Definition: namespace.c:815
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by eval_resource_helper(), uacpi_install_gpe_block(), uacpi_setup_gpe_for_wake(), and uacpi_uninstall_gpe_block().

◆ uacpi_namespace_node_is_alias()

uacpi_bool uacpi_namespace_node_is_alias ( uacpi_namespace_node *  node)

Returns UACPI_TRUE if the provided 'node' is an alias.

Definition at line 335 of file namespace.c.

336{
338}
#define UACPI_NAMESPACE_NODE_FLAG_ALIAS
Definition: namespace.h:10

Referenced by do_sta_ini().

◆ uacpi_namespace_node_is_one_of()

uacpi_status uacpi_namespace_node_is_one_of ( const uacpi_namespace_node *  node,
uacpi_object_type_bits  type_mask,
uacpi_bool *  out 
)

Returns UACPI_TRUE via 'out' if the type of the object stored at the namespace node matches any of the type bits in the provided value, UACPI_FALSE otherwise.

NOTE: due to the existance of the CopyObject operator in AML, the return value of this function is subject to TOCTOU bugs.

Definition at line 815 of file namespace.c.

819{
821
824 return ret;
825
827
829 return ret;
830}
#define uacpi_unlikely_error(expr)
Definition: status.h:50
uacpi_status
Definition: status.h:10
return ret
Definition: mutex.c:147
uacpi_status uacpi_namespace_read_unlock(void)
Definition: namespace.c:41
uacpi_status uacpi_namespace_read_lock(void)
Definition: namespace.c:36
uacpi_status uacpi_namespace_node_is_one_of_unlocked(const uacpi_namespace_node *node, uacpi_object_type_bits type_mask, uacpi_bool *out)
Definition: namespace.c:797

Referenced by uacpi_namespace_node_is().

◆ uacpi_namespace_node_name()

uacpi_object_name uacpi_namespace_node_name ( const uacpi_namespace_node *  node)

Definition at line 759 of file namespace.c.

760{
761 return node->name;
762}

Referenced by async_run_gpe_handler(), uacpi_eval_cid(), uacpi_eval_hid(), uacpi_eval_uid(), and uacpi_get_namespace_node_info().

◆ uacpi_namespace_node_next()

uacpi_status uacpi_namespace_node_next ( uacpi_namespace_node *  parent,
uacpi_namespace_node **  iter 
)

Retrieve the next peer namespace node of '*iter', or, if '*iter' is UACPI_NULL, retrieve the first child of 'parent' instead. The resulting namespace node is stored at '*iter'.

This API can be used to implement an "iterator" version of the for_each_child helpers.

Example usage: void recurse(uacpi_namespace_node *parent) { uacpi_namespace_node *iter = UACPI_NULL;

while (uacpi_namespace_node_next(parent, &iter) == UACPI_STATUS_OK) { // Do something with iter... descending_callback(iter);

// Recurse down to walk over the children of iter recurse(iter); } }

Prefer the for_each_child family of helpers if possible instead of this API as they avoid recursion and/or the need to use dynamic data structures entirely.

Definition at line 1025 of file namespace.c.

1028{
1031 );
1032}
uacpi_status uacpi_namespace_node_next_typed(uacpi_namespace_node *parent, uacpi_namespace_node **iter, uacpi_object_type_bits type_mask)
Definition: namespace.c:1003

◆ uacpi_namespace_node_next_typed()

uacpi_status uacpi_namespace_node_next_typed ( uacpi_namespace_node *  parent,
uacpi_namespace_node **  iter,
uacpi_object_type_bits  type_mask 
)

Retrieve the next peer namespace node of '*iter', or, if '*iter' is UACPI_NULL, retrieve the first child of 'parent' instead. The resulting namespace node is stored at '*iter'. Only nodes which type matches one of the types set in 'type_mask' are returned.

See comment above 'uacpi_namespace_node_next' for usage examples.

Prefer the for_each_child family of helpers if possible instead of this API as they avoid recursion and/or the need to use dynamic data structures entirely.

Definition at line 1003 of file namespace.c.

1007{
1009
1011
1012 if (uacpi_unlikely(parent == UACPI_NULL && *iter == UACPI_NULL))
1014
1017 return ret;
1018
1020
1022 return ret;
1023}
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED
Definition: types.h:72
uacpi_status uacpi_namespace_node_next_typed_unlocked(uacpi_namespace_node *parent, uacpi_namespace_node **iter, uacpi_object_type_bits type_mask)
Definition: namespace.c:967

Referenced by uacpi_namespace_node_next().

◆ uacpi_namespace_node_parent()

uacpi_namespace_node * uacpi_namespace_node_parent ( uacpi_namespace_node *  node)

Definition at line 1046 of file namespace.c.

1049{
1050 return node->parent;
1051}

◆ uacpi_namespace_node_resolve_from_aml_namepath()

uacpi_status uacpi_namespace_node_resolve_from_aml_namepath ( uacpi_namespace_node *  scope,
const uacpi_char *  path,
uacpi_namespace_node **  out_node 
)

Same as uacpi_namespace_node_find, except the search recurses upwards when the namepath consists of only a single nameseg. Usually, this behavior is only desired if resolving a namepath specified in an aml-provided object, such as a package element.

Definition at line 641 of file namespace.c.

646{
650 );
651}
@ UACPI_MAY_SEARCH_ABOVE_PARENT_YES
Definition: namespace.h:89

Referenced by uacpi_object_resolve_as_aml_namepath().

◆ uacpi_namespace_node_type()

uacpi_status uacpi_namespace_node_type ( const uacpi_namespace_node *  node,
uacpi_object_type *  out_type 
)

Returns the type of object stored at the namespace node.

NOTE: due to the existance of the CopyObject operator in AML, the return value of this function is subject to TOCTOU bugs.

Definition at line 781 of file namespace.c.

784{
786
789 return ret;
790
792
794 return ret;
795}
uacpi_status uacpi_namespace_node_type_unlocked(const uacpi_namespace_node *node, uacpi_object_type *out_type)
Definition: namespace.c:764

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

◆ uacpi_namespace_root()