xref: /openbmc/qemu/include/hw/s390x/event-facility.h (revision 14a650ec)
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 
21 /* SCLP event types */
22 #define SCLP_EVENT_OPRTNS_COMMAND               0x01
23 #define SCLP_EVENT_MESSAGE                      0x02
24 #define SCLP_EVENT_PMSGCMD                      0x09
25 #define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
26 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
27 
28 /* SCLP event masks */
29 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
30 #define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
31 #define SCLP_EVENT_MASK_OP_CMD                  0x80000000
32 #define SCLP_EVENT_MASK_MSG                     0x40000000
33 #define SCLP_EVENT_MASK_PMSGCMD                 0x00800000
34 
35 #define SCLP_UNCONDITIONAL_READ                 0x00
36 #define SCLP_SELECTIVE_READ                     0x01
37 
38 #define TYPE_SCLP_EVENT "s390-sclp-event-type"
39 #define SCLP_EVENT(obj) \
40      OBJECT_CHECK(SCLPEvent, (obj), TYPE_SCLP_EVENT)
41 #define SCLP_EVENT_CLASS(klass) \
42      OBJECT_CLASS_CHECK(SCLPEventClass, (klass), TYPE_SCLP_EVENT)
43 #define SCLP_EVENT_GET_CLASS(obj) \
44      OBJECT_GET_CLASS(SCLPEventClass, (obj), TYPE_SCLP_EVENT)
45 
46 typedef struct WriteEventMask {
47     SCCBHeader h;
48     uint16_t _reserved;
49     uint16_t mask_length;
50     uint32_t cp_receive_mask;
51     uint32_t cp_send_mask;
52     uint32_t receive_mask;
53     uint32_t send_mask;
54 } QEMU_PACKED WriteEventMask;
55 
56 typedef struct EventBufferHeader {
57     uint16_t length;
58     uint8_t  type;
59     uint8_t  flags;
60     uint16_t _reserved;
61 } QEMU_PACKED EventBufferHeader;
62 
63 typedef struct MdbHeader {
64     uint16_t length;
65     uint16_t type;
66     uint32_t tag;
67     uint32_t revision_code;
68 } QEMU_PACKED MdbHeader;
69 
70 typedef struct MTO {
71     uint16_t line_type_flags;
72     uint8_t  alarm_control;
73     uint8_t  _reserved[3];
74     char     message[];
75 } QEMU_PACKED MTO;
76 
77 typedef struct GO {
78     uint32_t domid;
79     uint8_t  hhmmss_time[8];
80     uint8_t  th_time[3];
81     uint8_t  _reserved_0;
82     uint8_t  dddyyyy_date[7];
83     uint8_t  _reserved_1;
84     uint16_t general_msg_flags;
85     uint8_t  _reserved_2[10];
86     uint8_t  originating_system_name[8];
87     uint8_t  job_guest_name[8];
88 } QEMU_PACKED GO;
89 
90 #define MESSAGE_TEXT 0x0004
91 
92 typedef struct MDBO {
93     uint16_t length;
94     uint16_t type;
95     union {
96         GO go;
97         MTO mto;
98     };
99 } QEMU_PACKED MDBO;
100 
101 typedef struct MDB {
102     MdbHeader header;
103     MDBO mdbo[0];
104 } QEMU_PACKED MDB;
105 
106 typedef struct SclpMsg {
107     EventBufferHeader header;
108     MDB mdb;
109 } QEMU_PACKED SclpMsg;
110 
111 #define GDS_ID_MDSMU                            0x1310
112 #define GDS_ID_CPMSU                            0x1212
113 #define GDS_ID_TEXTCMD                          0x1320
114 
115 typedef struct GdsVector {
116     uint16_t length;
117     uint16_t gds_id;
118 } QEMU_PACKED GdsVector;
119 
120 #define GDS_KEY_SELFDEFTEXTMSG                  0x31
121 #define GDS_KEY_TEXTMSG                         0x30
122 
123 typedef struct GdsSubvector {
124     uint8_t length;
125     uint8_t key;
126 } QEMU_PACKED GdsSubvector;
127 
128 /* MDS Message Unit */
129 typedef struct MDMSU {
130     GdsVector mdmsu;
131     GdsVector cpmsu;
132     GdsVector text_command;
133     GdsSubvector self_def_text_message;
134     GdsSubvector text_message;
135 } QEMU_PACKED MDMSU;
136 
137 typedef struct WriteEventData {
138     SCCBHeader h;
139     EventBufferHeader ebh;
140 } QEMU_PACKED WriteEventData;
141 
142 typedef struct ReadEventData {
143     SCCBHeader h;
144     EventBufferHeader ebh;
145     uint32_t mask;
146 } QEMU_PACKED ReadEventData;
147 
148 typedef struct SCLPEvent {
149     DeviceState qdev;
150     bool event_pending;
151     char *name;
152 } SCLPEvent;
153 
154 typedef struct SCLPEventClass {
155     DeviceClass parent_class;
156     int (*init)(SCLPEvent *event);
157     int (*exit)(SCLPEvent *event);
158 
159     /* get SCLP's send mask */
160     unsigned int (*get_send_mask)(void);
161 
162     /* get SCLP's receive mask */
163     unsigned int (*get_receive_mask)(void);
164 
165     int (*read_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
166                            int *slen);
167 
168     int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr);
169 
170     /* can we handle this event type? */
171     bool (*can_handle_event)(uint8_t type);
172 } SCLPEventClass;
173 
174 #endif
175