Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SCLP |
| 3 | * Event Facility definitions |
| 4 | * |
| 5 | * Copyright IBM, Corp. 2012 |
| 6 | * |
| 7 | * Authors: |
| 8 | * Heinz Graalfs <graalfs@de.ibm.com> |
| 9 | * |
| 10 | * This work is licensed under the terms of the GNU GPL, version 2 or (at your |
| 11 | * option) any later version. See the COPYING file in the top-level directory. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef HW_S390_SCLP_EVENT_FACILITY_H |
| 16 | #define HW_S390_SCLP_EVENT_FACILITY_H |
| 17 | |
Markus Armbruster | a9c9427 | 2016-06-22 19:11:19 +0200 | [diff] [blame] | 18 | #include "hw/qdev.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 19 | #include "qemu/thread.h" |
Jason J. Herne | 4920445 | 2014-01-20 14:51:50 -0500 | [diff] [blame] | 20 | #include "hw/s390x/sclp.h" |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 21 | |
| 22 | /* SCLP event types */ |
Heinz Graalfs | 6a444f8 | 2013-05-22 14:11:36 +0200 | [diff] [blame] | 23 | #define SCLP_EVENT_OPRTNS_COMMAND 0x01 |
| 24 | #define SCLP_EVENT_MESSAGE 0x02 |
Jason J. Herne | 4920445 | 2014-01-20 14:51:50 -0500 | [diff] [blame] | 25 | #define SCLP_EVENT_CONFIG_MGT_DATA 0x04 |
Heinz Graalfs | 6a444f8 | 2013-05-22 14:11:36 +0200 | [diff] [blame] | 26 | #define SCLP_EVENT_PMSGCMD 0x09 |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 27 | #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a |
| 28 | #define SCLP_EVENT_SIGNAL_QUIESCE 0x1d |
| 29 | |
| 30 | /* SCLP event masks */ |
| 31 | #define SCLP_EVENT_MASK_SIGNAL_QUIESCE 0x00000008 |
| 32 | #define SCLP_EVENT_MASK_MSG_ASCII 0x00000040 |
Jason J. Herne | 4920445 | 2014-01-20 14:51:50 -0500 | [diff] [blame] | 33 | #define SCLP_EVENT_MASK_CONFIG_MGT_DATA 0x10000000 |
Heinz Graalfs | 6a444f8 | 2013-05-22 14:11:36 +0200 | [diff] [blame] | 34 | #define SCLP_EVENT_MASK_OP_CMD 0x80000000 |
| 35 | #define SCLP_EVENT_MASK_MSG 0x40000000 |
| 36 | #define SCLP_EVENT_MASK_PMSGCMD 0x00800000 |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 37 | |
| 38 | #define SCLP_UNCONDITIONAL_READ 0x00 |
| 39 | #define SCLP_SELECTIVE_READ 0x01 |
| 40 | |
| 41 | #define TYPE_SCLP_EVENT "s390-sclp-event-type" |
| 42 | #define SCLP_EVENT(obj) \ |
| 43 | OBJECT_CHECK(SCLPEvent, (obj), TYPE_SCLP_EVENT) |
| 44 | #define SCLP_EVENT_CLASS(klass) \ |
| 45 | OBJECT_CLASS_CHECK(SCLPEventClass, (klass), TYPE_SCLP_EVENT) |
| 46 | #define SCLP_EVENT_GET_CLASS(obj) \ |
| 47 | OBJECT_GET_CLASS(SCLPEventClass, (obj), TYPE_SCLP_EVENT) |
| 48 | |
Jason J. Herne | 4920445 | 2014-01-20 14:51:50 -0500 | [diff] [blame] | 49 | #define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug" |
David Hildenbrand | 35925a7 | 2015-05-11 15:31:47 +0200 | [diff] [blame] | 50 | #define TYPE_SCLP_QUIESCE "sclpquiesce" |
Jason J. Herne | 4920445 | 2014-01-20 14:51:50 -0500 | [diff] [blame] | 51 | |
Cornelia Huck | 67915de | 2017-10-11 09:39:53 -0400 | [diff] [blame] | 52 | #define SCLP_EVENT_MASK_LEN_MAX 1021 |
| 53 | |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 54 | typedef struct WriteEventMask { |
| 55 | SCCBHeader h; |
| 56 | uint16_t _reserved; |
| 57 | uint16_t mask_length; |
Cornelia Huck | 67915de | 2017-10-11 09:39:53 -0400 | [diff] [blame] | 58 | uint8_t masks[]; |
| 59 | /* |
| 60 | * Layout of the masks is |
| 61 | * uint8_t cp_receive_mask[mask_length]; |
| 62 | * uint8_t cp_send_mask[mask_length]; |
| 63 | * uint8_t receive_mask[mask_length]; |
| 64 | * uint8_t send_mask[mask_length]; |
| 65 | * where 1 <= mask_length <= SCLP_EVENT_MASK_LEN_MAX |
| 66 | */ |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 67 | } QEMU_PACKED WriteEventMask; |
| 68 | |
Cornelia Huck | 67915de | 2017-10-11 09:39:53 -0400 | [diff] [blame] | 69 | #define WEM_CP_RECEIVE_MASK(wem, mask_len) ((wem)->masks) |
| 70 | #define WEM_CP_SEND_MASK(wem, mask_len) ((wem)->masks + (mask_len)) |
| 71 | #define WEM_RECEIVE_MASK(wem, mask_len) ((wem)->masks + 2 * (mask_len)) |
| 72 | #define WEM_SEND_MASK(wem, mask_len) ((wem)->masks + 3 * (mask_len)) |
| 73 | |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 74 | typedef struct EventBufferHeader { |
| 75 | uint16_t length; |
| 76 | uint8_t type; |
| 77 | uint8_t flags; |
| 78 | uint16_t _reserved; |
| 79 | } QEMU_PACKED EventBufferHeader; |
| 80 | |
Heinz Graalfs | 6a444f8 | 2013-05-22 14:11:36 +0200 | [diff] [blame] | 81 | typedef struct MdbHeader { |
| 82 | uint16_t length; |
| 83 | uint16_t type; |
| 84 | uint32_t tag; |
| 85 | uint32_t revision_code; |
| 86 | } QEMU_PACKED MdbHeader; |
| 87 | |
| 88 | typedef struct MTO { |
| 89 | uint16_t line_type_flags; |
| 90 | uint8_t alarm_control; |
| 91 | uint8_t _reserved[3]; |
| 92 | char message[]; |
| 93 | } QEMU_PACKED MTO; |
| 94 | |
| 95 | typedef struct GO { |
| 96 | uint32_t domid; |
| 97 | uint8_t hhmmss_time[8]; |
| 98 | uint8_t th_time[3]; |
| 99 | uint8_t _reserved_0; |
| 100 | uint8_t dddyyyy_date[7]; |
| 101 | uint8_t _reserved_1; |
| 102 | uint16_t general_msg_flags; |
| 103 | uint8_t _reserved_2[10]; |
| 104 | uint8_t originating_system_name[8]; |
| 105 | uint8_t job_guest_name[8]; |
| 106 | } QEMU_PACKED GO; |
| 107 | |
| 108 | #define MESSAGE_TEXT 0x0004 |
| 109 | |
| 110 | typedef struct MDBO { |
| 111 | uint16_t length; |
| 112 | uint16_t type; |
| 113 | union { |
| 114 | GO go; |
| 115 | MTO mto; |
| 116 | }; |
| 117 | } QEMU_PACKED MDBO; |
| 118 | |
| 119 | typedef struct MDB { |
| 120 | MdbHeader header; |
| 121 | MDBO mdbo[0]; |
| 122 | } QEMU_PACKED MDB; |
| 123 | |
| 124 | typedef struct SclpMsg { |
| 125 | EventBufferHeader header; |
| 126 | MDB mdb; |
| 127 | } QEMU_PACKED SclpMsg; |
| 128 | |
| 129 | #define GDS_ID_MDSMU 0x1310 |
| 130 | #define GDS_ID_CPMSU 0x1212 |
| 131 | #define GDS_ID_TEXTCMD 0x1320 |
| 132 | |
| 133 | typedef struct GdsVector { |
| 134 | uint16_t length; |
| 135 | uint16_t gds_id; |
| 136 | } QEMU_PACKED GdsVector; |
| 137 | |
| 138 | #define GDS_KEY_SELFDEFTEXTMSG 0x31 |
| 139 | #define GDS_KEY_TEXTMSG 0x30 |
| 140 | |
| 141 | typedef struct GdsSubvector { |
| 142 | uint8_t length; |
| 143 | uint8_t key; |
| 144 | } QEMU_PACKED GdsSubvector; |
| 145 | |
| 146 | /* MDS Message Unit */ |
| 147 | typedef struct MDMSU { |
| 148 | GdsVector mdmsu; |
| 149 | GdsVector cpmsu; |
| 150 | GdsVector text_command; |
| 151 | GdsSubvector self_def_text_message; |
| 152 | GdsSubvector text_message; |
| 153 | } QEMU_PACKED MDMSU; |
| 154 | |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 155 | typedef struct WriteEventData { |
| 156 | SCCBHeader h; |
| 157 | EventBufferHeader ebh; |
| 158 | } QEMU_PACKED WriteEventData; |
| 159 | |
| 160 | typedef struct ReadEventData { |
| 161 | SCCBHeader h; |
Cornelia Huck | f7822aa | 2015-07-27 16:55:23 +0200 | [diff] [blame] | 162 | union { |
| 163 | uint32_t mask; |
| 164 | EventBufferHeader ebh; |
| 165 | }; |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 166 | } QEMU_PACKED ReadEventData; |
| 167 | |
| 168 | typedef struct SCLPEvent { |
| 169 | DeviceState qdev; |
| 170 | bool event_pending; |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 171 | char *name; |
| 172 | } SCLPEvent; |
| 173 | |
| 174 | typedef struct SCLPEventClass { |
| 175 | DeviceClass parent_class; |
| 176 | int (*init)(SCLPEvent *event); |
| 177 | int (*exit)(SCLPEvent *event); |
| 178 | |
| 179 | /* get SCLP's send mask */ |
| 180 | unsigned int (*get_send_mask)(void); |
| 181 | |
| 182 | /* get SCLP's receive mask */ |
| 183 | unsigned int (*get_receive_mask)(void); |
| 184 | |
| 185 | int (*read_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr, |
| 186 | int *slen); |
| 187 | |
| 188 | int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr); |
| 189 | |
Christian Borntraeger | c3d9f24 | 2013-09-17 13:07:30 +0200 | [diff] [blame] | 190 | /* can we handle this event type? */ |
| 191 | bool (*can_handle_event)(uint8_t type); |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 192 | } SCLPEventClass; |
| 193 | |
Heinz Graalfs | 477a72a | 2013-12-18 10:10:49 +0100 | [diff] [blame] | 194 | #define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility" |
| 195 | #define EVENT_FACILITY(obj) \ |
| 196 | OBJECT_CHECK(SCLPEventFacility, (obj), TYPE_SCLP_EVENT_FACILITY) |
| 197 | #define EVENT_FACILITY_CLASS(klass) \ |
| 198 | OBJECT_CLASS_CHECK(SCLPEventFacilityClass, (klass), \ |
| 199 | TYPE_SCLP_EVENT_FACILITY) |
| 200 | #define EVENT_FACILITY_GET_CLASS(obj) \ |
| 201 | OBJECT_GET_CLASS(SCLPEventFacilityClass, (obj), \ |
| 202 | TYPE_SCLP_EVENT_FACILITY) |
| 203 | |
Heinz Graalfs | 477a72a | 2013-12-18 10:10:49 +0100 | [diff] [blame] | 204 | typedef struct SCLPEventFacilityClass { |
David Hildenbrand | f6102c3 | 2015-05-21 12:43:31 +0200 | [diff] [blame] | 205 | SysBusDeviceClass parent_class; |
Heinz Graalfs | 477a72a | 2013-12-18 10:10:49 +0100 | [diff] [blame] | 206 | void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t code); |
| 207 | bool (*event_pending)(SCLPEventFacility *ef); |
| 208 | } SCLPEventFacilityClass; |
| 209 | |
Heinz Graalfs | 559a17a | 2012-10-29 02:13:23 +0000 | [diff] [blame] | 210 | #endif |