PatchworkOS
966e257
A non-POSIX operating system.
Theme:
Default
Round
Robot
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
7
typedef
struct
aml_unresolved
aml_unresolved_t
;
8
typedef
struct
aml_object
aml_object_t
;
9
typedef
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
*/
25
typedef
uint64_t
(*
aml_patch_up_resolve_callback_t
)(
aml_state_t
* state,
aml_object_t
* match,
aml_object_t
* unresolved);
26
27
/**
28
* @brief Entry in the global list of unresolved references.
29
* @struct aml_patch_up_entry_t
30
*/
31
typedef
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.
35
}
aml_patch_up_entry_t
;
36
37
/**
38
* @brief Initialize the patch-up system.
39
*
40
* @return On success, `0`. On failure, `ERR` and `errno` is set.
41
*/
42
uint64_t
aml_patch_up_init
(
void
);
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
*/
53
uint64_t
aml_patch_up_add_unresolved
(
aml_unresolved_t
* unresolved);
54
55
/**
56
* @brief Removes an unresolved reference from the global list.
57
*
58
* @param unresolved The unresolved object to remove.
59
*/
60
void
aml_patch_up_remove_unresolved
(
aml_unresolved_t
* unresolved);
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
*/
74
uint64_t
aml_patch_up_resolve_all
(
void
);
75
76
/**
77
* @brief Get the number of unresolved references in the global list.
78
*
79
* @return The number of unresolved references.
80
*/
81
uint64_t
aml_patch_up_unresolved_count
(
void
);
82
83
/** @} */
aml_patch_up_init
uint64_t aml_patch_up_init(void)
Initialize the patch-up system.
Definition
patch_up.c:15
aml_patch_up_unresolved_count
uint64_t aml_patch_up_unresolved_count(void)
Get the number of unresolved references in the global list.
Definition
patch_up.c:105
aml_patch_up_add_unresolved
uint64_t aml_patch_up_add_unresolved(aml_unresolved_t *unresolved)
Adds a unresolved reference to the global list.
Definition
patch_up.c:21
aml_patch_up_resolve_all
uint64_t aml_patch_up_resolve_all(void)
Attempts to resolve all unresolved references.
Definition
patch_up.c:60
aml_patch_up_remove_unresolved
void aml_patch_up_remove_unresolved(aml_unresolved_t *unresolved)
Removes an unresolved reference from the global list.
Definition
patch_up.c:41
aml_patch_up_resolve_callback_t
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
list.h
stdbool.h
stdint.h
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
aml_object_t
ACPI object.
Definition
object.h:447
aml_patch_up_entry_t
Entry in the global list of unresolved references.
Definition
patch_up.h:32
aml_patch_up_entry_t::unresolved
aml_unresolved_t * unresolved
The unresolved object.
Definition
patch_up.h:34
aml_patch_up_entry_t::entry
list_entry_t entry
List entry for the global list of unresolved references.
Definition
patch_up.h:33
aml_state_t
AML State.
Definition
state.h:25
aml_unresolved_t
Data for an unresolved object.
Definition
object.h:412
list_entry_t
A entry in a doubly linked list.
Definition
list.h:36
include
modules
acpi
aml
patch_up.h
Generated on Mon Dec 15 2025 21:55:53 for PatchworkOS by
1.9.8