xref: /openbmc/linux/drivers/s390/char/sclp.h (revision 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2)
1 /*
2  *  drivers/s390/char/sclp.h
3  *
4  *  S390 version
5  *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6  *    Author(s): Martin Peschke <mpeschke@de.ibm.com>
7  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
8  */
9 
10 #ifndef __SCLP_H__
11 #define __SCLP_H__
12 
13 #include <linux/types.h>
14 #include <linux/list.h>
15 
16 #include <asm/ebcdic.h>
17 
18 /* maximum number of pages concerning our own memory management */
19 #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
20 #define MAX_CONSOLE_PAGES	4
21 
22 #define EvTyp_OpCmd		0x01
23 #define EvTyp_Msg		0x02
24 #define EvTyp_StateChange	0x08
25 #define EvTyp_PMsgCmd		0x09
26 #define EvTyp_CntlProgOpCmd	0x20
27 #define EvTyp_CntlProgIdent	0x0B
28 #define EvTyp_SigQuiesce	0x1D
29 #define EvTyp_VT220Msg		0x1A
30 
31 #define EvTyp_OpCmd_Mask	0x80000000
32 #define EvTyp_Msg_Mask		0x40000000
33 #define EvTyp_StateChange_Mask	0x01000000
34 #define EvTyp_PMsgCmd_Mask	0x00800000
35 #define EvTyp_CtlProgOpCmd_Mask	0x00000001
36 #define EvTyp_CtlProgIdent_Mask	0x00200000
37 #define EvTyp_SigQuiesce_Mask	0x00000008
38 #define EvTyp_VT220Msg_Mask	0x00000040
39 
40 #define GnrlMsgFlgs_DOM		0x8000
41 #define GnrlMsgFlgs_SndAlrm	0x4000
42 #define GnrlMsgFlgs_HoldMsg	0x2000
43 
44 #define LnTpFlgs_CntlText	0x8000
45 #define LnTpFlgs_LabelText	0x4000
46 #define LnTpFlgs_DataText	0x2000
47 #define LnTpFlgs_EndText	0x1000
48 #define LnTpFlgs_PromptText	0x0800
49 
50 typedef unsigned int sclp_cmdw_t;
51 
52 #define SCLP_CMDW_READDATA	0x00770005
53 #define SCLP_CMDW_WRITEDATA	0x00760005
54 #define SCLP_CMDW_WRITEMASK	0x00780005
55 
56 #define GDS_ID_MDSMU		0x1310
57 #define GDS_ID_MDSRouteInfo	0x1311
58 #define GDS_ID_AgUnWrkCorr	0x1549
59 #define GDS_ID_SNACondReport	0x1532
60 #define GDS_ID_CPMSU		0x1212
61 #define GDS_ID_RoutTargInstr	0x154D
62 #define GDS_ID_OpReq		0x8070
63 #define GDS_ID_TextCmd		0x1320
64 
65 #define GDS_KEY_SelfDefTextMsg	0x31
66 
67 typedef u32 sccb_mask_t;	/* ATTENTION: assumes 32bit mask !!! */
68 
69 struct sccb_header {
70 	u16	length;
71 	u8	function_code;
72 	u8	control_mask[3];
73 	u16	response_code;
74 } __attribute__((packed));
75 
76 struct gds_subvector {
77 	u8	length;
78 	u8	key;
79 } __attribute__((packed));
80 
81 struct gds_vector {
82 	u16	length;
83 	u16	gds_id;
84 } __attribute__((packed));
85 
86 struct evbuf_header {
87 	u16	length;
88 	u8	type;
89 	u8	flags;
90 	u16	_reserved;
91 } __attribute__((packed));
92 
93 struct sclp_req {
94 	struct list_head list;		/* list_head for request queueing. */
95 	sclp_cmdw_t command;		/* sclp command to execute */
96 	void	*sccb;			/* pointer to the sccb to execute */
97 	char	status;			/* status of this request */
98 	int     start_count;		/* number of SVCs done for this req */
99 	/* Callback that is called after reaching final status. */
100 	void (*callback)(struct sclp_req *, void *data);
101 	void *callback_data;
102 };
103 
104 #define SCLP_REQ_FILLED	  0x00	/* request is ready to be processed */
105 #define SCLP_REQ_QUEUED	  0x01	/* request is queued to be processed */
106 #define SCLP_REQ_RUNNING  0x02	/* request is currently running */
107 #define SCLP_REQ_DONE	  0x03	/* request is completed successfully */
108 #define SCLP_REQ_FAILED	  0x05	/* request is finally failed */
109 
110 /* function pointers that a high level driver has to use for registration */
111 /* of some routines it wants to be called from the low level driver */
112 struct sclp_register {
113 	struct list_head list;
114 	/* event masks this user is registered for */
115 	sccb_mask_t receive_mask;
116 	sccb_mask_t send_mask;
117 	/* actually present events */
118 	sccb_mask_t sclp_receive_mask;
119 	sccb_mask_t sclp_send_mask;
120 	/* called if event type availability changes */
121 	void (*state_change_fn)(struct sclp_register *);
122 	/* called for events in cp_receive_mask/sclp_receive_mask */
123 	void (*receiver_fn)(struct evbuf_header *);
124 };
125 
126 /* externals from sclp.c */
127 int sclp_add_request(struct sclp_req *req);
128 void sclp_sync_wait(void);
129 int sclp_register(struct sclp_register *reg);
130 void sclp_unregister(struct sclp_register *reg);
131 int sclp_remove_processed(struct sccb_header *sccb);
132 int sclp_deactivate(void);
133 int sclp_reactivate(void);
134 
135 /* useful inlines */
136 
137 /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
138 /* translate single character from ASCII to EBCDIC */
139 static inline unsigned char
140 sclp_ascebc(unsigned char ch)
141 {
142 	return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
143 }
144 
145 /* translate string from EBCDIC to ASCII */
146 static inline void
147 sclp_ebcasc_str(unsigned char *str, int nr)
148 {
149 	(MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
150 }
151 
152 /* translate string from ASCII to EBCDIC */
153 static inline void
154 sclp_ascebc_str(unsigned char *str, int nr)
155 {
156 	(MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
157 }
158 
159 #endif	 /* __SCLP_H__ */
160