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 */ 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 */ 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 */ 189 #define RIO_PTR(C,O) (((caddr_t)(C))+(0xFFFF&(O))) 190 #define RIO_OFF(C,O) ((int)(O)-(int)(C)) 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 219 typedef struct DbInf 220 { 221 uint Flag; 222 char Name[8]; 223 } DbInf; 224 225 #ifndef TRUE 226 #define TRUE (1==1) 227 #endif 228 #ifndef FALSE 229 #define FALSE (!TRUE) 230 #endif 231 232 #define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \ 233 ((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \ 234 ((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \ 235 ((ushort *)(pkt_ptr))[6] + ((ushort *)(pkt_ptr))[7] + \ 236 ((ushort *)(pkt_ptr))[8] + ((ushort *)(pkt_ptr))[9] ) 237 238 /* 239 ** This happy little macro copies SIZE bytes of data from FROM to TO 240 ** quite well. SIZE must be a constant. 241 */ 242 #define CCOPY( FROM, TO, SIZE ) { *(struct s { char data[SIZE]; } *)(TO) = *(struct s *)(FROM); } 243 244 /* 245 ** increment a buffer pointer modulo the size of the buffer... 246 */ 247 #define BUMP( P, I ) ((P) = (((P)+(I)) & RIOBufferMask)) 248 249 #define INIT_PACKET( PK, PP ) \ 250 { \ 251 *((uint *)PK) = PP->PacketInfo; \ 252 } 253 254 #define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */ 255 /* prevent a really stupid race condition. */ 256 257 #define NOT_INITIALISED 0 258 #define INITIALISED 1 259 260 #define NOT_POLLING 0 261 #define POLLING 1 262 263 #define NOT_CHANGED 0 264 #define CHANGED 1 265 266 #define NOT_INUSE 0 267 268 #define DISCONNECT 0 269 #define CONNECT 1 270 271 272 /* 273 ** Machine types - these must NOT overlap with product codes 0-15 274 */ 275 #define RIO_MIPS_R3230 31 276 #define RIO_MIPS_R4030 32 277 278 #define RIO_IO_UNKNOWN -2 279 280 #undef MODERN 281 #define ERROR( E ) do { u.u_error = E; return OPENFAIL } while ( 0 ) 282 283 /* Defines for MPX line discipline routines */ 284 285 #define DIST_LINESW_OPEN 0x01 286 #define DIST_LINESW_CLOSE 0x02 287 #define DIST_LINESW_READ 0x04 288 #define DIST_LINESW_WRITE 0x08 289 #define DIST_LINESW_IOCTL 0x10 290 #define DIST_LINESW_INPUT 0x20 291 #define DIST_LINESW_OUTPUT 0x40 292 #define DIST_LINESW_MDMINT 0x80 293 294 #endif /* __rio_h__ */ 295