From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qy46j-0003mK-BH for qemu-devel@nongnu.org; Mon, 29 Aug 2011 11:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qy46h-0004mz-9z for qemu-devel@nongnu.org; Mon, 29 Aug 2011 11:50:41 -0400 Received: from goliath.siemens.de ([192.35.17.28]:34274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qy46h-0004mk-1S for qemu-devel@nongnu.org; Mon, 29 Aug 2011 11:50:39 -0400 Message-ID: <4E5BB532.4010106@siemens.com> Date: Mon, 29 Aug 2011 17:50:10 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] Probe HPET existence List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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