kernel: Implemented various features
+ lapic: Start implementation + ioapic: Start implementation + apic: Now properly working + madt: Start implementation + pit: Start implementation + smp: Start implementation (only grabs the bootstrap processor's LAPIC ID)
This commit is contained in:
parent
dcea7360d2
commit
b2cf9b4710
22 changed files with 520 additions and 79 deletions
|
@ -12,10 +12,41 @@
|
|||
#include <boot/limine.h>
|
||||
#include <lib/log.h>
|
||||
#include <mm/memop.h>
|
||||
#include <mm/pmm.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static bool __acpi_use_xsdt;
|
||||
static uint64_t __acpi_rsdt_addr;
|
||||
|
||||
void *acpi_find_table(char *sign) {
|
||||
if (__acpi_use_xsdt) {
|
||||
acpi_xsdt_t *xsdt = (acpi_xsdt_t*)__acpi_rsdt_addr;
|
||||
uint32_t entries = (xsdt->hdr.len - sizeof(xsdt->hdr)) / 8;
|
||||
|
||||
for (uint32_t i = 0; i < entries; i++)
|
||||
{
|
||||
acpi_sdt_hdr_t *h = (acpi_sdt_hdr_t *)higher_half(*((uint64_t*)xsdt->entries + i));
|
||||
if (!memcmp(h->sign, sign, 4))
|
||||
return (void *) h;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
acpi_rsdt_t *rsdt = (acpi_rsdt_t*)__acpi_rsdt_addr;
|
||||
int entries = (rsdt->hdr.len - sizeof(rsdt->hdr)) / 4;
|
||||
uint32_t *entries_hhalf = (uint32_t *)higher_half((uint64_t)rsdt->entries);
|
||||
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
acpi_sdt_hdr_t *h = (acpi_sdt_hdr_t *)(entries_hhalf[i] + (i * sizeof(uint32_t)));
|
||||
if (!memcmp(h->sign, sign, 4))
|
||||
return (void *) h;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void acpi_init() {
|
||||
acpi_rsdp_t *rsdp = (acpi_rsdp_t*)limine_get_rsdp();
|
||||
if (memcmp(rsdp->sign, "RSD PTR ", 8))
|
||||
|
@ -30,13 +61,13 @@ void acpi_init() {
|
|||
|
||||
acpi_xsdp_t *xsdp = (acpi_xsdp_t *)rsdp;
|
||||
__acpi_use_xsdt = 1;
|
||||
__acpi_rsdt_addr = xsdp->xsdt_addr;
|
||||
__acpi_rsdt_addr = higher_half(xsdp->xsdt_addr);
|
||||
|
||||
goto initialized;
|
||||
}
|
||||
|
||||
__acpi_use_xsdt = 0;
|
||||
__acpi_rsdt_addr = rsdp->rsdt_addr; // Do not use a pointer, to shut up the compiler.
|
||||
__acpi_rsdt_addr = higher_half(rsdp->rsdt_addr); // Do not use a pointer, to shut up the compiler.
|
||||
|
||||
initialized:
|
||||
trace("acpi: Initialized!\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue