ReactOS 0.4.17-dev-683-g0dafdc5
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_nodeuacpi_namespace_root (void)
 
uacpi_namespace_nodeuacpi_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_nodeuacpi_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_charuacpi_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 1074 of file namespace.c.

1075{
1077}
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 948 of file namespace.c.

953{
955 parent, descending_callback, ascending_callback, type_mask, max_depth,
957 );
958}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
@ UACPI_PERMANENT_ONLY_YES
Definition: namespace.h:90
@ UACPI_SHOULD_LOCK_YES
Definition: namespace.h:95
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:834
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 938 of file namespace.c.

941{
945 );
946}
#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:326

◆ 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 %d", 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 1015 of file namespace.c.

1016{
1017 uacpi_size depth = 0;
1018
1019 while (node->parent) {
1020 depth++;
1021 node = node->parent;
1022 }
1023
1024 return depth;
1025}
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 623 of file namespace.c.

627{
631 );
632}
@ UACPI_MAY_SEARCH_ABOVE_PARENT_NO
Definition: namespace.h:84
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:491

◆ uacpi_namespace_node_generate_absolute_path()

const uacpi_char * uacpi_namespace_node_generate_absolute_path ( const uacpi_namespace_node node)

Definition at line 1034 of file namespace.c.

1037{
1039 uacpi_size bytes_needed;
1041
1043
1044 // \ only needs 1 byte, the rest is 4 bytes
1045 bytes_needed = 1 + (depth - 1) * sizeof(uacpi_object_name);
1046
1047 // \ and the first NAME don't need a '.', every other segment does
1048 bytes_needed += depth > 2 ? depth - 2 : 0;
1049
1050 // Null terminator
1051 bytes_needed += 1;
1052
1053 path = uacpi_kernel_alloc(bytes_needed);
1055 return path;
1056
1057 path[0] = '\\';
1058
1059 offset = bytes_needed - 1;
1060 path[offset] = '\0';
1061
1062 while (node != uacpi_namespace_root()) {
1063 offset -= sizeof(uacpi_object_name);
1064 uacpi_memcpy(&path[offset], node->name.text, sizeof(uacpi_object_name));
1065
1066 node = node->parent;
1067 if (node != uacpi_namespace_root())
1068 path[--offset] = '.';
1069 }
1070
1071 return path;
1072}
#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:1015
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(), 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 825 of file namespace.c.

828{
830 node, 1u << type, out
831 );
832}
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:808
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 328 of file namespace.c.

329{
331}
#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 808 of file namespace.c.

812{
814
817 return ret;
818
820
822 return ret;
823}
#define uacpi_unlikely_error(expr)
Definition: status.h:49
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:790

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 752 of file namespace.c.

753{
754 return node->name;
755}

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 1006 of file namespace.c.

1009{
1012 );
1013}
uacpi_status uacpi_namespace_node_next_typed(uacpi_namespace_node *parent, uacpi_namespace_node **iter, uacpi_object_type_bits type_mask)
Definition: namespace.c:960

◆ 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 960 of file namespace.c.

964{
968
970
971 if (uacpi_unlikely(parent == UACPI_NULL && *iter == UACPI_NULL))
973
976 return ret;
977
978 node = *iter;
979 if (node == UACPI_NULL)
980 node = parent->child;
981 else
982 node = node->next;
983
984 for (; node != UACPI_NULL; node = node->next) {
986 continue;
987
989 node, type_mask, &is_one_of
990 );
992 break;
993 if (is_one_of)
994 break;
995 }
996
998 if (node == UACPI_NULL)
1000
1002 *iter = node;
1003 return ret;
1004}
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
bool uacpi_bool
Definition: types.h:31
#define uacpi_likely_success(expr)
Definition: status.h:53
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
@ UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED
Definition: types.h:72
uacpi_bool uacpi_namespace_node_is_temporary(uacpi_namespace_node *node)
Definition: namespace.c:338
static uacpi_bool is_one_of(uacpi_char c, const uacpi_char *list)
Definition: stdlib.c:436
void * next
Definition: dlist.c:360

Referenced by uacpi_namespace_node_next().

◆ uacpi_namespace_node_parent()

uacpi_namespace_node * uacpi_namespace_node_parent ( uacpi_namespace_node node)

Definition at line 1027 of file namespace.c.

1030{
1031 return node->parent;
1032}

◆ 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 634 of file namespace.c.

639{
643 );
644}
@ UACPI_MAY_SEARCH_ABOVE_PARENT_YES
Definition: namespace.h:85

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 774 of file namespace.c.

777{
779
782 return ret;
783
785
787 return ret;
788}
uacpi_status uacpi_namespace_node_type_unlocked(const uacpi_namespace_node *node, uacpi_object_type *out_type)
Definition: namespace.c:757

Referenced by do_sta_ini(), and pci_region_attach().

◆ uacpi_namespace_root()