aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/acpi.h
diff options
context:
space:
mode:
authorGravatar ornitorrincos 2026-08-18 12:15:05 +0200
committerGravatar ornitorrincos 2026-08-18 12:15:05 +0200
commit132d3236bb884433bf94e961f6d32264e0334aec (patch)
tree06638976b06f019ea4037175ff228f8271057c44 /kernel/acpi.h
Diffstat (limited to '')
-rw-r--r--kernel/acpi.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/kernel/acpi.h b/kernel/acpi.h
new file mode 100644
index 0000000..ec9eeaa
--- /dev/null
+++ b/kernel/acpi.h
@@ -0,0 +1,125 @@
+#pragma once
+
+#include <stdint.h>
+
+typedef struct __attribute__((packed))
+{
+ uint8_t signature[8];
+ uint8_t checksum;
+ uint8_t OEMID[6];
+ uint8_t revision;
+ uint32_t deprecated;
+ uint32_t length;
+ uint64_t xsdtaddress;
+ uint8_t extendedchecksum;
+ uint8_t reserved[3];
+} XSDP;
+
+typedef struct __attribute__((packed))
+{
+ uint8_t signature[4];
+ uint32_t length;
+ uint8_t revision;
+ uint8_t checksum;
+ uint8_t OEMID[6];
+ uint8_t OEMTableId[8];
+ uint32_t OEMRevision;
+ uint32_t creatorID;
+ uint32_t creatorrevision;
+} ACPISDTHeader;
+
+typedef struct __attribute__((packed))
+{
+ uint8_t siganture[4];
+ uint32_t length;
+ uint8_t revision;
+ uint8_t checksum;
+ uint8_t OEMID[6];
+ uint8_t OEMTableId[8];
+ uint32_t OEMRevision;
+ uint32_t creatorID;
+ uint32_t creatorrevision;
+
+ // APIC Fields
+ uint32_t l_ic_addr;
+ uint32_t flags;
+} APICHeader; // At 44 byte starts the variable part;
+
+typedef struct __attribute__((packed))
+{
+ uint8_t type;
+ uint8_t length;
+} APICEntry;
+
+typedef struct __attribute__((packed))
+{
+ uint8_t type;
+ uint8_t length;
+ uint8_t id;
+ uint8_t rsv;
+ uint32_t addr;
+ uint32_t si_base;
+} IOAPICTable;
+
+enum ACPI_TABLES
+{
+ APIC, // <- MADT
+ BGRT,
+ BERT,
+ CPEP,
+ DSDT,
+ ECDT,
+ EINJ,
+ ERST,
+ FACP, // <- FADT
+ FACS,
+ HEST,
+ MSCT,
+ MPST,
+ OEMx,
+ PMTT,
+ PSDT,
+ RASF,
+ RSDT,
+ SBST,
+ SLIT,
+ SRAT,
+ SSDT,
+ XSDT,
+ HPET,
+ NONE
+};
+
+enum APIC_TYPE
+{
+ LAPIC = 0,
+ IOAPIC = 1,
+ ISO = 2,
+ NMI_S = 3,
+ LAPIC_NMI = 4,
+ LAPIC_AO = 5,
+ IOSAPIC = 6,
+ LSAPIC = 7,
+ PIS = 8,
+ PLX2APIC = 9,
+ LX2APIC_NMI = 0xA,
+ GICC = 0xB,
+ GICD = 0xC,
+ GIC_MSI_FRAME = 0xD,
+ GICR = 0xE,
+ GIC_ITS = 0xF,
+ MP_WAKEUP = 0x10,
+ CORE_PIC = 0x11,
+ LIO_PIC = 0x12,
+ HT_PIC = 0x13,
+ EIO_PIC = 0x14,
+ MSI_PIC = 0x15,
+ BIO_PIC = 0x16,
+ LPC_PIC = 0x17,
+ RINTC = 0x18,
+ IMSIC = 0x19,
+ APLIC = 0x20,
+ PLIC = 0x21
+};
+
+void init_acpi(XSDP* xsdp);