iPXE
isapnp.h
Go to the documentation of this file.
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 
41 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
42 
43 #ifndef ISAPNP_H
44 #define ISAPNP_H
45 
46 #include <stdint.h>
47 #include <ipxe/isa_ids.h>
48 #include <ipxe/device.h>
49 #include <ipxe/tables.h>
50 
51 /*
52  * ISAPnP constants
53  *
54  */
55 
56 /* Port addresses */
57 #define ISAPNP_ADDRESS 0x279
58 #define ISAPNP_WRITE_DATA 0xa79
59 #define ISAPNP_READ_PORT_MIN 0x203
60 #define ISAPNP_READ_PORT_START 0x213 /* ISAPnP spec says 0x203, but
61  * Linux ISAPnP starts at
62  * 0x213 with no explanatory
63  * comment. 0x203 probably
64  * clashes with something. */
65 #define ISAPNP_READ_PORT_MAX 0x3ff
66 #define ISAPNP_READ_PORT_STEP 0x10 /* Can be any multiple of 4
67  * according to the spec, but
68  * since ISA I/O addresses are
69  * allocated in blocks of 16,
70  * it makes no sense to use
71  * any value less than 16.
72  */
73 
74 /* Card select numbers */
75 #define ISAPNP_CSN_MIN 0x01
76 #define ISAPNP_CSN_MAX 0x0f
77 
78 /* Registers */
79 #define ISAPNP_READPORT 0x00
80 #define ISAPNP_SERIALISOLATION 0x01
81 #define ISAPNP_CONFIGCONTROL 0x02
82 #define ISAPNP_WAKE 0x03
83 #define ISAPNP_RESOURCEDATA 0x04
84 #define ISAPNP_STATUS 0x05
85 #define ISAPNP_CARDSELECTNUMBER 0x06
86 #define ISAPNP_LOGICALDEVICENUMBER 0x07
87 #define ISAPNP_ACTIVATE 0x30
88 #define ISAPNP_IORANGECHECK 0x31
89 #define ISAPNP_IOBASE(n) ( 0x60 + ( (n) * 2 ) )
90 #define ISAPNP_IRQNO(n) ( 0x70 + ( (n) * 2 ) )
91 #define ISAPNP_IRQTYPE(n) ( 0x71 + ( (n) * 2 ) )
92 
93 /* Bits in the CONFIGCONTROL register */
94 #define ISAPNP_CONFIG_RESET ( 1 << 0 )
95 #define ISAPNP_CONFIG_WAIT_FOR_KEY ( 1 << 1 )
96 #define ISAPNP_CONFIG_RESET_CSN ( 1 << 2 )
97 #define ISAPNP_CONFIG_RESET_DRV ( ISAPNP_CONFIG_RESET | \
98  ISAPNP_CONFIG_WAIT_FOR_KEY | \
99  ISAPNP_CONFIG_RESET_CSN )
100 
101 /* The LFSR used for the initiation key and for checksumming */
102 #define ISAPNP_LFSR_SEED 0x6a
103 
104 /* Small tags */
105 #define ISAPNP_IS_SMALL_TAG(tag) ( ! ( (tag) & 0x80 ) )
106 #define ISAPNP_SMALL_TAG_NAME(tag) ( ( (tag) >> 3 ) & 0xf )
107 #define ISAPNP_SMALL_TAG_LEN(tag) ( ( (tag) & 0x7 ) )
108 #define ISAPNP_TAG_PNPVERNO 0x01
109 #define ISAPNP_TAG_LOGDEVID 0x02
110 #define ISAPNP_TAG_COMPATDEVID 0x03
111 #define ISAPNP_TAG_IRQ 0x04
112 #define ISAPNP_TAG_DMA 0x05
113 #define ISAPNP_TAG_STARTDEP 0x06
114 #define ISAPNP_TAG_ENDDEP 0x07
115 #define ISAPNP_TAG_IOPORT 0x08
116 #define ISAPNP_TAG_FIXEDIO 0x09
117 #define ISAPNP_TAG_RSVDSHORTA 0x0A
118 #define ISAPNP_TAG_RSVDSHORTB 0x0B
119 #define ISAPNP_TAG_RSVDSHORTC 0x0C
120 #define ISAPNP_TAG_RSVDSHORTD 0x0D
121 #define ISAPNP_TAG_VENDORSHORT 0x0E
122 #define ISAPNP_TAG_END 0x0F
123 /* Large tags */
124 #define ISAPNP_IS_LARGE_TAG(tag) ( ( (tag) & 0x80 ) )
125 #define ISAPNP_LARGE_TAG_NAME(tag) (tag)
126 #define ISAPNP_TAG_MEMRANGE 0x81
127 #define ISAPNP_TAG_ANSISTR 0x82
128 #define ISAPNP_TAG_UNICODESTR 0x83
129 #define ISAPNP_TAG_VENDORLONG 0x84
130 #define ISAPNP_TAG_MEM32RANGE 0x85
131 #define ISAPNP_TAG_FIXEDMEM32RANGE 0x86
132 #define ISAPNP_TAG_RSVDLONG0 0xF0
133 #define ISAPNP_TAG_RSVDLONG1 0xF1
134 #define ISAPNP_TAG_RSVDLONG2 0xF2
135 #define ISAPNP_TAG_RSVDLONG3 0xF3
136 #define ISAPNP_TAG_RSVDLONG4 0xF4
137 #define ISAPNP_TAG_RSVDLONG5 0xF5
138 #define ISAPNP_TAG_RSVDLONG6 0xF6
139 #define ISAPNP_TAG_RSVDLONG7 0xF7
140 #define ISAPNP_TAG_RSVDLONG8 0xF8
141 #define ISAPNP_TAG_RSVDLONG9 0xF9
142 #define ISAPNP_TAG_RSVDLONGA 0xFA
143 #define ISAPNP_TAG_RSVDLONGB 0xFB
144 #define ISAPNP_TAG_RSVDLONGC 0xFC
145 #define ISAPNP_TAG_RSVDLONGD 0xFD
146 #define ISAPNP_TAG_RSVDLONGE 0xFE
147 #define ISAPNP_TAG_RSVDLONGF 0xFF
148 #define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100
149 
150 /** An ISAPnP serial identifier */
152  /** Vendor ID */
154  /** Product ID */
156  /** Serial number */
158  /** Checksum */
160 } __attribute__ (( packed ));
161 
162 /** An ISAPnP logical device ID structure */
164  /** Vendor ID */
166  /** Product ID */
168  /** Flags */
170 } __attribute__ (( packed ));
171 
172 /** An ISAPnP device ID list entry */
174  /** Name */
175  const char *name;
176  /** Vendor ID */
178  /** Product ID */
180 };
181 
182 /** An ISAPnP device */
184  /** Generic device */
185  struct device dev;
186  /** Vendor ID */
188  /** Product ID */
190  /** I/O address */
192  /** Interrupt number */
194  /** Card Select Number */
196  /** Logical Device ID */
198  /** Driver for this device */
200  /** Driver-private data
201  *
202  * Use isapnp_set_drvdata() and isapnp_get_drvdata() to access
203  * this field.
204  */
205  void *priv;
206 };
207 
208 /** An ISAPnP driver */
210  /** ISAPnP ID table */
212  /** Number of entries in ISAPnP ID table */
213  unsigned int id_count;
214  /**
215  * Probe device
216  *
217  * @v isapnp ISAPnP device
218  * @v id Matching entry in ID table
219  * @ret rc Return status code
220  */
221  int ( * probe ) ( struct isapnp_device *isapnp,
222  const struct isapnp_device_id *id );
223  /**
224  * Remove device
225  *
226  * @v isapnp ISAPnP device
227  */
228  void ( * remove ) ( struct isapnp_device *isapnp );
229 };
230 
231 /** ISAPnP driver table */
232 #define ISAPNP_DRIVERS __table ( struct isapnp_driver, "isapnp_drivers" )
233 
234 /** Declare an ISAPnP driver */
235 #define __isapnp_driver __table_entry ( ISAPNP_DRIVERS, 01 )
236 
238 
239 extern void isapnp_device_activation ( struct isapnp_device *isapnp,
240  int activation );
241 
242 /**
243  * Activate ISAPnP device
244  *
245  * @v isapnp ISAPnP device
246  */
247 static inline void activate_isapnp_device ( struct isapnp_device *isapnp ) {
248  isapnp_device_activation ( isapnp, 1 );
249 }
250 
251 /**
252  * Deactivate ISAPnP device
253  *
254  * @v isapnp ISAPnP device
255  */
256 static inline void deactivate_isapnp_device ( struct isapnp_device *isapnp ) {
257  isapnp_device_activation ( isapnp, 0 );
258 }
259 
260 /**
261  * Set ISAPnP driver-private data
262  *
263  * @v isapnp ISAPnP device
264  * @v priv Private data
265  */
266 static inline void isapnp_set_drvdata ( struct isapnp_device *isapnp,
267  void *priv ) {
268  isapnp->priv = priv;
269 }
270 
271 /**
272  * Get ISAPnP driver-private data
273  *
274  * @v isapnp ISAPnP device
275  * @ret priv Private data
276  */
277 static inline void * isapnp_get_drvdata ( struct isapnp_device *isapnp ) {
278  return isapnp->priv;
279 }
280 
281 #endif /* ISAPNP_H */
#define __attribute__(x)
Definition: compiler.h:10
struct device dev
Generic device.
Definition: isapnp.h:185
int(* probe)(struct isapnp_device *isapnp, const struct isapnp_device_id *id)
Probe device.
Definition: isapnp.h:221
unsigned short uint16_t
Definition: stdint.h:11
unsigned int id_count
Number of entries in ISAPnP ID table.
Definition: isapnp.h:213
static void deactivate_isapnp_device(struct isapnp_device *isapnp)
Deactivate ISAPnP device.
Definition: isapnp.h:256
const char * name
Name.
Definition: isapnp.h:175
An ISAPnP driver.
Definition: isapnp.h:209
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:187
An ISAPnP device ID list entry.
Definition: isapnp.h:173
uint16_t prod_id
Product ID.
Definition: isapnp.h:155
void(* remove)(struct isapnp_device *isapnp)
Remove device.
Definition: isapnp.h:228
uint16_t prod_id
Product ID.
Definition: isapnp.h:167
An ISAPnP logical device ID structure.
Definition: isapnp.h:163
uint16_t ioaddr
I/O address.
Definition: isapnp.h:191
struct isapnp_device_id * ids
ISAPnP ID table.
Definition: isapnp.h:211
A hardware device.
Definition: device.h:73
uint16_t prod_id
Product ID.
Definition: isapnp.h:189
uint16_t prod_id
Product ID.
Definition: isapnp.h:179
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:153
void * priv
Driver-private data.
Definition: isapnp.h:205
uint32_t serial
Serial number.
Definition: isapnp.h:157
struct isapnp_driver * driver
Driver for this device.
Definition: isapnp.h:199
static void * isapnp_get_drvdata(struct isapnp_device *isapnp)
Get ISAPnP driver-private data.
Definition: isapnp.h:277
static void isapnp_set_drvdata(struct isapnp_device *isapnp, void *priv)
Set ISAPnP driver-private data.
Definition: isapnp.h:266
An ISAPnP device.
Definition: isapnp.h:183
uint8_t id
Request identifier.
Definition: ena.h:12
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:177
unsigned char uint8_t
Definition: stdint.h:10
void isapnp_device_activation(struct isapnp_device *isapnp, int activation)
Activate or deactivate an ISAPnP device.
Definition: isapnp.c:554
unsigned int uint32_t
Definition: stdint.h:12
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t irqno
Interrupt number.
Definition: isapnp.h:193
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:165
static struct tlan_private * priv
Definition: tlan.c:224
uint16_t flags
Flags.
Definition: isapnp.h:169
static void activate_isapnp_device(struct isapnp_device *isapnp)
Activate ISAPnP device.
Definition: isapnp.h:247
An ISAPnP serial identifier.
Definition: isapnp.h:151
Linker tables.
Device model.
uint8_t csn
Card Select Number.
Definition: isapnp.h:195
uint8_t logdev
Logical Device ID.
Definition: isapnp.h:197
uint8_t checksum
Checksum.
Definition: isapnp.h:159
uint16_t isapnp_read_port
ISAPnP Read Port address.
Definition: isapnp.c:76