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