mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
kernel: change apic and acpi external functions to have arch_ before
This commit is contained in:
@@ -13,7 +13,7 @@ static volatile struct limine_rsdp_request rsdpreq = {
|
||||
.revision = 0
|
||||
};
|
||||
|
||||
bool acpi_checksumok(void *table) {
|
||||
bool arch_acpi_checksumok(void *table) {
|
||||
sdtheader_t *header = table;
|
||||
uint8_t *ptr = table;
|
||||
uint8_t sum = 0;
|
||||
@@ -23,7 +23,7 @@ bool acpi_checksumok(void *table) {
|
||||
return sum == 0;
|
||||
}
|
||||
|
||||
void *acpi_findtable(char *sig, int n) {
|
||||
void *arch_acpi_findtable(char *sig, int n) {
|
||||
for (size_t i = 0; i < headercount; ++i) {
|
||||
if (headers[i] == NULL)
|
||||
continue;
|
||||
@@ -36,7 +36,7 @@ void *acpi_findtable(char *sig, int n) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void acpi_init() {
|
||||
void arch_acpi_init() {
|
||||
// FIXME search if no response
|
||||
__assert(rsdpreq.response);
|
||||
rsdp_t *rsdp = rsdpreq.response->address;
|
||||
@@ -44,26 +44,26 @@ void acpi_init() {
|
||||
if (rsdp->revision == 0) {
|
||||
printf("\e[93mACPI version 1.0 -- Using RSDT instead of XSDT.\e[0m\n");
|
||||
rsdt_t *rsdt = MAKE_HHDM((rsdt_t *)(uint64_t)rsdp->rsdt);
|
||||
__assert(acpi_checksumok(rsdt));
|
||||
__assert(arch_acpi_checksumok(rsdt));
|
||||
headercount = (rsdt->header.length - sizeof(sdtheader_t)) / sizeof(uint32_t);
|
||||
headers = alloc(sizeof(sdtheader_t *) * headercount);
|
||||
__assert(headers);
|
||||
|
||||
for (size_t i = 0; i < headercount; ++i) {
|
||||
void *addr = MAKE_HHDM((void *)(uint64_t)rsdt->tables[i]);
|
||||
if (acpi_checksumok(addr))
|
||||
if (arch_acpi_checksumok(addr))
|
||||
headers[i] = addr;
|
||||
}
|
||||
} else {
|
||||
xsdt_t *xsdt = MAKE_HHDM((xsdt_t *)rsdp->xsdt);
|
||||
__assert(acpi_checksumok(xsdt));
|
||||
__assert(arch_acpi_checksumok(xsdt));
|
||||
headercount = (xsdt->header.length - sizeof(sdtheader_t)) / sizeof(uint64_t);
|
||||
headers = alloc(sizeof(sdtheader_t *) * headercount);
|
||||
__assert(headers);
|
||||
|
||||
for (size_t i = 0; i < headercount; ++i) {
|
||||
void *addr = MAKE_HHDM((void *)xsdt->tables[i]);
|
||||
if (acpi_checksumok(addr))
|
||||
if (arch_acpi_checksumok(addr))
|
||||
headers[i] = addr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,24 @@
|
||||
#define IOAPIC_REG_PRIORITY 2
|
||||
#define IOAPIC_REG_ENTRY 0x10
|
||||
|
||||
#define APIC_REG_ID 0x20
|
||||
#define APIC_REG_EOI 0xB0
|
||||
#define APIC_REG_SPURIOUS 0xF0
|
||||
#define APIC_REG_ICR_LO 0x300
|
||||
#define APIC_REG_ICR_HI 0x310
|
||||
#define APIC_LVT_TIMER 0x320
|
||||
#define APIC_LVT_THERMAL 0x330
|
||||
#define APIC_LVT_PERFORMANCE 0x340
|
||||
#define APIC_LVT_LINT0 0x350
|
||||
#define APIC_LVT_LINT1 0x360
|
||||
#define APIC_LVT_ERROR 0x370
|
||||
#define APIC_TIMER_INITIALCOUNT 0x380
|
||||
#define APIC_TIMER_COUNT 0x390
|
||||
#define APIC_TIMER_DIVIDE 0x3E0
|
||||
|
||||
#define LVT_DELIVERY_NMI (0b100 << 8)
|
||||
#define LVT_MASK (1 << 16)
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
@@ -100,8 +118,12 @@ static void writeiored(void *ioapic, uint8_t entry, uint8_t vector, uint8_t deli
|
||||
writeioapic(ioapic, 0x11 + entry * 2, (uint32_t)dest << 24);
|
||||
}
|
||||
|
||||
void apic_init() {
|
||||
madt = acpi_findtable("APIC", 0);
|
||||
void arch_apic_initap() {
|
||||
|
||||
}
|
||||
|
||||
void arch_apic_init() {
|
||||
madt = arch_acpi_findtable("APIC", 0);
|
||||
__assert(madt);
|
||||
|
||||
liststart = (void *)((uintptr_t)madt + sizeof(madt_t));
|
||||
|
||||
@@ -26,7 +26,7 @@ void kernel_entry() {
|
||||
arch_mmu_init();
|
||||
vmm_init();
|
||||
alloc_init();
|
||||
acpi_init();
|
||||
apic_init();
|
||||
arch_acpi_init();
|
||||
arch_apic_init();
|
||||
__assert(!"kernel entry end");
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ typedef struct {
|
||||
#define ACPI_MADT_TYPE_64BITADDR 5
|
||||
#define ACPI_MADT_TYPE_X2APIC 9
|
||||
|
||||
bool acpi_checksumok(void *table);
|
||||
void *acpi_findtable(char *sig, int n);
|
||||
void acpi_init();
|
||||
bool arch_acpi_checksumok(void *table);
|
||||
void *arch_acpi_findtable(char *sig, int n);
|
||||
void arch_acpi_init();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef _APIC_H
|
||||
#define _APIC_H
|
||||
|
||||
void apic_init();
|
||||
void arch_apic_init();
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user