1
2
3
4
5
6
7
8#ifndef __SCLP_H__
9#define __SCLP_H__
10
11#include <linux/types.h>
12#include <linux/list.h>
13#include <asm/sclp.h>
14#include <asm/ebcdic.h>
15
16
17#define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
18#define MAX_CONSOLE_PAGES 6
19
20#define EVTYP_OPCMD 0x01
21#define EVTYP_MSG 0x02
22#define EVTYP_STATECHANGE 0x08
23#define EVTYP_PMSGCMD 0x09
24#define EVTYP_CNTLPROGOPCMD 0x20
25#define EVTYP_CNTLPROGIDENT 0x0B
26#define EVTYP_SIGQUIESCE 0x1D
27#define EVTYP_VT220MSG 0x1A
28#define EVTYP_CONFMGMDATA 0x04
29#define EVTYP_SDIAS 0x1C
30#define EVTYP_ASYNC 0x0A
31#define EVTYP_OCF 0x1E
32
33#define EVTYP_OPCMD_MASK 0x80000000
34#define EVTYP_MSG_MASK 0x40000000
35#define EVTYP_STATECHANGE_MASK 0x01000000
36#define EVTYP_PMSGCMD_MASK 0x00800000
37#define EVTYP_CTLPROGOPCMD_MASK 0x00000001
38#define EVTYP_CTLPROGIDENT_MASK 0x00200000
39#define EVTYP_SIGQUIESCE_MASK 0x00000008
40#define EVTYP_VT220MSG_MASK 0x00000040
41#define EVTYP_CONFMGMDATA_MASK 0x10000000
42#define EVTYP_SDIAS_MASK 0x00000010
43#define EVTYP_ASYNC_MASK 0x00400000
44#define EVTYP_OCF_MASK 0x00000004
45
46#define GNRLMSGFLGS_DOM 0x8000
47#define GNRLMSGFLGS_SNDALRM 0x4000
48#define GNRLMSGFLGS_HOLDMSG 0x2000
49
50#define LNTPFLGS_CNTLTEXT 0x8000
51#define LNTPFLGS_LABELTEXT 0x4000
52#define LNTPFLGS_DATATEXT 0x2000
53#define LNTPFLGS_ENDTEXT 0x1000
54#define LNTPFLGS_PROMPTTEXT 0x0800
55
56typedef unsigned int sclp_cmdw_t;
57
58#define SCLP_CMDW_READ_EVENT_DATA 0x00770005
59#define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
60#define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
61
62#define GDS_ID_MDSMU 0x1310
63#define GDS_ID_MDSROUTEINFO 0x1311
64#define GDS_ID_AGUNWRKCORR 0x1549
65#define GDS_ID_SNACONDREPORT 0x1532
66#define GDS_ID_CPMSU 0x1212
67#define GDS_ID_ROUTTARGINSTR 0x154D
68#define GDS_ID_OPREQ 0x8070
69#define GDS_ID_TEXTCMD 0x1320
70
71#define GDS_KEY_SELFDEFTEXTMSG 0x31
72
73enum sclp_pm_event {
74 SCLP_PM_EVENT_FREEZE,
75 SCLP_PM_EVENT_THAW,
76 SCLP_PM_EVENT_RESTORE,
77};
78
79#define SCLP_PANIC_PRIO 1
80#define SCLP_PANIC_PRIO_CLIENT 0
81
82typedef u32 sccb_mask_t;
83
84struct sccb_header {
85 u16 length;
86 u8 function_code;
87 u8 control_mask[3];
88 u16 response_code;
89} __attribute__((packed));
90
91extern u64 sclp_facilities;
92#define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
93#define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)
94#define SCLP_HAS_CPU_INFO (sclp_facilities & 0x0800000000000000ULL)
95#define SCLP_HAS_CPU_RECONFIG (sclp_facilities & 0x0400000000000000ULL)
96
97
98struct gds_subvector {
99 u8 length;
100 u8 key;
101} __attribute__((packed));
102
103struct gds_vector {
104 u16 length;
105 u16 gds_id;
106} __attribute__((packed));
107
108struct evbuf_header {
109 u16 length;
110 u8 type;
111 u8 flags;
112 u16 _reserved;
113} __attribute__((packed));
114
115struct sclp_req {
116 struct list_head list;
117 sclp_cmdw_t command;
118 void *sccb;
119 char status;
120 int start_count;
121
122 void (*callback)(struct sclp_req *, void *data);
123 void *callback_data;
124};
125
126#define SCLP_REQ_FILLED 0x00
127#define SCLP_REQ_QUEUED 0x01
128#define SCLP_REQ_RUNNING 0x02
129#define SCLP_REQ_DONE 0x03
130#define SCLP_REQ_FAILED 0x05
131
132
133
134struct sclp_register {
135 struct list_head list;
136
137 sccb_mask_t receive_mask;
138
139 sccb_mask_t send_mask;
140
141 sccb_mask_t sclp_receive_mask;
142
143 sccb_mask_t sclp_send_mask;
144
145 void (*state_change_fn)(struct sclp_register *);
146
147 void (*receiver_fn)(struct evbuf_header *);
148
149 void (*pm_event_fn)(struct sclp_register *, enum sclp_pm_event);
150
151 int pm_event_posted;
152};
153
154
155int sclp_add_request(struct sclp_req *req);
156void sclp_sync_wait(void);
157int sclp_register(struct sclp_register *reg);
158void sclp_unregister(struct sclp_register *reg);
159int sclp_remove_processed(struct sccb_header *sccb);
160int sclp_deactivate(void);
161int sclp_reactivate(void);
162int sclp_service_call(sclp_cmdw_t command, void *sccb);
163
164int sclp_sdias_init(void);
165void sclp_sdias_exit(void);
166
167
168
169
170
171static inline unsigned char
172sclp_ascebc(unsigned char ch)
173{
174 return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
175}
176
177
178static inline void
179sclp_ebcasc_str(unsigned char *str, int nr)
180{
181 (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
182}
183
184
185static inline void
186sclp_ascebc_str(unsigned char *str, int nr)
187{
188 (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
189}
190
191static inline struct gds_vector *
192sclp_find_gds_vector(void *start, void *end, u16 id)
193{
194 struct gds_vector *v;
195
196 for (v = start; (void *) v < end; v = (void *) v + v->length)
197 if (v->gds_id == id)
198 return v;
199 return NULL;
200}
201
202static inline struct gds_subvector *
203sclp_find_gds_subvector(void *start, void *end, u8 key)
204{
205 struct gds_subvector *sv;
206
207 for (sv = start; (void *) sv < end; sv = (void *) sv + sv->length)
208 if (sv->key == key)
209 return sv;
210 return NULL;
211}
212
213#endif
214