Explorar el Código

Updated to new API.

tags/v0.9.3
Michael Brown hace 19 años
padre
commit
329ccfdc21
Se han modificado 1 ficheros con 68 adiciones y 56 borrados
  1. 68
    56
      src/drivers/net/skel.c

+ 68
- 56
src/drivers/net/skel.c Ver fichero

@@ -104,23 +104,6 @@ static void skel_transmit ( struct nic *nic __unused,
104 104
 	 */
105 105
 }
106 106
 
107
-/**************************************************************************
108
- * DISABLE - Turn off ethernet interface
109
- **************************************************************************
110
- */
111
-static void skel_disable ( struct nic *nic __unused ) {
112
-	/* put the card in its initial state */
113
-	/* This function serves 3 purposes.
114
-	 * This disables DMA and interrupts so we don't receive
115
-	 *  unexpected packets or interrupts from the card after
116
-	 *  etherboot has finished. 
117
-	 * This frees resources so etherboot may use
118
-	 *  this driver on another interface
119
-	 * This allows etherboot to reinitialize the interface
120
-	 *  if something is something goes wrong.
121
-	 */
122
-}
123
-
124 107
 /**************************************************************************
125 108
  * IRQ - handle interrupts
126 109
  **************************************************************************
@@ -163,15 +146,15 @@ static struct nic_operations skel_operations = {
163 146
 	.poll		= skel_poll,
164 147
 	.transmit	= skel_transmit,
165 148
 	.irq		= skel_irq,
166
-
167 149
 };
168 150
 
169 151
 /**************************************************************************
170 152
  * PROBE - Look for an adapter
171 153
  *
172
- * You need to define a probe routine for each bus type that your
173
- * driver supports, together with tables that enable Etherboot to
174
- * identify that your driver should be used for a particular device.
154
+ * You need to define a probe routine and a disable routine for each
155
+ * bus type that your driver supports, together with tables that
156
+ * enable Etherboot to identify that your driver should be used for a
157
+ * particular device.
175 158
  *
176 159
  * Delete whichever of the following sections you don't need.  For
177 160
  * example, most PCI devices will only need the PCI probing section;
@@ -186,18 +169,13 @@ static struct nic_operations skel_operations = {
186 169
  */
187 170
 
188 171
 /**************************************************************************
189
- * PCI PROBE - Look for an adapter
172
+ * PCI PROBE and DISABLE
190 173
  **************************************************************************
191 174
  */
192 175
 static int skel_pci_probe ( struct nic *nic, struct pci_device *pci ) {
193 176
 
194
-
195 177
 	pci_fill_nic ( nic, pci );
196 178
 
197
-
198
-	nic->ioaddr = pci->ioaddr;
199
-	nic->irqno = pci->irq;
200
-
201 179
 	/* Test for physical presence of NIC */
202 180
 	/*
203 181
 	   if ( ! my_tests ) {
@@ -211,6 +189,13 @@ static int skel_pci_probe ( struct nic *nic, struct pci_device *pci ) {
211 189
 	return 1;
212 190
 }
213 191
 
192
+static void skel_pci_disable ( struct nic *nic __unused,
193
+			       struct pci_device *pci __unused ) {
194
+	/* Reset the card to its initial state, disable DMA and
195
+	 * interrupts
196
+	 */
197
+}
198
+
214 199
 static struct pci_id skel_pci_nics[] = {
215 200
 PCI_ROM ( 0x0000, 0x0000, "skel-pci", "Skeleton PCI Adapter" ),
216 201
 };
@@ -219,18 +204,17 @@ static struct pci_driver skel_pci_driver =
219 204
 	PCI_DRIVER ( skel_pci_nics, PCI_NO_CLASS );
220 205
 
221 206
 DRIVER ( "SKEL/PCI", nic_driver, pci_driver, skel_pci_driver,
222
-	 skel_pci_probe, skel_disable );
207
+	 skel_pci_probe, skel_pci_disable );
223 208
 
224 209
 /**************************************************************************
225
- * EISA PROBE - Look for an adapter
210
+ * EISA PROBE and DISABLE
226 211
  **************************************************************************
227 212
  */
