All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Probe HPET existence
@ 2011-08-29 15:50 Jan Kiszka
  2011-08-30  0:35 ` Kevin O'Connor
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2011-08-29 15:50 UTC (permalink / raw)
  To: Kevin O'Connor, seabios
  Cc: Andrew Theurer, Gleb Natapov, ya su, Alexander Graf, qemu-devel,
	Avi Kivity

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>
---

This allows to postpone the hpet_fw_cfg vs. ACPI discussion until we
have >1 HPET blocks and/or put them at non-standard addresses.

 src/acpi.c |   14 +++++++++++++-
 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;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Probe HPET existence
  2011-08-29 15:50 [Qemu-devel] [PATCH] Probe HPET existence Jan Kiszka
@ 2011-08-30  0:35 ` Kevin O'Connor
  2011-08-31 16:45   ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin O'Connor @ 2011-08-30  0:35 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Andrew Theurer, Gleb Natapov, seabios, ya su, Alexander Graf,
	qemu-devel, Avi Kivity

On Mon, Aug 29, 2011 at 05:50:10PM +0200, Jan Kiszka wrote:
> 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.

It looks okay to me.

BTW, any particular reason to use 0x05F5E100 instead of 100000000?

-Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Probe HPET existence
  2011-08-30  0:35 ` Kevin O'Connor
@ 2011-08-31 16:45   ` Jan Kiszka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2011-08-31 16:45 UTC (permalink / raw)
  To: Kevin O'Connor
  Cc: Andrew Theurer, Gleb Natapov, seabios, ya su, Alexander Graf,
	qemu-devel, Avi Kivity

On 2011-08-30 02:35, Kevin O'Connor wrote:
> On Mon, Aug 29, 2011 at 05:50:10PM +0200, Jan Kiszka wrote:
>> 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.
> 
> It looks okay to me.
> 
> BTW, any particular reason to use 0x05F5E100 instead of 100000000?

No, I just blindly grabbed the first number I found in the spec. You may
change if you like on commit.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-31 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-29 15:50 [Qemu-devel] [PATCH] Probe HPET existence Jan Kiszka
2011-08-30  0:35 ` Kevin O'Connor
2011-08-31 16:45   ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.