aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-08-29 17:50:10 +0200
committerKevin O'Connor <kevin@koconnor.net>2011-09-02 18:04:04 -0400
commitb8a90f513ba83283ee2ac3961d6ce7ae731498d0 (patch)
tree308ed3ca7fcb00a6f4f6127ec04fd88f85b7437f
parent83012de1646d2d2156dbe2fe894fd2ca478c7ab5 (diff)
downloadseabios-b8a90f513ba83283ee2ac3961d6ce7ae731498d0.zip
seabios-b8a90f513ba83283ee2ac3961d6ce7ae731498d0.tar.gz
seabios-b8a90f513ba83283ee2ac3961d6ce7ae731498d0.tar.bz2
Probe HPET existence
QEMU does not provide a HPET block if it was configured with -no-hpet, other machines SeaBIOS runs on may lack a HPET as well. Perform basic checks the ID register for a reasonable vendor ID and a clock period within the valid range, do not build the HPET table if that fails. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
-rw-r--r--src/acpi.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/acpi.c b/src/acpi.c
index ea7b171..29160f4 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -158,6 +158,9 @@ struct acpi_20_hpet {
} PACKED;
#define ACPI_HPET_ADDRESS 0xFED00000UL
+#define HPET_ID 0x000
+#define HPET_PERIOD 0x004
+
/*
* SRAT (NUMA topology description) table
*/
@@ -464,7 +467,16 @@ build_ssdt(void)
static void*
build_hpet(void)
{
- struct acpi_20_hpet *hpet = malloc_high(sizeof(*hpet));
+ struct acpi_20_hpet *hpet;
+ const void *hpet_base = (void *)ACPI_HPET_ADDRESS;
+ u32 hpet_vendor = readl(hpet_base + HPET_ID) >> 16;
+ u32 hpet_period = readl(hpet_base + HPET_PERIOD);
+
+ if (hpet_vendor == 0 || hpet_vendor == 0xffff ||
+ hpet_period == 0 || hpet_period > 0x05F5E100)
+ return NULL;
+
+ hpet = malloc_high(sizeof(*hpet));
if (!hpet) {
warn_noalloc();
return NULL;