44 lines
814 B
C++
44 lines
814 B
C++
#ifndef ARCH_ACPI_LOCAL_APIC_HPP_
|
|
#define ARCH_ACPI_LOCAL_APIC_HPP_
|
|
|
|
#include <socks/status.h>
|
|
#include <stdint.h>
|
|
|
|
#define APIC_LVT_INT_MASKED 0x10000
|
|
#define APIC_LVT_TIMER_MODE_PERIODIC 0x20000
|
|
|
|
struct acpi_madt;
|
|
|
|
namespace arch::acpi {
|
|
class local_apic {
|
|
uint32_t *base_ = nullptr;
|
|
|
|
public:
|
|
enum {
|
|
EOI = 0xB0,
|
|
IPI_STATUS = 0x280,
|
|
IPI_ICR = 0x300,
|
|
IPI_DEST = 0x310,
|
|
LVT_TIMER = 0x320,
|
|
TIMER_INITCOUNT = 0x380,
|
|
TIMER_CURCOUNT = 0x390,
|
|
TIMER_DIV = 0x3E0,
|
|
};
|
|
|
|
local_apic(uint32_t *base = nullptr);
|
|
|
|
static kern_status_t find(struct acpi_madt *madt, local_apic& out);
|
|
static local_apic& get(void);
|
|
|
|
uint32_t read(uint32_t reg);
|
|
void write(uint32_t reg, uint32_t val);
|
|
void ack();
|
|
|
|
uint32_t *ptr() const { return base_; }
|
|
|
|
void send_ipi(unsigned int dest, unsigned int data);
|
|
};
|
|
}
|
|
|
|
#endif
|