Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

isapnp.h 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /**************************************************************************
  2. *
  3. * isapnp.h -- Etherboot isapnp support for the 3Com 3c515
  4. * Written 2002-2003 by Timothy Legge <tlegge@rogers.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * Portions of this code:
  21. * Copyright (C) 2001 P.J.H.Fox (fox@roestock.demon.co.uk)
  22. *
  23. *
  24. *
  25. * REVISION HISTORY:
  26. * ================
  27. * Version 0.1 April 26, 2002 TJL
  28. * Version 0.2 01/08/2003 TJL Renamed from 3c515_isapnp.h
  29. *
  30. *
  31. * Generalised into an ISAPnP bus that can be used by more than just
  32. * the 3c515 by Michael Brown <mbrown@fensystems.co.uk>
  33. *
  34. ***************************************************************************/
  35. #ifndef ISAPNP_H
  36. #define ISAPNP_H
  37. #include <stdint.h>
  38. #include <gpxe/isa_ids.h>
  39. #include <gpxe/device.h>
  40. #include <gpxe/tables.h>
  41. /*
  42. * ISAPnP constants
  43. *
  44. */
  45. /* Port addresses */
  46. #define ISAPNP_ADDRESS 0x279
  47. #define ISAPNP_WRITE_DATA 0xa79
  48. #define ISAPNP_READ_PORT_MIN 0x203
  49. #define ISAPNP_READ_PORT_START 0x213 /* ISAPnP spec says 0x203, but
  50. * Linux ISAPnP starts at
  51. * 0x213 with no explanatory
  52. * comment. 0x203 probably
  53. * clashes with something. */
  54. #define ISAPNP_READ_PORT_MAX 0x3ff
  55. #define ISAPNP_READ_PORT_STEP 0x10 /* Can be any multiple of 4
  56. * according to the spec, but
  57. * since ISA I/O addresses are
  58. * allocated in blocks of 16,
  59. * it makes no sense to use
  60. * any value less than 16.
  61. */
  62. /* Card select numbers */
  63. #define ISAPNP_CSN_MIN 0x01
  64. #define ISAPNP_CSN_MAX 0x0f
  65. /* Registers */
  66. #define ISAPNP_READPORT 0x00
  67. #define ISAPNP_SERIALISOLATION 0x01
  68. #define ISAPNP_CONFIGCONTROL 0x02
  69. #define ISAPNP_WAKE 0x03
  70. #define ISAPNP_RESOURCEDATA 0x04
  71. #define ISAPNP_STATUS 0x05
  72. #define ISAPNP_CARDSELECTNUMBER 0x06
  73. #define ISAPNP_LOGICALDEVICENUMBER 0x07
  74. #define ISAPNP_ACTIVATE 0x30
  75. #define ISAPNP_IORANGECHECK 0x31
  76. #define ISAPNP_IOBASE(n) ( 0x60 + ( (n) * 2 ) )
  77. #define ISAPNP_IRQNO(n) ( 0x70 + ( (n) * 2 ) )
  78. #define ISAPNP_IRQTYPE(n) ( 0x71 + ( (n) * 2 ) )
  79. /* Bits in the CONFIGCONTROL register */
  80. #define ISAPNP_CONFIG_RESET ( 1 << 0 )
  81. #define ISAPNP_CONFIG_WAIT_FOR_KEY ( 1 << 1 )
  82. #define ISAPNP_CONFIG_RESET_CSN ( 1 << 2 )
  83. #define ISAPNP_CONFIG_RESET_DRV ( ISAPNP_CONFIG_RESET | \
  84. ISAPNP_CONFIG_WAIT_FOR_KEY | \
  85. ISAPNP_CONFIG_RESET_CSN )
  86. /* The LFSR used for the initiation key and for checksumming */
  87. #define ISAPNP_LFSR_SEED 0x6a
  88. /* Small tags */
  89. #define ISAPNP_IS_SMALL_TAG(tag) ( ! ( (tag) & 0x80 ) )
  90. #define ISAPNP_SMALL_TAG_NAME(tag) ( ( (tag) >> 3 ) & 0xf )
  91. #define ISAPNP_SMALL_TAG_LEN(tag) ( ( (tag) & 0x7 ) )
  92. #define ISAPNP_TAG_PNPVERNO 0x01
  93. #define ISAPNP_TAG_LOGDEVID 0x02
  94. #define ISAPNP_TAG_COMPATDEVID 0x03
  95. #define ISAPNP_TAG_IRQ 0x04
  96. #define ISAPNP_TAG_DMA 0x05
  97. #define ISAPNP_TAG_STARTDEP 0x06
  98. #define ISAPNP_TAG_ENDDEP 0x07
  99. #define ISAPNP_TAG_IOPORT 0x08
  100. #define ISAPNP_TAG_FIXEDIO 0x09
  101. #define ISAPNP_TAG_RSVDSHORTA 0x0A
  102. #define ISAPNP_TAG_RSVDSHORTB 0x0B
  103. #define ISAPNP_TAG_RSVDSHORTC 0x0C
  104. #define ISAPNP_TAG_RSVDSHORTD 0x0D
  105. #define ISAPNP_TAG_VENDORSHORT 0x0E
  106. #define ISAPNP_TAG_END 0x0F
  107. /* Large tags */
  108. #define ISAPNP_IS_LARGE_TAG(tag) ( ( (tag) & 0x80 ) )
  109. #define ISAPNP_LARGE_TAG_NAME(tag) (tag)
  110. #define ISAPNP_TAG_MEMRANGE 0x81
  111. #define ISAPNP_TAG_ANSISTR 0x82
  112. #define ISAPNP_TAG_UNICODESTR 0x83
  113. #define ISAPNP_TAG_VENDORLONG 0x84
  114. #define ISAPNP_TAG_MEM32RANGE 0x85
  115. #define ISAPNP_TAG_FIXEDMEM32RANGE 0x86
  116. #define ISAPNP_TAG_RSVDLONG0 0xF0
  117. #define ISAPNP_TAG_RSVDLONG1 0xF1
  118. #define ISAPNP_TAG_RSVDLONG2 0xF2
  119. #define ISAPNP_TAG_RSVDLONG3 0xF3
  120. #define ISAPNP_TAG_RSVDLONG4 0xF4
  121. #define ISAPNP_TAG_RSVDLONG5 0xF5
  122. #define ISAPNP_TAG_RSVDLONG6 0xF6
  123. #define ISAPNP_TAG_RSVDLONG7 0xF7
  124. #define ISAPNP_TAG_RSVDLONG8 0xF8
  125. #define ISAPNP_TAG_RSVDLONG9 0xF9
  126. #define ISAPNP_TAG_RSVDLONGA 0xFA
  127. #define ISAPNP_TAG_RSVDLONGB 0xFB
  128. #define ISAPNP_TAG_RSVDLONGC 0xFC
  129. #define ISAPNP_TAG_RSVDLONGD 0xFD
  130. #define ISAPNP_TAG_RSVDLONGE 0xFE
  131. #define ISAPNP_TAG_RSVDLONGF 0xFF
  132. #define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100
  133. /** An ISAPnP serial identifier */
  134. struct isapnp_identifier {
  135. /** Vendor ID */
  136. uint16_t vendor_id;
  137. /** Product ID */
  138. uint16_t prod_id;
  139. /** Serial number */
  140. uint32_t serial;
  141. /** Checksum */
  142. uint8_t checksum;
  143. } __attribute__ (( packed ));
  144. /** An ISAPnP logical device ID structure */
  145. struct isapnp_logdevid {
  146. /** Vendor ID */
  147. uint16_t vendor_id;
  148. /** Product ID */
  149. uint16_t prod_id;
  150. /** Flags */
  151. uint16_t flags;
  152. } __attribute__ (( packed ));
  153. /** An ISAPnP device ID list entry */
  154. struct isapnp_device_id {
  155. /** Name */
  156. const char *name;
  157. /** Vendor ID */
  158. uint16_t vendor_id;
  159. /** Product ID */
  160. uint16_t prod_id;
  161. };
  162. /** An ISAPnP device */
  163. struct isapnp_device {
  164. /** Generic device */
  165. struct device dev;
  166. /** Vendor ID */
  167. uint16_t vendor_id;
  168. /** Product ID */
  169. uint16_t prod_id;
  170. /** I/O address */
  171. uint16_t ioaddr;
  172. /** Interrupt number */
  173. uint8_t irqno;
  174. /** Card Select Number */
  175. uint8_t csn;
  176. /** Logical Device ID */
  177. uint8_t logdev;
  178. /** Driver for this device */
  179. struct isapnp_driver *driver;
  180. /** Driver-private data
  181. *
  182. * Use isapnp_set_drvdata() and isapnp_get_drvdata() to access
  183. * this field.
  184. */
  185. void *priv;
  186. /** Driver name */
  187. const char *driver_name;
  188. };
  189. /** An ISAPnP driver */
  190. struct isapnp_driver {
  191. /** ISAPnP ID table */
  192. struct isapnp_device_id *ids;
  193. /** Number of entries in ISAPnP ID table */
  194. unsigned int id_count;
  195. /**
  196. * Probe device
  197. *
  198. * @v isapnp ISAPnP device
  199. * @v id Matching entry in ID table
  200. * @ret rc Return status code
  201. */
  202. int ( * probe ) ( struct isapnp_device *isapnp,
  203. const struct isapnp_device_id *id );
  204. /**
  205. * Remove device
  206. *
  207. * @v isapnp ISAPnP device
  208. */
  209. void ( * remove ) ( struct isapnp_device *isapnp );
  210. };
  211. /** Declare an ISAPnP driver */
  212. #define __isapnp_driver __table ( struct isapnp_driver, isapnp_drivers, 01 )
  213. extern uint16_t isapnp_read_port;
  214. extern void isapnp_device_activation ( struct isapnp_device *isapnp,
  215. int activation );
  216. /**
  217. * Activate ISAPnP device
  218. *
  219. * @v isapnp ISAPnP device
  220. */
  221. static inline void activate_isapnp_device ( struct isapnp_device *isapnp ) {
  222. isapnp_device_activation ( isapnp, 1 );
  223. }
  224. /**
  225. * Deactivate ISAPnP device
  226. *
  227. * @v isapnp ISAPnP device
  228. */
  229. static inline void deactivate_isapnp_device ( struct isapnp_device *isapnp ) {
  230. isapnp_device_activation ( isapnp, 0 );
  231. }
  232. /**
  233. * Set ISAPnP driver-private data
  234. *
  235. * @v isapnp ISAPnP device
  236. * @v priv Private data
  237. */
  238. static inline void isapnp_set_drvdata ( struct isapnp_device *isapnp,
  239. void *priv ) {
  240. isapnp->priv = priv;
  241. }
  242. /**
  243. * Get ISAPnP driver-private data
  244. *
  245. * @v isapnp ISAPnP device
  246. * @ret priv Private data
  247. */
  248. static inline void * isapnp_get_drvdata ( struct isapnp_device *isapnp ) {
  249. return isapnp->priv;
  250. }
  251. #endif /* ISAPNP_H */