瀏覽代碼

Able to at least compile again now.

tags/v0.9.3
Michael Brown 19 年之前
父節點
當前提交
e1d0cebfa8
共有 1 個文件被更改,包括 41 次插入50 次删除
  1. 41
    50
      src/arch/i386/drivers/net/undi.c

+ 41
- 50
src/arch/i386/drivers/net/undi.c 查看文件

@@ -61,7 +61,6 @@ static undi_t undi = {
61 61
 	.started          = 0, 
62 62
 	.initialized      = 0, 
63 63
 	.opened           = 0,
64
-	.pci	          = { 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, NULL },
65 64
 	.irq              = IRQ_NONE 
66 65
 };
67 66
 
@@ -302,7 +301,7 @@ static int hunt_rom ( void ) {
302 301
 	/* If we are not a PCI device, we cannot search for a ROM that
303 302
 	 * matches us (?)
304 303
 	 */
305
-	if ( ! undi.pci.vendor )
304
+	if ( ! undi.pci->vendor )
306 305
 		return 0;
307 306
 
308 307
 	printf ( "Hunting for ROMs..." );
@@ -327,11 +326,11 @@ static int hunt_rom ( void ) {
327 326
 			}
328 327
 			printf ( "PCI:%hx:%hx...", pcir_header->vendor_id,
329 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 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 334
 				continue;
336 335
 			}
337 336
 			if ( undi.rom->pnp_off == 0 ) {
@@ -661,13 +660,13 @@ static void nontrivial_irq_debug ( irq_t irq ) {
661 660
 static int undi_loader ( void ) {
662 661
 	pxe_t *pxe = NULL;
663 662
 
664
-	if ( ! undi.pci.vendor ) {
663
+	if ( ! undi.pci->vendor ) {
665 664
 		printf ( "ERROR: attempted to call loader of an ISA ROM?\n" );
666 665
 		return 0;
667 666
 	}
668 667
 
669 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 670
 	/* BX and DX set to 0xffff for non-ISAPnP devices
672 671
 	 * (BIOS boot specification)
673 672
 	 */
@@ -735,7 +734,7 @@ static int eb_pxenv_start_undi ( void ) {
735 734
 	int success = 0;
736 735
 
737 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 739
 	/* BX and DX set to 0xffff for non-ISAPnP devices
741 740
 	 * (BIOS boot specification)
@@ -1331,7 +1330,7 @@ static void undi_transmit(
1331 1330
 /**************************************************************************
1332 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 1334
 	undi_full_shutdown();
1336 1335
 	free_base_mem_data();
1337 1336
 }
@@ -1364,22 +1363,44 @@ static int hunt_pixies_and_undi_roms ( void ) {
1364 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 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 1393
 	/* Zero out global undi structure */
1375 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 1400
 	/* Store PCI parameters; we will need them to initialize the
1378 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 1405
 	/* Find the BIOS' $PnP structure */
1385 1406
 	if ( ! hunt_pnp_bios() ) {
@@ -1425,44 +1446,14 @@ static int undi_probe(struct dev *dev, struct pci_device *pci)
1425 1446
 		printf ( "NDIS type %s interface at %d Mbps\n",
1426 1447
 			 undi.pxs->undi_get_iface_info.IfaceType,
1427 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 1451
 		return 1;
1432 1452
 	}
1433
-	undi_disable ( dev ); /* To free base memory structures */
1453
+	undi_disable ( nic ); /* To free base memory structures */
1434 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 1459
 #endif /* PCBIOS */

Loading…
取消
儲存