1b804e8a6SJing Liu /*
2b804e8a6SJing Liu * Common device infrastructure for devices in the virtual css
3b804e8a6SJing Liu *
4b804e8a6SJing Liu * Copyright 2016 IBM Corp.
5b804e8a6SJing Liu * Author(s): Jing Liu <liujbjl@linux.vnet.ibm.com>
6b804e8a6SJing Liu *
7b804e8a6SJing Liu * This work is licensed under the terms of the GNU GPL, version 2 or (at
8b804e8a6SJing Liu * your option) any later version. See the COPYING file in the top-level
9b804e8a6SJing Liu * directory.
10b804e8a6SJing Liu */
11b804e8a6SJing Liu
12b804e8a6SJing Liu #ifndef HW_S390X_CCW_DEVICE_H
13b804e8a6SJing Liu #define HW_S390X_CCW_DEVICE_H
14b804e8a6SJing Liu #include "qom/object.h"
15b804e8a6SJing Liu #include "hw/qdev-core.h"
16b804e8a6SJing Liu #include "hw/s390x/css.h"
17a6d8b731SPhilippe Mathieu-Daudé #include "hw/s390x/css-bridge.h"
18b804e8a6SJing Liu
19db1015e9SEduardo Habkost struct CcwDevice {
20b804e8a6SJing Liu DeviceState parent_obj;
21b804e8a6SJing Liu SubchDev *sch;
22b804e8a6SJing Liu /* <cssid>.<ssid>.<device number> */
23d8d98db5SDong Jia Shi /* The user-set busid of the virtual ccw device. */
242a78ac66SDong Jia Shi CssDevId devno;
25d8d98db5SDong Jia Shi /* The actual busid of the virtual ccw device. */
26d8d98db5SDong Jia Shi CssDevId dev_id;
27d8d98db5SDong Jia Shi /* The actual busid of the virtual subchannel. */
28d8d98db5SDong Jia Shi CssDevId subch_id;
29bb185de4SJared Rossi /* If set, use this loadparm value when device is boot target */
30bb185de4SJared Rossi uint8_t loadparm[8];
31db1015e9SEduardo Habkost };
32db1015e9SEduardo Habkost typedef struct CcwDevice CcwDevice;
33b804e8a6SJing Liu
34517ff12cSHalil Pasic extern const VMStateDescription vmstate_ccw_dev;
35517ff12cSHalil Pasic #define VMSTATE_CCW_DEVICE(_field, _state) \
36517ff12cSHalil Pasic VMSTATE_STRUCT(_field, _state, 1, vmstate_ccw_dev, CcwDevice)
37517ff12cSHalil Pasic
38db1015e9SEduardo Habkost struct CCWDeviceClass {
39b804e8a6SJing Liu DeviceClass parent_class;
40b804e8a6SJing Liu void (*unplug)(HotplugHandler *, DeviceState *, Error **);
414a6a90f3SCédric Le Goater bool (*realize)(CcwDevice *, Error **);
42d8d98db5SDong Jia Shi void (*refill_ids)(CcwDevice *);
43db1015e9SEduardo Habkost };
44b804e8a6SJing Liu
to_ccw_dev_fast(DeviceState * d)45b804e8a6SJing Liu static inline CcwDevice *to_ccw_dev_fast(DeviceState *d)
46b804e8a6SJing Liu {
47b804e8a6SJing Liu return container_of(d, CcwDevice, parent_obj);
48b804e8a6SJing Liu }
49b804e8a6SJing Liu
50b804e8a6SJing Liu #define TYPE_CCW_DEVICE "ccw-device"
51b804e8a6SJing Liu
52a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(CcwDevice, CCWDeviceClass, CCW_DEVICE)
53b804e8a6SJing Liu
54*6e7c96aeSThomas Huth extern const PropertyInfo ccw_loadparm;
55*6e7c96aeSThomas Huth
56*6e7c96aeSThomas Huth #define DEFINE_PROP_CCW_LOADPARM(_n, _s, _f) \
57*6e7c96aeSThomas Huth DEFINE_PROP(_n, _s, _f, ccw_loadparm, typeof(uint8_t[8]))
58*6e7c96aeSThomas Huth
59b804e8a6SJing Liu #endif
60