Add back the missing reserved field in FADT.
[lunaix-os.git] / lunaix-os / includes / hal / acpi / acpi.h
1 #ifndef __LUNAIX_ACPI_ACPI_H
2 #define __LUNAIX_ACPI_ACPI_H
3
4 #include <stdint.h>
5 #include <stddef.h>
6 #include <arch/x86/boot/multiboot.h>
7
8 #include "sdt.h"
9 #include "madt.h"
10 #include "fadt.h"
11
12 // * for quick conversion from a table name into ACPI favoured signature
13 // * use `echo <TableName> | xxd -eg4`
14
15 #define ACPI_RSDP_SIG_L       0x20445352      // 'RSD '
16 #define ACPI_RSDP_SIG_H      0x20525450       // 'PTR '
17
18 #define ACPI_MADT_SIG        0x43495041       // 'APIC'
19 #define ACPI_FADT_SIG        0x50434146       // 'FACP' Notice that it is not 'FADT'.
20
21 typedef struct {
22     uint32_t signature_l;
23     uint32_t signature_h;
24     uint8_t chksum;
25     char oem_id[6];
26     // Revision
27     uint8_t rev;
28     acpi_rsdt_t* rsdt;
29     uint32_t length;
30     acpi_sdthdr_t* xsdt;
31     uint8_t x_chksum;
32     char reserved[3];    // Reserved field
33 } __attribute__((packed)) acpi_rsdp_t;
34
35 /**
36  * @brief Main TOC of ACPI tables, provide hassle-free access of ACPI info.
37  * 
38  */
39 typedef struct
40 {
41     // Make it as null terminated
42     char oem_id[7];
43     acpi_madt_toc_t madt;
44     acpi_fadt_t fadt;
45 } acpi_context;
46
47 int
48 acpi_init(multiboot_info_t* mb_info);
49
50 acpi_context*
51 acpi_get_context();
52
53 #endif /* __LUNAIX_ACPI_ACPI_H */