refactor: add a async read/write variant to device ops, with allow async io to be...
[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 "fadt.h"
5 #include "madt.h"
6 #include "mcfg.h"
7 #include "sdt.h"
8
9 // * for quick conversion from a table name into ACPI favoured signature
10 // * use `echo <TableName> | xxd -eg4`
11
12 #define ACPI_RSDP_SIG_L 0x20445352 // 'RSD '
13 #define ACPI_RSDP_SIG_H 0x20525450 // 'PTR '
14
15 #define ACPI_MADT_SIG 0x43495041 // 'APIC'
16 #define ACPI_FADT_SIG 0x50434146 // 'FACP' Notice that it is not 'FADT'.
17
18 // 'MCFG' (Not part of ACPI standard. See PCI Firmware Spec.)
19 #define ACPI_MCFG_SIG 0x4746434d
20
21 typedef struct
22 {
23     u32_t signature_l;
24     u32_t signature_h;
25     u8_t chksum;
26     char oem_id[6];
27     // Revision
28     u8_t rev;
29     acpi_rsdt_t* rsdt;
30     u32_t length;
31     acpi_sdthdr_t* xsdt;
32     u8_t x_chksum;
33     char reserved[3]; // Reserved field
34 } __attribute__((packed)) acpi_rsdp_t;
35
36 /**
37  * @brief Main TOC of ACPI tables, provide hassle-free access of ACPI info.
38  *
39  */
40 typedef struct
41 {
42     // Make it as null terminated
43     char oem_id[7];
44     acpi_madt_toc_t madt;
45     acpi_fadt_t fadt;
46     struct acpi_mcfg_toc mcfg;
47 } acpi_context;
48
49 acpi_context*
50 acpi_get_context();
51
52 u8_t
53 acpi_gsimap(u8_t old_irq);
54
55 #endif /* __LUNAIX_ACPI_ACPI_H */