Kaynağa Gözat

eth_ntoa and warnings cleanup

tags/v0.9.3
Marty Connor 18 yıl önce
ebeveyn
işleme
0d1087a5de
1 değiştirilmiş dosya ile 44 ekleme ve 54 silme
  1. 44
    54
      src/drivers/net/tlan.c

+ 44
- 54
src/drivers/net/tlan.c Dosyayı Görüntüle

@@ -38,12 +38,10 @@
38 38
 *    Indent Options: indent -kr -i8
39 39
 ***************************************************************************/
40 40
 
41
-/* to get some global routines like printf */
42 41
 #include "etherboot.h"
43
-/* to get the interface to the body of the program */
44 42
 #include "nic.h"
45
-/* to get the PCI support functions, if this is a PCI NIC */
46 43
 #include <gpxe/pci.h>
44
+#include <gpxe/ethernet.h>
47 45
 #include "timer.h"
48 46
 #include "tlan.h"
49 47
 
@@ -58,13 +56,6 @@
58 56
 #define virt_to_le32desc(addr)  cpu_to_le32(virt_to_bus(addr))
59 57
 #define le32desc_to_virt(addr)  bus_to_virt(le32_to_cpu(addr))
60 58
 
61
-//#define EDEBUG
62
-#ifdef EDEBUG
63
-#define dprintf(x) printf x
64
-#else
65
-#define dprintf(x)
66
-#endif
67
-
68 59
 static void TLan_ResetLists(struct nic *nic __unused);
69 60
 static void TLan_ResetAdapter(struct nic *nic __unused);
70 61
 static void TLan_FinishReset(struct nic *nic __unused);
@@ -414,7 +405,7 @@ void TLan_FinishReset(struct nic *nic)
414 405
 	if ((tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY)
415 406
 	    || (priv->aui)) {
416 407
 		status = MII_GS_LINK;
417
-		dprintf(("TLAN:  %s: Link forced.\n", priv->nic_name));
408
+		DBG ( "TLAN:  %s: Link forced.\n", priv->nic_name );
418 409
 	} else {
419 410
 		TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
420 411
 		udelay(1000);
@@ -426,27 +417,27 @@ void TLan_FinishReset(struct nic *nic)
426 417
 			TLan_MiiReadReg(nic, phy, TLAN_TLPHY_PAR,
427 418
 					&tlphy_par);
428 419
 
429
-			dprintf(("TLAN: %s: Link active with ",
430
-			       priv->nic_name));
420
+			DBG ( "TLAN: %s: Link active with ",
421
+			       priv->nic_name );
431 422
 			if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
432
-				dprintf(("forced 10%sMbps %s-Duplex\n",
423
+				DBG ( "forced 10%sMbps %s-Duplex\n",
433 424
 				       tlphy_par & TLAN_PHY_SPEED_100 ? ""
434 425
 				       : "0",
435 426
 				       tlphy_par & TLAN_PHY_DUPLEX_FULL ?
436
-				       "Full" : "Half"));
427
+				       "Full" : "Half" );
437 428
 			} else {
438
-				dprintf
439
-				    (("AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
429
+				DBG 
430
+				    ( "AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
440 431
 				     tlphy_par & TLAN_PHY_SPEED_100 ? "" :
441 432
 				     "0",
442 433
 				     tlphy_par & TLAN_PHY_DUPLEX_FULL ?
443
-				     "Full" : "Half"));
444
-				dprintf(("TLAN: Partner capability: "));
434
+				     "Full" : "Half" );
435
+				DBG ( "TLAN: Partner capability: " );
445 436
 				for (i = 5; i <= 10; i++)
446 437
 					if (partner & (1 << i)) {
447
-						dprintf(("%s", media[i - 5]));
438
+						DBG ( "%s", media[i - 5] );
448 439
 					}
449
-				dprintf(("\n"));
440
+				DBG ( "\n" );
450 441
 			}
