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 SCLP_CONSOLE_PAGES 6
20 #define SCLP_EVTYP_MASK(T) (1U << (32 - (T)))
22 #define EVTYP_OPCMD 0x01
23 #define EVTYP_MSG 0x02
24 #define EVTYP_CONFMGMDATA 0x04
25 #define EVTYP_DIAG_TEST 0x07
26 #define EVTYP_STATECHANGE 0x08
27 #define EVTYP_PMSGCMD 0x09
28 #define EVTYP_ASYNC 0x0A
29 #define EVTYP_CTLPROGIDENT 0x0B
30 #define EVTYP_ERRNOTIFY 0x18
31 #define EVTYP_VT220MSG 0x1A
32 #define EVTYP_SDIAS 0x1C
33 #define EVTYP_SIGQUIESCE 0x1D
34 #define EVTYP_OCF 0x1E
36 #define EVTYP_OPCMD_MASK SCLP_EVTYP_MASK(EVTYP_OPCMD)
37 #define EVTYP_MSG_MASK SCLP_EVTYP_MASK(EVTYP_MSG)
38 #define EVTYP_CONFMGMDATA_MASK SCLP_EVTYP_MASK(EVTYP_CONFMGMDATA)
39 #define EVTYP_DIAG_TEST_MASK SCLP_EVTYP_MASK(EVTYP_DIAG_TEST)
40 #define EVTYP_STATECHANGE_MASK SCLP_EVTYP_MASK(EVTYP_STATECHANGE)
41 #define EVTYP_PMSGCMD_MASK SCLP_EVTYP_MASK(EVTYP_PMSGCMD)
42 #define EVTYP_ASYNC_MASK SCLP_EVTYP_MASK(EVTYP_ASYNC)
43 #define EVTYP_CTLPROGIDENT_MASK SCLP_EVTYP_MASK(EVTYP_CTLPROGIDENT)
44 #define EVTYP_ERRNOTIFY_MASK SCLP_EVTYP_MASK(EVTYP_ERRNOTIFY)
45 #define EVTYP_VT220MSG_MASK SCLP_EVTYP_MASK(EVTYP_VT220MSG)
46 #define EVTYP_SDIAS_MASK SCLP_EVTYP_MASK(EVTYP_SDIAS)
47 #define EVTYP_SIGQUIESCE_MASK SCLP_EVTYP_MASK(EVTYP_SIGQUIESCE)
48 #define EVTYP_OCF_MASK SCLP_EVTYP_MASK(EVTYP_OCF)
50 #define GNRLMSGFLGS_DOM 0x8000
51 #define GNRLMSGFLGS_SNDALRM 0x4000
52 #define GNRLMSGFLGS_HOLDMSG 0x2000
54 #define LNTPFLGS_CNTLTEXT 0x8000
55 #define LNTPFLGS_LABELTEXT 0x4000
56 #define LNTPFLGS_DATATEXT 0x2000
57 #define LNTPFLGS_ENDTEXT 0x1000
58 #define LNTPFLGS_PROMPTTEXT 0x0800
60 typedef unsigned int sclp_cmdw_t
;
62 #define SCLP_CMDW_READ_CPU_INFO 0x00010001
63 #define SCLP_CMDW_READ_EVENT_DATA 0x00770005
64 #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
65 #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
67 #define GDS_ID_MDSMU 0x1310
68 #define GDS_ID_MDSROUTEINFO 0x1311
69 #define GDS_ID_AGUNWRKCORR 0x1549
70 #define GDS_ID_SNACONDREPORT 0x1532
71 #define GDS_ID_CPMSU 0x1212
72 #define GDS_ID_ROUTTARGINSTR 0x154D
73 #define GDS_ID_OPREQ 0x8070
74 #define GDS_ID_TEXTCMD 0x1320
76 #define GDS_KEY_SELFDEFTEXTMSG 0x31
81 SCLP_PM_EVENT_RESTORE
,
84 #define SCLP_PANIC_PRIO 1
85 #define SCLP_PANIC_PRIO_CLIENT 0
87 typedef u32 sccb_mask_t
; /* ATTENTION: assumes 32bit mask !!! */
94 } __attribute__((packed
));
97 struct sccb_header header
;
100 sccb_mask_t receive_mask
;
101 sccb_mask_t send_mask
;
102 sccb_mask_t sclp_receive_mask
;
103 sccb_mask_t sclp_send_mask
;
104 } __attribute__((packed
));
106 struct read_cpu_info_sccb
{
107 struct sccb_header header
;
109 u16 offset_configured
;
112 u8 reserved
[4096 - 16];
113 } __attribute__((packed
, aligned(PAGE_SIZE
)));
115 static inline void sclp_fill_core_info(struct sclp_core_info
*info
,
116 struct read_cpu_info_sccb
*sccb
)
118 char *page
= (char *) sccb
;
120 memset(info
, 0, sizeof(*info
));
121 info
->configured
= sccb
->nr_configured
;
122 info
->standby
= sccb
->nr_standby
;
123 info
->combined
= sccb
->nr_configured
+ sccb
->nr_standby
;
124 memcpy(&info
->core
, page
+ sccb
->offset_configured
,
125 info
->combined
* sizeof(struct sclp_core_entry
));
128 #define SCLP_HAS_CHP_INFO (sclp.facilities & 0x8000000000000000ULL)
129 #define SCLP_HAS_CHP_RECONFIG (sclp.facilities & 0x2000000000000000ULL)
130 #define SCLP_HAS_CPU_INFO (sclp.facilities & 0x0800000000000000ULL)
131 #define SCLP_HAS_CPU_RECONFIG (sclp.facilities & 0x0400000000000000ULL)
132 #define SCLP_HAS_PCI_RECONFIG (sclp.facilities & 0x0000000040000000ULL)
135 struct gds_subvector
{
138 } __attribute__((packed
));
143 } __attribute__((packed
));
145 struct evbuf_header
{
150 } __attribute__((packed
));
153 struct list_head list
; /* list_head for request queueing. */
154 sclp_cmdw_t command
; /* sclp command to execute */
155 void *sccb
; /* pointer to the sccb to execute */
156 char status
; /* status of this request */
157 int start_count
; /* number of SVCs done for this req */
158 /* Callback that is called after reaching final status. */
159 void (*callback
)(struct sclp_req
*, void *data
);
161 int queue_timeout
; /* request queue timeout (sec), set by
162 caller of sclp_add_request(), if
164 /* Internal fields */
165 unsigned long queue_expires
; /* request queue timeout (jiffies) */
168 #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
169 #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
170 #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
171 #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
172 #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
173 #define SCLP_REQ_QUEUED_TIMEOUT 0x06 /* request on queue timed out */
175 #define SCLP_QUEUE_INTERVAL 5 /* timeout interval for request queue */
177 /* function pointers that a high level driver has to use for registration */
178 /* of some routines it wants to be called from the low level driver */
179 struct sclp_register
{
180 struct list_head list
;
181 /* User wants to receive: */
182 sccb_mask_t receive_mask
;
183 /* User wants to send: */
184 sccb_mask_t send_mask
;
185 /* H/W can receive: */
186 sccb_mask_t sclp_receive_mask
;
188 sccb_mask_t sclp_send_mask
;
189 /* called if event type availability changes */
190 void (*state_change_fn
)(struct sclp_register
*);
191 /* called for events in cp_receive_mask/sclp_receive_mask */
192 void (*receiver_fn
)(struct evbuf_header
*);
193 /* called for power management events */
194 void (*pm_event_fn
)(struct sclp_register
*, enum sclp_pm_event
);
195 /* pm event posted flag */
199 /* externals from sclp.c */
200 int sclp_add_request(struct sclp_req
*req
);
201 void sclp_sync_wait(void);
202 int sclp_register(struct sclp_register
*reg
);
203 void sclp_unregister(struct sclp_register
*reg
);
204 int sclp_remove_processed(struct sccb_header
*sccb
);
205 int sclp_deactivate(void);
206 int sclp_reactivate(void);
207 int sclp_service_call(sclp_cmdw_t command
, void *sccb
);
208 int sclp_sync_request(sclp_cmdw_t command
, void *sccb
);
209 int sclp_sync_request_timeout(sclp_cmdw_t command
, void *sccb
, int timeout
);
211 int sclp_sdias_init(void);
212 void sclp_sdias_exit(void);
214 extern int sclp_console_pages
;
215 extern int sclp_console_drop
;
216 extern unsigned long sclp_console_full
;
220 /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
221 /* translate single character from ASCII to EBCDIC */
222 static inline unsigned char
223 sclp_ascebc(unsigned char ch
)
225 return (MACHINE_IS_VM
) ? _ascebc
[ch
] : _ascebc_500
[ch
];
228 /* translate string from EBCDIC to ASCII */
230 sclp_ebcasc_str(unsigned char *str
, int nr
)
232 (MACHINE_IS_VM
) ? EBCASC(str
, nr
) : EBCASC_500(str
, nr
);
235 /* translate string from ASCII to EBCDIC */
237 sclp_ascebc_str(unsigned char *str
, int nr
)
239 (MACHINE_IS_VM
) ? ASCEBC(str
, nr
) : ASCEBC_500(str
, nr
);
242 static inline struct gds_vector
*
243 sclp_find_gds_vector(void *start
, void *end
, u16 id
)
245 struct gds_vector
*v
;
247 for (v
= start
; (void *) v
< end
; v
= (void *) v
+ v
->length
)
253 static inline struct gds_subvector
*
254 sclp_find_gds_subvector(void *start
, void *end
, u8 key
)
256 struct gds_subvector
*sv
;
258 for (sv
= start
; (void *) sv
< end
; sv
= (void *) sv
+ sv
->length
)
264 #endif /* __SCLP_H__ */