From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Subject: [Qemu-devel] [PATCH 10/11] isa: give bus to isa_create() methods
Date: Sun, 18 Sep 2011 16:56:42 +0200 [thread overview]
Message-ID: <1316357803-2366-11-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <1316357803-2366-1-git-send-email-hpoussin@reactos.org>
This allows to create a device on requested ISA bus. If argument
is not provided, 'default' ISA bus is used.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/cs4231a.c | 2 +-
hw/fdc.h | 2 +-
hw/gus.c | 2 +-
hw/ide/isa.c | 2 +-
hw/isa-bus.c | 30 +++++++++++++++++++-----------
hw/isa.h | 6 +++---
hw/m48t59.c | 2 +-
hw/mc146818rtc.c | 2 +-
hw/mips_fulong2e.c | 2 +-
hw/mips_malta.c | 2 +-
hw/mips_r4k.c | 2 +-
hw/pc.c | 8 ++++----
hw/pc.h | 12 ++++++------
hw/ppc_prep.c | 2 +-
hw/sb16.c | 2 +-
hw/sun4u.c | 2 +-
16 files changed, 44 insertions(+), 36 deletions(-)
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index e16f9a3..9e6fbaa 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -661,7 +661,7 @@ static int cs4231a_initfn (ISADevice *dev)
int cs4231a_init(ISABus *bus)
{
- isa_create_simple ("cs4231a");
+ isa_create_simple(bus, "cs4231a");
return 0;
}
diff --git a/hw/fdc.h b/hw/fdc.h
index 09f73c6..65a4a8d 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -11,7 +11,7 @@ static inline void fdctrl_init_isa(DriveInfo **fds)
{
ISADevice *dev;
- dev = isa_try_create("isa-fdc");
+ dev = isa_try_create(NULL, "isa-fdc");
if (!dev) {
return;
}
diff --git a/hw/gus.c b/hw/gus.c
index e4dbc8a..fa56f8f 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -296,7 +296,7 @@ static int gus_initfn (ISADevice *dev)
int GUS_init(ISABus *bus)
{
- isa_create_simple ("gus");
+ isa_create_simple(bus, "gus");
return 0;
}
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 28b69d2..032f105 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -81,7 +81,7 @@ ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
ISADevice *dev;
ISAIDEState *s;
- dev = isa_create("isa-ide");
+ dev = isa_create(NULL, "isa-ide");
qdev_prop_set_uint32(&dev->qdev, "iobase", iobase);
qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2);
qdev_prop_set_uint32(&dev->qdev, "irq", isairq);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 37642b7..b697f65 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -126,35 +126,41 @@ void isa_qdev_register(ISADeviceInfo *info)
qdev_register(&info->qdev);
}
-ISADevice *isa_create(const char *name)
+ISADevice *isa_create(ISABus *bus, const char *name)
{
DeviceState *dev;
- if (!isabus) {
+ if (!bus) {
+ bus = isabus;
+ }
+ if (!bus) {
hw_error("Tried to create isa device %s with no isa bus present.",
name);
}
- dev = qdev_create(&isabus->qbus, name);
+ dev = qdev_create(&bus->qbus, name);
return DO_UPCAST(ISADevice, qdev, dev);
}
-ISADevice *isa_try_create(const char *name)
+ISADevice *isa_try_create(ISABus *bus, const char *name)
{
DeviceState *dev;
- if (!isabus) {
+ if (!bus) {
+ bus = isabus;
+ }
+ if (!bus) {
hw_error("Tried to create isa device %s with no isa bus present.",
name);
}
- dev = qdev_try_create(&isabus->qbus, name);
+ dev = qdev_try_create(&bus->qbus, name);
return DO_UPCAST(ISADevice, qdev, dev);
}
-ISADevice *isa_create_simple(const char *name)
+ISADevice *isa_create_simple(ISABus *bus, const char *name)
{
ISADevice *dev;
- dev = isa_create(name);
+ dev = isa_create(bus, name);
qdev_init_nofail(&dev->qdev);
return dev;
}
@@ -188,9 +194,11 @@ static char *isabus_get_fw_dev_path(DeviceState *dev)
MemoryRegion *isa_address_space(ISADevice *dev)
{
- if (!isabus || !isabus->ops->get_address_space) {
- hw_error("Tried to get isa address space with no isa bus present.");
+ ISABus *bus = FROM_QBUS(ISABus, qdev_get_parent_bus(&dev->qdev));
+
+ if (!bus->ops->get_address_space) {
+ hw_error("Tried to get isa address space on invalid isa bus.");
}
- return isabus->ops->get_address_space(isabus);
+ return bus->ops->get_address_space(bus);
}
diff --git a/hw/isa.h b/hw/isa.h
index 5219b98..03ecd55 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -48,9 +48,9 @@ void isa_init_ioport(ISADevice *dev, uint16_t ioport);
void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
void isa_qdev_register(ISADeviceInfo *info);
MemoryRegion *isa_address_space(ISADevice *dev);
-ISADevice *isa_create(const char *name);
-ISADevice *isa_try_create(const char *name);
-ISADevice *isa_create_simple(const char *name);
+ISADevice *isa_create(ISABus *bus, const char *name);
+ISADevice *isa_try_create(ISABus *bus, const char *name);
+ISADevice *isa_create_simple(ISABus *bus, const char *name);
extern target_phys_addr_t isa_mem_base;
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 0cc361e..91b8c47 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -661,7 +661,7 @@ M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type)
ISADevice *dev;
M48t59State *s;
- dev = isa_create("m48t59_isa");
+ dev = isa_create(NULL, "m48t59_isa");
qdev_prop_set_uint32(&dev->qdev, "type", type);
qdev_prop_set_uint32(&dev->qdev, "size", size);
qdev_prop_set_uint32(&dev->qdev, "io_base", io_base);
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index feb3b25..dd07656 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -646,7 +646,7 @@ ISADevice *rtc_init(int base_year, qemu_irq intercept_irq)
ISADevice *dev;
RTCState *s;
- dev = isa_create("mc146818rtc");
+ dev = isa_create(NULL, "mc146818rtc");
s = DO_UPCAST(RTCState, dev, dev);
qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
qdev_init_nofail(&dev->qdev);
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 3034a9c..938aeaf 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -358,7 +358,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
DMA_init(0, cpu_exit_irq);
/* Super I/O */
- isa_create_simple("i8042");
+ isa_create_simple(NULL, "i8042");
rtc_init(2000, NULL);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 65e5915..fe90db1 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -951,7 +951,7 @@ void mips_malta_init (ram_addr_t ram_size,
DMA_init(0, cpu_exit_irq);
/* Super I/O */
- isa_create_simple("i8042");
+ isa_create_simple(NULL, "i8042");
rtc_init(2000, NULL);
serial_isa_init(0, serial_hds[0]);
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index aaa38b0..d09c62d 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -294,7 +294,7 @@ void mips_r4k_init (ram_addr_t ram_size,
hd[MAX_IDE_DEVS * i],
hd[MAX_IDE_DEVS * i + 1]);
- isa_create_simple("i8042");
+ isa_create_simple(NULL, "i8042");
}
static QEMUMachine mips_machine = {
diff --git a/hw/pc.c b/hw/pc.c
index 5bc845a..c33992f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1103,7 +1103,7 @@ void pc_vga_init(PCIBus *pci_bus)
* For nographic case, sga is enabled at all times
*/
if (display_type == DT_NOGRAPHIC) {
- isa_create_simple("sga");
+ isa_create_simple(NULL, "sga");
}
}
@@ -1161,11 +1161,11 @@ void pc_basic_device_init(qemu_irq *isa_irq,
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
- i8042 = isa_create_simple("i8042");
+ i8042 = isa_create_simple(NULL, "i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
if (!no_vmport) {
vmport_init();
- vmmouse = isa_try_create("vmmouse");
+ vmmouse = isa_try_create(NULL, "vmmouse");
} else {
vmmouse = NULL;
}
@@ -1173,7 +1173,7 @@ void pc_basic_device_init(qemu_irq *isa_irq,
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
qdev_init_nofail(&vmmouse->qdev);
}
- port92 = isa_create_simple("port92");
+ port92 = isa_create_simple(NULL, "port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
diff --git a/hw/pc.h b/hw/pc.h
index 8d1573f..1824787 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -23,7 +23,7 @@ static inline bool serial_isa_init(int index, CharDriverState *chr)
{
ISADevice *dev;
- dev = isa_try_create("isa-serial");
+ dev = isa_try_create(NULL, "isa-serial");
if (!dev) {
return false;
}
@@ -42,7 +42,7 @@ static inline bool parallel_init(int index, CharDriverState *chr)
{
ISADevice *dev;
- dev = isa_try_create("isa-parallel");
+ dev = isa_try_create(NULL, "isa-parallel");
if (!dev) {
return false;
}
@@ -88,7 +88,7 @@ static inline ISADevice *pit_init(int base, int irq)
{
ISADevice *dev;
- dev = isa_create("isa-pit");
+ dev = isa_create(NULL, "isa-pit");
qdev_prop_set_uint32(&dev->qdev, "iobase", base);
qdev_prop_set_uint32(&dev->qdev, "irq", irq);
qdev_init_nofail(&dev->qdev);
@@ -108,7 +108,7 @@ void hpet_pit_enable(void);
/* vmport.c */
static inline void vmport_init(void)
{
- isa_create_simple("vmport");
+ isa_create_simple(NULL, "vmport");
}
void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque);
void vmmouse_get_data(uint32_t *data);
@@ -208,7 +208,7 @@ static inline int isa_vga_init(void)
{
ISADevice *dev;
- dev = isa_try_create("isa-vga");
+ dev = isa_try_create(NULL, "isa-vga");
if (!dev) {
fprintf(stderr, "Warning: isa-vga not available\n");
return 0;
@@ -233,7 +233,7 @@ static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd)
qemu_check_nic_model(nd, "ne2k_isa");
- dev = isa_try_create("ne2k_isa");
+ dev = isa_try_create(NULL, "ne2k_isa");
if (!dev) {
return false;
}
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 5b313c8..b72453c 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -688,7 +688,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
hd[2 * i],
hd[2 * i + 1]);
}
- isa_create_simple("i8042");
+ isa_create_simple(NULL, "i8042");
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(1, cpu_exit_irq);
diff --git a/hw/sb16.c b/hw/sb16.c
index 6af2f59..b851fcb 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -1393,7 +1393,7 @@ static int sb16_initfn (ISADevice *dev)
int SB16_init(ISABus *bus)
{
- isa_create_simple ("sb16");
+ isa_create_simple(bus, "sb16");
return 0;
}
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 211a9bd..4981c3a 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -805,7 +805,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
pci_cmd646_ide_init(pci_bus, hd, 1);
- isa_create_simple("i8042");
+ isa_create_simple(NULL, "i8042");
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
--
1.7.5.4
next prev parent reply other threads:[~2011-09-18 14:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-18 14:56 [Qemu-devel] [PATCH 00/11] ISA bus improvements Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 01/11] isa: rename isa_bus_new to isa_bus_bridge_init Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 02/11] isa: rework ISA bus internals, and add ISA bus ops structure Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 03/11] isa: implement isa_address_space() as a method of ISA bus Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 04/11] audio: give ISA bus to sound cards, instead of PIC Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 05/11] pc: improve bus implementation of PIIX3 bridge Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 06/11] fulong2e: move pic initialization + ISA bus creation to south bridge Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 07/11] sun4u: improve bus implementation of EBus bridge Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 08/11] malta: improve bus implementation of PIIX4 bridge Hervé Poussineau
2011-09-18 14:56 ` [Qemu-devel] [PATCH 09/11] isa: remove unused parameter to isa_bus_bridge_init() Hervé Poussineau
2011-09-18 14:56 ` Hervé Poussineau [this message]
2011-09-18 14:56 ` [Qemu-devel] [PATCH 11/11] isa: remove limitation of only one ISA bus Hervé Poussineau
2011-09-18 19:21 ` [Qemu-devel] [PATCH 00/11] ISA bus improvements Jan Kiszka
2011-09-18 19:33 ` Hervé Poussineau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1316357803-2366-11-git-send-email-hpoussin@reactos.org \
--to=hpoussin@reactos.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.