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 |
| 30 | #define EVTYP_SDIAS 0x1C |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame^] | 32 | #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 |
| 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 |
| 57 | #define SCLP_CMDW_READ_SCP_INFO 0x00020001 |
| 58 | #define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001 |
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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | struct gds_subvector { |
| 74 | u8 length; |
| 75 | u8 key; |
| 76 | } __attribute__((packed)); |
| 77 | |
| 78 | struct gds_vector { |
| 79 | u16 length; |
| 80 | u16 gds_id; |
| 81 | } __attribute__((packed)); |
| 82 | |
| 83 | struct evbuf_header { |
| 84 | u16 length; |
| 85 | u8 type; |
| 86 | u8 flags; |
| 87 | u16 _reserved; |
| 88 | } __attribute__((packed)); |
| 89 | |
| 90 | struct sclp_req { |
| 91 | struct list_head list; /* list_head for request queueing. */ |
| 92 | sclp_cmdw_t command; /* sclp command to execute */ |
| 93 | void *sccb; /* pointer to the sccb to execute */ |
| 94 | char status; /* status of this request */ |
| 95 | int start_count; /* number of SVCs done for this req */ |
| 96 | /* Callback that is called after reaching final status. */ |
| 97 | void (*callback)(struct sclp_req *, void *data); |
| 98 | void *callback_data; |
| 99 | }; |
| 100 | |
| 101 | #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */ |
| 102 | #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */ |
| 103 | #define SCLP_REQ_RUNNING 0x02 /* request is currently running */ |
| 104 | #define SCLP_REQ_DONE 0x03 /* request is completed successfully */ |
| 105 | #define SCLP_REQ_FAILED 0x05 /* request is finally failed */ |
| 106 | |
| 107 | /* function pointers that a high level driver has to use for registration */ |
| 108 | /* of some routines it wants to be called from the low level driver */ |
| 109 | struct sclp_register { |
| 110 | struct list_head list; |
| 111 | /* event masks this user is registered for */ |
| 112 | sccb_mask_t receive_mask; |
| 113 | sccb_mask_t send_mask; |
| 114 | /* actually present events */ |
| 115 | sccb_mask_t sclp_receive_mask; |
| 116 | sccb_mask_t sclp_send_mask; |
| 117 | /* called if event type availability changes */ |
| 118 | void (*state_change_fn)(struct sclp_register *); |
| 119 | /* called for events in cp_receive_mask/sclp_receive_mask */ |
| 120 | void (*receiver_fn)(struct evbuf_header *); |
| 121 | }; |
| 122 | |
| 123 | /* externals from sclp.c */ |
| 124 | int sclp_add_request(struct sclp_req *req); |
| 125 | void sclp_sync_wait(void); |
| 126 | int sclp_register(struct sclp_register *reg); |
| 127 | void sclp_unregister(struct sclp_register *reg); |
| 128 | int sclp_remove_processed(struct sccb_header *sccb); |
| 129 | int sclp_deactivate(void); |
| 130 | int sclp_reactivate(void); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 131 | int sclp_service_call(sclp_cmdw_t command, void *sccb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | /* useful inlines */ |
| 134 | |
| 135 | /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */ |
| 136 | /* translate single character from ASCII to EBCDIC */ |
| 137 | static inline unsigned char |
| 138 | sclp_ascebc(unsigned char ch) |
| 139 | { |
| 140 | return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch]; |
| 141 | } |
| 142 | |
| 143 | /* translate string from EBCDIC to ASCII */ |
| 144 | static inline void |
| 145 | sclp_ebcasc_str(unsigned char *str, int nr) |
| 146 | { |
| 147 | (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr); |
| 148 | } |
| 149 | |
| 150 | /* translate string from ASCII to EBCDIC */ |
| 151 | static inline void |
| 152 | sclp_ascebc_str(unsigned char *str, int nr) |
| 153 | { |
| 154 | (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr); |
| 155 | } |
| 156 | |
| 157 | #endif /* __SCLP_H__ */ |