mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
s390x/event-facility: code restructure
Code restructure in order to simplify class hierarchy - remove S390SCLPDevice abstract base class and move function pointers into new SCLPEventFacilityClass - implement SCLPEventFacility as SysBusDevice - use define constants for instance creation strings The following ascii-art shows the class structure wrt the SCLP EventFacility before (CURRENT) and after the restructure (NEW): ---- CURRENT: "s390-sclp-events-bus" +-------------------------+ | SCLPEventsBus | |-------------------------| |BusState qbus | +-------------------------+ +-------------------------+ | SCLPEventFacility | - to be replaced by new SCLPEventFacility, |-------------------------| which will be a SysBusDevice |SCLPEventsBus sbus | |DeviceState *qdev | |unsigned int receive_mask| +-------------------------+ +-------------------------+ | S390SCLPDeviceClass | - to be replaced by new SCLPEventFacilityClass |-------------------------| |DeviceClass qdev | |*(init)() | +-------------------------+ "s390-sclp-event-facility" | instance-of | V "s390-sclp-device" - this is an abstract class +-------------------------+ | S390SCLPDevice (A)| - to be replaced by new SCLPEventFacility |-------------------------| |SysBusDevice busdev | |SCLPEventFacility *ef | | | |*(sclp_command_handler)()| - these 2 go to new SCLPEventFacilityClass |*(event_pending)() | +-------------------------+ ---- NEW: "s390-sclp-events-bus" +-------------------------+ | SCLPEventsBus | |-------------------------| |BusState qbus | +-------------------------+ +-------------------------+ | SCLPEventFacilityClass | |-------------------------| |DeviceClass parent_class | | | |*(init)() | |*(command_handler)() | |*(event_pending)() | +-------------------------+ "s390-sclp-event-facility" +-------------------------+ | SCLPEventFacility | |-------------------------| |SysBusDevice parent_class| |SCLPEventsBus sbus | |unsigned int receive_mask| +-------------------------+ Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
This commit is contained in:
parent
65e526c24e
commit
477a72a1ef
4 changed files with 47 additions and 88 deletions
|
@ -26,8 +26,8 @@ typedef struct SCLPEventsBus {
|
|||
} SCLPEventsBus;
|
||||
|
||||
struct SCLPEventFacility {
|
||||
SysBusDevice parent_obj;
|
||||
SCLPEventsBus sbus;
|
||||
DeviceState *qdev;
|
||||
/* guest' receive mask */
|
||||
unsigned int receive_mask;
|
||||
};
|
||||
|
@ -315,21 +315,15 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code)
|
|||
}
|
||||
}
|
||||
|
||||
static int init_event_facility(S390SCLPDevice *sdev)
|
||||
static int init_event_facility(SCLPEventFacility *event_facility)
|
||||
{
|
||||
SCLPEventFacility *event_facility;
|
||||
DeviceState *sdev = DEVICE(event_facility);
|
||||
DeviceState *quiesce;
|
||||
|
||||
event_facility = g_malloc0(sizeof(SCLPEventFacility));
|
||||
sdev->ef = event_facility;
|
||||
sdev->sclp_command_handler = command_handler;
|
||||
sdev->event_pending = event_pending;
|
||||
|
||||
/* Spawn a new sclp-events facility */
|
||||
/* Spawn a new bus for SCLP events */
|
||||
qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus),
|
||||
TYPE_SCLP_EVENTS_BUS, DEVICE(sdev), NULL);
|
||||
TYPE_SCLP_EVENTS_BUS, sdev, NULL);
|
||||
event_facility->sbus.qbus.allow_hotplug = 0;
|
||||
event_facility->qdev = (DeviceState *) sdev;
|
||||
|
||||
quiesce = qdev_create(&event_facility->sbus.qbus, "sclpquiesce");
|
||||
if (!quiesce) {
|
||||
|
@ -346,25 +340,29 @@ static int init_event_facility(S390SCLPDevice *sdev)
|
|||
|
||||
static void reset_event_facility(DeviceState *dev)
|
||||
{
|
||||
S390SCLPDevice *sdev = SCLP_S390_DEVICE(dev);
|
||||
SCLPEventFacility *sdev = EVENT_FACILITY(dev);
|
||||
|
||||
sdev->ef->receive_mask = 0;
|
||||
sdev->receive_mask = 0;
|
||||
}
|
||||
|
||||
static void init_event_facility_class(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
S390SCLPDeviceClass *k = SCLP_S390_DEVICE_CLASS(klass);
|
||||
SysBusDeviceClass *sbdc = SYS_BUS_DEVICE_CLASS(klass);
|
||||
DeviceClass *dc = DEVICE_CLASS(sbdc);
|
||||
SCLPEventFacilityClass *k = EVENT_FACILITY_CLASS(dc);
|
||||
|
||||
dc->reset = reset_event_facility;
|
||||
k->init = init_event_facility;
|
||||
k->command_handler = command_handler;
|
||||
k->event_pending = event_pending;
|
||||
}
|
||||
|
||||
static const TypeInfo sclp_event_facility_info = {
|
||||
.name = "s390-sclp-event-facility",
|
||||
.parent = TYPE_DEVICE_S390_SCLP,
|
||||
.instance_size = sizeof(S390SCLPDevice),
|
||||
.name = TYPE_SCLP_EVENT_FACILITY,
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(SCLPEventFacility),
|
||||
.class_init = init_event_facility_class,
|
||||
.class_size = sizeof(SCLPEventFacilityClass),
|
||||
};
|
||||
|
||||
static int event_qdev_init(DeviceState *qdev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue