aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/acpi.h
blob: ec9eeaa07840ed1fad42b0ca3f0f4ed4771fc258 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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);