[Qemu-devel] [Qemu-ppc][PATCH v5 2/4] Add one new file vga-pci.h
From: Li Zhang Functions pci_vga_init() and pci_cirrus_vga_init() are declared in pc.h. That prevents other platforms (e.g. sPAPR) to use them. This patch is to create one new file vga-pci.h and move the declarations to vga-pci.h, so that they can be shared by all the platforms. Signed-off-by: Li Zhang --- hw/cirrus_vga.c |2 +- hw/pc.h |4 hw/vga-pci.c|2 +- hw/vga-pci.h| 13 + 4 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 hw/vga-pci.h diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 623dd68..3e8e5bb 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -27,11 +27,11 @@ * available at http://home.worldonline.dk/~finth/ */ #include "hw.h" -#include "pc.h" #include "pci.h" #include "console.h" #include "vga_int.h" #include "loader.h" +#include "vga-pci.h" /* * TODO: diff --git a/hw/pc.h b/hw/pc.h index 31ccb6f..e4db071 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -189,14 +189,10 @@ static inline DeviceState *isa_vga_init(ISABus *bus) return &dev->qdev; } -DeviceState *pci_vga_init(PCIBus *bus); 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 */ -DeviceState *pci_cirrus_vga_init(PCIBus *bus); - /* ne2000.c */ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd) { diff --git a/hw/vga-pci.c b/hw/vga-pci.c index 37dc019..4872056 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -23,12 +23,12 @@ */ #include "hw.h" #include "console.h" -#include "pc.h" #include "pci.h" #include "vga_int.h" #include "pixel_ops.h" #include "qemu-timer.h" #include "loader.h" +#include "vga-pci.h" typedef struct PCIVGAState { PCIDevice dev; diff --git a/hw/vga-pci.h b/hw/vga-pci.h new file mode 100644 index 000..e272deb --- /dev/null +++ b/hw/vga-pci.h @@ -0,0 +1,13 @@ +#ifndef VGA_PCI_H +#define VGA_PCI_H + +#include "qemu-common.h" +#include "qdev.h" + +/* vga-pci.c */ +DeviceState *pci_vga_init(PCIBus *bus); + +/* cirrus_vga.c */ +DeviceState *pci_cirrus_vga_init(PCIBus *bus); + +#endif -- 1.7.9.5
[Qemu-devel] [Qemu-ppc][PATCH v5 4/4] spapr: Add support for -vga option
From: Li Zhang Also instanciate the USB keyboard and mouse when that option is used (you can still use -device to create individual devices without all the defaults) Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Li Zhang --- hw/spapr.c | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/hw/spapr.c b/hw/spapr.c index 973de1b..3648cad 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -45,6 +45,8 @@ #include "kvm.h" #include "kvm_ppc.h" #include "pci.h" +#include "vga-pci.h" +#include "usb.h" #include "exec-memory.h" @@ -82,6 +84,7 @@ #define PHANDLE_XICP0x sPAPREnvironment *spapr; +bool spapr_has_graphics; qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num, enum xics_irq_type type) @@ -257,6 +260,9 @@ static void *spapr_create_fdt_skel(const char *cpu_model, _FDT((fdt_property(fdt, "qemu,boot-kernel", &kprop, sizeof(kprop; } _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device))); +_FDT((fdt_property_cell(fdt, "qemu,graphic-width", graphic_width))); +_FDT((fdt_property_cell(fdt, "qemu,graphic-height", graphic_height))); +_FDT((fdt_property_cell(fdt, "qemu,graphic-depth", graphic_depth))); _FDT((fdt_end_node(fdt))); @@ -503,7 +509,9 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, } } -spapr_populate_chosen_stdout(fdt, spapr->vio_bus); +if (!spapr_has_graphics) { +spapr_populate_chosen_stdout(fdt, spapr->vio_bus); +} _FDT((fdt_pack(fdt))); @@ -556,6 +564,16 @@ static void spapr_cpu_reset(void *opaque) cpu_reset(CPU(cpu)); } +static int spapr_vga_init(PCIBus *pci_bus) +{ +if (std_vga_enabled) { +pci_vga_init(pci_bus); +} else { +return 0; +} +return 1; +} + /* pSeries LPAR / sPAPR hardware init */ static void ppc_spapr_init(ram_addr_t ram_size, const char *boot_device, @@ -712,6 +730,11 @@ static void ppc_spapr_init(ram_addr_t ram_size, spapr_vscsi_create(spapr->vio_bus); } +/* Graphics */ +if (spapr_vga_init(QLIST_FIRST(&spapr->phbs)->host_state.bus)) { +spapr_has_graphics = true; +} + machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); if (machine_opts) { add_usb = qemu_opt_get_bool(machine_opts, "usb", true); @@ -720,6 +743,10 @@ static void ppc_spapr_init(ram_addr_t ram_size, if (add_usb) { pci_create_simple(QLIST_FIRST(&spapr->phbs)->host_state.bus, -1, "pci-ohci"); +if (spapr_has_graphics) { +usbdevice_create("keyboard"); +usbdevice_create("mouse"); +} } if (rma_size < (MIN_RMA_SLOF << 20)) { fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " -- 1.7.9.5
[Qemu-devel] [Qemu-ppc][PATCH v5 0/4] Add USB option and enable vga on spapr
From: Li Zhang v1 -> v2: * Convert USB option from char to bool. v2 -> v3: * Remove global USB option * Get USB option with qemu_opt_get_bool(). * Send vga patch for sPAPR which requires USB enabled. v3 -> v4: * Fix some English grammar and coding style faults * Replace usb_on with add_usb to be more functional. * Remove vga init functions' declearations from pc.h, and add one new file vga-pci.h for the declearations. * Cleanup pc.h on some platforms and add vga-pci.h * Remove graphic devices which are not supported on sPAPR platform. They will be added back when they are supported. v4 -> v5: * Correct several English words * Add header file "qemu-comman.h" in vga-pci.h, which defines PCIBus and DeviceState types. Move #endif to the end of the vga-pci.h and remove the trailing white line. Benjamin Herrenschmidt (1): spapr: Add support for -vga option Li Zhang (3): Add usb option in machine options Add one new file vga-pci.h Cleanup pc.h on other platforms hw/alpha_pci.c|1 + hw/cirrus_vga.c |2 +- hw/mips_malta.c |1 + hw/pc.c |1 + hw/pc.h |4 hw/ppc_newworld.c |2 +- hw/ppc_oldworld.c |2 +- hw/ppc_prep.c |1 + hw/spapr.c| 40 +++- hw/sun4u.c|1 + hw/vga-pci.c |2 +- hw/vga-pci.h | 13 + qemu-config.c |4 13 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 hw/vga-pci.h -- 1.7.9.5
[Qemu-devel] [Qemu-ppc][PATCH v5 3/4] Cleanup pc.h on other platforms
From: Li Zhang The declarations of pci_vga_init() and pci_cirrus_vga_init() are moved to vga-pci.h to be called by all the platforms. So it's necessary to cleanup pc.h on the platforms other than PC which include the file and add vga-pci.h on all the plaforms to call vga related functions. This patch is to cleanup pc.h and add vga-pci.h. Signed-off-by: Li Zhang --- hw/alpha_pci.c|1 + hw/mips_malta.c |1 + hw/pc.c |1 + hw/ppc_newworld.c |2 +- hw/ppc_oldworld.c |2 +- hw/ppc_prep.c |1 + hw/sun4u.c|1 + 7 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/alpha_pci.c b/hw/alpha_pci.c index 6735577..ea546f8 100644 --- a/hw/alpha_pci.c +++ b/hw/alpha_pci.c @@ -11,6 +11,7 @@ #include "qemu-log.h" #include "sysemu.h" #include "vmware_vga.h" +#include "vga-pci.h" /* PCI IO reads/writes, to byte-word addressable memory. */ diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 351c88e..ad23f26 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -48,6 +48,7 @@ #include "blockdev.h" #include "exec-memory.h" #include "sysbus.h" /* SysBusDevice */ +#include "vga-pci.h" //#define DEBUG_BOARD_INIT diff --git a/hw/pc.c b/hw/pc.c index c7e9ab3..f43e817 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -48,6 +48,7 @@ #include "memory.h" #include "exec-memory.h" #include "arch_init.h" +#include "vga-pci.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 4e2a6e6..e95cfe8 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -52,7 +52,6 @@ #include "adb.h" #include "mac_dbdma.h" #include "nvram.h" -#include "pc.h" #include "pci.h" #include "net.h" #include "sysemu.h" @@ -68,6 +67,7 @@ #include "hw/usb.h" #include "blockdev.h" #include "exec-memory.h" +#include "vga-pci.h" #define MAX_IDE_BUS 2 #define CFG_ADDR 0xf510 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index f2c6908..1dcd8a6 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -29,7 +29,6 @@ #include "adb.h" #include "mac_dbdma.h" #include "nvram.h" -#include "pc.h" #include "sysemu.h" #include "net.h" #include "isa.h" @@ -44,6 +43,7 @@ #include "kvm_ppc.h" #include "blockdev.h" #include "exec-memory.h" +#include "vga-pci.h" #define MAX_IDE_BUS 2 #define CFG_ADDR 0xf510 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index be2b268..7a87616 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -39,6 +39,7 @@ #include "blockdev.h" #include "arch_init.h" #include "exec-memory.h" +#include "vga-pci.h" //#define HARD_DEBUG_PPC_IO //#define DEBUG_PPC_IO diff --git a/hw/sun4u.c b/hw/sun4u.c index 137a7c6..07cd042 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -39,6 +39,7 @@ #include "elf.h" #include "blockdev.h" #include "exec-memory.h" +#include "vga-pci.h" //#define DEBUG_IRQ //#define DEBUG_EBUS -- 1.7.9.5
[Qemu-devel] [Qemu-ppc][PATCH v5 1/4] Add usb option in machine options
From: Li Zhang pSeries machine needs to enable USB to add a USB keyboard or USB mouse. -usb option won't be used in the future, and machine options are a better way to enable USB. So this patch is to add USB option to machine options (-machine type=pseries,usb=on/off) to enable/disable USB controller. And machines will get the machine option and create a USB controller if USB is on. By the way, USB is on by default on pSeries machine. So USB controller should be turned off explicitly through the command line for "-nodefault" case as the following: -machine type=pseries,usb=off. Signed-off-by: Li Zhang Reviewed-by: Andreas Färber --- hw/spapr.c| 11 +++ qemu-config.c |4 2 files changed, 15 insertions(+) diff --git a/hw/spapr.c b/hw/spapr.c index 81c9343..973de1b 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 *machine_opts; +bool add_usb = true; spapr = g_malloc0(sizeof(*spapr)); QLIST_INIT(&spapr->phbs); @@ -710,6 +712,15 @@ static void ppc_spapr_init(ram_addr_t ram_size, spapr_vscsi_create(spapr->vio_bus); } +machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); +if (machine_opts) { +add_usb = qemu_opt_get_bool(machine_opts, "usb", true); +} + +if (add_usb) { +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/qemu-config.c b/qemu-config.c index 5c3296b..b86ee36 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -595,6 +595,10 @@ static QemuOptsList qemu_machine_opts = { .name = "dt_compatible", .type = QEMU_OPT_STRING, .help = "Overrides the \"compatible\" property of the dt root node", +},{ +.name = "usb", +.type = QEMU_OPT_BOOL, +.help = "Set on/off to enable/disable usb", }, { /* End of list */ } }, -- 1.7.9.5
[Qemu-devel] [PATCH 1/1] Add usb option in machine options.
From: Li Zhang For pseries machine, it needs to enable usb to add kbd or usb mouse. -usb option won't be used in the future, and machine options is a better way to enable usb. So this patch is to add usb option to machine options (-machine type=psereis,usb=on/off) to enable/disable usb controller. In this patch, usb_opt is an global option which can be checked by machines. For example, on pseries, it will check if usb_opt is on, if it is on, it will create one usb ohci controller. As the following: if (usb_opts && strcmp(usb_opts, "on") == 0) pci_create_simple(bus, -1, "pci-ohci"); In this patch, usb is on by default. So, for -nodefault, usb should be set off in the command line as the following: -machine type=pseries,usb=off. Signed-off-by: Li Zhang reviewed-by: Anthony Liguori reviewed-by: Benjamin Herrenschmidt --- qemu-config.c |4 sysemu.h |1 + vl.c | 12 3 files changed, 17 insertions(+) diff --git a/qemu-config.c b/qemu-config.c index bb3bff4..258712a 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -583,6 +583,10 @@ static QemuOptsList qemu_machine_opts = { .name = "dtb", .type = QEMU_OPT_STRING, .help = "Linux kernel device tree file", +}, { +.name = "usb", +.type = QEMU_OPT_BOOL, +.help = "Set on/off to enable/disable usb", }, { /* End of list */ } }, diff --git a/sysemu.h b/sysemu.h index bc2c788..c5ea10d 100644 --- a/sysemu.h +++ b/sysemu.h @@ -13,6 +13,7 @@ /* vl.c */ extern const char *bios_name; +extern const char *usb_opt; extern const char *qemu_name; extern uint8_t qemu_uuid[]; diff --git a/vl.c b/vl.c index 204d85b..10f8e4c 100644 --- a/vl.c +++ b/vl.c @@ -171,6 +171,7 @@ int main(int argc, char **argv) static const char *data_dir; const char *bios_name = NULL; +const char *usb_opt = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; DisplayType display_type = DT_DEFAULT; int display_remote = 0; @@ -758,6 +759,15 @@ static int bt_parse(const char *opt) return 1; } +static int default_enable_usb(QemuOpts *opts) +{ +if (NULL == qemu_opt_get(opts, "usb")) { +qemu_opt_set(opts, "usb", "on"); +} + +return 0; +} + /***/ /* QEMU Block devices */ @@ -3356,6 +3366,8 @@ int main(int argc, char **argv, char **envp) kernel_filename = qemu_opt_get(machine_opts, "kernel"); initrd_filename = qemu_opt_get(machine_opts, "initrd"); kernel_cmdline = qemu_opt_get(machine_opts, "append"); +default_enable_usb(machine_opts); +usb_opt = qemu_opt_get(machine_opts, "usb"); } else { kernel_filename = initrd_filename = kernel_cmdline = NULL; } -- 1.7.9.5