]> Pileus Git - ~andy/linux/blob - drivers/s390/char/sclp.h
[S390] sclp: introduce some new interfaces.
[~andy/linux] / drivers / s390 / char / sclp.h
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 #include <asm/sclp.h>
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 #define EVTYP_CONFMGMDATA       0x04
31 #define EVTYP_SDIAS             0x1C
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
44 #define GNRLMSGFLGS_DOM         0x8000
45 #define GNRLMSGFLGS_SNDALRM     0x4000
46 #define GNRLMSGFLGS_HOLDMSG     0x2000
47
48 #define LNTPFLGS_CNTLTEXT       0x8000
49 #define LNTPFLGS_LABELTEXT      0x4000
50 #define LNTPFLGS_DATATEXT       0x2000
51 #define LNTPFLGS_ENDTEXT        0x1000
52 #define LNTPFLGS_PROMPTTEXT     0x0800
53
54 typedef unsigned int sclp_cmdw_t;
55
56 #define SCLP_CMDW_READ_EVENT_DATA       0x00770005
57 #define SCLP_CMDW_WRITE_EVENT_DATA      0x00760005
58 #define SCLP_CMDW_WRITE_EVENT_MASK      0x00780005
59 #define SCLP_CMDW_READ_SCP_INFO         0x00020001
60 #define SCLP_CMDW_READ_SCP_INFO_FORCED  0x00120001
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
73 typedef u32 sccb_mask_t;        /* ATTENTION: assumes 32bit mask !!! */
74
75 struct sccb_header {
76         u16     length;
77         u8      function_code;
78         u8      control_mask[3];
79         u16     response_code;
80 } __attribute__((packed));
81
82 struct gds_subvector {
83         u8      length;
84         u8      key;
85 } __attribute__((packed));
86
87 struct gds_vector {
88         u16     length;
89         u16     gds_id;
90 } __attribute__((packed));
91
92 struct evbuf_header {
93         u16     length;
94         u8      type;
95         u8      flags;
96         u16     _reserved;
97 } __attribute__((packed));
98
99 struct sclp_req {
100         struct list_head list;          /* list_head for request queueing. */
101         sclp_cmdw_t command;            /* sclp command to execute */
102         void    *sccb;                  /* pointer to the sccb to execute */
103         char    status;                 /* status of this request */
104         int     start_count;            /* number of SVCs done for this req */
105         /* Callback that is called after reaching final status. */
106         void (*callback)(struct sclp_req *, void *data);
107         void *callback_data;
108 };
109
110 #define SCLP_REQ_FILLED   0x00  /* request is ready to be processed */
111 #define SCLP_REQ_QUEUED   0x01  /* request is queued to be processed */
112 #define SCLP_REQ_RUNNING  0x02  /* request is currently running */
113 #define SCLP_REQ_DONE     0x03  /* request is completed successfully */
114 #define SCLP_REQ_FAILED   0x05  /* request is finally failed */
115
116 /* function pointers that a high level driver has to use for registration */
117 /* of some routines it wants to be called from the low level driver */
118 struct sclp_register {
119         struct list_head list;
120         /* event masks this user is registered for */
121         sccb_mask_t receive_mask;
122         sccb_mask_t send_mask;
123         /* actually present events */
124         sccb_mask_t sclp_receive_mask;
125         sccb_mask_t sclp_send_mask;
126         /* called if event type availability changes */
127         void (*state_change_fn)(struct sclp_register *);
128         /* called for events in cp_receive_mask/sclp_receive_mask */
129         void (*receiver_fn)(struct evbuf_header *);
130 };
131
132 /* externals from sclp.c */
133 int sclp_add_request(struct sclp_req *req);
134 void sclp_sync_wait(void);
135 int sclp_register(struct sclp_register *reg);
136 void sclp_unregister(struct sclp_register *reg);
137 int sclp_remove_processed(struct sccb_header *sccb);
138 int sclp_deactivate(void);
139 int sclp_reactivate(void);
140 int sclp_service_call(sclp_cmdw_t command, void *sccb);
141
142 int sclp_sdias_init(void);
143 void sclp_sdias_exit(void);
144
145 /* useful inlines */
146
147 /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
148 /* translate single character from ASCII to EBCDIC */
149 static inline unsigned char
150 sclp_ascebc(unsigned char ch)
151 {
152         return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
153 }
154
155 /* translate string from EBCDIC to ASCII */
156 static inline void
157 sclp_ebcasc_str(unsigned char *str, int nr)
158 {
159         (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
160 }
161
162 /* translate string from ASCII to EBCDIC */
163 static inline void
164 sclp_ascebc_str(unsigned char *str, int nr)
165 {
166         (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
167 }
168
169 #endif   /* __SCLP_H__ */