fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / includes / hal / acpi / madt.h
1 #ifndef __LUNAIX_ACPI_MADT_H
2 #define __LUNAIX_ACPI_MADT_H
3
4 #include "sdt.h"
5
6 #define ACPI_MADT_LAPIC 0x0  // Local APIC
7 #define ACPI_MADT_IOAPIC 0x1 // I/O APIC
8 #define ACPI_MADT_INTSO 0x2  // Interrupt Source Override
9
10 /**
11  * @brief ACPI Interrupt Controller Structure (ICS) Header
12  *
13  */
14 typedef struct
15 {
16     u8_t type;
17     u8_t length;
18 } ACPI_TABLE_PACKED acpi_ics_hdr_t;
19 #define __acpi_ics_hdr(acpi_ptr)   ((acpi_ics_hdr_t*)__ptr(acpi_ptr))
20
21 /**
22  * @brief ACPI Processor Local APIC Structure (PLAS)
23  * This structure tell information about our Local APIC per processor. Including
24  * the MMIO addr.
25  *
26  */
27 typedef struct
28 {
29     acpi_ics_hdr_t header;
30     u8_t processor_id;
31     u8_t apic_id;
32     u32_t flags;
33 } ACPI_TABLE_PACKED acpi_apic_t;
34 #define __acpi_apic(acpi_ptr)   ((acpi_apic_t*)__ptr(acpi_ptr))
35
36 /**
37  * @brief ACPI IO APIC Structure (IOAS)
38  *
39  * This structure tell information about our I/O APIC on motherboard. Including
40  * the MMIO addr.
41  *
42  */
43 typedef struct
44 {
45     acpi_ics_hdr_t header;
46     u8_t ioapic_id;
47     u8_t reserved;
48     u32_t ioapic_addr;
49     // The global system interrupt offset for this IOAPIC. (Kind of IRQ offset
50     // for a slave IOAPIC)
51     u32_t gis_offset;
52 } ACPI_TABLE_PACKED acpi_ioapic_t;
53 #define __acpi_ioapic(acpi_ptr)   ((acpi_ioapic_t*)__ptr(acpi_ptr))
54
55 /**
56  * @brief ACPI Interrupt Source Override (INTSO)
57  *
58  * According to the ACPI Spec, the IRQ config between APIC and 8259 PIC can be
59  * assumed to be identically mapped. However, some manufactures may have their
60  * own preference and hence expections may be introduced. This structure provide
61  * information on such exception.
62  *
63  */
64 typedef struct
65 {
66     acpi_ics_hdr_t header;
67     u8_t bus;
68     // source, which is the original IRQ back in the era of IBM PC/AT, the 8259
69     // PIC
70     u8_t source;
71     // global system interrupt. The override of source in APIC mode
72     u32_t gsi;
73     u16_t flags;
74 } ACPI_TABLE_PACKED acpi_intso_t;
75 #define __acpi_intso(acpi_ptr)   ((acpi_intso_t*)__ptr(acpi_ptr))
76
77 typedef struct
78 {
79     acpi_sdthdr_t header;
80     u32_t apic_addr;
81     u32_t flags;
82     // Here is a bunch of packed ICS reside here back-to-back.
83 } ACPI_TABLE_PACKED acpi_madt_t;
84 #define __acpi_madt(acpi_ptr)   ((acpi_madt_t*)__ptr(acpi_ptr))
85
86 typedef struct
87 {
88     u32_t apic_addr;
89     acpi_apic_t* apic;
90     acpi_ioapic_t* ioapic;
91     acpi_intso_t** irq_exception;
92 } ACPI_TABLE_PACKED acpi_madt_toc_t;
93
94 #endif /* __LUNAIX_ACPI_MADT_H */