xref: /openbmc/qemu/include/hw/s390x/event-facility.h (revision 2993683b)
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_ASCII_CONSOLE_DATA           0x1a
23 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
24 
25 /* SCLP event masks */
26 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
27 #define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
28 
29 #define SCLP_UNCONDITIONAL_READ                 0x00
30 #define SCLP_SELECTIVE_READ                     0x01
31 
32 #define TYPE_SCLP_EVENT "s390-sclp-event-type"
33 #define SCLP_EVENT(obj) \
34      OBJECT_CHECK(SCLPEvent, (obj), TYPE_SCLP_EVENT)
35 #define SCLP_EVENT_CLASS(klass) \
36      OBJECT_CLASS_CHECK(SCLPEventClass, (klass), TYPE_SCLP_EVENT)
37 #define SCLP_EVENT_GET_CLASS(obj) \
38      OBJECT_GET_CLASS(SCLPEventClass, (obj), TYPE_SCLP_EVENT)
39 
40 typedef struct WriteEventMask {
41     SCCBHeader h;
42     uint16_t _reserved;
43     uint16_t mask_length;
44     uint32_t cp_receive_mask;
45     uint32_t cp_send_mask;
46     uint32_t send_mask;
47     uint32_t receive_mask;
48 } QEMU_PACKED WriteEventMask;
49 
50 typedef struct EventBufferHeader {
51     uint16_t length;
52     uint8_t  type;
53     uint8_t  flags;
54     uint16_t _reserved;
55 } QEMU_PACKED EventBufferHeader;
56 
57 typedef struct WriteEventData {
58     SCCBHeader h;
59     EventBufferHeader ebh;
60 } QEMU_PACKED WriteEventData;
61 
62 typedef struct ReadEventData {
63     SCCBHeader h;
64     EventBufferHeader ebh;
65     uint32_t mask;
66 } QEMU_PACKED ReadEventData;
67 
68 typedef struct SCLPEvent {
69     DeviceState qdev;
70     bool event_pending;
71     uint32_t event_type;
72     char *name;
73 } SCLPEvent;
74 
75 typedef struct SCLPEventClass {
76     DeviceClass parent_class;
77     int (*init)(SCLPEvent *event);
78     int (*exit)(SCLPEvent *event);
79 
80     /* get SCLP's send mask */
81     unsigned int (*get_send_mask)(void);
82 
83     /* get SCLP's receive mask */
84     unsigned int (*get_receive_mask)(void);
85 
86     int (*read_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
87                            int *slen);
88 
89     int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr);
90 
91     /* returns the supported event type */
92     int (*event_type)(void);
93 
94 } SCLPEventClass;
95 
96 #endif
97