xref: /qemu/include/hw/s390x/event-facility.h (revision 67cc32eb)
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 <hw/qdev.h>
19 #include "qemu/thread.h"
20 #include "hw/s390x/sclp.h"
21 
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
29 
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
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 
49 #define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug"
50 #define TYPE_SCLP_QUIESCE "sclpquiesce"
51 
52 typedef struct WriteEventMask {
53     SCCBHeader h;
54     uint16_t _reserved;
55     uint16_t mask_length;
56     uint32_t cp_receive_mask;
57     uint32_t cp_send_mask;
58     uint32_t receive_mask;
59     uint32_t send_mask;
60 } QEMU_PACKED WriteEventMask;
61 
62 typedef struct EventBufferHeader {
63     uint16_t length;
64     uint8_t  type;
65     uint8_t  flags;
66     uint16_t _reserved;
67 } QEMU_PACKED EventBufferHeader;
68 
69 typedef struct MdbHeader {
70     uint16_t length;
71     uint16_t type;
72     uint32_t tag;
73     uint32_t revision_code;
74 } QEMU_PACKED MdbHeader;
75 
76 typedef struct MTO {
77     uint16_t line_type_flags;
78     uint8_t  alarm_control;
79     uint8_t  _reserved[3];
80     char     message[];
81 } QEMU_PACKED MTO;
82 
83 typedef struct GO {
84     uint32_t domid;
85     uint8_t  hhmmss_time[8];
86     uint8_t  th_time[3];
87     uint8_t  _reserved_0;
88     uint8_t  dddyyyy_date[7];
89     uint8_t  _reserved_1;
90     uint16_t general_msg_flags;
91     uint8_t  _reserved_2[10];
92     uint8_t  originating_system_name[8];
93     uint8_t  job_guest_name[8];
94 } QEMU_PACKED GO;
95 
96 #define MESSAGE_TEXT 0x0004
97 
98 typedef struct MDBO {
99     uint16_t length;
100     uint16_t type;
101     union {
102         GO go;
103         MTO mto;
104     };
105 } QEMU_PACKED MDBO;
106 
107 typedef struct MDB {
108     MdbHeader header;
109     MDBO mdbo[0];
110 } QEMU_PACKED MDB;
111 
112 typedef struct SclpMsg {
113     EventBufferHeader header;
114     MDB mdb;
115 } QEMU_PACKED SclpMsg;
116 
117 #define GDS_ID_MDSMU                            0x1310
118 #define GDS_ID_CPMSU                            0x1212
119 #define GDS_ID_TEXTCMD                          0x1320
120 
121 typedef struct GdsVector {
122     uint16_t length;
123     uint16_t gds_id;
124 } QEMU_PACKED GdsVector;
125 
126 #define GDS_KEY_SELFDEFTEXTMSG                  0x31
127 #define GDS_KEY_TEXTMSG                         0x30
128 
129 typedef struct GdsSubvector {
130     uint8_t length;
131     uint8_t key;
132 } QEMU_PACKED GdsSubvector;
133 
134 /* MDS Message Unit */
135 typedef struct MDMSU {
136     GdsVector mdmsu;
137     GdsVector cpmsu;
138     GdsVector text_command;
139     GdsSubvector self_def_text_message;
140     GdsSubvector text_message;
141 } QEMU_PACKED MDMSU;
142 
143 typedef struct WriteEventData {
144     SCCBHeader h;
145     EventBufferHeader ebh;
146 } QEMU_PACKED WriteEventData;
147 
148 typedef struct ReadEventData {
149     SCCBHeader h;
150     union {
151         uint32_t mask;
152         EventBufferHeader ebh;
153     };
154 } QEMU_PACKED ReadEventData;
155 
156 typedef struct SCLPEvent {
157     DeviceState qdev;
158     bool event_pending;
159     char *name;
160 } SCLPEvent;
161 
162 typedef struct SCLPEventClass {
163     DeviceClass parent_class;
164     int (*init)(SCLPEvent *event);
165     int (*exit)(SCLPEvent *event);
166 
167     /* get SCLP's send mask */
168     unsigned int (*get_send_mask)(void);
169 
170     /* get SCLP's receive mask */
171     unsigned int (*get_receive_mask)(void);
172 
173     int (*read_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
174                            int *slen);
175 
176     int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr);
177 
178     /* can we handle this event type? */
179     bool (*can_handle_event)(uint8_t type);
180 } SCLPEventClass;
181 
182 #define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"
183 #define EVENT_FACILITY(obj) \
184      OBJECT_CHECK(SCLPEventFacility, (obj), TYPE_SCLP_EVENT_FACILITY)
185 #define EVENT_FACILITY_CLASS(klass) \
186      OBJECT_CLASS_CHECK(SCLPEventFacilityClass, (klass), \
187                         TYPE_SCLP_EVENT_FACILITY)
188 #define EVENT_FACILITY_GET_CLASS(obj) \
189      OBJECT_GET_CLASS(SCLPEventFacilityClass, (obj), \
190                       TYPE_SCLP_EVENT_FACILITY)
191 
192 typedef struct SCLPEventFacilityClass {
193     SysBusDeviceClass parent_class;
194     void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t code);
195     bool (*event_pending)(SCLPEventFacility *ef);
196 } SCLPEventFacilityClass;
197 
198 #endif
199