228 213
 static int skel_eisa_probe ( struct nic *nic, struct eisa_device *eisa ) {
229
-	struct nic *nic = nic_device ( dev );
230 214
 
215
+	eisa_fill_nic ( nic, eisa );
231 216
 	enable_eisa_device ( eisa );
232
-	nic->ioaddr = eisa->ioaddr;
233
-	nic->irqno = 0;
217
+	nic->irqno = 0; /* No standard way to get irq from EISA cards */
234 218
 
235 219
 	/* Test for physical presence of NIC */
236 220
 	/*
@@ -245,29 +229,35 @@ static int skel_eisa_probe ( struct nic *nic, struct eisa_device *eisa ) {
245 229
 	return 1;
246 230
 }
247 231
 
232
+static void skel_eisa_disable ( struct nic *nic __unused,
233
+				struct eisa_device *eisa ) {
234
+	/* Reset the card to its initial state, disable DMA and
235
+	 * interrupts
236
+	 */
237
+	disable_eisa_device ( eisa );
238
+}
239
+
248 240
 static struct eisa_id skel_eisa_nics[] = {
249 241
 	{ "Skeleton EISA Adapter", EISA_VENDOR('S','K','L'), 0x0000 },
250 242
 };
251 243
 
252 244
 static struct eisa_driver skel_eisa_driver =
253
-	EISA_DRIVER ( "SKEL/EISA", skel_eisa_nics );
245
+	EISA_DRIVER ( skel_eisa_nics );
254 246
 
255
-BOOT_DRIVER ( "SKEL/EISA", find_eisa_boot_device,
256
-	      skel_eisa_driver, skel_eisa_probe );
247
+DRIVER ( "SKEL/EISA", nic_driver, eisa_driver, skel_eisa_driver,
248
+	 skel_eisa_probe, skel_eisa_disable );
257 249
 
258 250
 ISA_ROM ( "skel-eisa", "Skeleton EISA Adapter" );
259 251
 
260 252
 /**************************************************************************
261
- * ISAPnP PROBE - Look for an adapter
253
+ * ISAPnP PROBE and DISABLE
262 254
  **************************************************************************
263 255
  */
264 256
 static int skel_isapnp_probe ( struct nic *nic,
265 257
 			       struct isapnp_device *isapnp ) {
266
-	struct nic *nic = nic_device ( dev );
267 258
 
268
-	nic->ioaddr = isapnp->ioaddr;
269
-	nic->irqno = isapnp->irqno;
270
-	activate_isapnp_device ( isapnp, 1 );
259
+	isapnp_fill_nic ( nic, isapnp );
260
+	activate_isapnp_device ( isapnp );
271 261
 
272 262
 	/* Test for physical presence of NIC */
273 263
 	/*
@@ -282,25 +272,34 @@ static int skel_isapnp_probe ( struct nic *nic,
282 272
 	return 1;
283 273
 }
284 274
 
275
+static void skel_isapnp_disable ( struct nic *nic __unused,
276
+				  struct isapnp_device *isapnp ) {
277
+	/* Reset the card to its initial state, disable DMA and
278
+	 * interrupts
279
+	 */
280
+	deactivate_isapnp_device ( isapnp );
281
+}
282
+
285 283
 static struct isapnp_id skel_isapnp_nics[] = {
286 284
 	{ "Skeleton ISAPnP Adapter", ISAPNP_VENDOR('S','K','L'), 0x0000 },
287 285
 };
288 286
 
289 287
 static struct isapnp_driver skel_isapnp_driver =
290
-	ISAPNP_DRIVER ( "SKEL/ISAPnP", skel_isapnp_nics );
288
+	ISAPNP_DRIVER ( skel_isapnp_nics );
291 289
 
292
-BOOT_DRIVER ( "SKEL/ISAPnP", find_isapnp_boot_device,
293
-	      skel_isapnp_driver, skel_isapnp_probe );
290
+DRIVER ( "SKEL/ISAPnP", nic_driver, isapnp_driver, skel_isapnp_driver,
291
+	 skel_isapnp_probe, skel_isapnp_disable );
294 292
 
295 293
 ISA_ROM ( "skel-isapnp", "Skeleton ISAPnP Adapter" );
296 294
 
297 295
 /**************************************************************************
298
- * MCA PROBE - Look for an adapter
296
+ * MCA PROBE and DISABLE
299 297
  **************************************************************************
300 298
  */
