Init IOAPIC nad LAPICs

This commit is contained in:
2025-08-21 00:47:58 +02:00
parent 3f6df79885
commit 9d8849a425
25 changed files with 801 additions and 306 deletions

View File

@ -1,24 +1,59 @@
#include <stddef.h>
#include <stdint.h>
#include "uacpi/uacpi.h"
#include "uacpi/utilities.h"
#include "hal/hal.h"
#include "kprintf.h"
#include "dlmalloc/malloc.h"
#include "compiler/attr.h"
#include "acpi.h"
#include "assert.h"
#include "util/util.h"
#include "bootinfo/bootinfo.h"
#include "uacpi/uacpi.h"
#define PREINIT_BUFFER_SIZE 0x1000
// uACPI
struct acpi_madt *MADT;
void uacpi_kernel_log(uacpi_log_level lvl, const uacpi_char *s) {
char *t = NULL;
switch (lvl) {
case UACPI_LOG_INFO: t = "Info"; break;
case UACPI_LOG_WARN: t = "Warn"; break;
case UACPI_LOG_DEBUG: t = "Dbg"; break;
case UACPI_LOG_ERROR: t = "Err"; break;
case UACPI_LOG_TRACE: t = "Trc"; break;
}
LOG("uACPI", "%s %s", t, s);
}
void uacpi_kernel_unmap(void *addr, uacpi_size len) {
// .
}
void *uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len) {
return (void *)(BOOT_INFO.hhdm_off + addr);
}
uacpi_status uacpi_kernel_get_rsdp(uacpi_phys_addr *out) {
*out = BOOT_INFO.rsdp;
return UACPI_STATUS_OK;
}
void acpi_init(void) {
uacpi_status ret;
uacpi_status r;
void *preinit_buffer = dlmalloc(PREINIT_BUFFER_SIZE);
ret = uacpi_setup_early_table_access(preinit_buffer, PREINIT_BUFFER_SIZE);
if (uacpi_unlikely_error(ret)) {
ERR("acpi", "init err %s\n", uacpi_status_to_string(ret));
size_t tmpbufsize = 0x1000;
void *tmpbuf = dlmalloc(tmpbufsize);
if (tmpbuf == NULL) {
ERR("hal", "could not allocate uACPI tmp buf\n");
hal_hang();
}
r = uacpi_setup_early_table_access(tmpbuf, tmpbufsize);
if (uacpi_unlikely_error(r)) {
ERR("hal", "uACPI init early table failed\n");
hal_hang();
}
LOG("hal", "acpi init\n");
}
/* uint32_t acpi_remapirq(uint32_t irq) { */
/* } */