From: Liu Ping Fan <qemulist@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Anthony Liguori" <anthony@codemonkey.ws>,
"Jan Kiszka" <jan.kiszka@siemens.com>
Subject: [Qemu-devel] [PATCH v3 2/3] qdev: interface for SysBusDevice to change property on requirement
Date: Fri, 30 Aug 2013 15:53:51 +0800 [thread overview]
Message-ID: <1377849232-27822-3-git-send-email-pingfank@linux.vnet.ibm.com> (raw)
In-Reply-To: <1377849232-27822-1-git-send-email-pingfank@linux.vnet.ibm.com>
qdev's property can not be set after realized, but there is a
requirement of adjusting device's behavior on different mother
boards. So introducing a callback in sysbus_try_create_simple()
to adjust device's property on board's demand.
(This patch is needed by the later one which changes hpet's intcap
property)
Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
hw/core/sysbus.c | 5 ++++-
hw/i386/pc.c | 2 +-
include/hw/sysbus.h | 8 +++++---
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 9004d8c..e894bbb 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -172,7 +172,7 @@ DeviceState *sysbus_create_varargs(const char *name,
return dev;
}
-DeviceState *sysbus_try_create_varargs(const char *name,
+DeviceState *sysbus_try_create_varargs(const char *name, CompatSet set,
hwaddr addr, ...)
{
DeviceState *dev;
@@ -185,6 +185,9 @@ DeviceState *sysbus_try_create_varargs(const char *name,
if (!dev) {
return NULL;
}
+ if (set) {
+ set(dev);
+ }
s = SYS_BUS_DEVICE(dev);
qdev_init_nofail(dev);
if (addr != (hwaddr)-1) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e8bc8ce..09c10ac 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1247,7 +1247,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
* when the HPET wants to take over. Thus we have to disable the latter.
*/
if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
- hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
+ hpet = sysbus_try_create_simple("hpet", NULL, HPET_BASE, NULL);
if (hpet) {
for (i = 0; i < GSI_NUM_PINS; i++) {
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index bb50a87..47337f2 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -58,6 +58,8 @@ struct SysBusDevice {
pio_addr_t pio[QDEV_MAX_PIO];
};
+typedef void (*CompatSet)(DeviceState *dev);
+
void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
@@ -77,7 +79,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev);
/* Legacy helper function for creating devices. */
DeviceState *sysbus_create_varargs(const char *name,
hwaddr addr, ...);
-DeviceState *sysbus_try_create_varargs(const char *name,
+DeviceState *sysbus_try_create_varargs(const char *name, CompatSet set,
hwaddr addr, ...);
static inline DeviceState *sysbus_create_simple(const char *name,
hwaddr addr,
@@ -86,11 +88,11 @@ static inline DeviceState *sysbus_create_simple(const char *name,
return sysbus_create_varargs(name, addr, irq, NULL);
}
-static inline DeviceState *sysbus_try_create_simple(const char *name,
+static inline DeviceState *sysbus_try_create_simple(const char *name, CompatSet set,
hwaddr addr,
qemu_irq irq)
{
- return sysbus_try_create_varargs(name, addr, irq, NULL);
+ return sysbus_try_create_varargs(name, set, addr, irq, NULL);
}
#endif /* !HW_SYSBUS_H */
--
1.8.1.4
next prev parent reply other threads:[~2013-08-30 7:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-30 7:53 [Qemu-devel] [PATCH v3 0/3] bugs fix for hpet Liu Ping Fan
2013-08-30 7:53 ` [Qemu-devel] [PATCH v3 1/3] hpet: inverse polarity when pin above ISA_NUM_IRQS Liu Ping Fan
2013-08-30 7:53 ` Liu Ping Fan [this message]
2013-08-30 8:17 ` [Qemu-devel] [PATCH v3 2/3] qdev: interface for SysBusDevice to change property on requirement Paolo Bonzini
2013-08-30 12:32 ` Andreas Färber
2013-09-02 6:11 ` liu ping fan
2013-09-02 6:10 ` liu ping fan
2013-08-30 8:31 ` Peter Maydell
2013-08-30 7:53 ` [Qemu-devel] [PATCH v3 3/3] hpet: entitle more irq pins for hpet Liu Ping Fan
2013-08-30 12:31 ` Andreas Färber
2013-08-30 12:43 ` Paolo Bonzini
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=1377849232-27822-3-git-send-email-pingfank@linux.vnet.ibm.com \
--to=qemulist@gmail.com \
--cc=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=jan.kiszka@siemens.com \
--cc=pbonzini@redhat.com \
--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 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).