瀏覽代碼

Finished by hand

tags/v0.9.3
Michael Brown 19 年之前
父節點
當前提交
951e305081
共有 4 個檔案被更改,包括 60 行新增50 行删除
  1. 13
    9
      src/drivers/net/3c595.c
  2. 12
    11
      src/drivers/net/3c90x.c
  3. 13
    10
      src/drivers/net/davicom.c
  4. 22
    20
      src/drivers/net/dmfe.c

+ 13
- 9
src/drivers/net/3c595.c 查看文件

@@ -31,6 +31,9 @@
31 31
 #include "3c595.h"
32 32
 #include "timer.h"
33 33
 
34
+static struct nic_operations t595_operations;
35
+static struct pci_driver t595_driver;
36
+
34 37
 static unsigned short	eth_nic_base;
35 38
 static unsigned short	vx_connector, vx_connectors;
36 39
 
@@ -466,20 +469,20 @@ static void t595_irq(struct nic *nic __unused, irq_action_t action __unused)
466 469
 ETH_PROBE - Look for an adapter
467 470
 ***************************************************************************/
468 471
 static int t595_probe ( struct dev *dev ) {
469
-
470 472
 	struct nic *nic = nic_device ( dev );
471
-
472 473
 	struct pci_device *pci = pci_device ( dev );
473 474
 	int i;
474 475
 	unsigned short *p;
475 476
 
477
+	if ( ! find_pci_device ( pci, &t595_driver ) )
478
+		return 0;
479
+
476 480
 	if (pci->ioaddr == 0)
477 481
 		return 0;
478
-/*	eth_nic_base = probeaddrs[0] & ~3; */
479 482
 	eth_nic_base = pci->ioaddr;
480 483
 
481 484
 	nic->irqno  = 0;
482
-	nic->ioaddr = pci->ioaddr & ~3;
485
+	nic->ioaddr = pci->ioaddr;
483 486
 
484 487
 	GO_WINDOW(0);
485 488
 	outw(GLOBAL_RESET, BASE + VX_COMMAND);
@@ -508,17 +511,18 @@ static int t595_probe ( struct dev *dev ) {
508 511
 	printf("Ethernet address: %!\n", nic->node_addr);
509 512
 
510 513
 	t595_reset(nic);
511
-static struct nic_operations t595_operations;
514
+	nic->nic_op	= &t595_operations;
515
+	return 1;
516
+
517
+}
518
+
512 519
 static struct nic_operations t595_operations = {
513 520
 	.connect	= dummy_connect,
514 521
 	.poll		= t595_poll,
515 522
 	.transmit	= t595_transmit,
516 523
 	.irq		= t595_irq,
517 524
 	.disable	= t595_disable,
518
-};	nic->nic_op	= &t595_operations;
519
-	return 1;
520
-
521
-}
525
+};
522 526
 
