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