2 * Copyright IBM Corp. 1999,2012
4 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
11 #include <linux/types.h>
12 #include <linux/list.h>
14 #include <asm/ebcdic.h>
16 /* maximum number of pages concerning our own memory management */
17 #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
18 #define MAX_CONSOLE_PAGES 6
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
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
46 #define GNRLMSGFLGS_DOM 0x8000
47 #define GNRLMSGFLGS_SNDALRM 0x4000
48 #define GNRLMSGFLGS_HOLDMSG 0x2000
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
56 typedef unsigned int sclp_cmdw_t;
58 #define SCLP_CMDW_READ_EVENT_DATA 0x00770005
59 #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
60 #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
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
71 #define GDS_KEY_SELFDEFTEXTMSG 0x31
76 SCLP_PM_EVENT_RESTORE,
79 #define SCLP_PANIC_PRIO 1
80 #define SCLP_PANIC_PRIO_CLIENT 0
82 typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
89 } __attribute__((packed));
92 struct sccb_header header;
95 sccb_mask_t receive_mask;
96 sccb_mask_t send_mask;
97 sccb_mask_t sclp_receive_mask;
98 sccb_mask_t sclp_send_mask;
99 } __attribute__((packed));
101 extern u64 sclp_facilities;
102 #define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
103 #define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)
104 #define SCLP_HAS_CPU_INFO (sclp_facilities & 0x0800000000000000ULL)
105 #define SCLP_HAS_CPU_RECONFIG (sclp_facilities & 0x0400000000000000ULL)
106 #define SCLP_HAS_PCI_RECONFIG (sclp_facilities & 0x0000000040000000ULL)
109 struct gds_subvector {
112 } __attribute__((packed));
117 } __attribute__((packed));
119 struct evbuf_header {
124 } __attribute__((packed));
127 struct list_head list; /* list_head for request queueing. */
128 sclp_cmdw_t command; /* sclp command to execute */
129 void *sccb; /* pointer to the sccb to execute */
130 char status; /* status of this request */
131 int start_count; /* number of SVCs done for this req */
132 /* Callback that is called after reaching final status. */
133 void (*callback)(struct sclp_req *, void *data);
137 #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
138 #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
139 #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
140 #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
141 #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
143 /* function pointers that a high level driver has to use for registration */
144 /* of some routines it wants to be called from the low level driver */
145 struct sclp_register {
146 struct list_head list;
147 /* User wants to receive: */
148 sccb_mask_t receive_mask;
149 /* User wants to send: */
150 sccb_mask_t send_mask;
151 /* H/W can receive: */
152 sccb_mask_t sclp_receive_mask;
154 sccb_mask_t sclp_send_mask;
155 /* called if event type availability changes */
156 void (*state_change_fn)(struct sclp_register *);
157 /* called for events in cp_receive_mask/sclp_receive_mask */
158 void (*receiver_fn)(struct evbuf_header *);
159 /* called for power management events */
160 void (*pm_event_fn)(struct sclp_register *, enum sclp_pm_event);
161 /* pm event posted flag */
165 /* externals from sclp.c */
166 int sclp_add_request(struct sclp_req *req);
167 void sclp_sync_wait(void);
168 int sclp_register(struct sclp_register *reg);
169 void sclp_unregister(struct sclp_register *reg);
170 int sclp_remove_processed(struct sccb_header *sccb);
171 int sclp_deactivate(void);
172 int sclp_reactivate(void);
173 int sclp_service_call(sclp_cmdw_t command, void *sccb);
175 int sclp_sdias_init(void);
176 void sclp_sdias_exit(void);
180 /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
181 /* translate single character from ASCII to EBCDIC */
182 static inline unsigned char
183 sclp_ascebc(unsigned char ch)
185 return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
188 /* translate string from EBCDIC to ASCII */
190 sclp_ebcasc_str(unsigned char *str, int nr)
192 (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
195 /* translate string from ASCII to EBCDIC */
197 sclp_ascebc_str(unsigned char *str, int nr)
199 (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
202 static inline struct gds_vector *
203 sclp_find_gds_vector(void *start, void *end, u16 id)
205 struct gds_vector *v;
207 for (v = start; (void *) v < end; v = (void *) v + v->length)
213 static inline struct gds_subvector *
214 sclp_find_gds_subvector(void *start, void *end, u8 key)
216 struct gds_subvector *sv;
218 for (sv = start; (void *) sv < end; sv = (void *) sv + sv->length)
224 #endif /* __SCLP_H__ */