3 * Event Facility definitions
5 * Copyright IBM, Corp. 2012
8 * Heinz Graalfs <graalfs@de.ibm.com>
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.
15 #ifndef HW_S390_SCLP_EVENT_FACILITY_H
16 #define HW_S390_SCLP_EVENT_FACILITY_H
19 #include "qemu/thread.h"
20 #include "hw/s390x/sclp.h"
22 /* SCLP event types */
23 #define SCLP_EVENT_OPRTNS_COMMAND 0x01
24 #define SCLP_EVENT_MESSAGE 0x02
25 #define SCLP_EVENT_CONFIG_MGT_DATA 0x04
26 #define SCLP_EVENT_PMSGCMD 0x09
27 #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a
28 #define SCLP_EVENT_SIGNAL_QUIESCE 0x1d
30 /* SCLP event masks */
31 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE 0x00000008
32 #define SCLP_EVENT_MASK_MSG_ASCII 0x00000040
33 #define SCLP_EVENT_MASK_CONFIG_MGT_DATA 0x10000000
34 #define SCLP_EVENT_MASK_OP_CMD 0x80000000
35 #define SCLP_EVENT_MASK_MSG 0x40000000
36 #define SCLP_EVENT_MASK_PMSGCMD 0x00800000
38 #define SCLP_UNCONDITIONAL_READ 0x00
39 #define SCLP_SELECTIVE_READ 0x01
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)
49 #define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug"
51 typedef struct WriteEventMask {
55 uint32_t cp_receive_mask;
56 uint32_t cp_send_mask;
57 uint32_t receive_mask;
59 } QEMU_PACKED WriteEventMask;
61 typedef struct EventBufferHeader {
66 } QEMU_PACKED EventBufferHeader;
68 typedef struct MdbHeader {
72 uint32_t revision_code;
73 } QEMU_PACKED MdbHeader;
76 uint16_t line_type_flags;
77 uint8_t alarm_control;
84 uint8_t hhmmss_time[8];
87 uint8_t dddyyyy_date[7];
89 uint16_t general_msg_flags;
90 uint8_t _reserved_2[10];
91 uint8_t originating_system_name[8];
92 uint8_t job_guest_name[8];
95 #define MESSAGE_TEXT 0x0004
111 typedef struct SclpMsg {
112 EventBufferHeader header;
114 } QEMU_PACKED SclpMsg;
116 #define GDS_ID_MDSMU 0x1310
117 #define GDS_ID_CPMSU 0x1212
118 #define GDS_ID_TEXTCMD 0x1320
120 typedef struct GdsVector {
123 } QEMU_PACKED GdsVector;
125 #define GDS_KEY_SELFDEFTEXTMSG 0x31
126 #define GDS_KEY_TEXTMSG 0x30
128 typedef struct GdsSubvector {
131 } QEMU_PACKED GdsSubvector;
133 /* MDS Message Unit */
134 typedef struct MDMSU {
137 GdsVector text_command;
138 GdsSubvector self_def_text_message;
139 GdsSubvector text_message;
142 typedef struct WriteEventData {
144 EventBufferHeader ebh;
145 } QEMU_PACKED WriteEventData;
147 typedef struct ReadEventData {
149 EventBufferHeader ebh;
151 } QEMU_PACKED ReadEventData;
153 typedef struct SCLPEvent {
159 typedef struct SCLPEventClass {
160 DeviceClass parent_class;
161 int (*init)(SCLPEvent *event);
162 int (*exit)(SCLPEvent *event);
164 /* get SCLP's send mask */
165 unsigned int (*get_send_mask)(void);
167 /* get SCLP's receive mask */
168 unsigned int (*get_receive_mask)(void);
170 int (*read_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
173 int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr);
175 /* can we handle this event type? */
176 bool (*can_handle_event)(uint8_t type);
179 #define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"
180 #define EVENT_FACILITY(obj) \
181 OBJECT_CHECK(SCLPEventFacility, (obj), TYPE_SCLP_EVENT_FACILITY)
182 #define EVENT_FACILITY_CLASS(klass) \
183 OBJECT_CLASS_CHECK(SCLPEventFacilityClass, (klass), \
184 TYPE_SCLP_EVENT_FACILITY)
185 #define EVENT_FACILITY_GET_CLASS(obj) \
186 OBJECT_GET_CLASS(SCLPEventFacilityClass, (obj), \
187 TYPE_SCLP_EVENT_FACILITY)
189 typedef struct SCLPEventFacility SCLPEventFacility;
191 typedef struct SCLPEventFacilityClass {
192 DeviceClass parent_class;
193 int (*init)(SCLPEventFacility *ef);
194 void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t code);
195 bool (*event_pending)(SCLPEventFacility *ef);
196 } SCLPEventFacilityClass;