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