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 18 #include "qemu/thread.h" 19 #include "hw/qdev-core.h" 20 #include "hw/s390x/sclp.h" 21 #include "qom/object.h" 22 23 /* SCLP event types */ 24 #define SCLP_EVENT_OPRTNS_COMMAND 0x01 25 #define SCLP_EVENT_MESSAGE 0x02 26 #define SCLP_EVENT_CONFIG_MGT_DATA 0x04 27 #define SCLP_EVENT_PMSGCMD 0x09 28 #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a 29 #define SCLP_EVENT_SIGNAL_QUIESCE 0x1d 30 31 /* SCLP event masks */ 32 #define SCLP_EVMASK(T) (1ULL << (sizeof(sccb_mask_t) * 8 - (T))) 33 34 #define SCLP_EVENT_MASK_OP_CMD SCLP_EVMASK(SCLP_EVENT_OPRTNS_COMMAND) 35 #define SCLP_EVENT_MASK_MSG SCLP_EVMASK(SCLP_EVENT_MESSAGE) 36 #define SCLP_EVENT_MASK_CONFIG_MGT_DATA SCLP_EVMASK(SCLP_EVENT_CONFIG_MGT_DATA) 37 #define SCLP_EVENT_MASK_PMSGCMD SCLP_EVMASK(SCLP_EVENT_PMSGCMD) 38 #define SCLP_EVENT_MASK_MSG_ASCII SCLP_EVMASK(SCLP_EVENT_ASCII_CONSOLE_DATA) 39 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE SCLP_EVMASK(SCLP_EVENT_SIGNAL_QUIESCE) 40 41 #define SCLP_UNCONDITIONAL_READ 0x00 42 #define SCLP_SELECTIVE_READ 0x01 43 44 #define TYPE_SCLP_EVENT "s390-sclp-event-type" 45 typedef struct SCLPEvent SCLPEvent; 46 typedef struct SCLPEventClass SCLPEventClass; 47 #define SCLP_EVENT(obj) \ 48 OBJECT_CHECK(SCLPEvent, (obj), TYPE_SCLP_EVENT) 49 #define SCLP_EVENT_CLASS(klass) \ 50 OBJECT_CLASS_CHECK(SCLPEventClass, (klass), TYPE_SCLP_EVENT) 51 #define SCLP_EVENT_GET_CLASS(obj) \ 52 OBJECT_GET_CLASS(SCLPEventClass, (obj), TYPE_SCLP_EVENT) 53 54 #define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug" 55 #define TYPE_SCLP_QUIESCE "sclpquiesce" 56 57 #define SCLP_EVENT_MASK_LEN_MAX 1021 58 59 typedef struct WriteEventMask { 60 SCCBHeader h; 61 uint16_t _reserved; 62 uint16_t mask_length; 63 uint8_t masks[]; 64 /* 65 * Layout of the masks is 66 * uint8_t cp_receive_mask[mask_length]; 67 * uint8_t cp_send_mask[mask_length]; 68 * uint8_t receive_mask[mask_length]; 69 * uint8_t send_mask[mask_length]; 70 * where 1 <= mask_length <= SCLP_EVENT_MASK_LEN_MAX 71 */ 72 } QEMU_PACKED WriteEventMask; 73 74 #define WEM_CP_RECEIVE_MASK(wem, mask_len) ((wem)->masks) 75 #define WEM_CP_SEND_MASK(wem, mask_len) ((wem)->masks + (mask_len)) 76 #define WEM_RECEIVE_MASK(wem, mask_len) ((wem)->masks + 2 * (mask_len)) 77 #define WEM_SEND_MASK(wem, mask_len) ((wem)->masks + 3 * (mask_len)) 78 79 typedef uint64_t sccb_mask_t; 80 81 typedef struct EventBufferHeader { 82 uint16_t length; 83 uint8_t type; 84 uint8_t flags; 85 uint16_t _reserved; 86 } QEMU_PACKED EventBufferHeader; 87 88 typedef struct MdbHeader { 89 uint16_t length; 90 uint16_t type; 91 uint32_t tag; 92 uint32_t revision_code; 93 } QEMU_PACKED MdbHeader; 94 95 typedef struct MTO { 96 uint16_t line_type_flags; 97 uint8_t alarm_control; 98 uint8_t _reserved[3]; 99 char message[]; 100 } QEMU_PACKED MTO; 101 102 typedef struct GO { 103 uint32_t domid; 104 uint8_t hhmmss_time[8]; 105 uint8_t th_time[3]; 106 uint8_t _reserved_0; 107 uint8_t dddyyyy_date[7]; 108 uint8_t _reserved_1; 109 uint16_t general_msg_flags; 110 uint8_t _reserved_2[10]; 111 uint8_t originating_system_name[8]; 112 uint8_t job_guest_name[8]; 113 } QEMU_PACKED GO; 114 115 #define MESSAGE_TEXT 0x0004 116 117 typedef struct MDBO { 118 uint16_t length; 119 uint16_t type; 120 union { 121 GO go; 122 MTO mto; 123 }; 124 } QEMU_PACKED MDBO; 125 126 typedef struct MDB { 127 MdbHeader header; 128 MDBO mdbo[]; 129 } QEMU_PACKED MDB; 130 131 typedef struct SclpMsg { 132 EventBufferHeader header; 133 MDB mdb; 134 } QEMU_PACKED SclpMsg; 135 136 #define GDS_ID_MDSMU 0x1310 137 #define GDS_ID_CPMSU 0x1212 138 #define GDS_ID_TEXTCMD 0x1320 139 140 typedef struct GdsVector { 141 uint16_t length; 142 uint16_t gds_id; 143 } QEMU_PACKED GdsVector; 144 145 #define GDS_KEY_SELFDEFTEXTMSG 0x31 146 #define GDS_KEY_TEXTMSG 0x30 147 148 typedef struct GdsSubvector { 149 uint8_t length; 150 uint8_t key; 151 } QEMU_PACKED GdsSubvector; 152 153 /* MDS Message Unit */ 154 typedef struct MDMSU { 155 GdsVector mdmsu; 156 GdsVector cpmsu; 157 GdsVector text_command; 158 GdsSubvector self_def_text_message; 159 GdsSubvector text_message; 160 } QEMU_PACKED MDMSU; 161 162 typedef struct WriteEventData { 163 SCCBHeader h; 164 EventBufferHeader ebh; 165 } QEMU_PACKED WriteEventData; 166 167 typedef struct ReadEventData { 168 SCCBHeader h; 169 union { 170 sccb_mask_t mask; 171 EventBufferHeader ebh; 172 }; 173 } QEMU_PACKED ReadEventData; 174 175 struct SCLPEvent { 176 DeviceState qdev; 177 bool event_pending; 178 char *name; 179 }; 180 181 struct SCLPEventClass { 182 DeviceClass parent_class; 183 int (*init)(SCLPEvent *event); 184 185 /* get SCLP's send mask */ 186 sccb_mask_t (*get_send_mask)(void); 187 188 /* get SCLP's receive mask */ 189 sccb_mask_t (*get_receive_mask)(void); 190 191 int (*read_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr, 192 int *slen); 193 194 int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr); 195 196 /* can we handle this event type? */ 197 bool (*can_handle_event)(uint8_t type); 198 }; 199 200 #define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility" 201 typedef struct SCLPEventFacility SCLPEventFacility; 202 typedef struct SCLPEventFacilityClass SCLPEventFacilityClass; 203 #define EVENT_FACILITY(obj) \ 204 OBJECT_CHECK(SCLPEventFacility, (obj), TYPE_SCLP_EVENT_FACILITY) 205 #define EVENT_FACILITY_CLASS(klass) \ 206 OBJECT_CLASS_CHECK(SCLPEventFacilityClass, (klass), \ 207 TYPE_SCLP_EVENT_FACILITY) 208 #define EVENT_FACILITY_GET_CLASS(obj) \ 209 OBJECT_GET_CLASS(SCLPEventFacilityClass, (obj), \ 210 TYPE_SCLP_EVENT_FACILITY) 211 212 struct SCLPEventFacilityClass { 213 SysBusDeviceClass parent_class; 214 void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t code); 215 bool (*event_pending)(SCLPEventFacility *ef); 216 }; 217 218 BusState *sclp_get_event_facility_bus(void); 219 220 #endif 221