rio.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. #ifndef __rio_rio_h__
  33. #define __rio_rio_h__
  34. /*
  35. ** Maximum numbers of things
  36. */
  37. #define RIO_SLOTS 4 /* number of configuration slots */
  38. #define RIO_HOSTS 4 /* number of hosts that can be found */
  39. #define PORTS_PER_HOST 128 /* number of ports per host */
  40. #define LINKS_PER_UNIT 4 /* number of links from a host */
  41. #define RIO_PORTS (PORTS_PER_HOST * RIO_HOSTS) /* max. no. of ports */
  42. #define RTAS_PER_HOST (MAX_RUP) /* number of RTAs per host */
  43. #define PORTS_PER_RTA (PORTS_PER_HOST/RTAS_PER_HOST) /* ports on a rta */
  44. #define PORTS_PER_MODULE 4 /* number of ports on a plug-in module */
  45. /* number of modules on an RTA */
  46. #define MODULES_PER_RTA (PORTS_PER_RTA/PORTS_PER_MODULE)
  47. #define MAX_PRODUCT 16 /* numbr of different product codes */
  48. #define MAX_MODULE_TYPES 16 /* number of different types of module */
  49. #define RIO_CONTROL_DEV 128 /* minor number of host/control device */
  50. #define RIO_INVALID_MAJOR 0 /* test first host card's major no for validity */
  51. /*
  52. ** number of RTAs that can be bound to a master
  53. */
  54. #define MAX_RTA_BINDINGS (MAX_RUP * RIO_HOSTS)
  55. /*
  56. ** Unit types
  57. */
  58. #define PC_RTA16 0x90000000
  59. #define PC_RTA8 0xe0000000
  60. #define TYPE_HOST 0
  61. #define TYPE_RTA8 1
  62. #define TYPE_RTA16 2
  63. /*
  64. ** Flag values returned by functions
  65. */
  66. #define RIO_FAIL -1
  67. /*
  68. ** SysPort value for something that hasn't any ports
  69. */
  70. #define NO_PORT 0xFFFFFFFF
  71. /*
  72. ** Unit ID Of all hosts
  73. */
  74. #define HOST_ID 0
  75. /*
  76. ** Break bytes into nybles
  77. */
  78. #define LONYBLE(X) ((X) & 0xF)
  79. #define HINYBLE(X) (((X)>>4) & 0xF)
  80. /*
  81. ** Flag values passed into some functions
  82. */
  83. #define DONT_SLEEP 0
  84. #define OK_TO_SLEEP 1
  85. #define DONT_PRINT 1
  86. #define DO_PRINT 0
  87. #define PRINT_TO_LOG_CONS 0
  88. #define PRINT_TO_CONS 1
  89. #define PRINT_TO_LOG 2
  90. /*
  91. ** Timeout has trouble with times of less than 3 ticks...
  92. */
  93. #define MIN_TIMEOUT 3
  94. /*
  95. ** Generally useful constants
  96. */
  97. #define HUNDRED_MS ((HZ/10)?(HZ/10):1)
  98. #define ONE_MEG 0x100000
  99. #define SIXTY_FOUR_K 0x10000
  100. #define RIO_AT_MEM_SIZE SIXTY_FOUR_K
  101. #define RIO_EISA_MEM_SIZE SIXTY_FOUR_K
  102. #define RIO_MCA_MEM_SIZE SIXTY_FOUR_K
  103. #define COOK_WELL 0
  104. #define COOK_MEDIUM 1
  105. #define COOK_RAW 2
  106. /*
  107. ** Pointer manipulation stuff
  108. ** RIO_PTR takes hostp->Caddr and the offset into the DP RAM area
  109. ** and produces a UNIX caddr_t (pointer) to the object
  110. ** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
  111. ** returns the offset into the DP RAM area.
  112. */
  113. #define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O)))
  114. #define RIO_OFF(C,O) ((long)(O)-(long)(C))
  115. /*
  116. ** How to convert from various different device number formats:
  117. ** DEV is a dev number, as passed to open, close etc - NOT a minor
  118. ** number!
  119. **/
  120. #define RIO_MODEM_MASK 0x1FF
  121. #define RIO_MODEM_BIT 0x200
  122. #define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK)
  123. #define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT)
  124. #define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
  125. + MINOR(DEV)
  126. #define CSUM(pkt_ptr) (((u16 *)(pkt_ptr))[0] + ((u16 *)(pkt_ptr))[1] + \
  127. ((u16 *)(pkt_ptr))[2] + ((u16 *)(pkt_ptr))[3] + \
  128. ((u16 *)(pkt_ptr))[4] + ((u16 *)(pkt_ptr))[5] + \
  129. ((u16 *)(pkt_ptr))[6] + ((u16 *)(pkt_ptr))[7] + \
  130. ((u16 *)(pkt_ptr))[8] + ((u16 *)(pkt_ptr))[9] )
  131. #define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */
  132. /* prevent a really stupid race condition. */
  133. #define NOT_INITIALISED 0
  134. #define INITIALISED 1
  135. #define NOT_POLLING 0
  136. #define POLLING 1
  137. #define NOT_CHANGED 0
  138. #define CHANGED 1
  139. #define NOT_INUSE 0
  140. #define DISCONNECT 0
  141. #define CONNECT 1
  142. /* ------ Control Codes ------ */
  143. #define CONTROL '^'
  144. #define IFOAD ( CONTROL + 1 )
  145. #define IDENTIFY ( CONTROL + 2 )
  146. #define ZOMBIE ( CONTROL + 3 )
  147. #define UFOAD ( CONTROL + 4 )
  148. #define IWAIT ( CONTROL + 5 )
  149. #define IFOAD_MAGIC 0xF0AD /* of course */
  150. #define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
  151. #define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
  152. #define IWAIT_MAGIC 0xB1DE /* Bide your time */
  153. /* ------ Error Codes ------ */
  154. #define E_NO_ERROR ((ushort) 0)
  155. /* ------ Free Lists ------ */
  156. struct rio_free_list {
  157. u16 next;
  158. u16 prev;
  159. };
  160. /* NULL for card side linked lists */
  161. #define TPNULL ((ushort)(0x8000))
  162. /* We can add another packet to a transmit queue if the packet pointer pointed
  163. * to by the TxAdd pointer has PKT_IN_USE clear in its address. */
  164. #define PKT_IN_USE 0x1
  165. /* ------ Topology ------ */
  166. struct Top {
  167. u8 Unit;
  168. u8 Link;
  169. };
  170. #endif /* __rio_h__ */