451 442
 
452 443
 			TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
@@ -459,7 +450,7 @@ void TLan_FinishReset(struct nic *nic)
459 450
 			TLan_PhyMonitor(nic);
460 451
 #endif
461 452
 		} else if (status & MII_GS_LINK) {
462
-			dprintf(("TLAN: %s: Link active\n", priv->nic_name));
453
+			DBG ( "TLAN: %s: Link active\n", priv->nic_name );
463 454
 			TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
464 455
 		}
465 456
 	}
@@ -480,9 +471,9 @@ void TLan_FinishReset(struct nic *nic)
480 471
 		outl(virt_to_bus(&rx_ring), BASE + TLAN_CH_PARM);
481 472
 		outl(TLAN_HC_GO | TLAN_HC_RT, BASE + TLAN_HOST_CMD);
482 473
 	} else {
483
-		dprintf
484
-		    (("TLAN: %s: Link inactive, will retry in 10 secs...\n",
485
-		     priv->nic_name));
474
+		DBG 
475
+		    ( "TLAN: %s: Link inactive, will retry in 10 secs...\n",
476
+		     priv->nic_name );
486 477
 		/* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_FINISH_RESET ); */
487 478
 		mdelay(10000);
488 479
 		TLan_FinishReset(nic);
@@ -524,14 +515,14 @@ static int tlan_poll(struct nic *nic, int retrieve)
524 515
 
525 516
 	nic->packetlen = framesize;
526 517
 
527
-	dprintf((".%d.", framesize)); 
518
+	DBG ( ".%d.", framesize ); 
528 519
      
529 520
 	memcpy(nic->packet, rxb +
530 521
 	       (priv->cur_rx * TLAN_MAX_FRAME_SIZE), nic->packetlen);
531 522
 
532 523
 	rx_ring[entry].cStat = 0;
533 524
 
534
-	dprintf(("%d", entry));  
525
+	DBG ( "%d", entry );  
535 526
 
536 527
 	entry = (entry + 1) % TLAN_NUM_RX_LISTS;
537 528
 	priv->cur_rx = entry;
@@ -546,8 +537,8 @@ static int tlan_poll(struct nic *nic, int retrieve)
546 537
 		host_cmd = TLAN_HC_ACK | ack | (0x000C0000);
547 538
 		outl(host_cmd, BASE + TLAN_HOST_CMD);
548 539
 		
549
-		dprintf(("AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM))); 
550
-		dprintf(("PI-2: 0x%hX\n", inw(BASE + TLAN_HOST_INT)));
540
+		DBG ( "AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM) ); 
541
+		DBG ( "PI-2: 0x%hX\n", inw(BASE + TLAN_HOST_INT) );
551 542
 	}
552 543
 	refill_rx(nic);
553 544
 	return (1);		/* initially as this is called to flush the input */
@@ -585,12 +576,11 @@ static void tlan_transmit(struct nic *nic, const char *d,	/* Destination */
585 576
 	u32 host_cmd;
586 577
 	int eoc = 0;
587 578
 	u16 tmpCStat;
588
-#ifdef EBDEBUG
589 579
 	u16 host_int = inw(BASE + TLAN_HOST_INT);
590
-#endif
580
+
591 581
 	int entry = 0;
592 582
 
593
-	dprintf(("INT0-0x%hX\n", host_int));
583
+	DBG ( "INT0-0x%hX\n", host_int );
594 584
 
595 585
 	if (!priv->phyOnline) {
596 586
 		printf("TRANSMIT:  %s PHY is not ready\n", priv->nic_name);
@@ -600,7 +590,7 @@ static void tlan_transmit(struct nic *nic, const char *d,	/* Destination */
600 590
 	tail_list = priv->txList + priv->txTail;
601 591
 
602 592
 	if (tail_list->cStat != TLAN_CSTAT_UNUSED) {
603
-		printf("TRANSMIT: %s is busy (Head=%d Tail=%d)\n",
593
+		printf("TRANSMIT: %s is busy (Head=%p Tail=%x)\n",
604 594
 		       priv->nic_name, priv->txList, priv->txTail);
605 595
 		tx_ring[entry].cStat = TLAN_CSTAT_UNUSED;
606 596
 //		priv->txBusyCount++;
@@ -649,7 +639,7 @@ static void tlan_transmit(struct nic *nic, const char *d,	/* Destination */
649 639
 
650 640
 	tail_list->cStat = TLAN_CSTAT_READY;
651 641
 
652
-	dprintf(("INT1-0x%hX\n", inw(BASE + TLAN_HOST_INT)));
642
+	DBG ( "INT1-0x%hX\n", inw(BASE + TLAN_HOST_INT) );
653 643
 
654 644
 	if (!priv->txInProgress) {
655 645
 		priv->txInProgress = 1;
@@ -657,11 +647,11 @@ static void tlan_transmit(struct nic *nic, const char *d,	/* Destination */
657 647
 		outl(TLAN_HC_GO, BASE + TLAN_HOST_CMD);
658 648
 	} else {
659 649
 		if (priv->txTail == 0) {
660
-			dprintf(("Out buffer\n"));
650
+			DBG ( "Out buffer\n" );
661 651
 			(priv->txList + (TLAN_NUM_TX_LISTS - 1))->forward =
662 652
 			    virt_to_le32desc(tail_list);
663 653
 		} else {
664
-			dprintf(("Fix this \n"));
654
+			DBG ( "Fix this \n" );
665 655
 			(priv->txList + (priv->txTail - 1))->forward =
666 656
 			    virt_to_le32desc(tail_list);
667 657
 		}
@@ -669,7 +659,7 @@ static void tlan_transmit(struct nic *nic, const char *d,	/* Destination */
669 659
 	
670 660
 	CIRC_INC(priv->txTail, TLAN_NUM_TX_LISTS);
671 661
 
672
-	dprintf(("INT2-0x%hX\n", inw(BASE + TLAN_HOST_INT)));
662
+	DBG ( "INT2-0x%hX\n", inw(BASE + TLAN_HOST_INT) );
673 663
 
674 664
 	to = currticks() + TX_TIME_OUT;
675 665
 	while ((tail_list->cStat == TLAN_CSTAT_READY) && currticks() < to);
@@ -829,12 +819,12 @@ static int tlan_probe ( struct nic *nic, struct pci_device *pci ) {
829 819
 				       addrOfs + i,
830 820
 				       (u8 *) & nic->node_addr[i]);
831 821
 	if (err) {
832
-		printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
833
-		       pci->name, err);
834
-	} else 
835
-		/* Print out some hardware info */
836
-		printf("%s: %! at ioaddr %hX, ", 
837
-			pci->name, nic->node_addr, pci->ioaddr);
822
+  	    printf ( "TLAN: %s: Error reading MAC from eeprom: %d\n",
823
+		    pci->name, err);
824
+	} else {
825
+	    DBG ( "%s: %s at ioaddr %#lX, ", 
826
+		  pci->name, eth_ntoa ( nic->node_addr ), pci->ioaddr );
827
+	}
838 828
 
839 829
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
840 830
 	printf("revision: 0x%hX\n", priv->tlanRev);
@@ -1395,7 +1385,7 @@ void TLan_PhyPowerDown(struct nic *nic)
1395 1385
 {
1396 1386
 
1397 1387
 	u16 value;
1398
-	dprintf(("%s: Powering down PHY(s).\n", priv->nic_name));
1388
+	DBG ( "%s: Powering down PHY(s).\n", priv->nic_name );
1399 1389
 	value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
1400 1390
 	TLan_MiiSync(BASE);
1401 1391
 	TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
@@ -1422,7 +1412,7 @@ void TLan_PhyPowerUp(struct nic *nic)
1422 1412
 {
1423 1413
 	u16 value;
1424 1414
 
1425
-	dprintf(("%s: Powering up PHY.\n", priv->nic_name));
1415
+	DBG ( "%s: Powering up PHY.\n", priv->nic_name );
1426 1416
 	TLan_MiiSync(BASE);
1427 1417
 	value = MII_GC_LOOPBK;
1428 1418
 	TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
@@ -1444,7 +1434,7 @@ void TLan_PhyReset(struct nic *nic)
1444 1434
 
1445 1435
 	phy = priv->phy[priv->phyNum];
1446 1436
 
1447
-	dprintf(("%s: Reseting PHY.\n", priv->nic_name));
1437
+	DBG ( "%s: Reseting PHY.\n", priv->nic_name );
1448 1438
 	TLan_MiiSync(BASE);
1449 1439
 	value = MII_GC_LOOPBK | MII_GC_RESET;
1450 1440
 	TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, value);
@@ -1475,7 +1465,7 @@ void TLan_PhyStartLink(struct nic *nic)
1475 1465
 	u16 tctl;
1476 1466
 
1477 1467
 	phy = priv->phy[priv->phyNum];
1478
-	dprintf(("%s: Trying to activate link.\n", priv->nic_name));
1468
+	DBG ( "%s: Trying to activate link.\n", priv->nic_name );
1479 1469
 	TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
1480 1470
 	TLan_MiiReadReg(nic, phy, MII_GEN_STS, &ability);
1481 1471
 
@@ -1509,8 +1499,8 @@ void TLan_PhyStartLink(struct nic *nic)
1509 1499
 			 * but the card need additional time to start AN.
1510 1500
 			 * .5 sec should be plenty extra.
1511 1501
 			 */
1512
-			dprintf(("TLAN: %s: Starting autonegotiation.\n",
1513
-			       priv->nic_name));
1502
+			DBG ( "TLAN: %s: Starting autonegotiation.\n",
1503
+			       priv->nic_name );
1514 1504
 			mdelay(4000);
1515 1505
 			TLan_PhyFinishAutoNeg(nic);
1516 1506
 			/* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
@@ -1593,7 +1583,7 @@ void TLan_PhyFinishAutoNeg(struct nic *nic)
1593 1583
 		return;
1594 1584
 	}
1595 1585
 
1596
-	dprintf(("TLAN: %s: Autonegotiation complete.\n", priv->nic_name));
1586
+	DBG ( "TLAN: %s: Autonegotiation complete.\n", priv->nic_name );
1597 1587
 	TLan_MiiReadReg(nic, phy, MII_AN_ADV, &an_adv);
1598 1588
 	TLan_MiiReadReg(nic, phy, MII_AN_LPA, &an_lpa);
1599 1589
 	mode = an_adv & an_lpa & 0x03E0;
@@ -1624,13 +1614,13 @@ void TLan_PhyFinishAutoNeg(struct nic *nic)
1624 1614
 		    || (an_adv & an_lpa & 0x0040)) {
1625 1615
 			TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
1626 1616
 					 MII_GC_AUTOENB | MII_GC_DUPLEX);
1627
-			dprintf
1628
-			    (("TLAN:  Starting internal PHY with FULL-DUPLEX\n"));
1617
+			DBG 
1618
+			    ( "TLAN:  Starting internal PHY with FULL-DUPLEX\n" );
1629 1619
 		} else {
1630 1620
 			TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
1631 1621
 					 MII_GC_AUTOENB);
1632
-			dprintf
1633
-			    (("TLAN:  Starting internal PHY with HALF-DUPLEX\n"));
1622
+			DBG 
1623
+			    ( "TLAN:  Starting internal PHY with HALF-DUPLEX\n" );
1634 1624
 		}
1635 1625
 	}
1636 1626
 

Loading…
İptal
Kaydet