Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 15 | #include <asm/sclp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 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 |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 30 | #define EVTYP_CONFMGMDATA 0x04 |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 31 | #define EVTYP_SDIAS 0x1C |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 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 |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 41 | #define EVTYP_CONFMGMDATA_MASK 0x10000000 |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 42 | #define EVTYP_SDIAS_MASK 0x00000010 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 44 | #define GNRLMSGFLGS_DOM 0x8000 |
| 45 | #define GNRLMSGFLGS_SNDALRM 0x4000 |
| 46 | #define GNRLMSGFLGS_HOLDMSG 0x2000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | typedef unsigned int sclp_cmdw_t; |
| 55 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 56 | #define SCLP_CMDW_READ_EVENT_DATA 0x00770005 |
| 57 | #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005 |
| 58 | #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | #define GDS_ID_MDSMU 0x1310 |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 61 | #define GDS_ID_MDSROUTEINFO 0x1311 |
| 62 | #define GDS_ID_AGUNWRKCORR 0x1549 |
| 63 | #define GDS_ID_SNACONDREPORT 0x1532 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #define GDS_ID_CPMSU 0x1212 |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 65 | #define GDS_ID_ROUTTARGINSTR 0x154D |
| 66 | #define GDS_ID_OPREQ 0x8070 |
| 67 | #define GDS_ID_TEXTCMD 0x1320 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 69 | #define GDS_KEY_SELFDEFTEXTMSG 0x31 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */ |
| 72 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 73 | struct sccb_header { |
| 74 | u16 length; |
| 75 | u8 function_code; |
| 76 | u8 control_mask[3]; |
| 77 | u16 response_code; |
| 78 | } __attribute__((packed)); |
| 79 | |
Heiko Carstens | 83119ad | 2007-07-10 11:24:10 +0200 | [diff] [blame] | 80 | extern u64 sclp_facilities; |
| 81 | |
| 82 | #define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL) |
| 83 | #define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL) |
Heiko Carstens | 08d0796 | 2008-01-26 14:10:56 +0100 | [diff] [blame] | 84 | #define SCLP_HAS_CPU_INFO (sclp_facilities & 0x0800000000000000ULL) |
| 85 | #define SCLP_HAS_CPU_RECONFIG (sclp_facilities & 0x0400000000000000ULL) |
Heiko Carstens | 83119ad | 2007-07-10 11:24:10 +0200 | [diff] [blame] | 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct gds_subvector { |
| 88 | u8 length; |
| 89 | u8 key; |
| 90 | } __attribute__((packed)); |
| 91 | |
| 92 | struct gds_vector { |
| 93 | u16 length; |
| 94 | u16 gds_id; |
| 95 | } __attribute__((packed)); |
| 96 | |
| 97 | struct evbuf_header { |
| 98 | u16 length; |
| 99 | u8 type; |
| 100 | u8 flags; |
| 101 | u16 _reserved; |
| 102 | } __attribute__((packed)); |
| 103 | |
| 104 | struct sclp_req { |
| 105 | struct list_head list; /* list_head for request queueing. */ |
| 106 | sclp_cmdw_t command; /* sclp command to execute */ |
| 107 | void *sccb; /* pointer to the sccb to execute */ |
| 108 | char status; /* status of this request */ |
| 109 | int start_count; /* number of SVCs done for this req */ |
| 110 | /* Callback that is called after reaching final status. */ |
| 111 | void (*callback)(struct sclp_req *, void *data); |
| 112 | void *callback_data; |
| 113 | }; |
| 114 | |
| 115 | #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */ |
| 116 | #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */ |
| 117 | #define SCLP_REQ_RUNNING 0x02 /* request is currently running */ |
| 118 | #define SCLP_REQ_DONE 0x03 /* request is completed successfully */ |
| 119 | #define SCLP_REQ_FAILED 0x05 /* request is finally failed */ |
| 120 | |
| 121 | /* function pointers that a high level driver has to use for registration */ |
| 122 | /* of some routines it wants to be called from the low level driver */ |
| 123 | struct sclp_register { |
| 124 | struct list_head list; |
Peter Oberparleiter | d082d3c | 2008-02-19 15:29:32 +0100 | [diff] [blame^] | 125 | /* User wants to receive: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | sccb_mask_t receive_mask; |
Peter Oberparleiter | d082d3c | 2008-02-19 15:29:32 +0100 | [diff] [blame^] | 127 | /* User wants to send: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | sccb_mask_t send_mask; |
Peter Oberparleiter | d082d3c | 2008-02-19 15:29:32 +0100 | [diff] [blame^] | 129 | /* H/W can receive: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | sccb_mask_t sclp_receive_mask; |
Peter Oberparleiter | d082d3c | 2008-02-19 15:29:32 +0100 | [diff] [blame^] | 131 | /* H/W can send: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | sccb_mask_t sclp_send_mask; |
| 133 | /* called if event type availability changes */ |
| 134 | void (*state_change_fn)(struct sclp_register *); |
| 135 | /* called for events in cp_receive_mask/sclp_receive_mask */ |
| 136 | void (*receiver_fn)(struct evbuf_header *); |
| 137 | }; |
| 138 | |
| 139 | /* externals from sclp.c */ |
| 140 | int sclp_add_request(struct sclp_req *req); |
| 141 | void sclp_sync_wait(void); |
| 142 | int sclp_register(struct sclp_register *reg); |
| 143 | void sclp_unregister(struct sclp_register *reg); |
| 144 | int sclp_remove_processed(struct sccb_header *sccb); |
| 145 | int sclp_deactivate(void); |
| 146 | int sclp_reactivate(void); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 147 | int sclp_service_call(sclp_cmdw_t command, void *sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 149 | int sclp_sdias_init(void); |
| 150 | void sclp_sdias_exit(void); |
| 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | /* useful inlines */ |
| 153 | |
| 154 | /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */ |
| 155 | /* translate single character from ASCII to EBCDIC */ |
| 156 | static inline unsigned char |
| 157 | sclp_ascebc(unsigned char ch) |
| 158 | { |
| 159 | return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch]; |
| 160 | } |
| 161 | |
| 162 | /* translate string from EBCDIC to ASCII */ |
| 163 | static inline void |
| 164 | sclp_ebcasc_str(unsigned char *str, int nr) |
| 165 | { |
| 166 | (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr); |
| 167 | } |
| 168 | |
| 169 | /* translate string from ASCII to EBCDIC */ |
| 170 | static inline void |
| 171 | sclp_ascebc_str(unsigned char *str, int nr) |
| 172 | { |
| 173 | (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr); |
| 174 | } |
| 175 | |
| 176 | #endif /* __SCLP_H__ */ |