From patchwork Sun Jun 13 14:45:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 55456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 34B801007D1 for ; Mon, 14 Jun 2010 01:39:40 +1000 (EST) Received: from localhost ([127.0.0.1]:34889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ONpGm-0006et-6R for incoming@patchwork.ozlabs.org; Sun, 13 Jun 2010 11:38:44 -0400 Received: from [140.186.70.92] (port=41330 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ONpFW-0006Bc-2b for qemu-devel@nongnu.org; Sun, 13 Jun 2010 11:37:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ONpFU-0005zS-Rz for qemu-devel@nongnu.org; Sun, 13 Jun 2010 11:37:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46816) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ONpFU-0005zA-K6 for qemu-devel@nongnu.org; Sun, 13 Jun 2010 11:37:24 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5DFbNQ5017452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 13 Jun 2010 11:37:23 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5DEjnQV020412; Sun, 13 Jun 2010 10:45:50 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 4D12F18D472; Sun, 13 Jun 2010 17:45:49 +0300 (IDT) Date: Sun, 13 Jun 2010 17:45:49 +0300 From: Gleb Natapov To: seabios@seabios.org Message-ID: <20100613144549.GC6292@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] load hpet info for HPET ACPI table from qemu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Load hpet info for HPET ACPI table from qemu instead of using hardcoded values. Use hardcoded values anyway if old qemu is detected. Signed-off-by: Gleb Natapov --- Gleb. diff --git a/src/acpi.c b/src/acpi.c index 0559443..eeecca1 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -469,7 +469,7 @@ build_ssdt(void) #define HPET_SIGNATURE 0x54455048 //HPET static void* -build_hpet(void) +build_hpet(struct hpet_fw_entry *e, u8 id) { struct acpi_20_hpet *hpet = malloc_high(sizeof(*hpet)); if (!hpet) { @@ -478,11 +478,11 @@ build_hpet(void) } memset(hpet, 0, sizeof(*hpet)); - /* Note timer_block_id value must be kept in sync with value advertised by - * emulated hpet - */ - hpet->timer_block_id = cpu_to_le32(0x8086a201); - hpet->addr.address = cpu_to_le32(ACPI_HPET_ADDRESS); + hpet->timer_block_id = cpu_to_le32(e->event_timer_block_id); + hpet->addr.address = cpu_to_le32(e->address); + hpet->min_tick = cpu_to_le32(e->min_tick); + hpet->hpet_number = id; + hpet->page_protect = e->page_prot; build_header((void*)hpet, HPET_SIGNATURE, sizeof(*hpet), 1); return hpet; @@ -637,9 +637,28 @@ acpi_bios_init(void) ACPI_INIT_TABLE(build_fadt(bdf)); ACPI_INIT_TABLE(build_ssdt()); ACPI_INIT_TABLE(build_madt()); - ACPI_INIT_TABLE(build_hpet()); ACPI_INIT_TABLE(build_srat()); + u8 hpet_id = 0; + u32 c = qemu_cfg_hpet_entries(); + struct hpet_fw_entry e; + + if (c == ~0) { + /* qemu do not provide hpet description */ + e.event_timer_block_id = 0x8086a201; + e.address = ACPI_HPET_ADDRESS; + e.min_tick = 0; + c = 1; + } else if (c != 0) + qemu_cfg_hpet_load_next(&e); + + while (c--) { + ACPI_INIT_TABLE(build_hpet(&e, hpet_id++)); + if (c) + qemu_cfg_hpet_load_next(&e); + } + + u16 i, external_tables = qemu_cfg_acpi_additional_tables(); for(i = 0; i < external_tables; i++) { diff --git a/src/paravirt.c b/src/paravirt.c index 5c77b5c..13a4916 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -149,6 +149,26 @@ void* qemu_cfg_e820_load_next(void *addr) return addr; } +u32 qemu_cfg_hpet_entries(void) +{ + u8 cnt; + + if (!qemu_cfg_present) + return 0; + + /* read valid flags */ + qemu_cfg_read_entry(&cnt, QEMU_CFG_HPET, sizeof(cnt)); + if (!cnt) + return ~0; + qemu_cfg_read(&cnt, sizeof(cnt)); + return cnt; +} + +void qemu_cfg_hpet_load_next(struct hpet_fw_entry *e) +{ + qemu_cfg_read((u8*)e, sizeof(*e)); +} + struct smbios_header { u16 length; u8 type; diff --git a/src/paravirt.h b/src/paravirt.h index c46418f..2fd98cc 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -37,6 +37,7 @@ static inline int kvm_para_available(void) #define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1) #define QEMU_CFG_IRQ0_OVERRIDE (QEMU_CFG_ARCH_LOCAL + 2) #define QEMU_CFG_E820_TABLE (QEMU_CFG_ARCH_LOCAL + 3) +#define QEMU_CFG_HPET (QEMU_CFG_ARCH_LOCAL + 4) extern int qemu_cfg_present; @@ -68,10 +69,20 @@ struct e820_reservation { u32 type; }; +struct hpet_fw_entry +{ + u32 event_timer_block_id; + u64 address; + u16 min_tick; + u8 page_prot; +} __attribute__ ((packed)); + u16 qemu_cfg_first_file(QemuCfgFile *entry); u16 qemu_cfg_next_file(QemuCfgFile *entry); u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen); u32 qemu_cfg_e820_entries(void); void* qemu_cfg_e820_load_next(void *addr); +u32 qemu_cfg_hpet_entries(void); +void qemu_cfg_hpet_load_next(struct hpet_fw_entry *e); #endif