blob: 6bb5a6bdfab52a6d7e66dbcd872b0b2ed9d9ed37 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Michael Holzheu62b749422009-06-16 10:30:40 +02002 * Copyright IBM Corp. 1999, 2009
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Michael Holzheu62b749422009-06-16 10:30:40 +02004 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
8#ifndef __SCLP_H__
9#define __SCLP_H__
10
11#include <linux/types.h>
12#include <linux/list.h>
Heiko Carstensab14de62007-02-05 21:18:37 +010013#include <asm/sclp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/ebcdic.h>
15
16/* maximum number of pages concerning our own memory management */
17#define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
Michael Holzheu62b749422009-06-16 10:30:40 +020018#define MAX_CONSOLE_PAGES 6
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Stefan Haberland6d4740c2007-04-27 16:01:53 +020020#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
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020028#define EVTYP_CONFMGMDATA 0x04
Stefan Haberland6d4740c2007-04-27 16:01:53 +020029#define EVTYP_SDIAS 0x1C
Hans-Joachim Pichtc1147282009-09-11 10:28:47 +020030#define EVTYP_ASYNC 0x0A
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Stefan Haberland6d4740c2007-04-27 16:01:53 +020032#define EVTYP_OPCMD_MASK 0x80000000
33#define EVTYP_MSG_MASK 0x40000000
34#define EVTYP_STATECHANGE_MASK 0x01000000
35#define EVTYP_PMSGCMD_MASK 0x00800000
36#define EVTYP_CTLPROGOPCMD_MASK 0x00000001
37#define EVTYP_CTLPROGIDENT_MASK 0x00200000
38#define EVTYP_SIGQUIESCE_MASK 0x00000008
39#define EVTYP_VT220MSG_MASK 0x00000040
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020040#define EVTYP_CONFMGMDATA_MASK 0x10000000
Stefan Haberland6d4740c2007-04-27 16:01:53 +020041#define EVTYP_SDIAS_MASK 0x00000010
Hans-Joachim Pichtc1147282009-09-11 10:28:47 +020042#define EVTYP_ASYNC_MASK 0x00400000
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Stefan Haberland6d4740c2007-04-27 16:01:53 +020044#define GNRLMSGFLGS_DOM 0x8000
45#define GNRLMSGFLGS_SNDALRM 0x4000
46#define GNRLMSGFLGS_HOLDMSG 0x2000
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Stefan Haberland6d4740c2007-04-27 16:01:53 +020048#define LNTPFLGS_CNTLTEXT 0x8000
49#define LNTPFLGS_LABELTEXT 0x4000
50#define LNTPFLGS_DATATEXT 0x2000
51#define LNTPFLGS_ENDTEXT 0x1000
52#define LNTPFLGS_PROMPTTEXT 0x0800
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54typedef unsigned int sclp_cmdw_t;
55
Heiko Carstensab14de62007-02-05 21:18:37 +010056#define SCLP_CMDW_READ_EVENT_DATA 0x00770005
57#define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
58#define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#define GDS_ID_MDSMU 0x1310
Stefan Haberland6d4740c2007-04-27 16:01:53 +020061#define GDS_ID_MDSROUTEINFO 0x1311
62#define GDS_ID_AGUNWRKCORR 0x1549
63#define GDS_ID_SNACONDREPORT 0x1532
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define GDS_ID_CPMSU 0x1212
Stefan Haberland6d4740c2007-04-27 16:01:53 +020065#define GDS_ID_ROUTTARGINSTR 0x154D
66#define GDS_ID_OPREQ 0x8070
67#define GDS_ID_TEXTCMD 0x1320
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Stefan Haberland6d4740c2007-04-27 16:01:53 +020069#define GDS_KEY_SELFDEFTEXTMSG 0x31
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Michael Holzheu62b749422009-06-16 10:30:40 +020071enum sclp_pm_event {
72 SCLP_PM_EVENT_FREEZE,
73 SCLP_PM_EVENT_THAW,
74 SCLP_PM_EVENT_RESTORE,
75};
76
77#define SCLP_PANIC_PRIO 1
78#define SCLP_PANIC_PRIO_CLIENT 0
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
81
Heiko Carstens05dd2532007-07-10 11:24:09 +020082struct sccb_header {
83 u16 length;
84 u8 function_code;
85 u8 control_mask[3];
86 u16 response_code;
87} __attribute__((packed));
88
Heiko Carstens83119ad2007-07-10 11:24:10 +020089extern u64 sclp_facilities;
Heiko Carstens83119ad2007-07-10 11:24:10 +020090#define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
91#define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)
Heiko Carstens08d07962008-01-26 14:10:56 +010092#define SCLP_HAS_CPU_INFO (sclp_facilities & 0x0800000000000000ULL)
93#define SCLP_HAS_CPU_RECONFIG (sclp_facilities & 0x0400000000000000ULL)
Heiko Carstens83119ad2007-07-10 11:24:10 +020094
Hans-Joachim Pichtc1147282009-09-11 10:28:47 +020095
Linus Torvalds1da177e2005-04-16 15:20:36 -070096struct gds_subvector {
97 u8 length;
98 u8 key;
99} __attribute__((packed));
100
101struct gds_vector {
102 u16 length;
103 u16 gds_id;
104} __attribute__((packed));
105
106struct evbuf_header {
107 u16 length;
108 u8 type;
109 u8 flags;
110 u16 _reserved;
111} __attribute__((packed));
112
113struct sclp_req {
114 struct list_head list; /* list_head for request queueing. */
115 sclp_cmdw_t command; /* sclp command to execute */
116 void *sccb; /* pointer to the sccb to execute */
117 char status; /* status of this request */
118 int start_count; /* number of SVCs done for this req */
119 /* Callback that is called after reaching final status. */
120 void (*callback)(struct sclp_req *, void *data);
121 void *callback_data;
122};
123
124#define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
125#define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
126#define SCLP_REQ_RUNNING 0x02 /* request is currently running */
127#define SCLP_REQ_DONE 0x03 /* request is completed successfully */
128#define SCLP_REQ_FAILED 0x05 /* request is finally failed */
129
130/* function pointers that a high level driver has to use for registration */
131/* of some routines it wants to be called from the low level driver */
132struct sclp_register {
133 struct list_head list;
Peter Oberparleiterd082d3c2008-02-19 15:29:32 +0100134 /* User wants to receive: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 sccb_mask_t receive_mask;
Peter Oberparleiterd082d3c2008-02-19 15:29:32 +0100136 /* User wants to send: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 sccb_mask_t send_mask;
Peter Oberparleiterd082d3c2008-02-19 15:29:32 +0100138 /* H/W can receive: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 sccb_mask_t sclp_receive_mask;
Peter Oberparleiterd082d3c2008-02-19 15:29:32 +0100140 /* H/W can send: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 sccb_mask_t sclp_send_mask;
142 /* called if event type availability changes */
143 void (*state_change_fn)(struct sclp_register *);
144 /* called for events in cp_receive_mask/sclp_receive_mask */
145 void (*receiver_fn)(struct evbuf_header *);
Michael Holzheu62b749422009-06-16 10:30:40 +0200146 /* called for power management events */
147 void (*pm_event_fn)(struct sclp_register *, enum sclp_pm_event);
148 /* pm event posted flag */
149 int pm_event_posted;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150};
151
152/* externals from sclp.c */
153int sclp_add_request(struct sclp_req *req);
154void sclp_sync_wait(void);
155int sclp_register(struct sclp_register *reg);
156void sclp_unregister(struct sclp_register *reg);
157int sclp_remove_processed(struct sccb_header *sccb);
158int sclp_deactivate(void);
159int sclp_reactivate(void);
Heiko Carstensab14de62007-02-05 21:18:37 +0100160int sclp_service_call(sclp_cmdw_t command, void *sccb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Heiko Carstens763968e2007-05-10 15:45:46 +0200162int sclp_sdias_init(void);
163void sclp_sdias_exit(void);
164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165/* useful inlines */
166
167/* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
168/* translate single character from ASCII to EBCDIC */
169static inline unsigned char
170sclp_ascebc(unsigned char ch)
171{
172 return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
173}
174
175/* translate string from EBCDIC to ASCII */
176static inline void
177sclp_ebcasc_str(unsigned char *str, int nr)
178{
179 (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
180}
181
182/* translate string from ASCII to EBCDIC */
183static inline void
184sclp_ascebc_str(unsigned char *str, int nr)
185{
186 (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
187}
188
189#endif /* __SCLP_H__ */