| 1 | #ifndef SYS__APIC_H__ |
| 2 | #define SYS__APIC_H__ |
| 3 | |
| 4 | #include <stddef.h> |
| 5 | #include <stdint.h> |
| 6 | #include <stdbool.h> |
| 7 | |
| 8 | struct madt; |
| 9 | |
| 10 | #define LAPIC_REG_ICR0 0x300 |
| 11 | #define LAPIC_REG_ICR1 0x310 |
| 12 | #define LAPIC_REG_SPURIOUS 0x0f0 |
| 13 | #define LAPIC_REG_EOI 0x0b0 |
| 14 | #define LAPIC_REG_ID 0x020 |
| 15 | |
| 16 | bool lapic_check(void); |
| 17 | void lapic_eoi(void); |
| 18 | uint32_t lapic_read(uint32_t reg); |
| 19 | void lapic_write(uint32_t reg, uint32_t data); |
| 20 | void lapic_icr_wait(void); |
| 21 | |
| 22 | bool x2apic_check(void); |
| 23 | bool x2apic_enable(void); |
| 24 | bool x2apic_disable(void); |
| 25 | uint64_t x2apic_read(uint32_t reg); |
| 26 | void x2apic_write(uint32_t reg, uint64_t data); |
| 27 | |
| 28 | void lapic_configure_bsp(void); |
| 29 | void lapic_prep_lint(struct madt *madt, uint32_t acpi_uid, bool x2apic); |
| 30 | void lapic_configure_handoff_state(void); |
| 31 | |
| 32 | void init_io_apics(void); |
| 33 | uint32_t io_apic_read(size_t io_apic, uint32_t reg); |
| 34 | void io_apic_write(size_t io_apic, uint32_t reg, uint32_t value); |
| 35 | uint32_t io_apic_gsi_count(size_t io_apic); |
| 36 | void io_apic_mask_all(bool mask_nmi_and_extint); |
| 37 | |
| 38 | #endif |