xref: /openbmc/qemu/hw/s390x/ccw-device.h (revision 4f752191)
1 /*
2  * Common device infrastructure for devices in the virtual css
3  *
4  * Copyright 2016 IBM Corp.
5  * Author(s): Jing Liu <liujbjl@linux.vnet.ibm.com>
6  *
7  * This work is licensed under the terms of the GNU GPL, version 2 or (at
8  * your option) any later version. See the COPYING file in the top-level
9  * directory.
10  */
11 
12 #ifndef HW_S390X_CCW_DEVICE_H
13 #define HW_S390X_CCW_DEVICE_H
14 #include "qom/object.h"
15 #include "hw/qdev-core.h"
16 #include "hw/s390x/css.h"
17 #include "hw/s390x/css-bridge.h"
18 
19 struct CcwDevice {
20     DeviceState parent_obj;
21     SubchDev *sch;
22     /* <cssid>.<ssid>.<device number> */
23     /* The user-set busid of the virtual ccw device. */
24     CssDevId devno;
25     /* The actual busid of the virtual ccw device. */
26     CssDevId dev_id;
27     /* The actual busid of the virtual subchannel. */
28     CssDevId subch_id;
29     /* If set, use this loadparm value when device is boot target */
30     uint8_t loadparm[8];
31 };
32 typedef struct CcwDevice CcwDevice;
33 
34 extern const VMStateDescription vmstate_ccw_dev;
35 #define VMSTATE_CCW_DEVICE(_field, _state)                     \
36     VMSTATE_STRUCT(_field, _state, 1, vmstate_ccw_dev, CcwDevice)
37 
38 struct CCWDeviceClass {
39     DeviceClass parent_class;
40     void (*unplug)(HotplugHandler *, DeviceState *, Error **);
41     bool (*realize)(CcwDevice *, Error **);
42     void (*refill_ids)(CcwDevice *);
43 };
44 
45 static inline CcwDevice *to_ccw_dev_fast(DeviceState *d)
46 {
47     return container_of(d, CcwDevice, parent_obj);
48 }
49 
50 #define TYPE_CCW_DEVICE "ccw-device"
51 
52 OBJECT_DECLARE_TYPE(CcwDevice, CCWDeviceClass, CCW_DEVICE)
53 
54 #endif
55