From patchwork Sun Oct 16 16:49:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 120043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5E782B7182 for ; Mon, 17 Oct 2011 03:50:09 +1100 (EST) Received: from localhost ([::1]:51093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFTuV-0000dp-Co for incoming@patchwork.ozlabs.org; Sun, 16 Oct 2011 12:50:03 -0400 Received: from eggs.gnu.org ([140.186.70.92]:42467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFTuM-0000db-KW for qemu-devel@nongnu.org; Sun, 16 Oct 2011 12:49:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFTuL-0004Mw-30 for qemu-devel@nongnu.org; Sun, 16 Oct 2011 12:49:54 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:62125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFTuK-0004Mp-Ry for qemu-devel@nongnu.org; Sun, 16 Oct 2011 12:49:53 -0400 Received: by ywp17 with SMTP id 17so384751ywp.4 for ; Sun, 16 Oct 2011 09:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=bg1SHWucYCSCanfRP+ochiIjTcbY4Pr1ZSj2btAQSFg=; b=HlxWTW/PRcg8dX8ABUXyIdrhyFSsQOawOxRdzP+2TIfhNU+vnheOd2yKhkaA4j9D0r KzlLRNxe3g6lKruE9F4ZB8HrBlw/G/6HIoDErttDUVXiZZOgw/8bbtyf+Ocxr+DLO4LT WDf0n25wNZNZhXrTLVRwIwEC3XWx7RSGCgOCE= Received: by 10.182.7.100 with SMTP id i4mr8770364oba.66.1318783792248; Sun, 16 Oct 2011 09:49:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.121.8 with HTTP; Sun, 16 Oct 2011 09:49:31 -0700 (PDT) From: Blue Swirl Date: Sun, 16 Oct 2011 16:49:31 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.45 Subject: [Qemu-devel] [PATCH v2 1/4] vga: make PCI devices optional X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Blue Swirl --- hw/cirrus_vga.c | 5 ----- hw/pc.c | 6 +++++- hw/pc.h | 26 ++++++++++++++++++++++++-- hw/pci.c | 18 ++++++++++++++++++ hw/pci.h | 4 ++++ hw/vga-pci.c | 6 ------ 6 files changed, 51 insertions(+), 14 deletions(-) From b23f87c42ce7a6a5078ebb969bdb0dd8046f9578 Mon Sep 17 00:00:00 2001 Message-Id: From: Blue Swirl Date: Tue, 27 Sep 2011 19:15:42 +0000 Subject: [PATCH 1/4] vga: make PCI devices optional Signed-off-by: Blue Swirl --- hw/cirrus_vga.c | 5 ----- hw/pc.c | 6 +++++- hw/pc.h | 26 ++++++++++++++++++++++++-- hw/pci.c | 18 ++++++++++++++++++ hw/pci.h | 4 ++++ hw/vga-pci.c | 6 ------ 6 files changed, 51 insertions(+), 14 deletions(-) diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index c7e365b..a11444c 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -2955,11 +2955,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev) return 0; } -void pci_cirrus_vga_init(PCIBus *bus) -{ - pci_create_simple(bus, -1, "cirrus-vga"); -} - static PCIDeviceInfo cirrus_vga_info = { .qdev.name = "cirrus-vga", .qdev.desc = "Cirrus CLGD 54xx VGA", diff --git a/hw/pc.c b/hw/pc.c index f0802b7..8454344 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1074,7 +1074,11 @@ void pc_vga_init(PCIBus *pci_bus) { if (cirrus_vga_enabled) { if (pci_bus) { - pci_cirrus_vga_init(pci_bus); + if (!pci_cirrus_vga_init(pci_bus)) { + fprintf(stderr, "Warning: cirrus_vga not available," + " using standard VGA instead\n"); + pci_vga_init(pci_bus); + } } else { isa_cirrus_vga_init(get_system_memory()); } diff --git a/hw/pc.h b/hw/pc.h index b8ad9a3..40d6edb 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -9,6 +9,7 @@ #include "net.h" #include "memory.h" #include "ioapic.h" +#include "pci.h" /* PC-style peripherals (also used by other machines). */ @@ -216,13 +217,34 @@ static inline int isa_vga_init(void) return 1; } -int pci_vga_init(PCIBus *bus); +/* vga-pci.c */ +static inline bool pci_vga_init(PCIBus *bus) +{ + PCIDevice *dev; + + dev = pci_try_create_simple(bus, -1, "VGA"); + if (!dev) { + return false; + } + return true; +} + int isa_vga_mm_init(target_phys_addr_t vram_base, target_phys_addr_t ctrl_base, int it_shift, MemoryRegion *address_space); /* cirrus_vga.c */ -void pci_cirrus_vga_init(PCIBus *bus); +static inline bool pci_cirrus_vga_init(PCIBus *bus) +{ + PCIDevice *dev; + + dev = pci_try_create_simple(bus, -1, "cirrus-vga"); + if (!dev) { + return false; + } + return true; +} + void isa_cirrus_vga_init(MemoryRegion *address_space); /* ne2000.c */ diff --git a/hw/pci.c b/hw/pci.c index 749e8d8..46c01ac 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1687,6 +1687,19 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, return dev; } +PCIDevice *pci_try_create_simple_multifunction(PCIBus *bus, int devfn, + bool multifunction, + const char *name) +{ + PCIDevice *dev = pci_try_create_multifunction(bus, devfn, multifunction, + name); + if (!dev) { + return NULL; + } + qdev_init_nofail(&dev->qdev); + return dev; +} + PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name) { return pci_create_multifunction(bus, devfn, false, name); @@ -1702,6 +1715,11 @@ PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name) return pci_try_create_multifunction(bus, devfn, false, name); } +PCIDevice *pci_try_create_simple(PCIBus *bus, int devfn, const char *name) +{ + return pci_try_create_simple_multifunction(bus, devfn, false, name); +} + static int pci_find_space(PCIDevice *pdev, uint8_t size) { int config_size = pci_config_size(pdev); diff --git a/hw/pci.h b/hw/pci.h index 86a81c8..aa2e040 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -473,9 +473,13 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn, bool multifunction, const char *name); +PCIDevice *pci_try_create_simple_multifunction(PCIBus *bus, int devfn, + bool multifunction, + const char *name); PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name); PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name); +PCIDevice *pci_try_create_simple(PCIBus *bus, int devfn, const char *name); static inline int pci_is_express(const PCIDevice *d) { diff --git a/hw/vga-pci.c b/hw/vga-pci.c index 14bfadb..68fddd9 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -70,12 +70,6 @@ static int pci_vga_initfn(PCIDevice *dev) return 0; } -int pci_vga_init(PCIBus *bus) -{ - pci_create_simple(bus, -1, "VGA"); - return 0; -} - static PCIDeviceInfo vga_info = { .qdev.name = "VGA", .qdev.size = sizeof(PCIVGAState), -- 1.7.2.5