QOM infrastructure fixes and device conversions
* Assertion fix for device_add with non-device types * Documentation fix * qdev_init() error reporting cleanups -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJU7IMRAAoJEPou0S0+fgE/C+kP/AkIe+Uc9cotMxiJG7n7e1tB VN/hfPJWvRkC7Ap1PuJ/0+/cJyEALzsvj4DuUq+K7daiQfNppHhOeaHEpsDfYA02 Jsg8JHDGJxIQNRDcSMSFYTbZaY3WGQssp1q5ossRgo3I9Vc34Fdyo7hIE55bEO3K sHofEDQ3B6dG7CsZohd+yWstrq0L4T7KQGRWSaBX2s30o8pn61xYyIKITDkDQr9r /zshiyD7pPV7p0szW8MtRPk1ku3l6DRCAEjTl4OfY0FIDaOBJPRtMCCAqrbPL2If B6+um62/Os3uhR3RV39scxBDq29flbYo3qc5UHZH8ry2OWPeA1Qgld8bydovS/Ge ZLQjBbgMjrJySC8aoa2xl7u2+wPypZB7bMWm+ipnE4EQJ49eCnC2vW6RnMJ/KS+3 cOp0U7hdsFwrvcWYna8Mclp3tzhji8ysQMdl5p5eeHzq+0auo7ccsE9/o6VJv9Wb VbJlzahEkGT6qaiGhgtk3rU2PMrAHUkG6yDKiox9pW1uw4iV/4icKRsbipqLs5pO jR1ygWT9oELf205HmgrAHUTd9Lk2pPhwfcdsznw0IMuZR2BYogD2M9p6kpCQmJiu dYBKUB+qCWrlpuIzFwlK36bqrGT6dsfLTujwyzGIigyO5L8UN3CThWUUIkMW4q1A ZMVNGtBuvdW/WlzoO1QB =p+Qd -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging QOM infrastructure fixes and device conversions * Assertion fix for device_add with non-device types * Documentation fix * qdev_init() error reporting cleanups # gpg: Signature made Tue Feb 24 13:56:33 2015 GMT using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" * remotes/afaerber/tags/qom-devices-for-peter: parallel: parallel_hds_isa_init() shouldn't fail parallel: Factor out common parallel_hds_isa_init() serial: serial_hds_isa_init() shouldn't fail serial: Factor out common serial_hds_isa_init() etsec: Replace qdev_init() by qdev_init_nofail() leon3: Replace unchecked qdev_init() by qdev_init_nofail() ide/isa: Replace unchecked qdev_init() by qdev_init_nofail() qdev: Improve qdev_init_nofail()'s error reporting qom: Fix typo, 'my_class_init' -> 'derived_class_init' qdev: Avoid type assertion in qdev_build_hotpluggable_device_list() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
5de090464f
@ -83,11 +83,7 @@ static void clipper_init(MachineState *machine)
|
||||
pci_vga_init(pci_bus);
|
||||
|
||||
/* Serial code setup. */
|
||||
for (i = 0; i < MAX_SERIAL_PORTS; ++i) {
|
||||
if (serial_hds[i]) {
|
||||
serial_isa_init(isa_bus, i, serial_hds[i]);
|
||||
}
|
||||
}
|
||||
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
|
||||
|
||||
/* Network setup. e1000 is good enough, failing Tulip support. */
|
||||
for (i = 0; i < nb_nics; i++) {
|
||||
|
@ -641,3 +641,28 @@ static void parallel_register_types(void)
|
||||
}
|
||||
|
||||
type_init(parallel_register_types)
|
||||
|
||||
static void parallel_init(ISABus *bus, int index, CharDriverState *chr)
|
||||
{
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_create(bus, "isa-parallel");
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "index", index);
|
||||
qdev_prop_set_chr(dev, "chardev", chr);
|
||||
qdev_init_nofail(dev);
|
||||
}
|
||||
|
||||
void parallel_hds_isa_init(ISABus *bus, int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(n <= MAX_PARALLEL_PORTS);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (parallel_hds[i]) {
|
||||
parallel_init(bus, i, parallel_hds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,20 +119,27 @@ static void serial_register_types(void)
|
||||
|
||||
type_init(serial_register_types)
|
||||
|
||||
bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
|
||||
static void serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
|
||||
{
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_try_create(bus, TYPE_ISA_SERIAL);
|
||||
if (!isadev) {
|
||||
return false;
|
||||
}
|
||||
isadev = isa_create(bus, TYPE_ISA_SERIAL);
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "index", index);
|
||||
qdev_prop_set_chr(dev, "chardev", chr);
|
||||
if (qdev_init(dev) < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
qdev_init_nofail(dev);
|
||||
}
|
||||
|
||||
void serial_hds_isa_init(ISABus *bus, int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(n <= MAX_SERIAL_PORTS);
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (serial_hds[i]) {
|
||||
serial_isa_init(bus, i, serial_hds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,10 +373,15 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
|
||||
way is somewhat unclean, and best avoided. */
|
||||
void qdev_init_nofail(DeviceState *dev)
|
||||
{
|
||||
const char *typename = object_get_typename(OBJECT(dev));
|
||||
Error *err = NULL;
|
||||
|
||||
if (qdev_init(dev) < 0) {
|
||||
error_report("Initialization of device %s failed", typename);
|
||||
assert(!dev->realized);
|
||||
|
||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||
if (err) {
|
||||
error_report("Initialization of device %s failed: %s",
|
||||
object_get_typename(OBJECT(dev)),
|
||||
error_get_pretty(err));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -995,7 +1000,12 @@ void qdev_alias_all_properties(DeviceState *target, Object *source)
|
||||
static int qdev_add_hotpluggable_device(Object *obj, void *opaque)
|
||||
{
|
||||
GSList **list = opaque;
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
DeviceState *dev = (DeviceState *)object_dynamic_cast(OBJECT(obj),
|
||||
TYPE_DEVICE);
|
||||
|
||||
if (dev == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) {
|
||||
*list = g_slist_append(*list, dev);
|
||||
|
13
hw/i386/pc.c
13
hw/i386/pc.c
@ -1419,17 +1419,8 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||
pcspk_init(isa_bus, pit);
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
|
||||
if (serial_hds[i]) {
|
||||
serial_isa_init(isa_bus, i, serial_hds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
|
||||
if (parallel_hds[i]) {
|
||||
parallel_init(isa_bus, i, parallel_hds[i]);
|
||||
}
|
||||
}
|
||||
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
|
||||
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
|
||||
|
||||
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
|
||||
i8042 = isa_create_simple(isa_bus, "i8042");
|
||||
|
@ -88,9 +88,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
|
||||
qdev_prop_set_uint32(dev, "iobase", iobase);
|
||||
qdev_prop_set_uint32(dev, "iobase2", iobase2);
|
||||
qdev_prop_set_uint32(dev, "irq", isairq);
|
||||
if (qdev_init(dev) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
|
||||
s = ISA_IDE(dev);
|
||||
if (hd0) {
|
||||
|
@ -277,7 +277,6 @@ static void mips_fulong2e_init(MachineState *machine)
|
||||
PCIBus *pci_bus;
|
||||
ISABus *isa_bus;
|
||||
I2CBus *smbus;
|
||||
int i;
|
||||
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
MIPSCPU *cpu;
|
||||
CPUMIPSState *env;
|
||||
@ -384,15 +383,8 @@ static void mips_fulong2e_init(MachineState *machine)
|
||||
|
||||
rtc_init(isa_bus, 2000, NULL);
|
||||
|
||||
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
|
||||
if (serial_hds[i]) {
|
||||
serial_isa_init(isa_bus, i, serial_hds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (parallel_hds[0]) {
|
||||
parallel_init(isa_bus, 0, parallel_hds[0]);
|
||||
}
|
||||
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
|
||||
parallel_hds_isa_init(isa_bus, 1);
|
||||
|
||||
/* Sound card */
|
||||
audio_init(pci_bus);
|
||||
|
@ -1172,10 +1172,9 @@ void mips_malta_init(MachineState *machine)
|
||||
isa_create_simple(isa_bus, "i8042");
|
||||
|
||||
rtc_init(isa_bus, 2000, NULL);
|
||||
serial_isa_init(isa_bus, 0, serial_hds[0]);
|
||||
serial_isa_init(isa_bus, 1, serial_hds[1]);
|
||||
if (parallel_hds[0])
|
||||
parallel_init(isa_bus, 0, parallel_hds[0]);
|
||||
serial_hds_isa_init(isa_bus, 2);
|
||||
parallel_hds_isa_init(isa_bus, 1);
|
||||
|
||||
for(i = 0; i < MAX_FD; i++) {
|
||||
fd[i] = drive_get(IF_FLOPPY, 0, i);
|
||||
}
|
||||
|
@ -284,11 +284,7 @@ void mips_r4k_init(MachineState *machine)
|
||||
|
||||
pit = pit_init(isa_bus, 0x40, 0, NULL);
|
||||
|
||||
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
|
||||
if (serial_hds[i]) {
|
||||
serial_isa_init(isa_bus, i, serial_hds[i]);
|
||||
}
|
||||
}
|
||||
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
|
||||
|
||||
isa_vga_init(isa_bus);
|
||||
|
||||
|
@ -443,10 +443,7 @@ DeviceState *etsec_create(hwaddr base,
|
||||
|
||||
dev = qdev_create(NULL, "eTSEC");
|
||||
qdev_set_nic_properties(dev, nd);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, tx_irq);
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, rx_irq);
|
||||
|
@ -850,17 +850,9 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
|
||||
NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN);
|
||||
i++;
|
||||
}
|
||||
for(; i < MAX_SERIAL_PORTS; i++) {
|
||||
if (serial_hds[i]) {
|
||||
serial_isa_init(isa_bus, i, serial_hds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
|
||||
if (parallel_hds[i]) {
|
||||
parallel_init(isa_bus, i, parallel_hds[i]);
|
||||
}
|
||||
}
|
||||
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
|
||||
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
|
||||
|
||||
for(i = 0; i < nb_nics; i++)
|
||||
pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
|
||||
|
@ -92,6 +92,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
|
||||
|
||||
/* serial-isa.c */
|
||||
#define TYPE_ISA_SERIAL "isa-serial"
|
||||
bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr);
|
||||
void serial_hds_isa_init(ISABus *bus, int n);
|
||||
|
||||
#endif
|
||||
|
@ -107,23 +107,8 @@ struct PcGuestInfo {
|
||||
};
|
||||
|
||||
/* parallel.c */
|
||||
static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
|
||||
{
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_try_create(bus, "isa-parallel");
|
||||
if (!isadev) {
|
||||
return false;
|
||||
}
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "index", index);
|
||||
qdev_prop_set_chr(dev, "chardev", chr);
|
||||
if (qdev_init(dev) < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void parallel_hds_isa_init(ISABus *bus, int n);
|
||||
|
||||
bool parallel_mm_init(MemoryRegion *address_space,
|
||||
hwaddr base, int it_shift, qemu_irq irq,
|
||||
|
@ -55,9 +55,7 @@ DeviceState *grlib_irqmp_create(hwaddr base,
|
||||
qdev_prop_set_ptr(dev, "set_pil_in", set_pil_in);
|
||||
qdev_prop_set_ptr(dev, "set_pil_in_opaque", env);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
|
||||
env->irq_manager = dev;
|
||||
|
||||
@ -87,9 +85,7 @@ DeviceState *grlib_gptimer_create(hwaddr base,
|
||||
qdev_prop_set_uint32(dev, "frequency", freq);
|
||||
qdev_prop_set_uint32(dev, "irq-line", base_irq);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
|
||||
@ -112,9 +108,7 @@ DeviceState *grlib_apbuart_create(hwaddr base,
|
||||
dev = qdev_create(NULL, "grlib,apbuart");
|
||||
qdev_prop_set_chr(dev, "chrdev", serial);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
|
||||
|
@ -273,7 +273,7 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||
* .name = TYPE_DERIVED,
|
||||
* .parent = TYPE_MY,
|
||||
* .class_size = sizeof(DerivedClass),
|
||||
* .class_init = my_class_init,
|
||||
* .class_init = derived_class_init,
|
||||
* };
|
||||
* </programlisting>
|
||||
* </example>
|
||||
|
Loading…
Reference in New Issue
Block a user