refactor: make pci device driver loading passive, pci bus scanner will not load them...
[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 <stddef.h>
5 #include <stdint.h>
6
7 #include "fadt.h"
8 #include "madt.h"
9 #include "mcfg.h"
10 #include "sdt.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 // 'MCFG' (Not part of ACPI standard. See PCI Firmware Spec.)
22 #define ACPI_MCFG_SIG 0x4746434d
23
24 typedef struct
25 {
26     u32_t signature_l;
27     u32_t signature_h;
28     u8_t chksum;
29     char oem_id[6];
30     // Revision
31     u8_t rev;
32     acpi_rsdt_t* rsdt;
33     u32_t length;
34     acpi_sdthdr_t* xsdt;
35     u8_t x_chksum;
36     char reserved[3]; // Reserved field
37 } __attribute__((packed)) acpi_rsdp_t;
38
39 /**
40  * @brief Main TOC of ACPI tables, provide hassle-free access of ACPI info.
41  *
42  */
43 typedef struct
44 {
45     // Make it as null terminated
46     char oem_id[7];
47     acpi_madt_toc_t madt;
48     acpi_fadt_t fadt;
49     struct acpi_mcfg_toc mcfg;
50 } acpi_context;
51
52 acpi_context*
53 acpi_get_context();
54
55 u8_t
56 acpi_gsimap(u8_t old_irq);
57
58 #endif /* __LUNAIX_ACPI_ACPI_H */