22 buffer.parentId = parentId;
31 if (current ==
NULL || current->parent ==
NULL)
50 while (current->parent !=
NULL)
75 root->name =
AML_NAME(
'\\',
'_',
'_',
'_');
105 while (overlay !=
NULL)
113 overlay = overlay->
parent;
155 for (
uint64_t i = 0; i < nameCount; i++)
177 if (nameString ==
NULL)
227 if (path ==
NULL || path[0] ==
'\0')
234 const char* p = path;
240 else if (p[0] ==
'^')
276 const char* segmentStart = p;
277 while (*p !=
'.' && *p !=
'\0')
282 uint64_t segmentLength = p - segmentStart;
290 for (
uint64_t i = 0; i < segmentLength; i++)
303 if (
next ==
NULL && segmentCount == 1 && *p ==
'\0')
305 while (current->parent !=
NULL)
355 while (currentOverlay !=
NULL)
362 currentOverlay = currentOverlay->
parent;
370 list_push(&parent->children, &object->siblingsEntry);
373 object->overlay = overlay;
432 list_remove(&object->overlay->objects, &object->listEntry);
433 list_remove(&object->parent->children, &object->siblingsEntry);
435 object->overlay =
NULL;
436 object->parent =
NULL;
437 object->flags &= ~AML_OBJECT_NAMED;
467 object->overlay = overlay->
parent;
523 if (overlay ==
NULL ||
object ==
NULL)
532 while (currentOverlay !=
NULL)
536 return currentOverlay;
539 currentOverlay = currentOverlay->
parent;
static aml_object_t * aml_namespace_search_single_name(aml_namespace_overlay_t *overlay, aml_object_t *current, aml_name_t name)
static aml_object_t * aml_namespace_traverse_parents(aml_object_t *current, uint64_t depth)
static map_key_t aml_object_map_key(aml_object_id_t parentId, aml_name_t name)
static aml_object_t * namespaceRoot
static aml_namespace_overlay_t globalOverlay
#define assert(expression)
aml_object_t * aml_namespace_find(aml_namespace_overlay_t *overlay, aml_object_t *start, uint64_t nameCount,...)
Find an object in the namespace heirarchy by name segments.
aml_object_t * aml_namespace_find_by_name_string(aml_namespace_overlay_t *overlay, aml_object_t *start, const aml_name_string_t *nameString)
Find an object in the namespace heirarchy by a name string.
uint64_t aml_namespace_commit(aml_namespace_overlay_t *overlay)
Commit all names in a namespace overlay to the global namespace heirarchy.
uint64_t aml_namespace_init(aml_object_t *root)
Initialize the namespace heirarchy.
uint64_t aml_namespace_add_child(aml_namespace_overlay_t *overlay, aml_object_t *parent, aml_name_t name, aml_object_t *object)
Add an child to a parent in the namespace heirarchy.
void aml_namespace_overlay_set_parent(aml_namespace_overlay_t *overlay, aml_namespace_overlay_t *parent)
Set the parent of a namespace overlay.
#define AML_NAME_UNDEFINED
Macro for an undefined name.
aml_object_t * aml_namespace_find_child(aml_namespace_overlay_t *overlay, aml_object_t *parent, aml_name_t name)
Find a child object directly under a parent object in the namespace heirarchy.
uint64_t aml_namespace_expose(void)
Expose the entire namespace heirarchy to sysfs.
aml_object_t * aml_namespace_find_by_path(aml_namespace_overlay_t *overlay, aml_object_t *start, const char *path)
Find an object in the namespace heirarchy by a path string.
aml_namespace_overlay_t * aml_namespace_overlay_get_highest_that_contains(aml_namespace_overlay_t *overlay, aml_object_t *object)
Search a overlay and its parents for the first overlay that contains the given object.
uint64_t aml_namespace_overlay_init(aml_namespace_overlay_t *overlay)
Initialize a namespace overlay.
#define AML_NAME(a, b, c, d)
Macro to create an aml_name_t from 4 characters.
void aml_namespace_remove(aml_object_t *object)
Remove an object from the namespace heirarchy it was added to.
void aml_namespace_overlay_deinit(aml_namespace_overlay_t *overlay)
Deinitialize a namespace overlay.
uint64_t aml_namespace_add_by_name_string(aml_namespace_overlay_t *overlay, aml_object_t *start, const aml_name_string_t *nameString, aml_object_t *object)
Add an object to the namespace heirarchy using a name string.
uint32_t aml_name_t
Name type.
aml_object_t * aml_namespace_get_root(void)
Get the root object of the namespace heirarchy.
aml_object_t * aml_alias_obj_traverse(aml_alias_obj_t *alias)
Traverse an alias object to get the target object.
#define AML_OBJECT_ID_NONE
Value for an invalid object id.
uint64_t aml_object_id_t
Object id type.
@ AML_ALIAS
Not in the spec, used internally to represent Aliases.
@ AML_OBJECT_ROOT
Is the root object.
@ AML_OBJECT_NAMED
Appears in the namespace tree. Will be set in aml_object_add().
#define PACKED
GCC packed attribute.
static map_key_t map_key_buffer(const void *buffer, uint64_t length)
Create a map key from a buffer.
void map_deinit(map_t *map)
Deinitialize a map.
uint64_t map_insert(map_t *map, const map_key_t *key, map_entry_t *value)
Insert a key-value pair into the map.
uint64_t map_init(map_t *map)
Initialize a map.
void map_remove(map_t *map, const map_key_t *key)
Remove a key-value pair from the map.
bool map_is_empty(const map_t *map)
Check if the map is empty.
map_entry_t * map_get(map_t *map, const map_key_t *key)
Get a value from the map by key.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define DEREF(ptr)
Decrement reference count.
#define ENOENT
No such file or directory.
#define EEXIST
File exists.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
#define LIST_FOR_EACH_SAFE(elem, temp, list, member)
Safely iterates over a list, allowing for element removal during iteration.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
static void list_push(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static bool list_is_empty(list_t *list)
Checks if a list is empty.
static void list_init(list_t *list)
Initializes a list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
EFI_PHYSICAL_ADDRESS buffer
#define va_start(ap, parmN)
__builtin_va_list va_list
aml_name_seg_t * segments
Array of segments in the name path.
uint64_t segmentCount
Number of segments in the name path.
aml_prefix_path_t prefixPath
struct aml_namespace_overlay * parent
The parent overlay, or NULL if none.
map_t map
Used to find the children of namespaces using their id and the name of the child.
list_t objects
List of all objects in this namespace. Used for fast iteration.
bool present
If the first character is a root character ('\'), if yes, the name string is absolute.