Browse Source

Able to at least compile again now.

tags/v0.9.3
Michael Brown 20 years ago
parent
commit
e1d0cebfa8
1 changed files with 41 additions and 50 deletions
  1. 41
    50
      src/arch/i386/drivers/net/undi.c

+ 41
- 50
src/arch/i386/drivers/net/undi.c View File

61
 	.started          = 0, 
61
 	.started          = 0, 
62
 	.initialized      = 0, 
62
 	.initialized      = 0, 
63
 	.opened           = 0,
63
 	.opened           = 0,
64
-	.pci	          = { 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, NULL },
65
 	.irq              = IRQ_NONE 
64
 	.irq              = IRQ_NONE 
66
 };
65
 };
67
 
66
 
302
 	/* If we are not a PCI device, we cannot search for a ROM that
301
 	/* If we are not a PCI device, we cannot search for a ROM that
303
 	 * matches us (?)
302
 	 * matches us (?)
304
 	 */
303
 	 */
305
-	if ( ! undi.pci.vendor )
304
+	if ( ! undi.pci->vendor )
306
 		return 0;
305
 		return 0;
307
 
306
 
308
 	printf ( "Hunting for ROMs..." );
307
 	printf ( "Hunting for ROMs..." );
327
 			}
326
 			}
328
 			printf ( "PCI:%hx:%hx...", pcir_header->vendor_id,
327
 			printf ( "PCI:%hx:%hx...", pcir_header->vendor_id,
329
 				 pcir_header->device_id );
328
 				 pcir_header->device_id );
330
-			if ( ( pcir_header->vendor_id != undi.pci.vendor ) ||
331
-			     ( pcir_header->device_id != undi.pci.dev_id ) ) {
329
+			if ( ( pcir_header->vendor_id != undi.pci->vendor ) ||
330
+			     ( pcir_header->device_id != undi.pci->dev_id ) ) {
332
 				printf ( "not me (%hx:%hx)\n...",
331
 				printf ( "not me (%hx:%hx)\n...",
333
-					 undi.pci.vendor,
334
-					 undi.pci.dev_id );
332
+					 undi.pci->vendor,
333
+					 undi.pci->dev_id );
335
 				continue;
334
 				continue;
336
 			}
335
 			}
