git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: incorrect settings of msi registers.
[lunaix-os.git]
/
lunaix-os
/
hal
/
acpi
/
acpi.c
diff --git
a/lunaix-os/hal/acpi/acpi.c
b/lunaix-os/hal/acpi/acpi.c
index 47812197bf954cf70fde28aa67c2c4d1848c9504..0b1d9883b00ce7e381247696852ed0cb3913df2a 100644
(file)
--- a/
lunaix-os/hal/acpi/acpi.c
+++ b/
lunaix-os/hal/acpi/acpi.c
@@
-6,9
+6,9
@@
#include <klibc/string.h>
#include <klibc/string.h>
-#include "parser/
madt_
parser.h"
+#include "parser/parser.h"
-
acpi_context* toc
= NULL;
+
static acpi_context* ctx
= NULL;
LOG_MODULE("ACPI")
LOG_MODULE("ACPI")
@@
-26,46
+26,51
@@
acpi_init(multiboot_info_t* mb_info)
assert_msg(rsdp, "Fail to locate ACPI_RSDP");
assert_msg(acpi_rsdp_validate(rsdp), "Invalid ACPI_RSDP (checksum failed)");
assert_msg(rsdp, "Fail to locate ACPI_RSDP");
assert_msg(acpi_rsdp_validate(rsdp), "Invalid ACPI_RSDP (checksum failed)");
- kprintf(K
INFO
"RSDP found at %p, RSDT: %p\n", rsdp, rsdp->rsdt);
+ kprintf(K
DEBUG
"RSDP found at %p, RSDT: %p\n", rsdp, rsdp->rsdt);
acpi_rsdt_t* rsdt = rsdp->rsdt;
acpi_rsdt_t* rsdt = rsdp->rsdt;
-
toc
= lxcalloc(1, sizeof(acpi_context));
- assert_msg(
toc
, "Fail to create ACPI context");
+
ctx
= lxcalloc(1, sizeof(acpi_context));
+ assert_msg(
ctx
, "Fail to create ACPI context");
- strncpy(
toc
->oem_id, rsdt->header.oem_id, 6);
-
toc
->oem_id[6] = '\0';
+ strncpy(
ctx
->oem_id, rsdt->header.oem_id, 6);
+
ctx
->oem_id[6] = '\0';
size_t entry_n = (rsdt->header.length - sizeof(acpi_sdthdr_t)) >> 2;
for (size_t i = 0; i < entry_n; i++) {
acpi_sdthdr_t* sdthdr = ((acpi_apic_t**)&(rsdt->entry))[i];
switch (sdthdr->signature) {
case ACPI_MADT_SIG:
size_t entry_n = (rsdt->header.length - sizeof(acpi_sdthdr_t)) >> 2;
for (size_t i = 0; i < entry_n; i++) {
acpi_sdthdr_t* sdthdr = ((acpi_apic_t**)&(rsdt->entry))[i];
switch (sdthdr->signature) {
case ACPI_MADT_SIG:
- madt_parse((acpi_madt_t*)sdthdr, toc);
+ madt_parse((acpi_madt_t*)sdthdr, ctx);
+ break;
+ case ACPI_FADT_SIG:
+ // FADT just a plain structure, no need to parse.
+ ctx->fadt = *(acpi_fadt_t*)sdthdr;
+ break;
+ case ACPI_MCFG_SIG:
+ mcfg_parse(sdthdr, ctx);
break;
default:
break;
}
}
break;
default:
break;
}
}
- kprintf(KINFO "OEM: %s\n", toc->oem_id);
- kprintf(KINFO "IOAPIC address: %p\n", toc->madt.ioapic->ioapic_addr);
- kprintf(KINFO "APIC address: %p\n", toc->madt.apic_addr);
-
+ kprintf(KINFO "OEM: %s\n", ctx->oem_id);
+
for (size_t i = 0; i < 24; i++) {
for (size_t i = 0; i < 24; i++) {
- acpi_intso_t* intso =
toc
->madt.irq_exception[i];
+ acpi_intso_t* intso =
ctx
->madt.irq_exception[i];
if (!intso)
continue;
if (!intso)
continue;
- kprintf(K
INFO
"IRQ #%u -> GSI #%u\n", intso->source, intso->gsi);
+ kprintf(K
DEBUG
"IRQ #%u -> GSI #%u\n", intso->source, intso->gsi);
}
}
acpi_context*
acpi_get_context()
{
}
}
acpi_context*
acpi_get_context()
{
- assert_msg(
toc
, "ACPI is not initialized");
- return
toc
;
+ assert_msg(
ctx
, "ACPI is not initialized");
+ return
ctx
;
}
int
}
int
@@
-115,11
+120,12
@@
acpi_locate_rsdp(multiboot_info_t* mb_info)
#else
// You know what, I just search the entire 1MiB for Celestia's sake.
uint8_t* mem_start = 0x4000;
#else
// You know what, I just search the entire 1MiB for Celestia's sake.
uint8_t* mem_start = 0x4000;
- for (size_t j = 0; j < 0x100000; j += 16) {
- uint32_t sig_low = *((uint32_t*)(mem_start + j));
+ for (; mem_start < 0x100000; mem_start += 16) {
+ uint32_t sig_low = *((uint32_t*)(mem_start));
+ // XXX: do we need to compare this as well?
// uint32_t sig_high = *((uint32_t*)(mem_start+j) + 1);
if (sig_low == ACPI_RSDP_SIG_L) {
// uint32_t sig_high = *((uint32_t*)(mem_start+j) + 1);
if (sig_low == ACPI_RSDP_SIG_L) {
- rsdp = (acpi_rsdp_t*)(mem_start
+ j
);
+ rsdp = (acpi_rsdp_t*)(mem_start);
break;
}
}
break;
}
}