PatchworkOS
Loading...
Searching...
No Matches
Patch-up

Patch-up system for forward references. More...

Data Structures

struct  aml_patch_up_entry_t
 Entry in the global list of unresolved references. More...
 

Typedefs

typedef uint64_t(* aml_patch_up_resolve_callback_t) (aml_state_t *state, aml_object_t *match, aml_object_t *unresolved)
 Callback type for resolving a forward reference.
 

Functions

uint64_t aml_patch_up_init (void)
 Initialize the patch-up system.
 
uint64_t aml_patch_up_add_unresolved (aml_unresolved_obj_t *unresolved)
 Adds a unresolved reference to the global list.
 
void aml_patch_up_remove_unresolved (aml_unresolved_obj_t *unresolved)
 Removes an unresolved reference from the global list.
 
uint64_t aml_patch_up_resolve_all (void)
 Attempts to resolve all unresolved references.
 
uint64_t aml_patch_up_unresolved_count (void)
 Get the number of unresolved references in the global list.
 

Detailed Description

Patch-up system for forward references.

Typedef Documentation

◆ aml_patch_up_resolve_callback_t

typedef uint64_t(* aml_patch_up_resolve_callback_t) (aml_state_t *state, aml_object_t *match, aml_object_t *unresolved)

Callback type for resolving a forward reference.

Takes the now matched object and the previously unresolved object as parameters. The callback should patch the unresolved object in whatever way it wants, for example performing type conversion or similar.

Definition at line 25 of file patch_up.h.

Function Documentation

◆ aml_patch_up_add_unresolved()

uint64_t aml_patch_up_add_unresolved ( aml_unresolved_obj_t unresolved)

Adds a unresolved reference to the global list.

Does not take a reference to unresolved, unresolved objects will remove themselves from the list when they are freed.

Parameters
unresolvedThe unresolved object to add, must be of type AML_UNRESOLVED.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 21 of file patch_up.c.

References EINVAL, aml_patch_up_entry_t::entry, ERR, errno, list_entry_init(), list_push(), malloc(), NULL, aml_patch_up_entry_t::unresolved, and unresolvedObjects.

Referenced by aml_unresolved_set().

◆ aml_patch_up_init()

uint64_t aml_patch_up_init ( void  )

Initialize the patch-up system.

Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 15 of file patch_up.c.

References list_init(), and unresolvedObjects.

Referenced by aml_init().

◆ aml_patch_up_remove_unresolved()

void aml_patch_up_remove_unresolved ( aml_unresolved_obj_t unresolved)

Removes an unresolved reference from the global list.

Parameters
unresolvedThe unresolved object to remove.

Definition at line 41 of file patch_up.c.

References aml_patch_up_entry_t::entry, free(), LIST_FOR_EACH, list_remove(), NULL, aml_patch_up_entry_t::unresolved, and unresolvedObjects.

Referenced by aml_object_clear().

◆ aml_patch_up_resolve_all()

uint64_t aml_patch_up_resolve_all ( void  )

Attempts to resolve all unresolved references.

TODO: I am still not sure when would be the best time to call this function, for now its called after the DSDT and all SSDTs have been loaded, i am quite sure that we will end up getting issues with unresolved references due to this, but instead of trying to solve that now, we will just fix it as issues arise.

Note that a failure to resolve a object is not considered an error, the function will just continue to the next unresolved reference.

Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 60 of file patch_up.c.

References aml_name_string_to_string(), aml_namespace_find_by_name_string(), aml_state_deinit(), aml_state_init(), AML_UNRESOLVED, aml_unresolved_obj_t::callback, CONTAINER_OF, EILSEQ, EOK, ERR, errno, aml_unresolved_obj_t::from, LIST_FOR_EACH_SAFE, LOG_DEBUG, LOG_ERR, LOG_PANIC, aml_unresolved_obj_t::nameString, NULL, aml_state_t::overlay, aml_patch_up_entry_t::unresolved, and unresolvedObjects.

Referenced by aml_init().

◆ aml_patch_up_unresolved_count()

uint64_t aml_patch_up_unresolved_count ( void  )

Get the number of unresolved references in the global list.

Returns
The number of unresolved references.

Definition at line 105 of file patch_up.c.

References list_length(), and unresolvedObjects.

Referenced by aml_init().