PatchworkOS
Loading...
Searching...
No Matches
tables.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/acpi/acpi.h>
4
23
37
99
103#define FADT_SIGNATURE "FACP"
104
111
112#define MADT_FLAG_PCAT_COMPAT ((madt_flags_t)(1 << 0))
113
120
121#define INTERRUPT_CONTROLLER_PROCESSOR_LOCAL_APIC ((interrupt_controller_type_t)0)
122#define INTERRUPT_CONTROLLER_IO_APIC ((interrupt_controller_type_t)1)
123
133
140
141#define PROCESSOR_LOCAL_APIC_ENABLED (1 << 0)
142#define PROCESSOR_LOCAL_APIC_ONLINE_CAPABLE (1 << 1)
143
157
172
186
193#define MADT_FOR_EACH(madt, ic) \
194 for (ic = (typeof(ic))madt->interruptControllers; (uint8_t*)ic < (uint8_t*)madt + madt->header.length && \
195 (uint8_t*)ic + sizeof(interrupt_controller_header_t) <= (uint8_t*)madt + madt->header.length && \
196 (uint8_t*)ic + ic->header.length <= (uint8_t*)madt + madt->header.length; \
197 ic = (typeof(ic))((uint8_t*)ic + ic->header.length))
198
202#define MADT_SIGNATURE "APIC"
203
210typedef struct PACKED
211{
213 uint8_t definitionBlock[];
214} dsdt_t;
215
219#define DSDT_SIGNATURE "DSDT"
220
227typedef struct PACKED
228{
230 uint8_t definitionBlock[];
231} ssdt_t;
232
238#define SSDT_SIGNATURE "SSDT"
239
246typedef struct
247{
248 const char* signature;
249 uint64_t (*init)(sdt_header_t* table);
251
263
274#define ACPI_SDT_HANDLER_REGISTER(sig, initHandler) \
275 static const acpi_sdt_handler_t _acpiSdtHandler##handler_name \
276 __attribute__((used, section(".acpi_sdt_handlers"))) = { \
277 .signature = sig, \
278 .init = initHandler, \
279 };
280
284void acpi_tables_init(rsdp_t* rsdp);
285
289void acpi_tables_expose(void);
290
298sdt_header_t* acpi_tables_lookup(const char* signature, uint64_t n);
299
fadt_boot_arch_flags_t
Enum for the fadt_t::bootArchFlags field.
Definition tables.h:20
uint32_t madt_flags_t
Multiple APIC Description Table flags.
Definition tables.h:110
void acpi_tables_init(rsdp_t *rsdp)
Initialize ACPI tables and call their init handlers.
Definition tables.c:216
uint32_t processor_local_apic_flags_t
MADT Processor Local APIC flags.
Definition tables.h:139
sdt_header_t * acpi_tables_lookup(const char *signature, uint64_t n)
Lookup the n'th table matching the signature.
Definition tables.c:281
void acpi_tables_expose(void)
Expose ACPI tables to sysfs.
Definition tables.c:246
uint8_t interrupt_controller_type_t
MADT Interrupt Controller Types.
Definition tables.h:119
@ FADT_BOOT_ARCH_PS2_EXISTS
Definition tables.h:21
#define PACKED
GCC packed attribute.
Definition defs.h:32
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
__UINT16_TYPE__ uint16_t
Definition stdint.h:13
Cached ACPI table.
Definition tables.h:259
sdt_header_t * table
Definition tables.h:260
dentry_t * file
The sysfs file representing the table.
Definition tables.h:261
ACPI System Description Table handler.
Definition tables.h:247
const char * signature
The signature of the table to handle.
Definition tables.h:248
Directory entry structure.
Definition dentry.h:83
Differentiated System Description Table.
Definition tables.h:211
sdt_header_t header
Definition tables.h:212
FADT generic Address.
Definition tables.h:30
uint8_t bitWidth
Definition tables.h:32
uint64_t address
Definition tables.h:35
uint8_t bitOffset
Definition tables.h:33
uint8_t addressSpace
Definition tables.h:31
uint8_t accessSize
Definition tables.h:34
Fixed ACPI Description Table.
Definition tables.h:45
uint32_t gpe0Block
Definition tables.h:63
uint16_t sciInterrupt
Definition tables.h:51
uint8_t preferredPowerManagementProfile
Definition tables.h:50
fadt_gas_t xPm2ControlBlock
Definition tables.h:94
uint8_t cStateControl
Definition tables.h:72
uint8_t gpe0Length
Definition tables.h:69
uint8_t reserved
Definition tables.h:49
uint32_t gpe1Block
Definition tables.h:64
fadt_gas_t xPm1aControlBlock
Definition tables.h:92
uint32_t pm1aControlBlock
Definition tables.h:59
uint8_t pm1EventLength
Definition tables.h:65
fadt_gas_t xGpe0Block
Definition tables.h:96
uint8_t pm1ControlLength
Definition tables.h:66
uint8_t pstateControl
Definition tables.h:56
uint32_t firmwareControl
Definition tables.h:47
uint8_t s4BiosReq
Definition tables.h:55
uint8_t gpe1Length
Definition tables.h:70
uint8_t dayAlarm
Definition tables.h:79
uint32_t pm2ControlBlock
Definition tables.h:61
uint32_t pmTimerBlock
Definition tables.h:62
uint32_t pm1bEventBlock
Definition tables.h:58
uint32_t flags
Definition tables.h:84
uint32_t pm1aEventBlock
Definition tables.h:57
uint8_t pm2ControlLength
Definition tables.h:67
uint8_t reserved2
Definition tables.h:83
uint8_t century
Definition tables.h:81
fadt_gas_t xPmTimerBlock
Definition tables.h:95
uint8_t acpiDisable
Definition tables.h:54
uint64_t xDsdt
Extended pointer to dsdt, should be used if dsdt is 0.
Definition tables.h:89
uint8_t gpe1Base
Definition tables.h:71
fadt_gas_t xPm1bEventBlock
Definition tables.h:91
uint16_t worstC2Latency
Definition tables.h:73
uint32_t dsdt
Definition tables.h:48
uint8_t pmTimerLength
Definition tables.h:68
uint32_t smiCommandPort
Definition tables.h:52
uint8_t acpiEnable
Definition tables.h:53
uint16_t bootArchFlags
Definition tables.h:82
fadt_gas_t xPm1aEventBlock
Definition tables.h:90
fadt_gas_t xPm1bControlBlock
Definition tables.h:93
uint8_t dutyOffset
Definition tables.h:77
uint32_t pm1bControlBlock
Definition tables.h:60
fadt_gas_t resetReg
Definition tables.h:85
uint16_t flushStride
Definition tables.h:76
uint64_t xFirmwareControl
Definition tables.h:88
uint16_t flushSize
Definition tables.h:75
sdt_header_t header
Definition tables.h:46
uint8_t dutyWidth
Definition tables.h:78
uint16_t worstC3Latency
Definition tables.h:74
uint8_t monthAlarm
Definition tables.h:80
fadt_gas_t xGpe1Block
Definition tables.h:97
uint8_t resetValue
Definition tables.h:86
interrupt_controller_type_t type
Definition tables.h:130
IO APIC.
Definition tables.h:165
uint32_t ioApicAddress
Definition tables.h:169
uint8_t ioApicId
Definition tables.h:167
uint32_t globalSystemInterruptBase
Definition tables.h:170
interrupt_controller_header_t header
Definition tables.h:166
uint8_t reserved
Definition tables.h:168
Multiple APIC Description Table.
Definition tables.h:180
madt_flags_t flags
Definition tables.h:183
sdt_header_t header
Definition tables.h:181
uint32_t localInterruptControllerAddress
Definition tables.h:182
Processor Local APIC.
Definition tables.h:151
interrupt_controller_header_t header
Definition tables.h:152
uint8_t acpiProcessorUid
Definition tables.h:153
Root System Description Pointer.
Definition acpi.h:114
System Description Table Header.
Definition acpi.h:90
Secondary System Description Table.
Definition tables.h:228
sdt_header_t header
Definition tables.h:229