* [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
@ 2009-01-22 19:23 Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 1/9] PCI device registration helpers Markus Armbruster
` (9 more replies)
0 siblings, 10 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:23 UTC (permalink / raw)
To: qemu-devel
This patch series makes PCI device addresses configurable for a number
of devices. For now, I just covered the ones I consider important
and/or where the change is somewhat invasive.
Why is a configurable PCI device address useful? Currently, QEMU
assigns a few device addresses statically, and the rest dynamically on
a first come, first serve basis[*]. If you add or remove a device,
all devices registering later change address. I'm told a certain
operating system that can't be named in polite company can get rather
upset about that.
Making the device address configurable looks like the simplest
solution to this problem. Only users who really mind changing
addresses have to deal with the new configuration parameter.
I started with Izik's proposal to "allow setting static slot values
for pci devices from the command line", see
http://lists.gnu.org/archive/html/qemu-devel/2008-01/msg00601.html
http://lists.gnu.org/archive/html/qemu-devel/2007-11/msg00620.html
but ended up doing it quite differently.
I'm just soliciting comments. I do *not* ask for a commit of anything
right now.
The patch series consists of these parts:
[1/9] PCI device registration helpers
[2/9] Clean up handling of name=value,... part of -vga option argument
[3/9] Support pci=... in option argument of -vga
[4/9] Convert virtio_init_pci() to pci_register_device_2()
[5/9] Support pci=... in option argument of -net nic
[6/9] Make drives_opt[] accessible from device initialization
[7/9] Support pci=... in option argument of -drive if=virtio
[8/9] New option -audio as a more flexible alternative to -soundhw
[9/9] Support pci=... in option argument of -audio
Overall diffstat:
hw/ac97.c | 11 +---
hw/audiodev.h | 4 +-
hw/cirrus_vga.c | 6 +-
hw/e1000.c | 6 +-
hw/eepro100.c | 19 ++++----
hw/es1370.c | 11 +---
hw/mips_malta.c | 17 +++----
hw/ne2000.c | 7 +--
hw/pc.c | 23 ++++------
hw/pc.h | 11 +---
hw/pci.c | 109 ++++++++++++++++++++++++++++++++++++++++++++--
hw/pci.h | 25 ++++++----
hw/pcnet.c | 6 +-
hw/ppc440_bamboo.c | 5 +-
hw/ppc_chrp.c | 4 +-
hw/ppc_oldworld.c | 4 +-
hw/ppc_prep.c | 4 +-
hw/r2d.c | 8 ++--
hw/realview.c | 2 +-
hw/rtl8139.c | 7 +--
hw/sun4u.c | 4 +-
hw/versatilepb.c | 2 +-
hw/vga.c | 40 ++++++++--------
hw/virtio-balloon.c | 2 +-
hw/virtio-blk.c | 4 +-
hw/virtio-blk.h | 2 +-
hw/virtio-console.c | 2 +-
hw/virtio-net.c | 5 +-
hw/virtio-net.h | 2 +-
hw/virtio.c | 5 +-
hw/virtio.h | 2 +-
hw/vmware_vga.c | 7 ++-
net.c | 1 +
net.h | 1 +
sysemu.h | 13 +++++-
vl.c | 120 ++++++++++++++++++++++++++++++++-------------------
36 files changed, 315 insertions(+), 186 deletions(-)
[*] To be precise: it assigns the dev.func part dynamically. The
domain:bus: part is still statically assigned.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 1/9] PCI device registration helpers
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
@ 2009-01-22 19:30 ` Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 2/9] Clean up handling of name=value, ... part of -vga option argument Markus Armbruster
` (8 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:30 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
Registering a device with a PCI device address given as pci=... in the
common name=value,... option argument involves several steps: extract
the device address, parse it, find the PICBus, call
pci_register_device(). Put code for that in one place, namelt the new
helper function pci_register_device_2(). Yes, the name is stupid, and
is subject to change.
This code parses full PCI device addresses. It then rejects domains
other than zero, because these are not supported in QEMU.
FIXME it lets you specify .func, which is most probably inappropriate.
---
hw/pci.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/pci.h | 6 ++++
2 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index bba50d0..a0e8562 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -26,6 +26,7 @@
#include "console.h"
#include "net.h"
#include "virtio-net.h"
+#include "sysemu.h"
//#define DEBUG_PCI
@@ -158,6 +159,97 @@ static int pci_set_default_subsystem_id(PCIDevice *pci_dev)
return 0;
}
+/*
+ * Parse [[<domain>:]<bus>:]<dev>[.<func>], return -1 on error
+ */
+int pci_parse_devaddr(const char *addr, int *domp, int *busp, int *devfnp)
+{
+ const char *p;
+ char *e;
+ unsigned long val;
+ unsigned long dom = 0, bus = 0;
+ unsigned slot;
+ unsigned func = 0;
+
+ p = addr;
+ val = strtoul(p, &e, 16);
+ if (e == p)
+ return -1;
+ if (*e == ':') {
+ bus = val;
+ p = e + 1;
+ val = strtoul(p, &e, 16);
+ if (e == p)
+ return -1;
+ if (*e == ':') {
+ dom = bus;
+ bus = val;
+ p = e + 1;
+ val = strtoul(p, &e, 16);
+ if (e == p)
+ return -1;
+ }
+ }
+
+ if (dom > 0xffff || bus > 0xff || val > 0x1f)
+ return -1;
+ slot = val;
+
+ if (*e == '.') {
+ p = e + 1;
+ val = strtoul(p, &e, 16);
+ if (e == p || val > 7 || *e != '\0')
+ return -1;
+ func = val;
+ }
+
+ if (*e)
+ return -1;
+
+ *domp = dom;
+ *busp = bus;
+ *devfnp = (slot << 3) | func;
+ return 0;
+}
+
+PCIDevice *pci_register_device_2(const char *name, const char *opts,
+ int instance_size,
+ PCIConfigReadFunc *config_read,
+ PCIConfigWriteFunc *config_write)
+{
+ char devaddr[32];
+ int dom, bus_num, devfn;
+ PCIBus *bus;
+ PCIDevice *dev;
+
+ if (get_param_value(devaddr, sizeof(devaddr), "pci", opts)) {
+ if (pci_parse_devaddr(devaddr, &dom, &bus_num, &devfn) < 0) {
+ fprintf(stderr, "Bad PCI device address %s for %s",
+ devaddr, name);
+ return NULL;
+ }
+ } else {
+ dom = bus_num = 0;
+ devfn = -1;
+ }
+
+ /* Note: QEMU doesn't implement domains other than 0 */
+ if (dom != 0 || (bus = pci_find_bus(bus_num)) == NULL) {
+ fprintf(stderr, "PCI device address %s not supported for %s",
+ devaddr, name);
+ return NULL;
+ }
+
+ dev = pci_register_device(bus, name, instance_size, devfn,
+ config_read, config_write);
+ if (!dev) {
+ fprintf(stderr, "Could not set up PCI device %s", name);
+ return NULL;
+ }
+
+ return dev;
+}
+
/* -1 for devfn means auto assign */
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
int instance_size, int devfn,
@@ -713,6 +805,16 @@ static void pci_bridge_write_config(PCIDevice *d,
pci_default_write_config(d, address, val, len);
}
+PCIBus *pci_find_bus(int bus_num)
+{
+ PCIBus *bus = first_bus;
+
+ while (bus && bus->bus_num != bus_num)
+ bus = bus->next;
+
+ return bus;
+}
+
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
pci_map_irq_fn map_irq, const char *name)
{
diff --git a/hw/pci.h b/hw/pci.h
index 867e6fe..1528fc2 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -101,6 +101,10 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
int instance_size, int devfn,
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write);
+PCIDevice *pci_register_device_2(const char *name, const char *opts,
+ int instance_size,
+ PCIConfigReadFunc *config_read,
+ PCIConfigWriteFunc *config_write);
void pci_register_io_region(PCIDevice *pci_dev, int region_num,
uint32_t size, int type,
@@ -112,6 +116,7 @@ void pci_default_write_config(PCIDevice *d,
uint32_t address, uint32_t val, int len);
void pci_device_save(PCIDevice *s, QEMUFile *f);
int pci_device_load(PCIDevice *s, QEMUFile *f);
+int pci_parse_devaddr(const char *addr, int *domain, int *bus, int *devfn);
typedef void (*pci_set_irq_fn)(qemu_irq *pic, int irq_num, int level);
typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
@@ -124,6 +129,7 @@ void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
+PCIBus *pci_find_bus(int bus_num);
void pci_info(void);
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 2/9] Clean up handling of name=value, ... part of -vga option argument
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 1/9] PCI device registration helpers Markus Armbruster
@ 2009-01-22 19:30 ` Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 3/9] Support pci=... in option argument of -vga Markus Armbruster
` (7 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:30 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
Move interpretation of the option argument from select_vgahw() into
the device initialization functions. The only one that's currently
interested is vga_common_init(). Use get_param_value() there instead
of the special purpose code select_vgahw() used to use. The move
permits hiding vga_retrace_method & friends in vga.c, so do that.
---
hw/pc.h | 7 +------
hw/vga.c | 34 +++++++++++++++++-----------------
vl.c | 19 +++++--------------
3 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/hw/pc.h b/hw/pc.h
index 1ba3d9e..f43c138 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -119,12 +119,7 @@ extern PCIDevice *piix4_dev;
int piix4_init(PCIBus *bus, int devfn);
/* vga.c */
-enum vga_retrace_method {
- VGA_RETRACE_DUMB,
- VGA_RETRACE_PRECISE
-};
-
-extern enum vga_retrace_method vga_retrace_method;
+extern const char *vga_opts;
#ifndef TARGET_SPARC
#define VGA_RAM_SIZE (8192 * 1024)
diff --git a/hw/vga.c b/hw/vga.c
index 776ead0..164e652 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -29,6 +29,7 @@
#include "pixel_ops.h"
#include "qemu-timer.h"
#include "kvm.h"
+#include "sysemu.h"
//#define DEBUG_VGA
//#define DEBUG_VGA_MEM
@@ -1922,13 +1923,8 @@ void vga_reset(void *opaque)
memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table));
memset(s->last_palette, '\0', sizeof(s->last_palette));
memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr));
- switch (vga_retrace_method) {
- case VGA_RETRACE_DUMB:
- break;
- case VGA_RETRACE_PRECISE:
+ if (s->retrace == vga_precise_retrace)
memset(&s->retrace_info, 0, sizeof (s->retrace_info));
- break;
- }
}
#define TEXTMODE_X(x) ((x) % width)
@@ -2257,7 +2253,8 @@ static void vga_map(PCIDevice *pci_dev, int region_num,
void vga_common_init(VGAState *s, uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size)
{
- int i, j, v, b;
+ int i, j, v, b, precise_retrace;
+ char buf[32];
for(i = 0;i < 256; i++) {
v = 0;
@@ -2292,16 +2289,19 @@ void vga_common_init(VGAState *s, uint8_t *vga_ram_base,
s->invalidate = vga_invalidate_display;
s->screen_dump = vga_screen_dump;
s->text_update = vga_update_text;
- switch (vga_retrace_method) {
- case VGA_RETRACE_DUMB:
- s->retrace = vga_dumb_retrace;
- s->update_retrace_info = vga_dumb_update_retrace_info;
- break;
-
- case VGA_RETRACE_PRECISE:
- s->retrace = vga_precise_retrace;
- s->update_retrace_info = vga_precise_update_retrace_info;
- break;
+ precise_retrace = 0;
+ if (get_param_value(buf, sizeof(buf), "retrace", vga_opts)) {
+ if (!strcmp(buf, "precise"))
+ precise_retrace = 1;
+ else if (strcmp(buf, "dumb"))
+ fprintf(stderr, "Unknown VGA retrace=%s ignored\n", buf);
+ }
+ if (precise_retrace) {
+ s->retrace = vga_precise_retrace;
+ s->update_retrace_info = vga_precise_update_retrace_info;
+ } else {
+ s->retrace = vga_dumb_retrace;
+ s->update_retrace_info = vga_dumb_update_retrace_info;
}
vga_reset(s);
}
diff --git a/vl.c b/vl.c
index 63d954b..4c1045c 100644
--- a/vl.c
+++ b/vl.c
@@ -186,7 +186,6 @@ static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
DriveInfo drives_table[MAX_DRIVES+1];
int nb_drives;
static int vga_ram_size;
-enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
static DisplayState *display_state;
int nographic;
static int curses;
@@ -202,6 +201,7 @@ static int rtc_date_offset = -1; /* -1 means no change */
int cirrus_vga_enabled = 1;
int std_vga_enabled = 0;
int vmsvga_enabled = 0;
+const char *vga_opts = "";
#ifdef TARGET_SPARC
int graphic_width = 1024;
int graphic_height = 768;
@@ -4430,19 +4430,10 @@ static void select_vgahw (const char *p)
fprintf(stderr, "Unknown vga type: %s\n", p);
exit(1);
}
- while (*opts) {
- const char *nextopt;
-
- if (strstart(opts, ",retrace=", &nextopt)) {
- opts = nextopt;
- if (strstart(opts, "dumb", &nextopt))
- vga_retrace_method = VGA_RETRACE_DUMB;
- else if (strstart(opts, "precise", &nextopt))
- vga_retrace_method = VGA_RETRACE_PRECISE;
- else goto invalid_vga;
- } else goto invalid_vga;
- opts = nextopt;
- }
+ if (opts[0] == ',')
+ vga_opts = opts + 1;
+ else if (opts[0])
+ goto invalid_vga;
}
#ifdef _WIN32
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 3/9] Support pci=... in option argument of -vga
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 1/9] PCI device registration helpers Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 2/9] Clean up handling of name=value, ... part of -vga option argument Markus Armbruster
@ 2009-01-22 19:30 ` Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 4/9] Convert virtio_init_pci() to pci_register_device_2() Markus Armbruster
` (6 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:30 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
---
hw/cirrus_vga.c | 6 +++---
hw/mips_malta.c | 2 +-
hw/pc.c | 7 +++----
hw/pc.h | 4 ++--
hw/pci.h | 2 +-
hw/ppc_chrp.c | 2 +-
hw/ppc_oldworld.c | 2 +-
hw/ppc_prep.c | 2 +-
hw/sun4u.c | 2 +-
hw/vga.c | 6 +++---
hw/vmware_vga.c | 7 ++++---
11 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index ef939ae..e8d2857 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3339,7 +3339,7 @@ static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
s->cirrus_mmio_io_addr);
}
-void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_cirrus_vga_init(uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size)
{
PCICirrusVGAState *d;
@@ -3350,9 +3350,9 @@ void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
device_id = CIRRUS_ID_CLGD5446;
/* setup PCI configuration registers */
- d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
+ d = (PCICirrusVGAState *)pci_register_device_2("Cirrus VGA", vga_opts,
sizeof(PCICirrusVGAState),
- -1, NULL, NULL);
+ NULL, NULL);
pci_conf = d->dev.config;
pci_conf[0x00] = (uint8_t) (PCI_VENDOR_CIRRUS & 0xff);
pci_conf[0x01] = (uint8_t) (PCI_VENDOR_CIRRUS >> 8);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 9a41cdf..466c303 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -935,7 +935,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,
network_init(pci_bus);
/* Optional PCI video card */
- pci_cirrus_vga_init(pci_bus, phys_ram_base + ram_size,
+ pci_cirrus_vga_init(phys_ram_base + ram_size,
ram_size, vga_ram_size);
}
diff --git a/hw/pc.c b/hw/pc.c
index dd5fb8f..75b7374 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -945,8 +945,7 @@ vga_bios_error:
if (cirrus_vga_enabled) {
if (pci_enabled) {
- pci_cirrus_vga_init(pci_bus,
- phys_ram_base + vga_ram_addr,
+ pci_cirrus_vga_init(phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size);
} else {
isa_cirrus_vga_init(phys_ram_base + vga_ram_addr,
@@ -954,13 +953,13 @@ vga_bios_error:
}
} else if (vmsvga_enabled) {
if (pci_enabled)
- pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr,
+ pci_vmsvga_init(phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size);
else
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
} else if (std_vga_enabled) {
if (pci_enabled) {
- pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr,
+ pci_vga_init(phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size, 0, 0);
} else {
isa_vga_init(phys_ram_base + vga_ram_addr,
diff --git a/hw/pc.h b/hw/pc.h
index f43c138..827e8ba 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -129,7 +129,7 @@ extern const char *vga_opts;
int isa_vga_init(uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size);
-int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+int pci_vga_init(uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size,
unsigned long vga_bios_offset, int vga_bios_size);
int isa_vga_mm_init(uint8_t *vga_ram_base,
@@ -138,7 +138,7 @@ int isa_vga_mm_init(uint8_t *vga_ram_base,
int it_shift);
/* cirrus_vga.c */
-void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_cirrus_vga_init(uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size);
void isa_cirrus_vga_init(uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size);
diff --git a/hw/pci.h b/hw/pci.h
index 1528fc2..fe72881 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -141,7 +141,7 @@ void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
void *lsi_scsi_init(PCIBus *bus, int devfn);
/* vmware_vga.c */
-void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_vmsvga_init(uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size);
/* usb-uhci.c */
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index 64a613c..c15c4ae 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -256,7 +256,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL);
pci_bus = pci_pmac_init(pic);
/* init basic PC hardware */
- pci_vga_init(pci_bus, phys_ram_base + ram_size,
+ pci_vga_init(phys_ram_base + ram_size,
ram_size, vga_ram_size,
vga_bios_offset, vga_bios_size);
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index f60b174..882a523 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -296,7 +296,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
}
pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
pci_bus = pci_grackle_init(0xfec00000, pic);
- pci_vga_init(pci_bus, phys_ram_base + vga_ram_offset,
+ pci_vga_init(phys_ram_base + vga_ram_offset,
vga_ram_offset, vga_ram_size,
vga_bios_offset, vga_bios_size);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 934d520..bb692e3 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -655,7 +655,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory);
/* init basic PC hardware */
- pci_vga_init(pci_bus, phys_ram_base + ram_size, ram_size,
+ pci_vga_init(phys_ram_base + ram_size, ram_size,
vga_ram_size, 0, 0);
// openpic = openpic_init(0x00000000, 0xF0000000, 1);
// pit = pit_init(0x40, i8259[0]);
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 59aee1b..5d209fb 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -508,7 +508,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
&pci_bus3);
isa_mem_base = VGA_BASE;
vga_ram_offset = qemu_ram_alloc(vga_ram_size);
- pci_vga_init(pci_bus, phys_ram_base + vga_ram_offset,
+ pci_vga_init(phys_ram_base + vga_ram_offset,
vga_ram_offset, vga_ram_size,
0, 0);
diff --git a/hw/vga.c b/hw/vga.c
index 164e652..16ee247 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2481,7 +2481,7 @@ int isa_vga_mm_init(uint8_t *vga_ram_base,
return 0;
}
-int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+int pci_vga_init(uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size,
unsigned long vga_bios_offset, int vga_bios_size)
{
@@ -2489,9 +2489,9 @@ int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
VGAState *s;
uint8_t *pci_conf;
- d = (PCIVGAState *)pci_register_device(bus, "VGA",
+ d = (PCIVGAState *)pci_register_device_2("VGA", vga_opts,
sizeof(PCIVGAState),
- -1, NULL, NULL);
+ NULL, NULL);
if (!d)
return -1;
s = &d->vga_state;
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 950a98c..9a5380f 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -24,6 +24,7 @@
#include "hw.h"
#include "console.h"
#include "pci.h"
+#include "pc.h"
#define VERBOSE
#define EMBED_STDVGA
@@ -1214,15 +1215,15 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
#define PCI_CLASS_SUB_VGA 0x00
#define PCI_CLASS_HEADERTYPE_00h 0x00
-void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_vmsvga_init(uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size)
{
struct pci_vmsvga_state_s *s;
/* Setup PCI configuration */
s = (struct pci_vmsvga_state_s *)
- pci_register_device(bus, "QEMUware SVGA",
- sizeof(struct pci_vmsvga_state_s), -1, 0, 0);
+ pci_register_device_2("QEMUware SVGA", vga_opts,
+ sizeof(struct pci_vmsvga_state_s), 0, 0);
s->card.config[PCI_VENDOR_ID] = PCI_VENDOR_ID_VMWARE & 0xff;
s->card.config[PCI_VENDOR_ID + 1] = PCI_VENDOR_ID_VMWARE >> 8;
s->card.config[PCI_DEVICE_ID] = SVGA_PCI_DEVICE_ID & 0xff;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 4/9] Convert virtio_init_pci() to pci_register_device_2()
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (2 preceding siblings ...)
2009-01-22 19:30 ` [Qemu-devel] [PATCH 3/9] Support pci=... in option argument of -vga Markus Armbruster
@ 2009-01-22 19:31 ` Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 5/9] Support pci=... in option argument of -net nic Markus Armbruster
` (5 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:31 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
This is in preparation of pci=... support for virtio devices.
---
hw/virtio-balloon.c | 2 +-
hw/virtio-blk.c | 2 +-
hw/virtio-console.c | 2 +-
hw/virtio-net.c | 3 ++-
hw/virtio.c | 5 ++---
hw/virtio.h | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 0765516..0b9f7c9 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -171,7 +171,7 @@ void *virtio_balloon_init(PCIBus *bus)
{
VirtIOBalloon *s;
- s = (VirtIOBalloon *)virtio_init_pci(bus, "virtio-balloon",
+ s = (VirtIOBalloon *)virtio_init_pci("virtio-balloon", "",
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_BALLOON,
0, VIRTIO_ID_BALLOON,
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index e654cc5..f3a0dcb 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -224,7 +224,7 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs)
int cylinders, heads, secs;
static int virtio_blk_id;
- s = (VirtIOBlock *)virtio_init_pci(bus, "virtio-blk",
+ s = (VirtIOBlock *)virtio_init_pci("virtio-blk", "",
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_BLOCK,
0, VIRTIO_ID_BLOCK,
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index deae76d..77ac940 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -125,7 +125,7 @@ void *virtio_console_init(PCIBus *bus, CharDriverState *chr)
{
VirtIOConsole *s;
- s = (VirtIOConsole *)virtio_init_pci(bus, "virtio-console",
+ s = (VirtIOConsole *)virtio_init_pci("virtio-console", "",
6900, 0x1003,
0, VIRTIO_ID_CONSOLE,
0x03, 0x80, 0x00,
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 54c0030..3c7afb6 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -320,7 +320,8 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
VirtIONet *n;
static int virtio_net_id;
- n = (VirtIONet *)virtio_init_pci(bus, "virtio-net", 6900, 0x1000,
+ n = (VirtIONet *)virtio_init_pci("virtio-net", "",
+ 6900, 0x1000,
0, VIRTIO_ID_NET,
0x02, 0x00, 0x00,
sizeof(struct virtio_net_config),
diff --git a/hw/virtio.c b/hw/virtio.c
index dba80f8..c721c2a 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -805,7 +805,7 @@ void virtio_load(VirtIODevice *vdev, QEMUFile *f)
virtio_update_irq(vdev);
}
-VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name,
+VirtIODevice *virtio_init_pci(const char *name, const char *opts,
uint16_t vendor, uint16_t device,
uint16_t subvendor, uint16_t subdevice,
uint8_t class_code, uint8_t subclass_code,
@@ -817,8 +817,7 @@ VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name,
uint8_t *config;
uint32_t size;
- pci_dev = pci_register_device(bus, name, struct_size,
- -1, NULL, NULL);
+ pci_dev = pci_register_device_2(name, opts, struct_size, NULL, NULL);
if (!pci_dev)
return NULL;
diff --git a/hw/virtio.h b/hw/virtio.h
index 83511e2..18913fb 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -89,7 +89,7 @@ struct VirtIODevice
VirtQueue *vq;
};
-VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name,
+VirtIODevice *virtio_init_pci(const char *name, const char *opts,
uint16_t vendor, uint16_t device,
uint16_t subvendor, uint16_t subdevice,
uint8_t class_code, uint8_t subclass_code,
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 5/9] Support pci=... in option argument of -net nic
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (3 preceding siblings ...)
2009-01-22 19:31 ` [Qemu-devel] [PATCH 4/9] Convert virtio_init_pci() to pci_register_device_2() Markus Armbruster
@ 2009-01-22 19:31 ` Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 6/9] Make drives_opt[] accessible from device initialization Markus Armbruster
` (4 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:31 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
FIXME: the code registers two NICs with fixed device addresses. The
patch preserves that, but it's a disgusting hack.
---
hw/e1000.c | 6 +++---
hw/eepro100.c | 19 +++++++++----------
hw/mips_malta.c | 9 ++++-----
hw/ne2000.c | 7 +++----
hw/pc.c | 2 +-
hw/pci.c | 7 +++----
hw/pci.h | 17 ++++++++---------
hw/pcnet.c | 6 +++---
hw/ppc440_bamboo.c | 2 +-
hw/ppc_chrp.c | 2 +-
hw/ppc_oldworld.c | 2 +-
hw/ppc_prep.c | 2 +-
hw/r2d.c | 8 ++++----
hw/realview.c | 2 +-
hw/rtl8139.c | 7 +++----
hw/sun4u.c | 2 +-
hw/versatilepb.c | 2 +-
hw/virtio-net.c | 4 ++--
hw/virtio-net.h | 2 +-
net.c | 1 +
net.h | 1 +
21 files changed, 53 insertions(+), 57 deletions(-)
diff --git a/hw/e1000.c b/hw/e1000.c
index ccf9bc0..06f8c49 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1035,7 +1035,7 @@ e1000_mmio_map(PCIDevice *pci_dev, int region_num,
}
void
-pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
+pci_e1000_init(NICInfo *nd)
{
E1000State *d;
uint8_t *pci_conf;
@@ -1043,8 +1043,8 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
static const char info_str[] = "e1000";
int i;
- d = (E1000State *)pci_register_device(bus, "e1000",
- sizeof(E1000State), devfn, NULL, NULL);
+ d = (E1000State *)pci_register_device_2("e1000", nd->opts,
+ sizeof(E1000State), NULL, NULL);
pci_conf = d->dev.config;
memset(pci_conf, 0, 256);
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 5eca105..1784b7f 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1736,16 +1736,15 @@ static void nic_save(QEMUFile * f, void *opaque)
qemu_put_buffer(f, s->configuration, sizeof(s->configuration));
}
-static void nic_init(PCIBus * bus, NICInfo * nd,
- const char *name, uint32_t device)
+static void nic_init(NICInfo * nd, const char *name, uint32_t device)
{
PCIEEPRO100State *d;
EEPRO100State *s;
logout("\n");
- d = (PCIEEPRO100State *) pci_register_device(bus, name,
- sizeof(PCIEEPRO100State), -1,
+ d = (PCIEEPRO100State *) pci_register_device_2(name, nd->opts,
+ sizeof(PCIEEPRO100State),
NULL, NULL);
s = &d->eepro100;
@@ -1786,20 +1785,20 @@ static void nic_init(PCIBus * bus, NICInfo * nd,
register_savevm(name, -1, 3, nic_save, nic_load, s);
}
-void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
+void pci_i82551_init(NICInfo * nd)
{
- nic_init(bus, nd, "i82551", i82551);
+ nic_init(nd, "i82551", i82551);
//~ uint8_t *pci_conf = d->dev.config;
}
-void pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
+void pci_i82557b_init(NICInfo * nd)
{
- nic_init(bus, nd, "i82557b", i82557B);
+ nic_init(nd, "i82557b", i82557B);
}
-void pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
+void pci_i82559er_init(NICInfo * nd)
{
- nic_init(bus, nd, "i82559er", i82559ER);
+ nic_init(nd, "i82559er", i82559ER);
}
/* eof */
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 466c303..bce141d 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -483,19 +483,18 @@ static void audio_init (PCIBus *pci_bus)
#endif
/* Network support */
-static void network_init (PCIBus *pci_bus)
+static void network_init (void)
{
int i;
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
- int devfn = -1;
if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
/* The malta board has a PCNet card using PCI SLOT 11 */
- devfn = 88;
+ nd->opts = "pci=11"; /* FIXME disgusting hack */
- pci_nic_init(pci_bus, nd, devfn, "pcnet");
+ pci_nic_init(nd, "pcnet");
}
}
@@ -932,7 +931,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,
#endif
/* Network card */
- network_init(pci_bus);
+ network_init();
/* Optional PCI video card */
pci_cirrus_vga_init(phys_ram_base + ram_size,
diff --git a/hw/ne2000.c b/hw/ne2000.c
index a85730f..a59099e 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -779,15 +779,14 @@ static void ne2000_map(PCIDevice *pci_dev, int region_num,
register_ioport_read(addr + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
}
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
+void pci_ne2000_init(NICInfo *nd)
{
PCINE2000State *d;
NE2000State *s;
uint8_t *pci_conf;
- d = (PCINE2000State *)pci_register_device(bus,
- "NE2000", sizeof(PCINE2000State),
- devfn,
+ d = (PCINE2000State *)pci_register_device_2("NE2000", nd->opts,
+ sizeof(PCINE2000State),
NULL, NULL);
pci_conf = d->dev.config;
pci_conf[0x00] = 0xec; // Realtek 8029
diff --git a/hw/pc.c b/hw/pc.c
index 75b7374..5e70ca6 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1006,7 +1006,7 @@ vga_bios_error:
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd, i8259);
else
- pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
+ pci_nic_init(nd, "ne2k_pci");
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
diff --git a/hw/pci.c b/hw/pci.c
index a0e8562..ebfa5b7 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -756,7 +756,7 @@ static const char * const pci_nic_models[] = {
NULL
};
-typedef void (*PCINICInitFn)(PCIBus *, NICInfo *, int);
+typedef void (*PCINICInitFn)(NICInfo *);
static PCINICInitFn pci_nic_init_fns[] = {
pci_ne2000_init,
@@ -771,8 +771,7 @@ static PCINICInitFn pci_nic_init_fns[] = {
};
/* Initialize a PCI NIC. */
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
- const char *default_model)
+void pci_nic_init(NICInfo *nd, const char *default_model)
{
int i;
@@ -780,7 +779,7 @@ void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
for (i = 0; pci_nic_models[i]; i++)
if (strcmp(nd->model, pci_nic_models[i]) == 0)
- pci_nic_init_fns[i](bus, nd, devfn);
+ pci_nic_init_fns[i](nd);
}
typedef struct {
diff --git a/hw/pci.h b/hw/pci.h
index fe72881..ae6a4dd 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -123,8 +123,7 @@ typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq);
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
- const char *default_model);
+void pci_nic_init(NICInfo *nd, const char *default_model);
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
@@ -153,23 +152,23 @@ void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn);
/* eepro100.c */
-void pci_i82551_init(PCIBus *bus, NICInfo *nd, int devfn);
-void pci_i82557b_init(PCIBus *bus, NICInfo *nd, int devfn);
-void pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_i82551_init(NICInfo *nd);
+void pci_i82557b_init(NICInfo *nd);
+void pci_i82559er_init(NICInfo *nd);
/* ne2000.c */
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_ne2000_init(NICInfo *nd);
/* rtl8139.c */
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_rtl8139_init(NICInfo *nd);
/* e1000.c */
-void pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_e1000_init(NICInfo *nd);
/* pcnet.c */
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_pcnet_init(NICInfo *nd);
/* prep_pci.c */
PCIBus *pci_prep_init(qemu_irq *pic);
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 4411f75..1dcaf03 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1985,7 +1985,7 @@ static void pci_physical_memory_read(void *dma_opaque, target_phys_addr_t addr,
cpu_physical_memory_read(addr, buf, len);
}
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
+void pci_pcnet_init(NICInfo *nd)
{
PCNetState *d;
uint8_t *pci_conf;
@@ -1995,8 +1995,8 @@ void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));
#endif
- d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState),
- devfn, NULL, NULL);
+ d = (PCNetState *)pci_register_device_2("PCNet", nd->opts,
+ sizeof(PCNetState), NULL, NULL);
pci_conf = d->dev.config;
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 5f03661..3520b14 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -126,7 +126,7 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
for (i = 0; i < nb_nics; i++) {
/* There are no PCI NICs on the Bamboo board, but there are
* PCI slots, so we can pick whatever default model we want. */
- pci_nic_init(pcibus, &nd_table[i], -1, "e1000");
+ pci_nic_init(&nd_table[i], "e1000");
}
}
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index c15c4ae..af89d4e 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -267,7 +267,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(&nd_table[i], "ne2k_pci");
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 882a523..93a91a8 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -304,7 +304,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(&nd_table[i], "ne2k_pci");
/* First IDE channel is a CMD646 on the PCI bus */
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index bb692e3..ddd0b75 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -672,7 +672,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
} else {
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(&nd_table[i], "ne2k_pci");
}
}
diff --git a/hw/r2d.c b/hw/r2d.c
index 09305f3..044049c 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -201,7 +201,6 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
struct SH7750State *s;
ram_addr_t sdram_addr, sm501_vga_ram_addr;
qemu_irq *irq;
- PCIBus *pci;
int i;
if (!cpu_model)
@@ -219,7 +218,7 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
/* Register peripherals */
s = sh7750_init(env);
irq = r2d_fpga_init(0x04000000, sh7750_irl(s));
- pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4);
+ sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4);
sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE);
sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE,
@@ -230,9 +229,10 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);
/* NIC: rtl8139 on-board, and 2 slots. */
- pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
+ nd_table[0].opts = "pci=2"; /* FIXME disgusting hack */
+ pci_nic_init(&nd_table[0], "rtl8139");
for (i = 1; i < nb_nics; i++)
- pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(&nd_table[i], "ne2k_pci");
/* Todo: register on board registers */
{
diff --git a/hw/realview.c b/hw/realview.c
index aae4b86..c341225 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -126,7 +126,7 @@ static void realview_init(ram_addr_t ram_size, int vga_ram_size,
smc91c111_init(nd, 0x4e000000, pic[28]);
done_smc = 1;
} else {
- pci_nic_init(pci_bus, nd, -1, "rtl8139");
+ pci_nic_init(nd, "rtl8139");
}
}
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 70cb080..3a7c3ba 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3414,15 +3414,14 @@ static void rtl8139_timer(void *opaque)
}
#endif /* RTL8139_ONBOARD_TIMER */
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
+void pci_rtl8139_init(NICInfo *nd)
{
PCIRTL8139State *d;
RTL8139State *s;
uint8_t *pci_conf;
- d = (PCIRTL8139State *)pci_register_device(bus,
- "RTL8139", sizeof(PCIRTL8139State),
- devfn,
+ d = (PCIRTL8139State *)pci_register_device_2("RTL8139", nd->opts,
+ sizeof(PCIRTL8139State),
NULL, NULL);
pci_conf = d->dev.config;
pci_conf[0x00] = 0xec; /* Realtek 8139 */
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 5d209fb..f29d588 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -536,7 +536,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
}
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(&nd_table[i], "ne2k_pci");
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index f601e2f..c8e7e8c 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -199,7 +199,7 @@ static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
- pci_nic_init(pci_bus, nd, -1, "rtl8139");
+ pci_nic_init(nd, "rtl8139");
}
}
if (usb_enabled) {
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3c7afb6..0b03597 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -315,12 +315,12 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
+void virtio_net_init(NICInfo *nd)
{
VirtIONet *n;
static int virtio_net_id;
- n = (VirtIONet *)virtio_init_pci("virtio-net", "",
+ n = (VirtIONet *)virtio_init_pci("virtio-net", nd->opts,
6900, 0x1000,
0, VIRTIO_ID_NET,
0x02, 0x00, 0x00,
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 148ec47..4866ac9 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -80,6 +80,6 @@ struct virtio_net_hdr_mrg_rxbuf
uint16_t num_buffers; /* Number of merged rx buffers */
};
-void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
+void virtio_net_init(NICInfo *nd);
#endif
diff --git a/net.c b/net.c
index 86ee7d5..9f6b1e4 100644
--- a/net.c
+++ b/net.c
@@ -1581,6 +1581,7 @@ int net_client_init(const char *device, const char *p)
}
nd->vlan = vlan;
nd->name = name;
+ nd->opts = p;
name = NULL;
nb_nics++;
vlan->nb_guest_devs++;
diff --git a/net.h b/net.h
index 291807a..9e93dce 100644
--- a/net.h
+++ b/net.h
@@ -63,6 +63,7 @@ struct NICInfo {
uint8_t macaddr[6];
const char *model;
const char *name;
+ const char *opts;
VLANState *vlan;
};
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 6/9] Make drives_opt[] accessible from device initialization
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (4 preceding siblings ...)
2009-01-22 19:31 ` [Qemu-devel] [PATCH 5/9] Support pci=... in option argument of -net nic Markus Armbruster
@ 2009-01-22 19:31 ` Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 7/9] Support pci=... in option argument of -drive if=virtio Markus Armbruster
` (3 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:31 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
This is in preparation of pci=... support for block devices.
---
sysemu.h | 10 ++++++++++
vl.c | 7 ++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/sysemu.h b/sysemu.h
index 56eb9b3..79cbdf0 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -134,6 +134,7 @@ typedef struct DriveInfo {
int bus;
int unit;
char serial[21];
+ int drive_opt_idx;
} DriveInfo;
#define MAX_IDE_DEVS 2
@@ -143,6 +144,15 @@ typedef struct DriveInfo {
extern int nb_drives;
extern DriveInfo drives_table[MAX_DRIVES+1];
+struct drive_opt {
+ const char *file;
+ char opt[1024];
+ int used;
+};
+
+extern struct drive_opt drives_opt[MAX_DRIVES];
+extern int nb_drives_opt;
+
extern int drive_get_index(BlockInterfaceType type, int bus, int unit);
extern int drive_get_max_bus(BlockInterfaceType type);
extern const char *drive_get_serial(BlockDriverState *bdrv);
diff --git a/vl.c b/vl.c
index 4c1045c..cf413c2 100644
--- a/vl.c
+++ b/vl.c
@@ -246,11 +246,8 @@ int alt_grab = 0;
unsigned int nb_prom_envs = 0;
const char *prom_envs[MAX_PROM_ENVS];
#endif
-static int nb_drives_opt;
-static struct drive_opt {
- const char *file;
- char opt[1024];
-} drives_opt[MAX_DRIVES];
+int nb_drives_opt;
+struct drive_opt drives_opt[MAX_DRIVES];
static CPUState *cur_cpu;
static CPUState *next_cpu;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 7/9] Support pci=... in option argument of -drive if=virtio
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (5 preceding siblings ...)
2009-01-22 19:31 ` [Qemu-devel] [PATCH 6/9] Make drives_opt[] accessible from device initialization Markus Armbruster
@ 2009-01-22 19:31 ` Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw Markus Armbruster
` (2 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:31 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
---
hw/pc.c | 3 ++-
hw/ppc440_bamboo.c | 3 ++-
hw/virtio-blk.c | 2 +-
hw/virtio-blk.h | 2 +-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 5e70ca6..5fd8356 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1091,7 +1091,8 @@ vga_bios_error:
int unit_id = 0;
while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
- virtio_blk_init(pci_bus, drives_table[index].bdrv);
+ virtio_blk_init(drives_table[index].bdrv,
+ drives_opt[drives_table[index].drive_opt_idx].opt);
unit_id++;
}
}
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 3520b14..434fdc4 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -112,7 +112,8 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
/* Add virtio block devices. */
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
- virtio_blk_init(pcibus, drives_table[i].bdrv);
+ virtio_blk_init(drives_table[i].bdrv,
+ drives_opt[drives_table[i].drive_opt_idx].opt);
unit_id++;
}
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index f3a0dcb..8217424 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -218,7 +218,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs)
+void *virtio_blk_init(BlockDriverState *bs, const char *opts)
{
VirtIOBlock *s;
int cylinders, heads, secs;
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index 8c91e1e..4af3ccb 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -70,6 +70,6 @@ struct virtio_blk_inhdr
unsigned char status;
};
-void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs);
+void *virtio_blk_init(BlockDriverState *bs, const char *opts);
#endif
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (6 preceding siblings ...)
2009-01-22 19:31 ` [Qemu-devel] [PATCH 7/9] Support pci=... in option argument of -drive if=virtio Markus Armbruster
@ 2009-01-22 19:31 ` Markus Armbruster
2009-01-22 22:03 ` malc
2009-01-22 19:31 ` [Qemu-devel] [PATCH 9/9] Support pci=... in option argument of -audio Markus Armbruster
2009-01-22 20:06 ` [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Anthony Liguori
9 siblings, 1 reply; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:31 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
This is in preparation of pci=... support for audio devices. -soundhw
doesn't support the common name=value,... syntax.
---
sysemu.h | 1 +
vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 69 insertions(+), 26 deletions(-)
diff --git a/sysemu.h b/sysemu.h
index 79cbdf0..c47318b 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -199,6 +199,7 @@ void pstrcpy_targphys(target_phys_addr_t dest, int buf_size,
struct soundhw {
const char *name;
const char *descr;
+ const char *opts;
int enabled;
int isa;
union {
diff --git a/vl.c b/vl.c
index cf413c2..736c917 100644
--- a/vl.c
+++ b/vl.c
@@ -3866,6 +3866,8 @@ static void help(int exitcode)
#endif
#ifdef HAS_AUDIO
"-audio-help print list of audio drivers and their options\n"
+ "-audio model=type[,name=str]\n"
+ " enable a sound card\n"
"-soundhw c1,... enable audio support\n"
" and only specified sound cards (comma separated list)\n"
" use -soundhw ? to get the list of supported cards\n"
@@ -4034,6 +4036,7 @@ enum {
QEMU_OPTION_portrait,
#ifdef HAS_AUDIO
QEMU_OPTION_audio_help,
+ QEMU_OPTION_audio,
QEMU_OPTION_soundhw,
#endif
@@ -4134,6 +4137,7 @@ static const QEMUOption qemu_options[] = {
{ "k", HAS_ARG, QEMU_OPTION_k },
#ifdef HAS_AUDIO
{ "audio-help", 0, QEMU_OPTION_audio_help },
+ { "audio", HAS_ARG, QEMU_OPTION_audio },
{ "soundhw", HAS_ARG, QEMU_OPTION_soundhw },
#endif
@@ -4268,6 +4272,7 @@ struct soundhw soundhw[] = {
{
"pcspk",
"PC speaker",
+ NULL,
0,
1,
{ .init_isa = pcspk_audio_init }
@@ -4278,6 +4283,7 @@ struct soundhw soundhw[] = {
{
"sb16",
"Creative Sound Blaster 16",
+ NULL,
0,
1,
{ .init_isa = SB16_init }
@@ -4288,6 +4294,7 @@ struct soundhw soundhw[] = {
{
"cs4231a",
"CS4231A",
+ NULL,
0,
1,
{ .init_isa = cs4231a_init }
@@ -4302,6 +4309,7 @@ struct soundhw soundhw[] = {
#else
"Yamaha YM3812 (OPL2)",
#endif
+ NULL,
0,
1,
{ .init_isa = Adlib_init }
@@ -4312,6 +4320,7 @@ struct soundhw soundhw[] = {
{
"gus",
"Gravis Ultrasound GF1",
+ NULL,
0,
1,
{ .init_isa = GUS_init }
@@ -4322,6 +4331,7 @@ struct soundhw soundhw[] = {
{
"ac97",
"Intel 82801AA AC97 Audio",
+ NULL,
0,
0,
{ .init_pci = ac97_init }
@@ -4332,6 +4342,7 @@ struct soundhw soundhw[] = {
{
"es1370",
"ENSONIQ AudioPCI ES1370",
+ NULL,
0,
0,
{ .init_pci = es1370_init }
@@ -4340,60 +4351,88 @@ struct soundhw soundhw[] = {
#endif /* HAS_AUDIO_CHOICE */
- { NULL, NULL, 0, 0, { NULL } }
+ { NULL, NULL, NULL, 0, 0, { NULL } }
};
+static struct soundhw *soundhw_by_name(const char *name)
+{
+ struct soundhw *c;
+
+ for (c = soundhw; c->name; c++) {
+ if (!strcmp (c->name, name))
+ return c;
+ }
+ return NULL;
+}
+
+static void audio_show_models(void)
+{
+ struct soundhw *c;
+
+ for (c = soundhw; c->name; c++)
+ printf ("%-11s %s\n", c->name, c->descr);
+}
+
+static void audio_enable(const char *optarg)
+{
+ char model[16];
+ struct soundhw *c;
+
+ if (!get_param_value(model, sizeof(model), "model", optarg)) {
+ fprintf(stderr, "FIXME need model\n");
+ exit(1);
+ }
+
+ if (!strcmp(model, "?")) {
+ audio_show_models();
+ exit(0);
+ }
+
+ c = soundhw_by_name(model);
+ if (!c) {
+ fprintf(stderr, "FIXME unknown model\n");
+ exit(1);
+ }
+ c->enabled = 1;
+ c->opts = optarg;
+}
+
static void select_soundhw (const char *optarg)
{
struct soundhw *c;
+ char buf[32];
if (*optarg == '?') {
show_valid_cards:
printf ("Valid sound card names (comma separated):\n");
- for (c = soundhw; c->name; ++c) {
- printf ("%-11s %s\n", c->name, c->descr);
- }
+ audio_show_models();
printf ("\n-soundhw all will enable all of the above\n");
exit (*optarg != '?');
}
else {
- size_t l;
const char *p;
- char *e;
int bad_card = 0;
if (!strcmp (optarg, "all")) {
for (c = soundhw; c->name; ++c) {
c->enabled = 1;
+ c->opts = NULL;
}
return;
}
p = optarg;
while (*p) {
- e = strchr (p, ',');
- l = !e ? strlen (p) : (size_t) (e - p);
-
- for (c = soundhw; c->name; ++c) {
- if (!strncmp (c->name, p, l)) {
- c->enabled = 1;
- break;
- }
- }
-
- if (!c->name) {
- if (l > 80) {
- fprintf (stderr,
- "Unknown sound card name (too big to show)\n");
- }
- else {
- fprintf (stderr, "Unknown sound card name `%.*s'\n",
- (int) l, p);
- }
+ p = get_opt_value(buf, sizeof(buf), p);
+ c = soundhw_by_name(buf);
+ if (c) {
+ c->enabled = 1;
+ c->opts = NULL;
+ } else {
+ fprintf (stderr, "Unknown sound card name `%s'\n", buf);
bad_card = 1;
}
- p += l + (e != NULL);
}
if (bad_card)
@@ -4839,6 +4878,9 @@ int main(int argc, char **argv, char **envp)
AUD_help ();
exit (0);
break;
+ case QEMU_OPTION_audio:
+ audio_enable(optarg);
+ break;
case QEMU_OPTION_soundhw:
select_soundhw (optarg);
break;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PATCH 9/9] Support pci=... in option argument of -audio
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (7 preceding siblings ...)
2009-01-22 19:31 ` [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw Markus Armbruster
@ 2009-01-22 19:31 ` Markus Armbruster
2009-01-22 20:06 ` [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Anthony Liguori
9 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-22 19:31 UTC (permalink / raw)
To: qemu-devel
From: Markus Armbruster <armbru@pond.sub.org>
---
hw/ac97.c | 11 +++--------
hw/audiodev.h | 4 ++--
hw/es1370.c | 11 +++--------
hw/mips_malta.c | 6 +++---
hw/pc.c | 11 ++++-------
sysemu.h | 2 +-
6 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/hw/ac97.c b/hw/ac97.c
index dc9a165..eab56a8 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -1308,25 +1308,20 @@ static void ac97_on_reset (void *opaque)
mixer_reset (s);
}
-int ac97_init (PCIBus *bus, AudioState *audio)
+int ac97_init (AudioState *audio, const char *opts)
{
PCIAC97LinkState *d;
AC97LinkState *s;
uint8_t *c;
- if (!bus) {
- AUD_log ("ac97", "No PCI bus\n");
- return -1;
- }
-
if (!audio) {
AUD_log ("ac97", "No audio state\n");
return -1;
}
- d = (PCIAC97LinkState *) pci_register_device (bus, "AC97",
+ d = (PCIAC97LinkState *) pci_register_device_2("AC97", opts,
sizeof (PCIAC97LinkState),
- -1, NULL, NULL);
+ NULL, NULL);
if (!d) {
AUD_log ("ac97", "Failed to register PCI device\n");
diff --git a/hw/audiodev.h b/hw/audiodev.h
index 5f4a211..8b7ff9b 100644
--- a/hw/audiodev.h
+++ b/hw/audiodev.h
@@ -1,5 +1,5 @@
/* es1370.c */
-int es1370_init (PCIBus *bus, AudioState *s);
+int es1370_init (AudioState *s, const char *opts);
/* sb16.c */
int SB16_init (AudioState *s, qemu_irq *pic);
@@ -11,7 +11,7 @@ int Adlib_init (AudioState *s, qemu_irq *pic);
int GUS_init (AudioState *s, qemu_irq *pic);
/* ac97.c */
-int ac97_init (PCIBus *buf, AudioState *s);
+int ac97_init (AudioState *s, const char *opts);
/* cs4231a.c */
int cs4231a_init (AudioState *s, qemu_irq *pic);
diff --git a/hw/es1370.c b/hw/es1370.c
index bad237d..5f77ca4 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -1005,25 +1005,20 @@ static void es1370_on_reset (void *opaque)
es1370_reset (s);
}
-int es1370_init (PCIBus *bus, AudioState *audio)
+int es1370_init (AudioState *audio, const char *opts)
{
PCIES1370State *d;
ES1370State *s;
uint8_t *c;
- if (!bus) {
- dolog ("No PCI bus\n");
- return -1;
- }
-
if (!audio) {
dolog ("No audio state\n");
return -1;
}
- d = (PCIES1370State *) pci_register_device (bus, "ES1370",
+ d = (PCIES1370State *) pci_register_device_2 ("ES1370", opts,
sizeof (PCIES1370State),
- -1, NULL, NULL);
+ NULL, NULL);
if (!d) {
AUD_log (NULL, "Failed to register PCI device for ES1370\n");
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index bce141d..066bf15 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -459,7 +459,7 @@ static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir
/* Audio support */
#ifdef HAS_AUDIO
-static void audio_init (PCIBus *pci_bus)
+static void audio_init (void)
{
struct soundhw *c;
int audio_enabled = 0;
@@ -475,7 +475,7 @@ static void audio_init (PCIBus *pci_bus)
if (s) {
for (c = soundhw; c->name; ++c) {
if (c->enabled)
- c->init.init_pci (pci_bus, s);
+ c->init.init_pci (s, c->opts);
}
}
}
@@ -927,7 +927,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,
/* Sound card */
#ifdef HAS_AUDIO
- audio_init(pci_bus);
+ audio_init();
#endif
/* Network card */
diff --git a/hw/pc.c b/hw/pc.c
index 5fd8356..deb8dcb 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -709,7 +709,7 @@ static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
#ifdef HAS_AUDIO
-static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
+static void audio_init (qemu_irq *pic)
{
struct soundhw *c;
int audio_enabled = 0;
@@ -727,11 +727,8 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
if (c->enabled) {
if (c->isa) {
c->init.init_isa (s, pic);
- }
- else {
- if (pci_bus) {
- c->init.init_pci (pci_bus, s);
- }
+ } else {
+ c->init.init_pci (s, c->opts);
}
}
}
@@ -1034,7 +1031,7 @@ vga_bios_error:
i8042_init(i8259[1], i8259[12], 0x60);
DMA_init(0);
#ifdef HAS_AUDIO
- audio_init(pci_enabled ? pci_bus : NULL, i8259);
+ audio_init(i8259);
#endif
for(i = 0; i < MAX_FD; i++) {
diff --git a/sysemu.h b/sysemu.h
index c47318b..cac3fa7 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -204,7 +204,7 @@ struct soundhw {
int isa;
union {
int (*init_isa) (AudioState *s, qemu_irq *pic);
- int (*init_pci) (PCIBus *bus, AudioState *s);
+ int (*init_pci) (AudioState *s, const char *opts);
} init;
};
--
1.6.0.6
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
` (8 preceding siblings ...)
2009-01-22 19:31 ` [Qemu-devel] [PATCH 9/9] Support pci=... in option argument of -audio Markus Armbruster
@ 2009-01-22 20:06 ` Anthony Liguori
2009-01-23 9:04 ` Markus Armbruster
` (2 more replies)
9 siblings, 3 replies; 22+ messages in thread
From: Anthony Liguori @ 2009-01-22 20:06 UTC (permalink / raw)
To: qemu-devel
Markus Armbruster wrote:
> This patch series makes PCI device addresses configurable for a number
> of devices. For now, I just covered the ones I consider important
> and/or where the change is somewhat invasive.
>
> Why is a configurable PCI device address useful? Currently, QEMU
> assigns a few device addresses statically, and the rest dynamically on
> a first come, first serve basis[*]. If you add or remove a device,
> all devices registering later change address. I'm told a certain
> operating system that can't be named in polite company can get rather
> upset about that.
>
> Making the device address configurable looks like the simplest
> solution to this problem. Only users who really mind changing
> addresses have to deal with the new configuration parameter.
>
I think we're starting to get to the tipping point where we really just
need to introduce a machine config file.
Paul, you mentioned you were working on something before? Care to
update us on the status?
I know there was a fair bit of support before for a FDT based machine
config.
Regards,
Anthony Liguori
> I started with Izik's proposal to "allow setting static slot values
> for pci devices from the command line", see
>
> http://lists.gnu.org/archive/html/qemu-devel/2008-01/msg00601.html
> http://lists.gnu.org/archive/html/qemu-devel/2007-11/msg00620.html
>
> but ended up doing it quite differently.
>
> I'm just soliciting comments. I do *not* ask for a commit of anything
> right now.
>
> The patch series consists of these parts:
>
> [1/9] PCI device registration helpers
> [2/9] Clean up handling of name=value,... part of -vga option argument
> [3/9] Support pci=... in option argument of -vga
> [4/9] Convert virtio_init_pci() to pci_register_device_2()
> [5/9] Support pci=... in option argument of -net nic
> [6/9] Make drives_opt[] accessible from device initialization
> [7/9] Support pci=... in option argument of -drive if=virtio
> [8/9] New option -audio as a more flexible alternative to -soundhw
> [9/9] Support pci=... in option argument of -audio
>
> Overall diffstat:
>
> hw/ac97.c | 11 +---
> hw/audiodev.h | 4 +-
> hw/cirrus_vga.c | 6 +-
> hw/e1000.c | 6 +-
> hw/eepro100.c | 19 ++++----
> hw/es1370.c | 11 +---
> hw/mips_malta.c | 17 +++----
> hw/ne2000.c | 7 +--
> hw/pc.c | 23 ++++------
> hw/pc.h | 11 +---
> hw/pci.c | 109 ++++++++++++++++++++++++++++++++++++++++++++--
> hw/pci.h | 25 ++++++----
> hw/pcnet.c | 6 +-
> hw/ppc440_bamboo.c | 5 +-
> hw/ppc_chrp.c | 4 +-
> hw/ppc_oldworld.c | 4 +-
> hw/ppc_prep.c | 4 +-
> hw/r2d.c | 8 ++--
> hw/realview.c | 2 +-
> hw/rtl8139.c | 7 +--
> hw/sun4u.c | 4 +-
> hw/versatilepb.c | 2 +-
> hw/vga.c | 40 ++++++++--------
> hw/virtio-balloon.c | 2 +-
> hw/virtio-blk.c | 4 +-
> hw/virtio-blk.h | 2 +-
> hw/virtio-console.c | 2 +-
> hw/virtio-net.c | 5 +-
> hw/virtio-net.h | 2 +-
> hw/virtio.c | 5 +-
> hw/virtio.h | 2 +-
> hw/vmware_vga.c | 7 ++-
> net.c | 1 +
> net.h | 1 +
> sysemu.h | 13 +++++-
> vl.c | 120 ++++++++++++++++++++++++++++++++-------------------
> 36 files changed, 315 insertions(+), 186 deletions(-)
>
>
> [*] To be precise: it assigns the dev.func part dynamically. The
> domain:bus: part is still statically assigned.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-22 19:31 ` [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw Markus Armbruster
@ 2009-01-22 22:03 ` malc
2009-01-23 8:32 ` Markus Armbruster
0 siblings, 1 reply; 22+ messages in thread
From: malc @ 2009-01-22 22:03 UTC (permalink / raw)
To: qemu-devel
On Thu, 22 Jan 2009, Markus Armbruster wrote:
> From: Markus Armbruster <armbru@pond.sub.org>
>
> This is in preparation of pci=... support for audio devices. -soundhw
> doesn't support the common name=value,... syntax.
> ---
> sysemu.h | 1 +
> vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
> 2 files changed, 69 insertions(+), 26 deletions(-)
This as, i guess, the rest of the patches is tab damaged. The
documentation wasn't updated either.
[..snip..]
--
mailto:av1474@comtv.ru
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-22 22:03 ` malc
@ 2009-01-23 8:32 ` Markus Armbruster
2009-01-23 9:29 ` Kevin Wolf
0 siblings, 1 reply; 22+ messages in thread
From: Markus Armbruster @ 2009-01-23 8:32 UTC (permalink / raw)
To: qemu-devel
malc <av1474@comtv.ru> writes:
> On Thu, 22 Jan 2009, Markus Armbruster wrote:
>
>> From: Markus Armbruster <armbru@pond.sub.org>
>>
>> This is in preparation of pci=... support for audio devices. -soundhw
>> doesn't support the common name=value,... syntax.
>> ---
>> sysemu.h | 1 +
>> vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
>> 2 files changed, 69 insertions(+), 26 deletions(-)
>
> This as, i guess, the rest of the patches is tab damaged. The
> documentation wasn't updated either.
>
> [..snip..]
It's just a sketch. How would you like your tabs?
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
2009-01-22 20:06 ` [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Anthony Liguori
@ 2009-01-23 9:04 ` Markus Armbruster
2009-01-23 10:23 ` Daniel P. Berrange
2009-01-23 19:06 ` Paul Brook
2 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-23 9:04 UTC (permalink / raw)
To: qemu-devel
Anthony Liguori <anthony@codemonkey.ws> writes:
> Markus Armbruster wrote:
>> This patch series makes PCI device addresses configurable for a number
>> of devices. For now, I just covered the ones I consider important
>> and/or where the change is somewhat invasive.
>>
>> Why is a configurable PCI device address useful? Currently, QEMU
>> assigns a few device addresses statically, and the rest dynamically on
>> a first come, first serve basis[*]. If you add or remove a device,
>> all devices registering later change address. I'm told a certain
>> operating system that can't be named in polite company can get rather
>> upset about that.
>>
>> Making the device address configurable looks like the simplest
>> solution to this problem. Only users who really mind changing
>> addresses have to deal with the new configuration parameter.
>>
>
> I think we're starting to get to the tipping point where we really
> just need to introduce a machine config file.
Makes sense to me. But considering the idea has been mulled around
for so long (half a year?) without obvious progress (obvious to
ignorant me!), I chose to scratch my itch right away. Any chance I
can get it scratched now, or do I have to wait for the machine
description file feature?
> Paul, you mentioned you were working on something before? Care to
> update us on the status?
Yes, please!
> I know there was a fair bit of support before for a FDT based machine
> config.
>
> Regards,
>
> Anthony Liguori
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-23 8:32 ` Markus Armbruster
@ 2009-01-23 9:29 ` Kevin Wolf
2009-01-23 10:04 ` Markus Armbruster
0 siblings, 1 reply; 22+ messages in thread
From: Kevin Wolf @ 2009-01-23 9:29 UTC (permalink / raw)
To: qemu-devel
Markus Armbruster schrieb:
> malc <av1474@comtv.ru> writes:
>
>> On Thu, 22 Jan 2009, Markus Armbruster wrote:
>>
>>> From: Markus Armbruster <armbru@pond.sub.org>
>>>
>>> This is in preparation of pci=... support for audio devices. -soundhw
>>> doesn't support the common name=value,... syntax.
>>> ---
>>> sysemu.h | 1 +
>>> vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
>>> 2 files changed, 69 insertions(+), 26 deletions(-)
>> This as, i guess, the rest of the patches is tab damaged. The
>> documentation wasn't updated either.
>>
>> [..snip..]
>
> It's just a sketch. How would you like your tabs?
Probably four spaces, just like in the surrounding code (as almost
everywhere in qemu).
Kevin
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-23 9:29 ` Kevin Wolf
@ 2009-01-23 10:04 ` Markus Armbruster
2009-01-23 10:24 ` Kevin Wolf
0 siblings, 1 reply; 22+ messages in thread
From: Markus Armbruster @ 2009-01-23 10:04 UTC (permalink / raw)
To: qemu-devel
Kevin Wolf <kwolf@suse.de> writes:
> Markus Armbruster schrieb:
>> malc <av1474@comtv.ru> writes:
>>
>>> On Thu, 22 Jan 2009, Markus Armbruster wrote:
>>>
>>>> From: Markus Armbruster <armbru@pond.sub.org>
>>>>
>>>> This is in preparation of pci=... support for audio devices. -soundhw
>>>> doesn't support the common name=value,... syntax.
>>>> ---
>>>> sysemu.h | 1 +
>>>> vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
>>>> 2 files changed, 69 insertions(+), 26 deletions(-)
>>> This as, i guess, the rest of the patches is tab damaged. The
>>> documentation wasn't updated either.
>>>
>>> [..snip..]
>>
>> It's just a sketch. How would you like your tabs?
>
> Probably four spaces, just like in the surrounding code (as almost
> everywhere in qemu).
>
> Kevin
Can't see where I got that wrong.
Any preference on use of the tab character?
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
2009-01-22 20:06 ` [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Anthony Liguori
2009-01-23 9:04 ` Markus Armbruster
@ 2009-01-23 10:23 ` Daniel P. Berrange
2009-01-23 19:06 ` Paul Brook
2 siblings, 0 replies; 22+ messages in thread
From: Daniel P. Berrange @ 2009-01-23 10:23 UTC (permalink / raw)
To: qemu-devel
On Thu, Jan 22, 2009 at 02:06:08PM -0600, Anthony Liguori wrote:
> Markus Armbruster wrote:
> >This patch series makes PCI device addresses configurable for a number
> >of devices. For now, I just covered the ones I consider important
> >and/or where the change is somewhat invasive.
> >
> >Why is a configurable PCI device address useful? Currently, QEMU
> >assigns a few device addresses statically, and the rest dynamically on
> >a first come, first serve basis[*]. If you add or remove a device,
> >all devices registering later change address. I'm told a certain
> >operating system that can't be named in polite company can get rather
> >upset about that.
> >
> >Making the device address configurable looks like the simplest
> >solution to this problem. Only users who really mind changing
> >addresses have to deal with the new configuration parameter.
> >
>
> I think we're starting to get to the tipping point where we really just
> need to introduce a machine config file.
I think we passed that point a long time ago :-) If someone were to make
use of every single QEMU command line arg, with many disks & nics we're
probably already hitting the ARGV size limit.
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-23 10:04 ` Markus Armbruster
@ 2009-01-23 10:24 ` Kevin Wolf
2009-01-23 11:51 ` Markus Armbruster
0 siblings, 1 reply; 22+ messages in thread
From: Kevin Wolf @ 2009-01-23 10:24 UTC (permalink / raw)
To: qemu-devel
Markus Armbruster schrieb:
> Kevin Wolf <kwolf@suse.de> writes:
>
>> Markus Armbruster schrieb:
>>> malc <av1474@comtv.ru> writes:
>>>
>>>> On Thu, 22 Jan 2009, Markus Armbruster wrote:
>>>>
>>>>> From: Markus Armbruster <armbru@pond.sub.org>
>>>>>
>>>>> This is in preparation of pci=... support for audio devices. -soundhw
>>>>> doesn't support the common name=value,... syntax.
>>>>> ---
>>>>> sysemu.h | 1 +
>>>>> vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
>>>>> 2 files changed, 69 insertions(+), 26 deletions(-)
>>>> This as, i guess, the rest of the patches is tab damaged. The
>>>> documentation wasn't updated either.
>>>>
>>>> [..snip..]
>>> It's just a sketch. How would you like your tabs?
>> Probably four spaces, just like in the surrounding code (as almost
>> everywhere in qemu).
>>
>> Kevin
>
> Can't see where I got that wrong.
>
> Any preference on use of the tab character?
Most of the qemu code only uses spaces, no real tabs.
Kevin
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
2009-01-23 10:24 ` Kevin Wolf
@ 2009-01-23 11:51 ` Markus Armbruster
0 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-23 11:51 UTC (permalink / raw)
To: qemu-devel
Kevin Wolf <kwolf@suse.de> writes:
> Markus Armbruster schrieb:
>> Kevin Wolf <kwolf@suse.de> writes:
>>
>>> Markus Armbruster schrieb:
>>>> malc <av1474@comtv.ru> writes:
>>>>
>>>>> On Thu, 22 Jan 2009, Markus Armbruster wrote:
>>>>>
>>>>>> From: Markus Armbruster <armbru@pond.sub.org>
>>>>>>
>>>>>> This is in preparation of pci=... support for audio devices. -soundhw
>>>>>> doesn't support the common name=value,... syntax.
>>>>>> ---
>>>>>> sysemu.h | 1 +
>>>>>> vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
>>>>>> 2 files changed, 69 insertions(+), 26 deletions(-)
>>>>> This as, i guess, the rest of the patches is tab damaged. The
>>>>> documentation wasn't updated either.
>>>>>
>>>>> [..snip..]
>>>> It's just a sketch. How would you like your tabs?
>>> Probably four spaces, just like in the surrounding code (as almost
>>> everywhere in qemu).
>>>
>>> Kevin
>>
>> Can't see where I got that wrong.
>>
>> Any preference on use of the tab character?
>
> Most of the qemu code only uses spaces, no real tabs.
>
> Kevin
I didn't bother to avoid tabs, because I found them in existing code.
But I can certainly avoid them. Thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
2009-01-22 20:06 ` [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Anthony Liguori
2009-01-23 9:04 ` Markus Armbruster
2009-01-23 10:23 ` Daniel P. Berrange
@ 2009-01-23 19:06 ` Paul Brook
2009-01-23 19:28 ` Anthony Liguori
2 siblings, 1 reply; 22+ messages in thread
From: Paul Brook @ 2009-01-23 19:06 UTC (permalink / raw)
To: qemu-devel
> I think we're starting to get to the tipping point where we really just
> need to introduce a machine config file.
>
> Paul, you mentioned you were working on something before? Care to
> update us on the status?
>
> I know there was a fair bit of support before for a FDT based machine
> config.
I have a FDT based machine descriptions working locally.
Currently it's only capable of generating a small subset ARM embedded boards.
There are a few issues that need to be resolved before it can replace most of
the current qemu machines:
- How to handle "plug-n-play" busses like PCI. The FDT provided to the kernel
generally just describes the host bridge, and the kernel/bios figures
everything else out using the normal PCI config mechanisms.
- How it will interact with commandline options like -nic that modify which
hardware is present. One possibility is to remove these options (remove -net
nic, but leave -net tap, etc.). If users want different numbers/types of NICs
they should use a different machine config.
- How to handle GPIO pins, and other interconnects like I2S, SSI and I2C. I
guess this is mainly coming up with suitable FDT representations.
I have not implemented a user level config file. My work effectively just
replaces integratorcp_init and friends.
Paul
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
2009-01-23 19:06 ` Paul Brook
@ 2009-01-23 19:28 ` Anthony Liguori
2009-01-26 8:55 ` Markus Armbruster
0 siblings, 1 reply; 22+ messages in thread
From: Anthony Liguori @ 2009-01-23 19:28 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
Paul Brook wrote:
>> I think we're starting to get to the tipping point where we really just
>> need to introduce a machine config file.
>>
>> Paul, you mentioned you were working on something before? Care to
>> update us on the status?
>>
>> I know there was a fair bit of support before for a FDT based machine
>> config.
>>
>
> I have a FDT based machine descriptions working locally.
>
Can you post what you have?
> Currently it's only capable of generating a small subset ARM embedded boards.
> There are a few issues that need to be resolved before it can replace most of
> the current qemu machines:
>
> - How to handle "plug-n-play" busses like PCI. The FDT provided to the kernel
> generally just describes the host bridge, and the kernel/bios figures
> everything else out using the normal PCI config mechanisms.
> - How it will interact with commandline options like -nic that modify which
> hardware is present. One possibility is to remove these options (remove -net
> nic, but leave -net tap, etc.). If users want different numbers/types of NICs
> they should use a different machine config.
> - How to handle GPIO pins, and other interconnects like I2S, SSI and I2C. I
> guess this is mainly coming up with suitable FDT representations.
>
> I have not implemented a user level config file. My work effectively just
> replaces integratorcp_init and friends.
>
A user level config file can come later.
Regards,
Anthony Liguori
> Paul
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses
2009-01-23 19:28 ` Anthony Liguori
@ 2009-01-26 8:55 ` Markus Armbruster
0 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2009-01-26 8:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook
Anthony Liguori <anthony@codemonkey.ws> writes:
> Paul Brook wrote:
>>> I think we're starting to get to the tipping point where we really just
>>> need to introduce a machine config file.
>>>
>>> Paul, you mentioned you were working on something before? Care to
>>> update us on the status?
>>>
>>> I know there was a fair bit of support before for a FDT based machine
>>> config.
>>>
>>
>> I have a FDT based machine descriptions working locally.
>>
>
> Can you post what you have?
Yes, please!
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2009-01-26 18:02 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-22 19:23 [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 1/9] PCI device registration helpers Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 2/9] Clean up handling of name=value, ... part of -vga option argument Markus Armbruster
2009-01-22 19:30 ` [Qemu-devel] [PATCH 3/9] Support pci=... in option argument of -vga Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 4/9] Convert virtio_init_pci() to pci_register_device_2() Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 5/9] Support pci=... in option argument of -net nic Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 6/9] Make drives_opt[] accessible from device initialization Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 7/9] Support pci=... in option argument of -drive if=virtio Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw Markus Armbruster
2009-01-22 22:03 ` malc
2009-01-23 8:32 ` Markus Armbruster
2009-01-23 9:29 ` Kevin Wolf
2009-01-23 10:04 ` Markus Armbruster
2009-01-23 10:24 ` Kevin Wolf
2009-01-23 11:51 ` Markus Armbruster
2009-01-22 19:31 ` [Qemu-devel] [PATCH 9/9] Support pci=... in option argument of -audio Markus Armbruster
2009-01-22 20:06 ` [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses Anthony Liguori
2009-01-23 9:04 ` Markus Armbruster
2009-01-23 10:23 ` Daniel P. Berrange
2009-01-23 19:06 ` Paul Brook
2009-01-23 19:28 ` Anthony Liguori
2009-01-26 8:55 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).