PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
patch_up.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5#include <sys/list.h>
6
7typedef struct aml_unresolved aml_unresolved_t;
8typedef struct aml_object aml_object_t;
9typedef struct aml_state aml_state_t;
10
11/**
12 * @brief Patch-up system for forward references.
13 * @defgroup modules_acpi_aml_patch_up Patch-up
14 * @ingroup modules_acpi_aml
15 *
16 * @{
17 */
18
19/**
20 * @brief Callback type for resolving a forward reference.
21 *
22 * Takes the now matched object and the previously unresolved object as parameters. The callback should patch
23 * the unresolved object in whatever way it wants, for example performing type conversion or similar.
24 */
26
27/**
28 * @brief Entry in the global list of unresolved references.
29 * @struct aml_patch_up_entry_t
30 */
31typedef struct aml_patch_up_entry
32{
33 list_entry_t entry; ///< List entry for the global list of unresolved references.
34 aml_unresolved_t* unresolved; ///< The unresolved object.
36
37/**
38 * @brief Initialize the patch-up system.
39 *
40 * @return On success, `0`. On failure, `ERR` and `errno` is set.
41 */
43
44/**
45 * @brief Adds a unresolved reference to the global list.
46 *
47 * Does not take a reference to `unresolved`, unresolved objects will remove themselves from the list when they are
48 * freed.
49 *
50 * @param unresolved The unresolved object to add, must be of type `AML_UNRESOLVED`.
51 * @return On success, `0`. On failure, `ERR` and `errno` is set.
52 */
54
55/**
56 * @brief Removes an unresolved reference from the global list.
57 *
58 * @param unresolved The unresolved object to remove.
59 */
61
62/**
63 * @brief Attempts to resolve all unresolved references.
64 *
65 * @todo I am still not sure when would be the best time to call this function, for now its called after the DSDT and
66 * all SSDTs have been loaded, i am quite sure that we will end up getting issues with unresolved references due to
67 * this, but instead of trying to solve that now, we will just fix it as issues arise.
68 *
69 * Note that a failure to resolve a object is not considered an error, the function will just continue
70 * to the next unresolved reference.
71 *
72 * @return On success, `0`. On failure, `ERR` and `errno` is set.
73 */
75
76/**
77 * @brief Get the number of unresolved references in the global list.
78 *
79 * @return The number of unresolved references.
80 */
82
83/** @} */
uint64_t aml_patch_up_init(void)
Initialize the patch-up system.
Definition patch_up.c:15
uint64_t aml_patch_up_unresolved_count(void)
Get the number of unresolved references in the global list.
Definition patch_up.c:105
uint64_t aml_patch_up_add_unresolved(aml_unresolved_t *unresolved)
Adds a unresolved reference to the global list.
Definition patch_up.c:21
uint64_t aml_patch_up_resolve_all(void)
Attempts to resolve all unresolved references.
Definition patch_up.c:60
void aml_patch_up_remove_unresolved(aml_unresolved_t *unresolved)
Removes an unresolved reference from the global list.
Definition patch_up.c:41
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.
Definition patch_up.h:25
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
ACPI object.
Definition object.h:447
Entry in the global list of unresolved references.
Definition patch_up.h:32
aml_unresolved_t * unresolved
The unresolved object.
Definition patch_up.h:34
list_entry_t entry
List entry for the global list of unresolved references.
Definition patch_up.h:33
AML State.
Definition state.h:25
Data for an unresolved object.
Definition object.h:412
A entry in a doubly linked list.
Definition list.h:36