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 | |
parent | 54d848127e2026b710463508b1e6ca89c2b4b068 (diff) |
Added RSDT sum check
-rw-r--r-- | src/kernel/acpi/acpi.c | 49 | ||||
-rw-r--r-- | src/kernel/cmos/rtc.c | 2 |
2 files changed, 27 insertions, 24 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 { diff --git a/src/kernel/cmos/rtc.c b/src/kernel/cmos/rtc.c index c995be2..734c18a 100644 --- a/src/kernel/cmos/rtc.c +++ b/src/kernel/cmos/rtc.c @@ -8,7 +8,7 @@ uint8_t minute; uint8_t hour; uint8_t day; uint8_t month; -unsigned int year; +uint32_t year; int get_update_in_progress_flag() { |