Jing Liu | b804e8a | 2016-02-26 06:46:12 +0100 | [diff] [blame] | 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> */ |
Dong Jia Shi | d8d98db | 2017-02-22 03:10:30 +0100 | [diff] [blame] | 22 | /* The user-set busid of the virtual ccw device. */ |
Dong Jia Shi | 2a78ac6 | 2017-02-15 06:33:03 +0100 | [diff] [blame] | 23 | CssDevId devno; |
Dong Jia Shi | d8d98db | 2017-02-22 03:10:30 +0100 | [diff] [blame] | 24 | /* The actual busid of the virtual ccw device. */ |
| 25 | CssDevId dev_id; |
| 26 | /* The actual busid of the virtual subchannel. */ |
| 27 | CssDevId subch_id; |
Jing Liu | b804e8a | 2016-02-26 06:46:12 +0100 | [diff] [blame] | 28 | } CcwDevice; |
| 29 | |
Halil Pasic | 517ff12 | 2017-07-03 23:34:14 +0200 | [diff] [blame] | 30 | extern const VMStateDescription vmstate_ccw_dev; |
| 31 | #define VMSTATE_CCW_DEVICE(_field, _state) \ |
| 32 | VMSTATE_STRUCT(_field, _state, 1, vmstate_ccw_dev, CcwDevice) |
| 33 | |
Jing Liu | b804e8a | 2016-02-26 06:46:12 +0100 | [diff] [blame] | 34 | typedef struct CCWDeviceClass { |
| 35 | DeviceClass parent_class; |
| 36 | void (*unplug)(HotplugHandler *, DeviceState *, Error **); |
Dong Jia Shi | d8d98db | 2017-02-22 03:10:30 +0100 | [diff] [blame] | 37 | void (*realize)(CcwDevice *, Error **); |
| 38 | void (*refill_ids)(CcwDevice *); |
Jing Liu | b804e8a | 2016-02-26 06:46:12 +0100 | [diff] [blame] | 39 | } CCWDeviceClass; |
| 40 | |
| 41 | static inline CcwDevice *to_ccw_dev_fast(DeviceState *d) |
| 42 | { |
| 43 | return container_of(d, CcwDevice, parent_obj); |
| 44 | } |
| 45 | |
| 46 | #define TYPE_CCW_DEVICE "ccw-device" |
| 47 | |
| 48 | #define CCW_DEVICE(obj) OBJECT_CHECK(CcwDevice, (obj), TYPE_CCW_DEVICE) |
| 49 | #define CCW_DEVICE_GET_CLASS(obj) \ |
| 50 | OBJECT_GET_CLASS(CCWDeviceClass, (obj), TYPE_CCW_DEVICE) |
| 51 | #define CCW_DEVICE_CLASS(klass) \ |
| 52 | OBJECT_CLASS_CHECK(CCWDeviceClass, (klass), TYPE_CCW_DEVICE) |
| 53 | |
| 54 | #endif |