From patchwork Mon Aug 3 13:32:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 30704 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 66F4EB6EDF for ; Tue, 4 Aug 2009 17:55:24 +1000 (EST) Received: from localhost ([127.0.0.1]:44707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYErg-0006Ly-6j for incoming@patchwork.ozlabs.org; Tue, 04 Aug 2009 03:55:20 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MYEll-0003zb-8i for qemu-devel@nongnu.org; Tue, 04 Aug 2009 03:49:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MYElf-0003uQ-Pb for qemu-devel@nongnu.org; Tue, 04 Aug 2009 03:49:12 -0400 Received: from [199.232.76.173] (port=46545 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYElf-0003u8-89 for qemu-devel@nongnu.org; Tue, 04 Aug 2009 03:49:07 -0400 Received: from mx20.gnu.org ([199.232.41.8]:39871) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MYEle-0007zS-Nx for qemu-devel@nongnu.org; Tue, 04 Aug 2009 03:49:06 -0400 Received: from relay3.sgi.com ([192.48.156.57] helo=relay.sgi.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MYEle-0005j8-0z for qemu-devel@nongnu.org; Tue, 04 Aug 2009 03:49:06 -0400 Received: from eye3.emea.sgi.com (eye3.emea.sgi.com [144.253.156.24]) by relay3.corp.sgi.com (Postfix) with ESMTP id 2F350AC014; Tue, 4 Aug 2009 00:48:56 -0700 (PDT) Received: from eye3.emea.sgi.com (localhost.localdomain [127.0.0.1]) by eye3.emea.sgi.com (8.14.3/8.14.3) with ESMTP id n747muq3004251; Tue, 4 Aug 2009 09:48:56 +0200 Received: (from jes@localhost) by eye3.emea.sgi.com (8.14.3/8.14.3/Submit) id n747mtNZ004250; Tue, 4 Aug 2009 09:48:55 +0200 X-Authentication-Warning: eye3.emea.sgi.com: jes set sender to jes@sgi.com using -f Message-Id: <20090803133317.151719274@sgi.com> User-Agent: quilt/0.47-1 Date: Mon, 03 Aug 2009 15:32:41 +0200 From: Jes Sorensen To: kevin@koconnor.net References: <20090803133236.207919528@sgi.com> Content-Disposition: inline; filename=0006-kvm-runtime-detect.patch X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Anthony Liguori , Beth Kon , qemu-devel , avi@redhat.com Subject: [Qemu-devel] [PATCH 5/5] Remove CONFIG_KVM and use emu_ver to runtime detect QEMU & KVM. 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 This patch makes Seabios use emu_ver to determine QEMU and KVM specific configuration at runtime. Signed-off-by: Jes Sorensen --- src/acpi.c | 14 +++++++------- src/config.h | 2 -- src/pciinit.c | 18 +++++++++++++----- src/post.c | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) Index: seabios/src/acpi.c =================================================================== --- seabios.orig/src/acpi.c +++ seabios/src/acpi.c @@ -196,12 +196,8 @@ struct madt_io_apic * lines start */ } PACKED; -#if CONFIG_KVM -/* IRQs 5,9,10,11 */ -#define PCI_ISA_IRQ_MASK 0x0e20 -#else -#define PCI_ISA_IRQ_MASK 0x0000 -#endif +/* IRQs 5,9,10,11 for QEMU/KQEMU/KVM */ +#define QEMU_PCI_ISA_IRQ_MASK 0x0e20 struct madt_intsrcovr { APIC_HEADER_DEF @@ -339,8 +335,12 @@ build_madt(struct rsdt_descriptor_rev1 * intsrcovr->flags = 0; /* conforms to bus specifications */ intsrcovr++; } + int pci_isa_irq_mask = 0; + if ((emu_ver & 0xff00) == EMU_QEMU) + pci_isa_irq_mask = QEMU_PCI_ISA_IRQ_MASK; + for (i = 1; i < 16; i++) { - if (!(PCI_ISA_IRQ_MASK & (1 << i))) + if (!(pci_isa_irq_mask & (1 << i))) /* No need for a INT source override structure. */ continue; memset(intsrcovr, 0, sizeof(*intsrcovr)); Index: seabios/src/config.h =================================================================== --- seabios.orig/src/config.h +++ seabios/src/config.h @@ -12,8 +12,6 @@ #define CONFIG_APPNAME6 "BOCHS " #define CONFIG_APPNAME4 "BXPC" -// Configure for use with KVM. -#define CONFIG_KVM 1 // Configure as a coreboot payload. #define CONFIG_COREBOOT 0 Index: seabios/src/pciinit.c =================================================================== --- seabios.orig/src/pciinit.c +++ seabios/src/pciinit.c @@ -18,12 +18,15 @@ static u32 pci_bios_io_addr; static u32 pci_bios_mem_addr; static u32 pci_bios_bigmem_addr; /* host irqs corresponding to PCI irqs A-D */ -static u8 pci_irqs[4] = { -#if CONFIG_KVM - 10, 10, 11, 11 -#else + +static u8 *pci_irqs; + +static u8 default_pci_irqs[4] = { 11, 9, 11, 9 -#endif +}; + +static u8 qemu_pci_irqs[4] = { + 10, 10, 11, 11 }; static void pci_set_io_region_addr(u16 bdf, int region_num, u32 addr) @@ -194,6 +197,11 @@ pci_bios_setup(void) // Already done by coreboot. return; + if ((emu_ver & 0xff00) == EMU_QEMU) + pci_irqs = qemu_pci_irqs; + else + pci_irqs = default_pci_irqs; + pci_bios_io_addr = 0xc000; pci_bios_mem_addr = 0xc0000000; pci_bios_bigmem_addr = RamSize; Index: seabios/src/post.c =================================================================== --- seabios.orig/src/post.c +++ seabios/src/post.c @@ -129,7 +129,7 @@ ram_probe(void) , E820_RESERVED); add_e820(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED); - if (CONFIG_KVM) + if (emu_ver == EMU_QEMU_KVM) // 4 pages before the bios, 3 pages for vmx tss pages, the // other page for EPT real mode pagetable add_e820(0xfffbc000, 4*4096, E820_RESERVED);