@@ -1,5 +1,5 @@
/* icc_bus.c
- * emulate x86 ICC(Interrupt Controller Communications) bus
+ * emulate x86 ICC (Interrupt Controller Communications) bus
*
* Copyright (c) 2013 Red Hat, Inc
*
@@ -23,6 +23,7 @@
#include "hw/sysbus.h"
/* icc-bridge implementation */
+
static void icc_bus_init(Object *obj)
{
BusState *b = BUS(obj);
@@ -37,18 +38,18 @@ static const TypeInfo icc_bus_info = {
.instance_init = icc_bus_init,
};
+
/* icc-device implementation */
-static void icc_device_realizefn(DeviceState *dev, Error **err)
+
+static void icc_device_realize(DeviceState *dev, Error **errp)
{
ICCDevice *id = ICC_DEVICE(dev);
ICCDeviceClass *k = ICC_DEVICE_GET_CLASS(id);
- Error *local_err = NULL;
if (k->init) {
if (k->init(id) < 0) {
- error_setg(&local_err, "%s initialization failed.",
+ error_setg(errp, "%s initialization failed.",
object_get_typename(OBJECT(dev)));
- error_propagate(err, local_err);
}
}
}
@@ -57,7 +58,7 @@ static void icc_device_class_init(ObjectClass *klass,
void *da
ta)
{
DeviceClass *k = DEVICE_CLASS(klass);
- k->realize = icc_device_realizefn;
+ k->realize = icc_device_realize;
k->bus_type = TYPE_ICC_BUS;
}
@@ -70,10 +71,14 @@ static const TypeInfo icc_device_info = {
.class_init = icc_device_class_init,
};
+
/* icc-bridge implementation */
+
typedef struct ICCBridgeState {
/*< private >*/
SysBusDevice parent_obj;
+ /*< public >*/
+
ICCBus icc_bus;
} ICCBridgeState;
@@ -1,5 +1,5 @@
/* icc_bus.h
- * emulate x86 ICC(Interrupt Controller Communications) bus
+ * emulate x86 ICC (Interrupt Controller Communications) bus
*
* Copyright (c) 2013 Red Hat, Inc
*
@@ -28,21 +28,42 @@
#ifndef CONFIG_USER_ONLY
+/**
+ * ICCBus:
+ *
+ * ICC bus
+ */
typedef struct ICCBus {
/*< private >*/
BusState parent_obj;
+ /*< public >*/
} ICCBus;
#define ICC_BUS(obj) OBJECT_CHECK(ICCBus, (obj), TYPE_ICC_BUS)
+/**
+ * ICCDevice:
+ *
+ * ICC device
+ */
typedef struct ICCDevice {
+ /*< private >*/
+ DeviceState parent_obj;
/*< public >*/
- DeviceState qdev;
} ICCDevice;
+/**
+ * ICCDeviceClass:
+ * @init: Initialization callback for derived classes.
+ *
+ * ICC device class
+ */
typedef struct ICCDeviceClass {
+ /*< private >*/
DeviceClass parent_class;
- int (*init)(ICCDevice *dev);
+ /*< public >*/
+
+ int (*init)(ICCDevice *dev); /* TODO replace with QOM realize */
} ICCDeviceClass;
#define TYPE_ICC_DEVICE "icc-device"
@@ -56,10 +56,10 @@ static void icc_device_realize(DeviceState *dev,
Error **errp)
static void icc_device_class_init(ObjectClass *klass, void *data)
{
- DeviceClass *k = DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- k->realize = icc_device_realize;
- k->bus_type = TYPE_ICC_BUS;
+ dc->realize = icc_device_realize;
+ dc->bus_type = TYPE_ICC_BUS;
}
static const TypeInfo icc_device_info = {
@@ -44,19 +44,19 @@ static const TypeInfo icc_bus_info = {
static void icc_device_realize(DeviceState *dev, Error **errp)
{
ICCDevice *id = ICC_DEVICE(dev);
- ICCDeviceClass *k = ICC_DEVICE_GET_CLASS(id);
+ ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id);
- if (k->init) {
- if (k->init(id) < 0) {
+ if (idc->init) {
+ if (idc->init(id) < 0) {
error_setg(errp, "%s initialization failed.",
object_get_typename(OBJECT(dev)));
}
}
}
-static void icc_device_class_init(ObjectClass *klass, void *data)
+static void icc_device_class_init(ObjectClass *oc, void *data)
{
- DeviceClass *dc = DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = icc_device_realize;
dc->bus_type = TYPE_ICC_BUS;