blob: 7d29ab45a6ed7fb21b392a5d2cd785e1f1c7983a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Heiko Carstensab14de62007-02-05 21:18:37 +010015#include <asm/sclp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#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
50typedef unsigned int sclp_cmdw_t;
51
Heiko Carstensab14de62007-02-05 21:18:37 +010052#define SCLP_CMDW_READ_EVENT_DATA 0x00770005
53#define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
54#define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
55#define SCLP_CMDW_READ_SCP_INFO 0x00020001
56#define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58#define GDS_ID_MDSMU 0x1310
59#define GDS_ID_MDSRouteInfo 0x1311
60#define GDS_ID_AgUnWrkCorr 0x1549
61#define GDS_ID_SNACondReport 0x1532
62#define GDS_ID_CPMSU 0x1212
63#define GDS_ID_RoutTargInstr 0x154D
64#define GDS_ID_OpReq 0x8070
65#define GDS_ID_TextCmd 0x1320
66
67#define GDS_KEY_SelfDefTextMsg 0x31
68
69typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071struct gds_subvector {
72 u8 length;
73 u8 key;
74} __attribute__((packed));
75
76struct gds_vector {
77 u16 length;
78 u16 gds_id;
79} __attribute__((packed));
80
81struct evbuf_header {
82 u16 length;
83 u8 type;
84 u8 flags;
85 u16 _reserved;
86} __attribute__((packed));
87
88struct sclp_req {
89 struct list_head list; /* list_head for request queueing. */
90 sclp_cmdw_t command; /* sclp command to execute */
91 void *sccb; /* pointer to the sccb to execute */
92 char status; /* status of this request */
93 int start_count; /* number of SVCs done for this req */
94 /* Callback that is called after reaching final status. */
95 void (*callback)(struct sclp_req *, void *data);
96 void *callback_data;
97};
98
99#define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
100#define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
101#define SCLP_REQ_RUNNING 0x02 /* request is currently running */
102#define SCLP_REQ_DONE 0x03 /* request is completed successfully */
103#define SCLP_REQ_FAILED 0x05 /* request is finally failed */
104
105/* function pointers that a high level driver has to use for registration */
106/* of some routines it wants to be called from the low level driver */
107struct sclp_register {
108 struct list_head list;
109 /* event masks this user is registered for */
110 sccb_mask_t receive_mask;
111 sccb_mask_t send_mask;
112 /* actually present events */
113 sccb_mask_t sclp_receive_mask;
114 sccb_mask_t sclp_send_mask;
115 /* called if event type availability changes */
116 void (*state_change_fn)(struct sclp_register *);
117 /* called for events in cp_receive_mask/sclp_receive_mask */
118 void (*receiver_fn)(struct evbuf_header *);
119};
120
121/* externals from sclp.c */
122int sclp_add_request(struct sclp_req *req);
123void sclp_sync_wait(void);
124int sclp_register(struct sclp_register *reg);
125void sclp_unregister(struct sclp_register *reg);
126int sclp_remove_processed(struct sccb_header *sccb);
127int sclp_deactivate(void);
128int sclp_reactivate(void);
Heiko Carstensab14de62007-02-05 21:18:37 +0100129int sclp_service_call(sclp_cmdw_t command, void *sccb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131/* useful inlines */
132
133/* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
134/* translate single character from ASCII to EBCDIC */
135static inline unsigned char
136sclp_ascebc(unsigned char ch)
137{
138 return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
139}
140
141/* translate string from EBCDIC to ASCII */
142static inline void
143sclp_ebcasc_str(unsigned char *str, int nr)
144{
145 (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
146}
147
148/* translate string from ASCII to EBCDIC */
149static inline void
150sclp_ascebc_str(unsigned char *str, int nr)
151{
152 (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
153}
154
155#endif /* __SCLP_H__ */