Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

isapnp.h 7.7KB

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