301 299
 static int skel_mca_probe ( struct nic *nic,
302
-			    struct mca_device *mca __unused ) {
303
-	struct nic *nic = nic_device ( dev );
300
+			    struct mca_device *mca ) {
301
+
302
+	mca_fill_nic ( nic, mca );
304 303
 
305 304
 	/* MCA parameters are available in the mca->pos[] array */
306 305
 	/*
@@ -321,20 +320,27 @@ static int skel_mca_probe ( struct nic *nic,
321 320
 	return 1;
322 321
 }
323 322
 
323
+static void skel_mca_disable ( struct nic *nic __unused,
324
+			       struct mca_device *mca __unused ) {
325
+	/* Reset the card to its initial state, disable DMA and
326
+	 * interrupts
327
+	 */
328
+}
329
+
324 330
 static struct mca_id skel_mca_nics[] = {
325 331
 	{ "Skeleton MCA Adapter", 0x0000 },
326 332
 };
327 333
 
328 334
 static struct mca_driver skel_mca_driver =
329
-	MCA_DRIVER ( "SKEL/MCA", skel_mca_nics );
335
+	MCA_DRIVER ( skel_mca_nics );
330 336
 
331
-BOOT_DRIVER ( "SKEL/MCA", find_mca_boot_device,
332
-	      skel_mca_driver, skel_mca_probe );
337
+DRIVER ( "SKEL/MCA", nic_driver, mca_driver, skel_mca_driver,
338
+	 skel_mca_probe, skel_mca_disable );
333 339
 
334 340
 ISA_ROM ( "skel-mca", "Skeleton MCA Adapter" );
335 341
 
336 342
 /**************************************************************************
337
- * ISA PROBE - Look for an adapter
343
+ * ISA PROBE and DISABLE
338 344
  *
339 345
  * The "classical" ISA probe is split into two stages: trying a list
340 346
  * of I/O addresses to see if there's anything listening, and then
@@ -358,10 +364,9 @@ static int skel_isa_probe_addr ( isa_probe_addr_t ioaddr __unused ) {
358 364
 }
359 365
 
360 366
 static int skel_isa_probe ( struct nic *nic, struct isa_device *isa ) {
361
-	struct nic *nic = nic_device ( dev );
362 367
 
363
-	nic->ioaddr = isa->ioaddr;
364
-	nic->irqno = 0;
368
+	isa_fill_nic ( nic, isa );
369
+	nic->irqno = 0; /* No standard way to get IRQ for ISA */
365 370
 
366 371
 	/* Test for physical presence of NIC */
367 372
 	/*
@@ -376,6 +381,13 @@ static int skel_isa_probe ( struct nic *nic, struct isa_device *isa ) {
376 381
 	return 1;
377 382
 }
378 383
 
384
+static void skel_isa_disable ( struct nic *nic __unused,
385
+			      struct isa_device *isa __unused ) {
386
+	/* Reset the card to its initial state, disable DMA and
387
+	 * interrupts
388
+	 */
389
+}
390
+
379 391
 static isa_probe_addr_t skel_isa_probe_addrs[] = {
380 392
 	/*
381 393
 	   0x200, 0x240,
@@ -383,11 +395,11 @@ static isa_probe_addr_t skel_isa_probe_addrs[] = {
383 395
 };
384 396
 
385 397
 static struct isa_driver skel_isa_driver =
386
-	ISA_DRIVER ( "SKEL/ISA", skel_isa_probe_addrs, skel_isa_probe_addr,
398
+	ISA_DRIVER ( skel_isa_probe_addrs, skel_isa_probe_addr,
387 399
 		     ISA_VENDOR('S','K','L'), 0x0000 );
388 400
 
389
-BOOT_DRIVER ( "SKEL/ISA", find_isa_boot_device,
390
-	      skel_isa_driver, skel_isa_probe );
401
+DRIVER ( "SKEL/ISA", nic_driver, isa_driver, skel_isa_driver,
402
+	 skel_isa_probe, skel_isa_disable );
391 403
 
392 404
 ISA_ROM ( "skel-isa", "Skeleton ISA Adapter" );
393 405
 

Loading…
Cancelar
Guardar