aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/acpi.c
diff options
context:
space:
mode:
authorMarvin Borner2020-09-06 15:45:48 +0200
committerMarvin Borner2020-09-06 15:45:48 +0200
commit2876d92663be7f1b46d72217e79b9f83d1756fd8 (patch)
tree2b31be5198b8081a032454acb9ef0909ef70a988 /kernel/drivers/acpi.c
parenta35b6b09b90da7180e3c1321abb313d581f9530c (diff)
ARGH structs
Diffstat (limited to 'kernel/drivers/acpi.c')
-rw-r--r--kernel/drivers/acpi.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/kernel/drivers/acpi.c b/kernel/drivers/acpi.c
index f7f643c..999c0ed 100644
--- a/kernel/drivers/acpi.c
+++ b/kernel/drivers/acpi.c
@@ -50,8 +50,12 @@ void *find_sdt(struct rsdt *rsdt, const char *signature)
for (int i = 0; i < entries; i++) {
struct sdt_header *header = (struct sdt_header *)rsdt->sdt_pointer[i];
- if (memcmp(header->signature, signature, 4) == 0)
- return header;
+ if (memcmp(header->signature, signature, 4) == 0) {
+ if (check_sdt(header))
+ return header;
+ else
+ break;
+ }
}
return NULL;
@@ -68,6 +72,18 @@ void acpi_install()
madt = find_sdt(rsdt, MADT_MAGIC);
fadt = find_sdt(rsdt, FADT_MAGIC);
hpet = find_sdt(rsdt, HPET_MAGIC);
- assert(madt && check_sdt(&madt->header) && fadt && check_sdt(&fadt->header) && hpet &&
- check_sdt(&hpet->header));
+}
+
+void hpet_install()
+{
+ if (hpet && hpet->legacy_replacement && hpet->comparator_count > 0) {
+ struct hpet_registers *r = (struct hpet_registers *)hpet->address.phys;
+ printf("HPET tick period: %dns\n", r->features.tick_period / 1000000);
+ printf("Periodic support: %d\n", r->timer.periodic_support);
+ r->config.enable = 1;
+ r->config.legacy_replacement = 1;
+ r->timer.enable = 1;
+ } else {
+ hpet = NULL;
+ }
}