523 527
 static struct pci_id t595_nics[] = {
524 528
 PCI_ROM(0x10b7, 0x5900, "3c590",           "3Com590"),		/* Vortex 10Mbps */

+ 12
- 11
src/drivers/net/3c90x.c 查看文件

@@ -42,6 +42,9 @@
42 42
 #include "pci.h"
43 43
 #include "timer.h"
44 44
 
45
+static struct nic_operations a3c90x_operations;
46
+static struct pci_driver a3c90x_driver;
47
+
45 48
 #define	XCVR_MAGIC	(0x5A00)
46 49
 /** any single transmission fails after 16 collisions or other errors
47 50
  ** this is the number of times to retry the transmission -- this should
@@ -688,9 +691,7 @@ static void a3c90x_irq(struct nic *nic __unused, irq_action_t action __unused)
688 691
  *** card.  We just have to init it here.
689 692
  ***/
690 693
 static int a3c90x_probe ( struct dev *dev ) {
691
-
692 694
     struct nic *nic = nic_device ( dev );
693
-
694 695
     struct pci_device *pci = pci_device ( dev );
695 696
     int i, c;
696 697
     unsigned short eeprom[0x21];
@@ -700,12 +701,13 @@ static int a3c90x_probe ( struct dev *dev ) {
700 701
     unsigned short linktype;
701 702
 #define	HWADDR_OFFSET	10
702 703
 
704
+    if ( ! find_pci_device ( pci, &a3c90x_driver ) )
705
+	    return 0;
706
+    
703 707
     if (pci->ioaddr == 0)
704 708
           return 0;
705 709
 
706
-    adjust_pci_device(pci);
707
-
708
-    nic->ioaddr = pci->ioaddr & ~3;
710
+    nic->ioaddr = pci->ioaddr;
709 711
     nic->irqno = 0;
710 712
 
711 713
     INF_3C90X.IOAddr = pci->ioaddr & ~3;
@@ -951,18 +953,17 @@ static int a3c90x_probe ( struct dev *dev ) {
951 953
                                  cmdAcknowledgeInterrupt, 0x661);
952 954
 
953 955
     /** Set our exported functions **/
954
-static struct nic_operations a3c90x_operations;
956
+    nic->nic_op	= &a3c90x_operations;
957
+    return 1;
958
+}
959
+
955 960
 static struct nic_operations a3c90x_operations = {
956 961
 	.connect	= dummy_connect,
957 962
 	.poll		= a3c90x_poll,
958 963
 	.transmit	= a3c90x_transmit,
959 964
 	.irq		= a3c90x_irq,
960 965
 	.disable	= a3c90x_disable,
961
-};    nic->nic_op	= &a3c90x_operations;
962
-
963
-    return 1;
964
-}
965
-
966
+};
966 967
 
