Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** ----------------------------------------------------------------------------- |
| 3 | ** |
| 4 | ** Perle Specialix driver for Linux |
| 5 | ** Ported from existing RIO Driver for SCO sources. |
| 6 | * |
| 7 | * (C) 1990 - 1998 Specialix International Ltd., Byfleet, Surrey, UK. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | ** |
| 23 | ** Module : rio.h |
| 24 | ** SID : 1.3 |
| 25 | ** Last Modified : 11/6/98 11:34:13 |
| 26 | ** Retrieved : 11/6/98 11:34:22 |
| 27 | ** |
| 28 | ** ident @(#)rio.h 1.3 |
| 29 | ** |
| 30 | ** ----------------------------------------------------------------------------- |
| 31 | */ |
| 32 | |
| 33 | #ifndef __rio_rio_h__ |
| 34 | #define __rio_rio_h__ |
| 35 | |
| 36 | #ifdef SCCS_LABELS |
| 37 | static char *_rio_h_sccs_ = "@(#)rio.h 1.3"; |
| 38 | #endif |
| 39 | |
| 40 | /* |
| 41 | ** 30.09.1998 ARG - |
| 42 | ** Introduced driver version and host card type strings |
| 43 | */ |
| 44 | #define RIO_DRV_STR "Specialix RIO Driver" |
| 45 | #define RIO_AT_HOST_STR "ISA" |
| 46 | #define RIO_PCI_HOST_STR "PCI" |
| 47 | |
| 48 | |
| 49 | /* |
| 50 | ** rio_info_store() commands (arbitary values) : |
| 51 | */ |
| 52 | #define RIO_INFO_PUT 0xA4B3C2D1 |
| 53 | #define RIO_INFO_GET 0xF1E2D3C4 |
| 54 | |
| 55 | |
| 56 | /* |
| 57 | ** anything that I couldn't cram in somewhere else |
| 58 | */ |
| 59 | /* |
| 60 | #ifndef RIODEBUG |
| 61 | #define debug |
| 62 | #else |
| 63 | #define debug rioprint |
| 64 | #endif |
| 65 | */ |
| 66 | |
| 67 | |
| 68 | /* |
| 69 | ** Maximum numbers of things |
| 70 | */ |
| 71 | #define RIO_SLOTS 4 /* number of configuration slots */ |
| 72 | #define RIO_HOSTS 4 /* number of hosts that can be found */ |
| 73 | #define PORTS_PER_HOST 128 /* number of ports per host */ |
| 74 | #define LINKS_PER_UNIT 4 /* number of links from a host */ |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 75 | #define RIO_PORTS (PORTS_PER_HOST * RIO_HOSTS) /* max. no. of ports */ |
| 76 | #define RTAS_PER_HOST (MAX_RUP) /* number of RTAs per host */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #define PORTS_PER_RTA (PORTS_PER_HOST/RTAS_PER_HOST) /* ports on a rta */ |
| 78 | #define PORTS_PER_MODULE 4 /* number of ports on a plug-in module */ |
| 79 | /* number of modules on an RTA */ |
| 80 | #define MODULES_PER_RTA (PORTS_PER_RTA/PORTS_PER_MODULE) |
| 81 | #define MAX_PRODUCT 16 /* numbr of different product codes */ |
| 82 | #define MAX_MODULE_TYPES 16 /* number of different types of module */ |
| 83 | |
| 84 | #define RIO_CONTROL_DEV 128 /* minor number of host/control device */ |
| 85 | #define RIO_INVALID_MAJOR 0 /* test first host card's major no for validity */ |
| 86 | |
| 87 | /* |
| 88 | ** number of RTAs that can be bound to a master |
| 89 | */ |
| 90 | #define MAX_RTA_BINDINGS (MAX_RUP * RIO_HOSTS) |
| 91 | |
| 92 | /* |
| 93 | ** Unit types |
| 94 | */ |
| 95 | #define PC_RTA16 0x90000000 |
| 96 | #define PC_RTA8 0xe0000000 |
| 97 | #define TYPE_HOST 0 |
| 98 | #define TYPE_RTA8 1 |
| 99 | #define TYPE_RTA16 2 |
| 100 | |
| 101 | /* |
| 102 | ** Flag values returned by functions |
| 103 | */ |
| 104 | #define RIO_FAIL -1 |
| 105 | #define RIO_SUCCESS 0 |
| 106 | #define COPYFAIL -1 /* copy[in|out] failed */ |
| 107 | |
| 108 | /* |
| 109 | ** SysPort value for something that hasn't any ports |
| 110 | */ |
| 111 | #define NO_PORT 0xFFFFFFFF |
| 112 | |
| 113 | /* |
| 114 | ** Unit ID Of all hosts |
| 115 | */ |
| 116 | #define HOST_ID 0 |
| 117 | |
| 118 | /* |
| 119 | ** Break bytes into nybles |
| 120 | */ |
| 121 | #define LONYBLE(X) ((X) & 0xF) |
| 122 | #define HINYBLE(X) (((X)>>4) & 0xF) |
| 123 | |
| 124 | /* |
| 125 | ** Flag values passed into some functions |
| 126 | */ |
| 127 | #define DONT_SLEEP 0 |
| 128 | #define OK_TO_SLEEP 1 |
| 129 | |
| 130 | #define DONT_PRINT 1 |
| 131 | #define DO_PRINT 0 |
| 132 | |
| 133 | #define PRINT_TO_LOG_CONS 0 |
| 134 | #define PRINT_TO_CONS 1 |
| 135 | #define PRINT_TO_LOG 2 |
| 136 | |
| 137 | /* |
| 138 | ** Timeout has trouble with times of less than 3 ticks... |
| 139 | */ |
| 140 | #define MIN_TIMEOUT 3 |
| 141 | |
| 142 | /* |
| 143 | ** Generally useful constants |
| 144 | */ |
| 145 | #define HALF_A_SECOND ((HZ)>>1) |
| 146 | #define A_SECOND (HZ) |
| 147 | #define HUNDRED_HZ ((HZ/100)?(HZ/100):1) |
| 148 | #define FIFTY_HZ ((HZ/50)?(HZ/50):1) |
| 149 | #define TWENTY_HZ ((HZ/20)?(HZ/20):1) |
| 150 | #define TEN_HZ ((HZ/10)?(HZ/10):1) |
| 151 | #define FIVE_HZ ((HZ/5)?(HZ/5):1) |
| 152 | #define HUNDRED_MS TEN_HZ |
| 153 | #define FIFTY_MS TWENTY_HZ |
| 154 | #define TWENTY_MS FIFTY_HZ |
| 155 | #define TEN_MS HUNDRED_HZ |
| 156 | #define TWO_SECONDS ((A_SECOND)*2) |
| 157 | #define FIVE_SECONDS ((A_SECOND)*5) |
| 158 | #define TEN_SECONDS ((A_SECOND)*10) |
| 159 | #define FIFTEEN_SECONDS ((A_SECOND)*15) |
| 160 | #define TWENTY_SECONDS ((A_SECOND)*20) |
| 161 | #define HALF_A_MINUTE (A_MINUTE>>1) |
| 162 | #define A_MINUTE (A_SECOND*60) |
| 163 | #define FIVE_MINUTES (A_MINUTE*5) |
| 164 | #define QUARTER_HOUR (A_MINUTE*15) |
| 165 | #define HALF_HOUR (A_MINUTE*30) |
| 166 | #define HOUR (A_MINUTE*60) |
| 167 | |
| 168 | #define SIXTEEN_MEG 0x1000000 |
| 169 | #define ONE_MEG 0x100000 |
| 170 | #define SIXTY_FOUR_K 0x10000 |
| 171 | |
| 172 | #define RIO_AT_MEM_SIZE SIXTY_FOUR_K |
| 173 | #define RIO_EISA_MEM_SIZE SIXTY_FOUR_K |
| 174 | #define RIO_MCA_MEM_SIZE SIXTY_FOUR_K |
| 175 | |
| 176 | #define POLL_VECTOR 0x100 |
| 177 | |
| 178 | #define COOK_WELL 0 |
| 179 | #define COOK_MEDIUM 1 |
| 180 | #define COOK_RAW 2 |
| 181 | |
| 182 | /* |
| 183 | ** Pointer manipulation stuff |
| 184 | ** RIO_PTR takes hostp->Caddr and the offset into the DP RAM area |
| 185 | ** and produces a UNIX caddr_t (pointer) to the object |
| 186 | ** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and |
| 187 | ** returns the offset into the DP RAM area. |
| 188 | */ |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 189 | #define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O))) |
| 190 | #define RIO_OFF(C,O) ((long)(O)-(long)(C)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
| 192 | /* |
| 193 | ** How to convert from various different device number formats: |
| 194 | ** DEV is a dev number, as passed to open, close etc - NOT a minor |
| 195 | ** number! |
| 196 | ** |
| 197 | ** Note: LynxOS only gives us 8 bits for the device minor number, |
| 198 | ** so all this crap here to deal with 'modem' bits etc. is |
| 199 | ** just a load of irrelevant old bunkum! |
| 200 | ** This however does not stop us needing to define a value |
| 201 | ** for RIO_MODEMOFFSET which is required by the 'riomkdev' |
| 202 | ** utility in the New Config Utilities suite. |
| 203 | */ |
| 204 | /* 0-511: direct 512-1023: modem */ |
| 205 | #define RIO_MODEMOFFSET 0x200 /* doesn't mean anything */ |
| 206 | #define RIO_MODEM_MASK 0x1FF |
| 207 | #define RIO_MODEM_BIT 0x200 |
| 208 | #define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK) |
| 209 | #define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT) |
| 210 | #define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \ |
| 211 | + MINOR(DEV) |
| 212 | |
| 213 | #define splrio spltty |
| 214 | |
| 215 | #define RIO_IPL 5 |
| 216 | #define RIO_PRI (PZERO+10) |
| 217 | #define RIO_CLOSE_PRI PZERO-1 /* uninterruptible sleeps for close */ |
| 218 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 219 | typedef struct DbInf { |
| 220 | uint Flag; |
| 221 | char Name[8]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | } DbInf; |
| 223 | |
| 224 | #ifndef TRUE |
| 225 | #define TRUE (1==1) |
| 226 | #endif |
| 227 | #ifndef FALSE |
| 228 | #define FALSE (!TRUE) |
| 229 | #endif |
| 230 | |
| 231 | #define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \ |
| 232 | ((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \ |
| 233 | ((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \ |
| 234 | ((ushort *)(pkt_ptr))[6] + ((ushort *)(pkt_ptr))[7] + \ |
| 235 | ((ushort *)(pkt_ptr))[8] + ((ushort *)(pkt_ptr))[9] ) |
| 236 | |
| 237 | /* |
| 238 | ** This happy little macro copies SIZE bytes of data from FROM to TO |
| 239 | ** quite well. SIZE must be a constant. |
| 240 | */ |
| 241 | #define CCOPY( FROM, TO, SIZE ) { *(struct s { char data[SIZE]; } *)(TO) = *(struct s *)(FROM); } |
| 242 | |
| 243 | /* |
| 244 | ** increment a buffer pointer modulo the size of the buffer... |
| 245 | */ |
| 246 | #define BUMP( P, I ) ((P) = (((P)+(I)) & RIOBufferMask)) |
| 247 | |
| 248 | #define INIT_PACKET( PK, PP ) \ |
| 249 | { \ |
| 250 | *((uint *)PK) = PP->PacketInfo; \ |
| 251 | } |
| 252 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 253 | #define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | /* prevent a really stupid race condition. */ |
| 255 | |
| 256 | #define NOT_INITIALISED 0 |
| 257 | #define INITIALISED 1 |
| 258 | |
| 259 | #define NOT_POLLING 0 |
| 260 | #define POLLING 1 |
| 261 | |
| 262 | #define NOT_CHANGED 0 |
| 263 | #define CHANGED 1 |
| 264 | |
| 265 | #define NOT_INUSE 0 |
| 266 | |
| 267 | #define DISCONNECT 0 |
| 268 | #define CONNECT 1 |
| 269 | |
| 270 | |
| 271 | /* |
| 272 | ** Machine types - these must NOT overlap with product codes 0-15 |
| 273 | */ |
| 274 | #define RIO_MIPS_R3230 31 |
| 275 | #define RIO_MIPS_R4030 32 |
| 276 | |
| 277 | #define RIO_IO_UNKNOWN -2 |
| 278 | |
| 279 | #undef MODERN |
| 280 | #define ERROR( E ) do { u.u_error = E; return OPENFAIL } while ( 0 ) |
| 281 | |
| 282 | /* Defines for MPX line discipline routines */ |
| 283 | |
| 284 | #define DIST_LINESW_OPEN 0x01 |
| 285 | #define DIST_LINESW_CLOSE 0x02 |
| 286 | #define DIST_LINESW_READ 0x04 |
| 287 | #define DIST_LINESW_WRITE 0x08 |
| 288 | #define DIST_LINESW_IOCTL 0x10 |
| 289 | #define DIST_LINESW_INPUT 0x20 |
| 290 | #define DIST_LINESW_OUTPUT 0x40 |
| 291 | #define DIST_LINESW_MDMINT 0x80 |
| 292 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 293 | #endif /* __rio_h__ */ |