From patchwork Sat Aug 4 12:05:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 175085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B44732C008C for ; Sat, 4 Aug 2012 22:07:08 +1000 (EST) Received: from localhost ([::1]:42566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sxd8M-00079x-Ng for incoming@patchwork.ozlabs.org; Sat, 04 Aug 2012 08:07:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sxd8B-00072V-DK for qemu-devel@nongnu.org; Sat, 04 Aug 2012 08:06:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sxd89-0003TL-Km for qemu-devel@nongnu.org; Sat, 04 Aug 2012 08:06:55 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:35131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sxd89-0002vX-DE; Sat, 04 Aug 2012 08:06:53 -0400 Received: by mail-ob0-f173.google.com with SMTP id ta14so2476455obb.4 for ; Sat, 04 Aug 2012 05:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=GA2hgTYMUKsuXV6x04tEqffnk5MdOxOePVNjuYLTBjY=; b=pNzFLC/E3zrc9cJ/6US7dsp8vFzwjNG2mr5J2sdDtZQn7Y86VkgRBmyy3ohF9QqYTN Q9mO61L8l5DeZpE2pTnzXorfY/3yTfWubtjZF17iFrfFouZXVWWsn7+1CNHVzMzMtZJb FQ4EsLioABWQG+6kUpI2Q4DQPeD/f/60oDR/KiDCfl8LXVwPy8MeDdQqj9WP6yk6Khun +TgZXkMypy3i/VBhUzTewTwL6Tyjfyt9WrLL7vVShDRBNEmG9MdKEkuG+AtoWUhwM49x xR2hKbOJ3R9p6Z/YgL65j7aow1ESdAucCG1j3REIBqfkcYw6sd1clu9bGejIWX4yg0GV myKw== Received: by 10.182.110.102 with SMTP id hz6mr10222755obb.79.1344082013078; Sat, 04 Aug 2012 05:06:53 -0700 (PDT) Received: from localhost.localdomain ([175.25.242.10]) by mx.google.com with ESMTPS id th3sm12393434obb.6.2012.08.04.05.06.47 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 04 Aug 2012 05:06:52 -0700 (PDT) From: Li Zhang To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Date: Sat, 4 Aug 2012 20:05:54 +0800 Message-Id: <1344081957-4717-3-git-send-email-zhlcindy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1344081957-4717-1-git-send-email-zhlcindy@linux.vnet.ibm.com> References: <1344081957-4717-1-git-send-email-zhlcindy@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.173 Cc: aliguori@us.ibm.com, agraf@suse.de, Li Zhang , afaerber@suse.de, david@gibson.dropbear.id.au Subject: [Qemu-devel] [Qemu-ppc][PATCH v6 2/5] Get USB option by machine options on all platforms 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 All the plaftorms use usb_enabled global variable to check USB option. Now that, usb_enabled has been removed and the value of USB option should be got from machine options. This patch is to clean up usb_enable on all platforms and get USB option by machine options. Actually, in vl.c, the default USB option is false. For specific machine, the default USB option can be changed to true. Take pseries for an example, pseries needs USB enabled when the machine is initialized. USB option will be enabled when passing the command line by one of the following three ways: * -M pseries * -machine type=pseries * -machine type=pseries,usb=on If USB option needs to be disabled, it should use the following options: * -machine type=pseries,usb=off For some plaforms, USB option is disabled as the default. If it needs to enable USB, it should pass the command line as the following: * -machine type=pseries,usb=on Signed-off-by: Li Zhang --- hw/nseries.c | 9 +++++++++ hw/pc_piix.c | 6 ++++++ hw/ppc_newworld.c | 10 +++++++++- hw/ppc_oldworld.c | 8 ++++++++ hw/ppc_prep.c | 7 +++++++ hw/pxa2xx.c | 15 +++++++++++++++ hw/realview.c | 8 ++++++++ hw/spapr.c | 12 ++++++++++++ hw/versatilepb.c | 8 ++++++++ 9 files changed, 82 insertions(+), 1 deletions(-) diff --git a/hw/nseries.c b/hw/nseries.c index 4df2670..8e385b7 100644 --- a/hw/nseries.c +++ b/hw/nseries.c @@ -1282,6 +1282,9 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device, int sdram_size = binfo->ram_size; DisplayState *ds; + QemuOpts *mach_opts; + bool usb_enabled = false; + s->mpu = omap2420_mpu_init(sysmem, sdram_size, cpu_model); /* Setup peripherals @@ -1322,6 +1325,12 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device, n8x0_dss_setup(s); n8x0_cbus_setup(s); n8x0_uart_setup(s); + + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", false); + } + if (usb_enabled) n8x0_usb_setup(s); diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 0c0096f..0bf25d0 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -148,6 +148,8 @@ static void pc_init1(MemoryRegion *system_memory, MemoryRegion *pci_memory; MemoryRegion *rom_memory; void *fw_cfg = NULL; + QemuOpts *mach_opts; + bool usb_enabled = false; pc_cpus_init(cpu_model); @@ -267,6 +269,10 @@ static void pc_init1(MemoryRegion *system_memory, pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, floppy, idebus[0], idebus[1], rtc_state); + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", false); + } if (pci_enabled && usb_enabled) { pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); } diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 4e2a6e6..1a324eb 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -159,6 +159,9 @@ static void ppc_core99_init (ram_addr_t ram_size, linux_boot = (kernel_filename != NULL); + QemuOpts *mach_opts; + bool usb_enabled = false; + /* init CPUs */ if (cpu_model == NULL) #ifdef TARGET_PPC64 @@ -350,7 +353,7 @@ static void ppc_core99_init (ram_addr_t ram_size, /* cuda also initialize ADB */ if (machine_arch == ARCH_MAC99_U3) { - usb_enabled = 1; + usb_enabled = true; } cuda_init(&cuda_mem, pic[0x19]); @@ -360,6 +363,11 @@ static void ppc_core99_init (ram_addr_t ram_size, macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem, dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar); + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", true); + } + if (usb_enabled) { pci_create_simple(pci_bus, -1, "pci-ohci"); } diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index f2c6908..da05705 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -101,6 +101,9 @@ static void ppc_heathrow_init (ram_addr_t ram_size, linux_boot = (kernel_filename != NULL); + QemuOpts *mach_opts; + bool usb_enabled = true; + /* init CPUs */ if (cpu_model == NULL) cpu_model = "G3"; @@ -286,6 +289,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size, macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem, dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar); + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", true); + } + if (usb_enabled) { pci_create_simple(pci_bus, -1, "pci-ohci"); } diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index be2b268..dc294ae 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -484,6 +484,9 @@ static void ppc_prep_init (ram_addr_t ram_size, linux_boot = (kernel_filename != NULL); + QemuOpts *mach_opts; + bool usb_enabled = true; + /* init CPUs */ if (cpu_model == NULL) cpu_model = "602"; @@ -661,6 +664,10 @@ static void ppc_prep_init (ram_addr_t ram_size, memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr); #endif + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", true); + } if (usb_enabled) { pci_create_simple(pci_bus, -1, "pci-ohci"); } diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index d5f1420..ed87797 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -2007,6 +2007,9 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, PXA2xxState *s; int i; DriveInfo *dinfo; + QemuOpts *mach_opts; + bool usb_enabled = false; + s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState)); if (revision && strncmp(revision, "pxa27", 5)) { @@ -2108,6 +2111,11 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); } + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", false); + } + if (usb_enabled) { sysbus_create_simple("sysbus-ohci", 0x4c000000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1)); @@ -2144,6 +2152,8 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) PXA2xxState *s; int i; DriveInfo *dinfo; + QemuOpts *mach_opts; + bool usb_enabled = false; s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState)); @@ -2239,6 +2249,11 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); } + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", false); + } + if (usb_enabled) { sysbus_create_simple("sysbus-ohci", 0x4c000000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1)); diff --git a/hw/realview.c b/hw/realview.c index 19db4d0..543d5dc 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -73,6 +73,8 @@ static void realview_init(ram_addr_t ram_size, uint32_t proc_id = 0; uint32_t sys_id; ram_addr_t low_ram_size; + QemuOpts *mach_opts; + bool usb_enabled = true; switch (board_type) { case BOARD_EB: @@ -227,6 +229,12 @@ static void realview_init(ram_addr_t ram_size, sysbus_connect_irq(busdev, 2, pic[50]); sysbus_connect_irq(busdev, 3, pic[51]); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); + + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", true); + } + if (usb_enabled) { pci_create_simple(pci_bus, -1, "pci-ohci"); } diff --git a/hw/spapr.c b/hw/spapr.c index 81c9343..4dc5e59 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -575,6 +575,8 @@ static void ppc_spapr_init(ram_addr_t ram_size, long load_limit, rtas_limit, fw_size; long pteg_shift = 17; char *filename; + QemuOpts *mach_opts; + bool usb_enabled = true; spapr = g_malloc0(sizeof(*spapr)); QLIST_INIT(&spapr->phbs); @@ -710,6 +712,16 @@ static void ppc_spapr_init(ram_addr_t ram_size, spapr_vscsi_create(spapr->vio_bus); } + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", true); + } + + if (usb_enabled) { + pci_create_simple(QLIST_FIRST(&spapr->phbs)->host_state.bus, + -1, "pci-ohci"); + } + if (rma_size < (MIN_RMA_SLOF << 20)) { fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " "%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF); diff --git a/hw/versatilepb.c b/hw/versatilepb.c index 4fd5d9b..4b2f70d 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -188,6 +188,8 @@ static void versatile_init(ram_addr_t ram_size, int n; int done_smc = 0; DriveInfo *dinfo; + QemuOpts *mach_opts; + bool usb_enabled = false; if (!cpu_model) { cpu_model = "arm926"; @@ -247,6 +249,12 @@ static void versatile_init(ram_addr_t ram_size, pci_nic_init_nofail(nd, "rtl8139", NULL); } } + + mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (mach_opts) { + usb_enabled = qemu_opt_get_bool(mach_opts, "usb", false); + } + if (usb_enabled) { pci_create_simple(pci_bus, -1, "pci-ohci"); }