967 968
 static struct pci_id a3c90x_nics[] = {
968 969
 /* Original 90x revisions: */

+ 13
- 10
src/drivers/net/davicom.c 查看文件

@@ -129,6 +129,9 @@ struct rxdesc {
129 129
 /* Global Storage                                                    */
130 130
 /*********************************************************************/
131 131
 
132
+static struct nic_operations davicom_operations;
133
+static struct pci_driver davicom_driver;
134
+
132 135
 /* PCI Bus parameters */
133 136
 static unsigned short vendor, dev_id;
134 137
 static unsigned long ioaddr;
@@ -653,26 +656,27 @@ static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
653 656
 /* eth_probe - Look for an adapter                                   */
654 657
 /*********************************************************************/
655 658
 static int davicom_probe ( struct dev *dev ) {
656
-
657 659
   struct nic *nic = nic_device ( dev );
658
-
659 660
   struct pci_device *pci = pci_device ( dev );
660 661
   unsigned int i;
661 662
 
662 663
   whereami("davicom_probe\n");
663 664
 
665
+  if ( ! find_pci_device ( pci, &davicom_driver ) )
666
+	  return 0;
667
+
664 668
   if (pci->ioaddr == 0)
665 669
     return 0;
666 670
 
667 671
   vendor  = pci->vendor;
668 672
   dev_id  = pci->dev_id;
669
-  ioaddr  = pci->ioaddr & ~3;
673
+  ioaddr  = pci->ioaddr;
670 674
 
671 675
   nic->irqno  = 0;
672
-  nic->ioaddr = pci->ioaddr & ~3;
676
+  nic->ioaddr = pci->ioaddr;
673 677
 
674 678
   /* wakeup chip */
675
-  pcibios_write_config_dword(pci->bus, pci->devfn, 0x40, 0x00000000);
679
+  pci_write_config_dword(pci, 0x40, 0x00000000);
676 680
 
677 681
   /* Stop the chip's Tx and Rx processes. */
678 682
   outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
@@ -694,7 +698,10 @@ static int davicom_probe ( struct dev *dev ) {
694 698
 
695 699
   /* initialize device */
696 700
   davicom_reset(nic);
697
-static struct nic_operations davicom_operations;
701
+  nic->nic_op	= &davicom_operations;
702
+  return 1;
703
+}
704
+
698 705
 static struct nic_operations davicom_operations = {
699 706
 	.connect	= dummy_connect,
700 707
 	.poll		= davicom_poll,
@@ -702,10 +709,6 @@ static struct nic_operations davicom_operations = {
702 709
 	.irq		= davicom_irq,
703 710
 	.disable	= davicom_disable,
704 711
 };
705
-  nic->nic_op	= &davicom_operations;
706
-
707
-  return 1;
708
-}
709 712
 
710 713
 static struct pci_id davicom_nics[] = {
711 714
 PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100"),

+ 22
- 20
src/drivers/net/dmfe.c 查看文件

@@ -195,12 +195,13 @@ enum dmfe_CR6_bits {
195 195
 };
196 196
 
197 197
 /* Global variable declaration ----------------------------- */
198
-static int dmfe_debug;
198
+static struct nic_operations dmfe_operations;
199
+static struct pci_driver dmfe_driver;
200
+
199 201
 static unsigned char dmfe_media_mode = DMFE_AUTO;
200 202
 static u32 dmfe_cr6_user_set;
201 203
 
202 204
 /* For module input parameter */
203
-static int debug;
204 205
 static u8 chkmode = 1;
205 206
 static u8 HPNA_mode;		/* Default: Low Power/High Speed */
206 207
 static u8 HPNA_rx_cmd;		/* Default: Disable Rx remote command */
@@ -245,8 +246,6 @@ static u16 phy_read(unsigned long, u8, u8, u32);
245 246
 static void phy_write(unsigned long, u8, u8, u16, u32);
246 247
 static void phy_write_1bit(unsigned long, u32);
247 248
 static u16 phy_read_1bit(unsigned long);
248
-static u8 dmfe_sense_speed(struct nic *nic);
249
-static void dmfe_process_mode(struct nic *nic);
250 249
 static void dmfe_set_phyxcer(struct nic *nic);
251 250
 
252 251
 static void dmfe_parse_srom(struct nic *nic);
@@ -461,19 +460,20 @@ PROBE - Look for an adapter, this routine's visible to the outside
461 460
 #define board_found 1
462 461
 #define valid_link 0
463 462
 static int dmfe_probe ( struct dev *dev ) {
464
-
465 463
 	struct nic *nic = nic_device ( dev );
466
-
467 464
 	struct pci_device *pci = pci_device ( dev );
468 465
 	uint32_t dev_rev, pci_pmr;
469 466
 	int i;
470 467
 
468
+	if ( ! find_pci_device ( pci, &dmfe_driver ) )
469
+		return 0;
470
+
471 471
 	if (pci->ioaddr == 0)
472 472
 		return 0;
473 473
 
474 474
 	BASE = pci->ioaddr;
475 475
 	printf("dmfe.c: Found %s Vendor=0x%hX Device=0x%hX\n",
476
-	       pci->name, pci->vendor, pci->dev_id);
476
+	       dev->name, pci->vendor, pci->dev_id);
477 477
 
478 478
 	/* Read Chip revision */
479 479
 	pci_read_config_dword(pci, PCI_REVISION_ID, &dev_rev);
@@ -504,7 +504,7 @@ static int dmfe_probe ( struct dev *dev ) {
504 504
 		nic->node_addr[i] = db->srom[20 + i];
505 505
 
506 506
 	/* Print out some hardware info */
507
-	printf("%s: %! at ioaddr %hX\n", pci->name, nic->node_addr, BASE);
507
+	printf("%s: %! at ioaddr %hX\n", dev->name, nic->node_addr, BASE);
508 508
 
509 509
 	/* Set the card as PCI Bus Master */
510 510
 	adjust_pci_device(pci);
@@ -515,14 +515,7 @@ static int dmfe_probe ( struct dev *dev ) {
515 515
 	nic->ioaddr = pci->ioaddr;
516 516
 
517 517
 	/* point to NIC specific routines */
518
-static struct nic_operations dmfe_operations;
519
-static struct nic_operations dmfe_operations = {
520
-	.connect	= dummy_connect,
521
-	.poll		= dmfe_poll,
522
-	.transmit	= dmfe_transmit,
523
-	.irq		= dmfe_irq,
524
-	.disable	= dmfe_disable,
525
-};	nic->nic_op	= &dmfe_operations;
518
+	nic->nic_op	= &dmfe_operations;
526 519
 
527 520
 	return 1;
528 521
 }
@@ -551,7 +544,7 @@ static void dmfe_descriptor_init(struct nic *nic __unused, unsigned long ioaddr)
551 544
 		txd[i].tdes1 = cpu_to_le32(0x81000000);	/* IC, chain */
552 545
 		txd[i].tdes2 = cpu_to_le32(virt_to_bus(&txb[i]));
553 546
 		txd[i].tdes3 = cpu_to_le32(virt_to_bus(&txd[i + 1]));
554
-		txd[i].next_tx_desc = cpu_to_le32(&txd[i + 1]);	
547
+		txd[i].next_tx_desc = virt_to_le32desc(&txd[i + 1]);	
555 548
 	}
556 549
 	/* Mark the last entry as wrapping the ring */
557 550
 	txd[i - 1].tdes3 = virt_to_le32desc(&txd[0]);
@@ -565,7 +558,7 @@ static void dmfe_descriptor_init(struct nic *nic __unused, unsigned long ioaddr)
565 558
 		rxd[i].rdes2 =
566 559
 		    cpu_to_le32(virt_to_bus(&rxb[i * RX_ALLOC_SIZE]));
567 560
 		rxd[i].rdes3 = cpu_to_le32(virt_to_bus(&rxd[i + 1]));
568
-		rxd[i].next_rx_desc = cpu_to_le32(&rxd[i + 1]);
561
+		rxd[i].next_rx_desc = virt_to_le32desc(&rxd[i + 1]);
569 562
 	}
570 563
 	/* Mark the last entry as wrapping the ring */
571 564
 	rxd[i - 1].rdes3 = cpu_to_le32(virt_to_bus(&rxd[0]));
@@ -722,6 +715,7 @@ static u16 read_srom_word(long ioaddr, int offset)
722 715
  *	Auto sense the media mode
723 716
  */
724 717
 
718
+#if 0 /* not used */
725 719
 static u8 dmfe_sense_speed(struct nic *nic __unused)
726 720
 {
727 721
 	u8 ErrFlag = 0;
@@ -769,7 +763,7 @@ static u8 dmfe_sense_speed(struct nic *nic __unused)
769 763
 
770 764
 	return ErrFlag;
771 765
 }
772
-
766
+#endif
773 767
 
774 768
 /*
775 769
  *	Set 10/100 phyxcer capability
@@ -841,6 +835,7 @@ static void dmfe_set_phyxcer(struct nic *nic __unused)
841 835
  *			N-way force capability with SWITCH
842 836
  */
843 837
 
838
+#if 0 /* not used */
844 839
 static void dmfe_process_mode(struct nic *nic __unused)
845 840
 {
846 841
 	u16 phy_reg;
@@ -890,7 +885,7 @@ static void dmfe_process_mode(struct nic *nic __unused)
890 885
 		}
891 886
 	}
892 887
 }
893
-
888
+#endif
894 889
 
895 890
 /*
896 891
  *	Write a word to Phy register
@@ -1217,6 +1212,13 @@ static void dmfe_program_DM9802(struct nic *nic __unused)
1217 1212
 	phy_write(BASE, db->phy_addr, 25, phy_reg, db->chip_id);
1218 1213
 }
1219 1214
 
1215
+static struct nic_operations dmfe_operations = {
1216
+	.connect	= dummy_connect,
1217
+	.poll		= dmfe_poll,
1218
+	.transmit	= dmfe_transmit,
1219
+	.irq		= dmfe_irq,
1220
+	.disable	= dmfe_disable,
1221
+};
1220 1222
 
1221 1223
 static struct pci_id dmfe_nics[] = {
1222 1224
 	PCI_ROM(0x1282, 0x9100, "dmfe9100", "Davicom 9100"),

Loading…
取消
儲存