diff options
author | Marvin Borner | 2020-04-18 18:27:43 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-18 18:27:43 +0200 |
commit | f943fad362a0e17f6e294341b32e49b9afd6e9d7 (patch) | |
tree | 8f7b669a8096c5b713d0a94e843320c06fe07d0e /src/kernel/acpi/acpi.c | |
parent | 54d848127e2026b710463508b1e6ca89c2b4b068 (diff) |
Added RSDT sum check
Diffstat (limited to 'src/kernel/acpi/acpi.c')
-rw-r--r-- | src/kernel/acpi/acpi.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/kernel/acpi/acpi.c b/src/kernel/acpi/acpi.c index d58e017..f826e19 100644 --- a/src/kernel/acpi/acpi.c +++ b/src/kernel/acpi/acpi.c @@ -37,29 +37,32 @@ void acpi_init(struct rsdp *rsdp) if (strncmp(rsdp->signature, "RSD PTR ", 8) == 0) { memcpy(rsdt, rsdp->rsdt_address, sizeof(struct rsdt) + 32); - - uint32_t *pointer = (uint32_t *)(rsdt + 1); - uint32_t *end = (uint32_t *)((uint8_t *)rsdt + rsdt->header.length); - - while (pointer < end) { - uint32_t address = *pointer++; - memcpy(header, (void *)address, sizeof(struct sdt_header)); - - if (strncmp(header->signature, "FACP", 4) == 0) { - info("Found FADT"); - memcpy(fadt, (void *)address, sizeof(struct fadt)); - if (!check_sum((struct sdt_header *)fadt)) - warn("Corrupted FADT!"); - } else if (strncmp(header->signature, "HPET", 4) == 0) { - info("Found HPET"); - memcpy(hpet, (void *)address, sizeof(struct hpet)); - if (!check_sum((struct sdt_header *)hpet)) - warn("Corrupted HPET!"); - } else if (strncmp(header->signature, "APIC", 4) == 0) { - info("Found MADT"); - memcpy(madt, (void *)address, sizeof(struct madt)); - if (!check_sum((struct sdt_header *)madt)) - warn("Corrupted MADT!"); // This is currently okay + if (!check_sum((struct sdt_header *)rsdt)) { + warn("Corrupted RSDT!"); + } else { + uint32_t *pointer = (uint32_t *)(rsdt + 1); + uint32_t *end = (uint32_t *)((uint8_t *)rsdt + rsdt->header.length); + + while (pointer < end) { + uint32_t address = *pointer++; + memcpy(header, (void *)address, sizeof(struct sdt_header)); + + if (strncmp(header->signature, "FACP", 4) == 0) { + info("Found FADT"); + memcpy(fadt, (void *)address, sizeof(struct fadt)); + if (!check_sum((struct sdt_header *)fadt)) + warn("Corrupted FADT!"); + } else if (strncmp(header->signature, "HPET", 4) == 0) { + info("Found HPET"); + memcpy(hpet, (void *)address, sizeof(struct hpet)); + if (!check_sum((struct sdt_header *)hpet)) + warn("Corrupted HPET!"); + } else if (strncmp(header->signature, "APIC", 4) == 0) { + info("Found MADT"); + memcpy(madt, (void *)address, sizeof(struct madt)); + if (!check_sum((struct sdt_header *)madt)) + warn("Corrupted MADT!"); + } } } } else { |