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_EVMASK(T) (1ULL << (sizeof(sccb_mask_t) * 8 - (T)))
33 #define SCLP_EVENT_MASK_OP_CMD SCLP_EVMASK(SCLP_EVENT_OPRTNS_COMMAND)
34 #define SCLP_EVENT_MASK_MSG SCLP_EVMASK(SCLP_EVENT_MESSAGE)
35 #define SCLP_EVENT_MASK_CONFIG_MGT_DATA SCLP_EVMASK(SCLP_EVENT_CONFIG_MGT_DATA)
36 #define SCLP_EVENT_MASK_PMSGCMD SCLP_EVMASK(SCLP_EVENT_PMSGCMD)
37 #define SCLP_EVENT_MASK_MSG_ASCII SCLP_EVMASK(SCLP_EVENT_ASCII_CONSOLE_DATA)
38 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE SCLP_EVMASK(SCLP_EVENT_SIGNAL_QUIESCE)
40 #define SCLP_UNCONDITIONAL_READ 0x00
41 #define SCLP_SELECTIVE_READ 0x01
43 #define TYPE_SCLP_EVENT "s390-sclp-event-type"
44 #define SCLP_EVENT(obj) \
45 OBJECT_CHECK(SCLPEvent, (obj), TYPE_SCLP_EVENT)
46 #define SCLP_EVENT_CLASS(klass) \
47 OBJECT_CLASS_CHECK(SCLPEventClass, (klass), TYPE_SCLP_EVENT)
48 #define SCLP_EVENT_GET_CLASS(obj) \
49 OBJECT_GET_CLASS(SCLPEventClass, (obj), TYPE_SCLP_EVENT)
51 #define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug"
52 #define TYPE_SCLP_QUIESCE "sclpquiesce"
54 #define SCLP_EVENT_MASK_LEN_MAX 1021
56 typedef struct WriteEventMask
{
62 * Layout of the masks is
63 * uint8_t cp_receive_mask[mask_length];
64 * uint8_t cp_send_mask[mask_length];
65 * uint8_t receive_mask[mask_length];
66 * uint8_t send_mask[mask_length];
67 * where 1 <= mask_length <= SCLP_EVENT_MASK_LEN_MAX
69 } QEMU_PACKED WriteEventMask
;
71 #define WEM_CP_RECEIVE_MASK(wem, mask_len) ((wem)->masks)
72 #define WEM_CP_SEND_MASK(wem, mask_len) ((wem)->masks + (mask_len))
73 #define WEM_RECEIVE_MASK(wem, mask_len) ((wem)->masks + 2 * (mask_len))
74 #define WEM_SEND_MASK(wem, mask_len) ((wem)->masks + 3 * (mask_len))
76 typedef uint32_t sccb_mask_t
;
78 typedef struct EventBufferHeader
{
83 } QEMU_PACKED EventBufferHeader
;
85 typedef struct MdbHeader
{
89 uint32_t revision_code
;
90 } QEMU_PACKED MdbHeader
;
93 uint16_t line_type_flags
;
94 uint8_t alarm_control
;
101 uint8_t hhmmss_time
[8];
104 uint8_t dddyyyy_date
[7];
106 uint16_t general_msg_flags
;
107 uint8_t _reserved_2
[10];
108 uint8_t originating_system_name
[8];
109 uint8_t job_guest_name
[8];
112 #define MESSAGE_TEXT 0x0004
114 typedef struct MDBO
{
128 typedef struct SclpMsg
{
129 EventBufferHeader header
;
131 } QEMU_PACKED SclpMsg
;
133 #define GDS_ID_MDSMU 0x1310
134 #define GDS_ID_CPMSU 0x1212
135 #define GDS_ID_TEXTCMD 0x1320
137 typedef struct GdsVector
{
140 } QEMU_PACKED GdsVector
;
142 #define GDS_KEY_SELFDEFTEXTMSG 0x31
143 #define GDS_KEY_TEXTMSG 0x30
145 typedef struct GdsSubvector
{
148 } QEMU_PACKED GdsSubvector
;
150 /* MDS Message Unit */
151 typedef struct MDMSU
{
154 GdsVector text_command
;
155 GdsSubvector self_def_text_message
;
156 GdsSubvector text_message
;
159 typedef struct WriteEventData
{
161 EventBufferHeader ebh
;
162 } QEMU_PACKED WriteEventData
;
164 typedef struct ReadEventData
{
168 EventBufferHeader ebh
;
170 } QEMU_PACKED ReadEventData
;
172 typedef struct SCLPEvent
{
178 typedef struct SCLPEventClass
{
179 DeviceClass parent_class
;
180 int (*init
)(SCLPEvent
*event
);
182 /* get SCLP's send mask */
183 sccb_mask_t (*get_send_mask
)(void);
185 /* get SCLP's receive mask */
186 sccb_mask_t (*get_receive_mask
)(void);
188 int (*read_event_data
)(SCLPEvent
*event
, EventBufferHeader
*evt_buf_hdr
,
191 int (*write_event_data
)(SCLPEvent
*event
, EventBufferHeader
*evt_buf_hdr
);
193 /* can we handle this event type? */
194 bool (*can_handle_event
)(uint8_t type
);
197 #define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"
198 #define EVENT_FACILITY(obj) \
199 OBJECT_CHECK(SCLPEventFacility, (obj), TYPE_SCLP_EVENT_FACILITY)
200 #define EVENT_FACILITY_CLASS(klass) \
201 OBJECT_CLASS_CHECK(SCLPEventFacilityClass, (klass), \
202 TYPE_SCLP_EVENT_FACILITY)
203 #define EVENT_FACILITY_GET_CLASS(obj) \
204 OBJECT_GET_CLASS(SCLPEventFacilityClass, (obj), \
205 TYPE_SCLP_EVENT_FACILITY)
207 typedef struct SCLPEventFacilityClass
{
208 SysBusDeviceClass parent_class
;
209 void (*command_handler
)(SCLPEventFacility
*ef
, SCCB
*sccb
, uint64_t code
);
210 bool (*event_pending
)(SCLPEventFacility
*ef
);
211 } SCLPEventFacilityClass
;