PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
aml.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/sync/mutex.h>
8
9#include <stdint.h>
10
11/**
12 * @brief ACPI AML
13 * @defgroup modules_acpi_aml AML
14 * @ingroup modules_acpi
15 *
16 * ACPI AML is a procedural turing complete bytecode language used to describe the hardware configuration of a computer
17 * system. A hardware manufacturer creates the bytecode to describe their hardware, and we, as the kernel, parse it. The
18 * bytecode contains instructions that create namespaces and provide device information, but it does not output this
19 * data, it's not like JSON or similar, instead AML itself expects a series of functions (e.g., for creating device
20 * objects, namespaces, etc.) that it can call to directly create these structures.
21 *
22 * The parser works like a recursive descent parser. For example, according to the specification, the entire AML code
23 * block is defined as `AMLCode := DefBlockHeader TermList`, since we have already read the header, we then just call
24 * the `aml_term_list_read()` function. A termlist is defined as `TermList := Nothing | <termobj termlist>`, this is a
25 * recursive definition, which we could flatten to `termobj termobj termobj ... Nothing`. So we now call the
26 * `aml_term_obj_read()` function on each termobj. A termobj is defined as `TermObj := Object | StatementOpcode |
27 * ExpressionOpcode` we then determine if this TermObj is an Object, StatementOpcode, or ExpressionOpcode and continue
28 * down the chain until we finally have something to execute.
29 *
30 * This parsing structure makes the parser a more or less 1:1 replica of the specification, hopefully making it easier
31 * to understand and maintain. But, it does also result in some overhead and redundant parsing, potentially hurting
32 * performance, however i believe the benefits outweigh the costs.
33 *
34 * Throughout the documentation objects are frequently said to have a definition, a breakdown of how these
35 * definitions are read can be found in section 20.1 of the ACPI specification.
36 *
37 * @{
38 */
39
40/**
41 * @brief The current revision of the AML subsystem.
42 *
43 * This number as far as i can tell just needs to be larger than 2. But the ACPICA tests expect it to be greater or
44 * equal 0x20140114 and less then or equal 0x20500000. So we just use a date code. There is no need to update this.
45 */
46#define AML_CURRENT_REVISION 0x20251010
47
48/**
49 * @brief Initialize the AML subsystem.
50 *
51 * @return On success, `0`. On failure, `ERR`.
52 */
53uint64_t aml_init(void);
54
55/**
56 * @brief Get the mutex for the entire AML subsystem.
57 *
58 * Must be held when interacting with any AML data structures.
59 *
60 * @return mutex_t* A pointer to the mutex.
61 */
63
64/** @} */
uint64_t aml_init(void)
Initialize the AML subsystem.
Definition aml.c:107
mutex_t * aml_big_mutex_get(void)
Get the mutex for the entire AML subsystem.
Definition aml.c:179
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Mutex structure.
Definition mutex.h:41