Parcourir la source

Updated to new device API.

tags/v0.9.3
Michael Brown il y a 19 ans
Parent
révision
72fe23a76e
3 fichiers modifiés avec 59 ajouts et 71 suppressions
  1. 47
    54
      src/drivers/net/3c509.c
  2. 2
    2
      src/drivers/net/3c529.c
  3. 10
    15
      src/drivers/net/pnic.c

+ 47
- 54
src/drivers/net/3c509.c Voir le fichier

@@ -6,7 +6,6 @@
6 6
 
7 7
 #include "eisa.h"
8 8
 #include "isa.h"
9
-#include "dev.h"
10 9
 #include "io.h"
11 10
 #include "timer.h"
12 11
 #include "string.h"
@@ -25,7 +24,6 @@
25 24
  */
26 25
 struct t509_device {
27 26
 	char *magic; /* must be first */
28
-	struct dev *dev;
29 27
 	uint16_t id_port;
30 28
 	uint16_t ioaddr;
31 29
 	unsigned char current_tag;
@@ -123,16 +121,11 @@ static inline int fill_t509_device ( struct t509_device *t509 ) {
123 121
 	uint16_t iobase;
124 122
 
125 123
 	/* 
126
-	 * If this is the start of the scan, find an id_port and clear
127
-	 * all tag registers.  Otherwise, tell already-found NICs not
128
-	 * to respond.
124
+	 * If this is the start of the scan, clear all tag registers.
125
+	 * Otherwise, tell already-found NICs not to respond.
129 126
 	 *
130 127
 	 */
131 128
 	if ( t509->current_tag == 0 ) {
132
-		if ( ! find_id_port ( t509 ) ) {
133
-			DBG ( "No ID port available for contention select\n" );
134
-			return 0;
135
-		}
136 129
 		outb ( 0xd0, t509->id_port );
137 130
 	} else {
138 131
 		outb ( 0xd8, t509->id_port ) ;
@@ -166,42 +159,48 @@ static inline int fill_t509_device ( struct t509_device *t509 ) {
166 159
 }
167 160
 
168 161
 /*
169
- * Obtain a struct t509_device * from a struct dev *
162
+ * Find a t509 device matching the specified driver.  ("Matching the
163
+ * specified driver" is, in this case, a no-op, but we want to
164
+ * preserve the common bus API).
165
+ *
166
+ * Called only once, so inlined for efficiency.
170 167
  *
171
- * If dev has not previously been used for a PCI device scan, blank
172
- * out struct t509_device
173 168
  */
174
-static struct t509_device * t509_device ( struct dev *dev ) {
175
-	struct t509_device *t509 = dev->bus;
169
+static inline int find_t509_device ( struct t509_device *t509,
170
+				     struct t509_driver *driver __unused ) {
176 171
 
172
+	/* Initialise struct t509 if it's the first time it's been used. */
177 173
 	if ( t509->magic != t509_magic ) {
178 174
 		memset ( t509, 0, sizeof ( *t509 ) );
179 175
 		t509->magic = t509_magic;
176
+		if ( ! find_id_port ( t509 ) ) {
177
+			DBG ( "No ID port available for contention select\n" );
178
+			return 0;
179
+		}
180 180
 	}
181
-	t509->dev = dev;
182
-	return t509;
181
+
182
+	/* Find the next t509 device */
183
+	if ( ! fill_t509_device ( t509 ) )
184
+		return 0;
185
+	
186
+	return 1;
183 187
 }
184 188
 
185 189
 /*
186
- * Find a t509 device matching the specified driver.  ("Matching the
187
- * specified driver" is, in this case, a no-op, but we want to
188
- * preserve the common bus API).
190
+ * Find the next T509 device that can be used to boot using the
191
+ * specified driver.
189 192
  *
190 193
  */
191
-static int find_t509_device ( struct t509_device *t509,
192
-				 struct t509_driver *driver ) {
193
-	/* Find the next t509 device */
194
-	if ( ! fill_t509_device ( t509 ) )
194
+int find_t509_boot_device ( struct dev *dev, struct t509_driver *driver ) {
195
+	struct t509_device *t509 = ( struct t509_device * )dev->bus;
196
+
197
+	if ( ! find_t509_device ( t509, driver ) )
195 198
 		return 0;
196
-	
197
-	/* Fill in dev structure, if present */
198
-	if ( t509->dev ) {
199
-		t509->dev->name = driver->name;
200
-		t509->dev->devid.bus_type = ISA_BUS_TYPE;
201
-		t509->dev->devid.vendor_id = MFG_ID;
202
-		t509->dev->devid.device_id = PROD_ID;
203
-	}
204 199
 
200
+	dev->name = driver->name;
201
+	dev->devid.bus_type = ISA_BUS_TYPE;
202
+	dev->devid.vendor_id = MFG_ID;
203
+	dev->devid.device_id = PROD_ID;
205 204
 	return 1;
206 205
 }
207 206
 
@@ -209,42 +208,28 @@ static int find_t509_device ( struct t509_device *t509,
209 208
  * The ISA probe function
210 209
  *
211 210
  */
212
-static struct t509_driver el3_t509_driver = { "3c509 (ISA)" };
213
-
214
-static int el3_t509_probe ( struct dev *dev ) {
211
+static int el3_t509_probe ( struct dev *dev, struct t509_device *t509 ) {
215 212
 	struct nic *nic = nic_device ( dev );
216
-	struct t509_device *t509 = t509_device ( dev );
217
-	
218
-	if ( ! find_t509_device ( t509, &el3_t509_driver ) )
219
-		return 0;
220 213
 	
221 214
 	nic->ioaddr = t509->ioaddr;
222 215
 	nic->irqno = 0;
223
-	printf ( "3C5x9 board on ISA at %#hx - ", nic->ioaddr );
216
+	printf ( "3c509 board on ISA at %#hx - ", nic->ioaddr );
224 217
 
225 218
 	/* Hand off to generic t5x9 probe routine */
226 219
 	return t5x9_probe ( nic, ISA_PROD_ID ( PROD_ID ), ISA_PROD_ID_MASK );
227 220
 }
228 221
 
229
-BOOT_DRIVER ( "3c509", el3_t509_probe );
222
+static struct t509_driver el3_t509_driver = { "3c509 (ISA)" };
223
+
224
+BOOT_DRIVER ( "3c509", find_t509_boot_device, el3_t509_driver,
225
+	      el3_t509_probe );
230 226
 
231 227
 /*
232
- * The 3c509 driver also supports EISA cards
228
+ * The EISA probe function
233 229
  *
234 230
  */
235
-static struct eisa_id el3_eisa_adapters[] = {
236
-	{ "3Com 3c509 EtherLink III (EISA)", MFG_ID, PROD_ID },
237
-};
238
-
239
-static struct eisa_driver el3_eisa_driver =
240
-	EISA_DRIVER ( "3c509 (EISA)", el3_eisa_adapters );
241
-
242
-static int el3_eisa_probe ( struct dev *dev ) {
231
+static int el3_eisa_probe ( struct dev *dev, struct eisa_device *eisa ) {
243 232
 	struct nic *nic = nic_device ( dev );
244
-	struct eisa_device *eisa = eisa_device ( dev );
245
-	
246
-	if ( ! find_eisa_device ( eisa, &el3_eisa_driver ) )
247
-		return 0;
248 233
 	
249 234
 	enable_eisa_device ( eisa );
250 235
 	nic->ioaddr = eisa->ioaddr;
@@ -255,7 +240,15 @@ static int el3_eisa_probe ( struct dev *dev ) {
255 240
 	return t5x9_probe ( nic, ISA_PROD_ID ( PROD_ID ), ISA_PROD_ID_MASK );
256 241
 }
257 242
 
258
-BOOT_DRIVER ( "3c509 (EISA)", el3_eisa_probe );
243
+static struct eisa_id el3_eisa_adapters[] = {
244
+	{ "3Com 3c509 EtherLink III (EISA)", MFG_ID, PROD_ID },
245
+};
246
+
247
+static struct eisa_driver el3_eisa_driver =
248
+	EISA_DRIVER ( "3c509 (EISA)", el3_eisa_adapters );
249
+
250
+BOOT_DRIVER ( "3c509 (EISA)", find_eisa_boot_device, el3_eisa_driver,
251
+	      el3_eisa_probe );
259 252
 
260 253
 /*
261 254
  * We currently build both ISA and EISA support into a single ROM

+ 2
- 2
src/drivers/net/3c529.c Voir le fichier

@@ -5,7 +5,7 @@
5 5
 
6 6
 #include "etherboot.h"
7 7
 #include "mca.h"
8
-#include "isa.h"
8
+#include "isa.h" /* for ISA_ROM */
9 9
 #include "nic.h"
10 10
 #include "3c509.h"
11 11
 
@@ -44,6 +44,6 @@ static struct mca_id el3_mca_adapters[] = {
44 44
 static struct mca_driver t529_driver
45 45
 	= MCA_DRIVER ( "3c529", el3_mca_adapters );
46 46
 
47
-BOOT_DRIVER ( "3c529", find_mca_boot_device, &t529_driver, t529_probe );
47
+BOOT_DRIVER ( "3c529", find_mca_boot_device, t529_driver, t529_probe );
48 48
 
49 49
 ISA_ROM( "3c529", "3c529 == MCA 3c509" );

+ 10
- 15
src/drivers/net/pnic.c Voir le fichier

@@ -211,28 +211,15 @@ static struct nic_operations pnic_operations = {
211 211
 	.disable        = pnic_disable,
212 212
 };
213 213
 
214
-static struct pci_id pnic_nics[] = {
215
-/* genrules.pl doesn't let us use macros for PCI IDs...*/
216
-PCI_ROM ( 0xfefe, 0xefef, "pnic", "Bochs Pseudo NIC Adaptor" ),
217
-};
218
-
219
-static struct pci_driver pnic_driver =
220
-	PCI_DRIVER ( "PNIC", pnic_nics, PCI_NO_CLASS );
221
-
222 214
 /**************************************************************************
223 215
 PROBE - Look for an adapter, this routine's visible to the outside
224 216
 ***************************************************************************/
225 217
 
226
-static int pnic_probe ( struct dev *dev ) {
218
+static int pnic_probe ( struct dev *dev, struct pci_device *pci ) {
227 219
 	struct nic *nic = nic_device ( dev );
228
-	struct pci_device *pci = pci_device ( dev );
229 220
 	uint16_t api_version;
230 221
 	uint16_t status;
231 222
 
232
-	/* Scan PCI bus for a PNIC device */
233
-	if ( ! find_pci_device ( pci, &pnic_driver ) )
234
-		return 0;
235
-
236 223
 	/* Retrieve relevant information about PCI device */
237 224
 	nic->ioaddr = pci->ioaddr;
238 225
 	nic->irqno = pci->irq;
@@ -257,4 +244,12 @@ static int pnic_probe ( struct dev *dev ) {
257 244
 	return 1;
258 245
 }
259 246
 
260
-BOOT_DRIVER ( "PNIC", pnic_probe );
247
+static struct pci_id pnic_nics[] = {
248
+/* genrules.pl doesn't let us use macros for PCI IDs...*/
249
+PCI_ROM ( 0xfefe, 0xefef, "pnic", "Bochs Pseudo NIC Adaptor" ),
250
+};
251
+
252
+static struct pci_driver pnic_driver =
253
+	PCI_DRIVER ( "PNIC", pnic_nics, PCI_NO_CLASS );
254
+
255
+BOOT_DRIVER ( "PNIC", find_pci_boot_device, pnic_driver, pnic_probe );

Chargement…
Annuler
Enregistrer