xref: /openbmc/qemu/hw/s390x/ccw-device.h (revision 4a09d0bb)
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 
18 typedef struct CcwDevice {
19     DeviceState parent_obj;
20     SubchDev *sch;
21     /* <cssid>.<ssid>.<device number> */
22     CssDevId bus_id;
23 } CcwDevice;
24 
25 typedef struct CCWDeviceClass {
26     DeviceClass parent_class;
27     void (*unplug)(HotplugHandler *, DeviceState *, Error **);
28 } CCWDeviceClass;
29 
30 static inline CcwDevice *to_ccw_dev_fast(DeviceState *d)
31 {
32     return container_of(d, CcwDevice, parent_obj);
33 }
34 
35 #define TYPE_CCW_DEVICE "ccw-device"
36 
37 #define CCW_DEVICE(obj) OBJECT_CHECK(CcwDevice, (obj), TYPE_CCW_DEVICE)
38 #define CCW_DEVICE_GET_CLASS(obj) \
39     OBJECT_GET_CLASS(CCWDeviceClass, (obj), TYPE_CCW_DEVICE)
40 #define CCW_DEVICE_CLASS(klass) \
41     OBJECT_CLASS_CHECK(CCWDeviceClass, (klass), TYPE_CCW_DEVICE)
42 
43 #endif
44