337
 			if ( undi.rom->pnp_off == 0 ) {
336
 			if ( undi.rom->pnp_off == 0 ) {
661
 static int undi_loader ( void ) {
660
 static int undi_loader ( void ) {
662
 	pxe_t *pxe = NULL;
661
 	pxe_t *pxe = NULL;
663
 
662
 
664
-	if ( ! undi.pci.vendor ) {
663
+	if ( ! undi.pci->vendor ) {
665
 		printf ( "ERROR: attempted to call loader of an ISA ROM?\n" );
664
 		printf ( "ERROR: attempted to call loader of an ISA ROM?\n" );
666
 		return 0;
665
 		return 0;
667
 	}
666
 	}
668
 
667
 
669
 	/* AX contains PCI bus:devfn (PCI specification) */
668
 	/* AX contains PCI bus:devfn (PCI specification) */
670
-	undi.pxs->loader.ax = ( undi.pci.bus << 8 ) | undi.pci.devfn;
669
+	undi.pxs->loader.ax = ( undi.pci->busdevfn );
671
 	/* BX and DX set to 0xffff for non-ISAPnP devices
670
 	/* BX and DX set to 0xffff for non-ISAPnP devices
672
 	 * (BIOS boot specification)
671
 	 * (BIOS boot specification)
673
 	 */
672
 	 */
735
 	int success = 0;
734
 	int success = 0;
736
 
735
 
737
 	/* AX contains PCI bus:devfn (PCI specification) */
736
 	/* AX contains PCI bus:devfn (PCI specification) */
738
-	undi.pxs->start_undi.ax = ( undi.pci.bus << 8 ) | undi.pci.devfn;
737
+	undi.pxs->start_undi.ax = undi.pci->busdevfn;
739
 
738
 
740
 	/* BX and DX set to 0xffff for non-ISAPnP devices
739
 	/* BX and DX set to 0xffff for non-ISAPnP devices
741
 	 * (BIOS boot specification)
740
 	 * (BIOS boot specification)
1331
 /**************************************************************************
1330
 /**************************************************************************
1332
 DISABLE - Turn off ethernet interface
1331
 DISABLE - Turn off ethernet interface
1333
 ***************************************************************************/
1332
 ***************************************************************************/
1334
-static void undi_disable ( struct dev *dev __unused ) {
1333
+static void undi_disable ( struct nic *nic __unused ) {
1335
 	undi_full_shutdown();
1334
 	undi_full_shutdown();
1336
 	free_base_mem_data();
1335
 	free_base_mem_data();
1337
 }
1336
 }
1364
 	return 0;
1363
 	return 0;
1365
 }
1364
 }
1366
 
1365
 
1366
+/* UNDI driver states that it is suitable for any PCI NIC (i.e. any
1367
+ * PCI device of class PCI_CLASS_NETWORK_ETHERNET).  If there are any
1368
+ * obscure UNDI NICs that have the incorrect PCI class, add them to
1369
+ * this list.
1370
+ */
1371
+static struct pci_id undi_nics[] = {
1372
+	PCI_ROM ( 0x0000, 0x0000, "undi", "UNDI driver support" ),
1373
+};
1374
+
1375
+static struct pci_driver undi_driver =
1376
+	PCI_DRIVER ( "UNDI", undi_nics, PCI_CLASS_NETWORK_ETHERNET );
1377
+
1378
+static struct nic_operations undi_operations = {
1379
+	.connect = dummy_connect,
1380
+	.poll = undi_poll,
1381
+	.transmit = undi_transmit,
1382
+	.irq = dummy_irq,
1383
+	.disable = undi_disable,
1384
+};
1385
+
1367
 /* The actual Etherboot probe routine.
1386
 /* The actual Etherboot probe routine.
1368
  */
1387
  */
1369
 
1388
 
1370
-static int undi_probe(struct dev *dev, struct pci_device *pci)
1371
-{
1372
-	struct nic *nic = (struct nic *)dev;
1389
+static int undi_probe ( struct dev *dev ) {
1390
+	struct nic *nic = nic_device ( dev );
1391
+	struct pci_device *pci = pci_device ( dev );
1373
 
1392
 
1374
 	/* Zero out global undi structure */
1393
 	/* Zero out global undi structure */
1375
 	memset ( &undi, 0, sizeof(undi) );
1394
 	memset ( &undi, 0, sizeof(undi) );
1376
 
1395
 
1396
+	/* Scan PCI bus for a suitable device */
1397
+	if ( ! find_pci_device ( pci, &undi_driver ) )
1398
+		return 0;
1399
+
1377
 	/* Store PCI parameters; we will need them to initialize the
1400
 	/* Store PCI parameters; we will need them to initialize the
1378
 	 * UNDI driver later.  If not a PCI device, leave as 0.
1401
 	 * UNDI driver later.  If not a PCI device, leave as 0.
1379
 	 */
1402
 	 */
1380
-	if ( pci ) {
1381
-		memcpy ( &undi.pci, pci, sizeof(undi.pci) );
1382
-	}
1403
+	undi.pci = pci;
1383
 
1404
 
1384
 	/* Find the BIOS' $PnP structure */
1405
 	/* Find the BIOS' $PnP structure */
1385
 	if ( ! hunt_pnp_bios() ) {
1406
 	if ( ! hunt_pnp_bios() ) {
1425
 		printf ( "NDIS type %s interface at %d Mbps\n",
1446
 		printf ( "NDIS type %s interface at %d Mbps\n",
1426
 			 undi.pxs->undi_get_iface_info.IfaceType,
1447
 			 undi.pxs->undi_get_iface_info.IfaceType,
1427
 			 undi.pxs->undi_get_iface_info.LinkSpeed / 1000000 );
1448
 			 undi.pxs->undi_get_iface_info.LinkSpeed / 1000000 );
1428
-		dev->disable  = undi_disable;
1429
-		nic->poll     = undi_poll;
1430
-		nic->transmit = undi_transmit;
1449
+
1450
+		nic->nic_op = &undi_operations;
1431
 		return 1;
1451
 		return 1;
1432
 	}
1452
 	}
1433
-	undi_disable ( dev ); /* To free base memory structures */
1453
+	undi_disable ( nic ); /* To free base memory structures */
1434
 	return 0;
1454
 	return 0;
1435
 }
1455
 }
1436
 
1456
 
1437
-static int undi_isa_probe ( struct dev *dev,
1438
-			    unsigned short *probe_addrs __unused ) {
1439
-	return undi_probe ( dev, NULL );
1440
-}
1441
-
1442
-
1443
-/* UNDI driver states that it is suitable for any PCI NIC (i.e. any
1444
- * PCI device of class PCI_CLASS_NETWORK_ETHERNET).  If there are any
1445
- * obscure UNDI NICs that have the incorrect PCI class, add them to
1446
- * this list.
1447
- */
1448
-static struct pci_id undi_nics[] = {
1449
-	PCI_ROM(0x0000, 0x0000, "undi", "UNDI driver support"),
1450
-};
1451
-
1452
-static struct pci_driver undi_driver __pci_driver = {
1453
-	.type     = NIC_DRIVER,
1454
-	.name     = "UNDI",
1455
-	.probe    = undi_probe,
1456
-	.ids      = undi_nics,
1457
- 	.id_count = sizeof(undi_nics)/sizeof(undi_nics[0]),
1458
-	.class    = PCI_CLASS_NETWORK_ETHERNET,
1459
-};
1460
-
1461
-static struct isa_driver undi_isa_driver __isa_driver = {
1462
-	.type     = NIC_DRIVER,
1463
-	.name     = "UNDI",
1464
-	.probe    = undi_isa_probe,
1465
-	.ioaddrs  = 0,
1466
-};
1457
+BOOT_DRIVER ( "UNDI", undi_probe );
1467
 
1458
 
1468
 #endif /* PCBIOS */
1459
 #endif /* PCBIOS */

Loading…
Cancel
Save