Преглед изворни кода

Finished by hand

tags/v0.9.3
Michael Brown пре 19 година
родитељ
комит
7cc6366a84
3 измењених фајлова са 104 додато и 113 уклоњено
  1. 13
    113
      src/drivers/net/prism2.c
  2. 18
    0
      src/drivers/net/prism2_pci.c
  3. 73
    0
      src/drivers/net/prism2_plx.c

+ 13
- 113
src/drivers/net/prism2.c Прегледај датотеку

@@ -161,12 +161,6 @@ typedef struct wlan_80211hdr
161 161
  * Function prototypes
162 162
  */
163 163
 
164
-#if (WLAN_HOSTIF == WLAN_PLX)
165
-static int prism2_find_plx ( hfa384x_t *hw, struct pci_device *p );
166
-#elif (WLAN_HOSTIF == WLAN_PCI)
167
-static int prism2_find_pci ( hfa384x_t *hw, struct pci_device *p );
168
-#endif
169
-
170 164
 /*
171 165
  * Hardware-level hfa384x functions
172 166
  * These are based on the ones in hfa384x.h (which are ifdef'd out since __KERNEL__ is not defined).
@@ -746,18 +740,22 @@ static void prism2_irq(struct nic *nic __unused, irq_action_t action __unused)
746 740
   }
747 741
 }
748 742
 
743
+/**************************************************************************
744
+Operations table
745
+***************************************************************************/
746
+static struct nic_operations prism2_operations = {
747
+	.connect	= dummy_connect,
748
+	.poll		= prism2_poll,
749
+	.transmit	= prism2_transmit,
750
+	.irq		= prism2_irq,
751
+	.disable	= prism2_disable,
752
+};
753
+
749 754
 /**************************************************************************
750 755
 PROBE - Look for an adapter, this routine's visible to the outside
751 756
 You should omit the last argument struct pci_device * for a non-PCI NIC
752 757
 ***************************************************************************/
753
-#if (WLAN_HOSTIF == WLAN_PLX)
754
-static int prism2_plx_probe(struct dev *dev, struct pci_device *p)
755
-#elif (WLAN_HOSTIF == WLAN_PCI)
756
-static int prism2_pci_probe(struct dev *dev, struct pci_device *p)
757
-#endif
758
-{
759
-  struct nic *nic = (struct nic *)dev;
760
-  hfa384x_t *hw = &hw_global;
758
+static int prism2_probe ( struct nic *nic, hfa384x_t *hw ) {
761 759
   int result;
762 760
   UINT16 tmp16 = 0;
763 761
   UINT16 infofid;
@@ -765,15 +763,6 @@ static int prism2_pci_probe(struct dev *dev, struct pci_device *p)
765 763
   char ssid[HFA384x_RID_CNFDESIREDSSID_LEN];
766 764
   int info_count = 0;
767 765
 
768
-  /* Find and intialise PLX Prism2 card */
769
-#if (WLAN_HOSTIF == WLAN_PLX)
770
-  if ( ! prism2_find_plx ( hw, p ) ) return 0;
771
-  nic->ioaddr = hw->iobase;
772
-#elif (WLAN_HOSTIF == WLAN_PCI)
773
-  if ( ! prism2_find_pci ( hw, p ) ) return 0;
774
-  nic->ioaddr = hw->membase;
775
-#endif
776
-
777 766
   nic->irqno  = 0;
778 767
 
779 768
   /* Initialize card */
@@ -856,96 +845,7 @@ static int prism2_pci_probe(struct dev *dev, struct pci_device *p)
856 845
   printf ( "Link connected (BSSID %! - MAC address %!)\n", hw->bssid, nic->node_addr );
857 846
   
858 847
   /* point to NIC specific routines */
859
-static struct nic_operations prism2_operations;
860
-static struct nic_operations prism2_operations = {
861
-	.connect	= dummy_connect,
862
-	.poll		= prism2_poll,
863
-	.transmit	= prism2_transmit,
864
-	.irq		= prism2_irq,
865
-	.disable	= prism2_disable,
866
-};  nic->nic_op	= &prism2_operations;
867
-  return 1;
868
-}
869
-
870
-#if (WLAN_HOSTIF == WLAN_PLX)
871
-/*
872
- * Find PLX card.  Prints out information strings from PCMCIA CIS as visual
873
- * confirmation of presence of card.
874
- *
875
- * Arguments:
876
- *	hw		device structure to be filled in
877
- *      p               PCI device structure
878
- *
879
- * Returns:
880
- *      1               Success
881
- */
882
-static int prism2_find_plx ( hfa384x_t *hw, struct pci_device *p )
883
-{
884
-  int found = 0;
885
-  uint32_t plx_lcr  = 0; /* PLX9052 Local Configuration Register Base (I/O) */
886
-  uint32_t attr_mem = 0; /* Prism2 Attribute Memory Base */
887
-  uint32_t iobase   = 0; /* Prism2 I/O Base */
888
-  unsigned char *cis_tpl  = NULL;
889
-  unsigned char *cis_string;
890
-  
891
-  /* Obtain all memory and IO base addresses */
892
-  pcibios_read_config_dword( p->bus, p->devfn, PLX_LOCAL_CONFIG_REGISTER_BASE, &plx_lcr);
893
-  plx_lcr &= PCI_BASE_ADDRESS_IO_MASK;
894
-  pcibios_read_config_dword( p->bus, p->devfn, PRISM2_PLX_ATTR_MEM_BASE, &attr_mem);
895
-  pcibios_read_config_dword( p->bus, p->devfn, PRISM2_PLX_IO_BASE, &iobase);
896
-  iobase &= PCI_BASE_ADDRESS_IO_MASK;
897
-
898
-  /* Fill out hw structure */
899
-  hw->membase = attr_mem;
900
-  hw->iobase = iobase;
901
-  printf ( "PLX9052 has local config registers at %#hx\n", plx_lcr );
902
-  printf ( "Prism2 has attribute memory at %#x and I/O base at %#hx\n", attr_mem, iobase );
903
-
904
-  /* Search for CIS strings */
905
-  printf ( "Searching for PCMCIA card...\n" );
906
-  cis_tpl = bus_to_virt(attr_mem);
907
-  while ( *cis_tpl != CISTPL_END ) {
908
-    if ( *cis_tpl == CISTPL_VERS_1 ) {
909
-      /* CISTPL_VERS_1 contains some nice text strings */
910
-      printf ( "...found " );
911
-      found = 1;
912
-      cis_string = cis_tpl + CISTPL_VERS_1_STR_OFF;
913
-      while ( ! ( ( *cis_string == 0 ) && ( *(cis_string+CIS_STEP) == 0 ) ) ) {
914
-	printf ( "%c", *cis_string == 0 ? ' ' : *cis_string );
915
-	cis_string += CIS_STEP;
916
-      }
917
-      printf ( "\n" );
918
-    }
919
-    /* printf ( "CIS tuple type %#hhx, length %#hhx\n", *cis_tpl, *(cis_tpl+CISTPL_LEN_OFF) ); */
920
-    cis_tpl += CISTPL_HEADER_LEN + CIS_STEP * ( *(cis_tpl+CISTPL_LEN_OFF) );
921
-  }
922
-  if ( found == 0 ) {
923
-    printf ( "...nothing found\n" );
924
-  }
925
-  ((unsigned char *)bus_to_virt(attr_mem))[COR_OFFSET] = COR_VALUE; /* Write COR to enable PC card */
926
-  return found;
927
-}
928
-#endif /* WLAN_PLX */
929
-
930
-#if (WLAN_HOSTIF == WLAN_PCI)
931
-/*
932
- * Find PCI card.
933
- *
934
- * Arguments:
935
- *	hw		device structure to be filled in
936
- *      p               PCI device structure
937
- *
938
- * Returns:
939
- *      1               Success
940
- */
941
-static int prism2_find_pci ( hfa384x_t *hw, struct pci_device *p )
942
-{
943
-  uint32_t membase = 0; /* Prism2.5 Memory Base */
944
-  pcibios_read_config_dword( p->bus, p->devfn, PRISM2_PCI_MEM_BASE, &membase);
945
-  membase &= PCI_BASE_ADDRESS_MEM_MASK;
946
-  hw->membase = (uint32_t) phys_to_virt(membase);
947
-  printf ( "Prism2.5 has registers at %#x\n", hw->membase );
848
+  nic->nic_op	= &prism2_operations;
948 849
   return 1;
949 850
 }
950
-#endif /* WLAN_PCI */
951 851
 

+ 18
- 0
src/drivers/net/prism2_pci.c Прегледај датотеку

@@ -26,5 +26,23 @@ PCI_ROM(0x1260, 0x3873, "dwl520",	"DLink DWL-520"),
26 26
 static struct pci_driver prism2_pci_driver =
27 27
 	PCI_DRIVER ( "Prism2_PCI", prism2_pci_nics, PCI_NO_CLASS );
28 28
 
29
+static int prism2_pci_probe ( struct dev *dev ) {
30
+  struct nic *nic = nic_device ( dev );
31
+  struct pci_device *pci = pci_device ( dev );
32
+  hfa384x_t *hw = &hw_global;
33
+  uint32_t membase = 0; /* Prism2.5 Memory Base */
34
+
35
+  if ( ! find_pci_device ( pci, &prism2_pci_driver ) )
36
+	  return 0;
37
+
38
+  pci_read_config_dword( pci, PRISM2_PCI_MEM_BASE, &membase);
39
+  membase &= PCI_BASE_ADDRESS_MEM_MASK;
40
+  hw->membase = (uint32_t) phys_to_virt(membase);
41
+  printf ( "Prism2.5 has registers at %#x\n", hw->membase );
42
+  nic->ioaddr = hw->membase;
43
+
44
+  return prism2_probe ( nic, hw );
45
+}   
46
+
29 47
 BOOT_DRIVER ( "Prism2_PCI", prism2_pci_probe );
30 48
 

+ 73
- 0
src/drivers/net/prism2_plx.c Прегледај датотеку

@@ -34,5 +34,78 @@ PCI_ROM(0x126c, 0x8030, "emobility",     "Nortel emobility"),
34 34
 static struct pci_driver prism2_plx_driver =
35 35
 	PCI_DRIVER ( "Prism2_PLX", prism2_plx_nics, PCI_NO_CLASS );
36 36
 
37
+/*
38
+ * Find PLX card.  Prints out information strings from PCMCIA CIS as visual
39
+ * confirmation of presence of card.
40
+ *
41
+ * Arguments:
42
+ *	hw		device structure to be filled in
43
+ *      p               PCI device structure
44
+ *
45
+ * Returns:
46
+ *      1               Success
47
+ */
48
+static int prism2_find_plx ( hfa384x_t *hw, struct pci_device *p )
49
+{
50
+  int found = 0;
51
+  uint32_t plx_lcr  = 0; /* PLX9052 Local Configuration Register Base (I/O) */
52
+  uint32_t attr_mem = 0; /* Prism2 Attribute Memory Base */
53
+  uint32_t iobase   = 0; /* Prism2 I/O Base */
54
+  unsigned char *cis_tpl  = NULL;
55
+  unsigned char *cis_string;
56
+  
57
+  /* Obtain all memory and IO base addresses */
58
+  pci_read_config_dword( p, PLX_LOCAL_CONFIG_REGISTER_BASE, &plx_lcr);
59
+  plx_lcr &= PCI_BASE_ADDRESS_IO_MASK;
60
+  pci_read_config_dword( p, PRISM2_PLX_ATTR_MEM_BASE, &attr_mem);
61
+  pci_read_config_dword( p, PRISM2_PLX_IO_BASE, &iobase);
62
+  iobase &= PCI_BASE_ADDRESS_IO_MASK;
63
+
64
+  /* Fill out hw structure */
65
+  hw->membase = attr_mem;
66
+  hw->iobase = iobase;
67
+  printf ( "PLX9052 has local config registers at %#hx\n", plx_lcr );
68
+  printf ( "Prism2 has attribute memory at %#x and I/O base at %#hx\n", attr_mem, iobase );
69
+
70
+  /* Search for CIS strings */
71
+  printf ( "Searching for PCMCIA card...\n" );
72
+  cis_tpl = bus_to_virt(attr_mem);
73
+  while ( *cis_tpl != CISTPL_END ) {
74
+    if ( *cis_tpl == CISTPL_VERS_1 ) {
75
+      /* CISTPL_VERS_1 contains some nice text strings */
76
+      printf ( "...found " );
77
+      found = 1;
78
+      cis_string = cis_tpl + CISTPL_VERS_1_STR_OFF;
79
+      while ( ! ( ( *cis_string == 0 ) && ( *(cis_string+CIS_STEP) == 0 ) ) ) {
80
+	printf ( "%c", *cis_string == 0 ? ' ' : *cis_string );
81
+	cis_string += CIS_STEP;
82
+      }
83
+      printf ( "\n" );
84
+    }
85
+    /* printf ( "CIS tuple type %#hhx, length %#hhx\n", *cis_tpl, *(cis_tpl+CISTPL_LEN_OFF) ); */
86
+    cis_tpl += CISTPL_HEADER_LEN + CIS_STEP * ( *(cis_tpl+CISTPL_LEN_OFF) );
87
+  }
88
+  if ( found == 0 ) {
89
+    printf ( "...nothing found\n" );
90
+  }
91
+  ((unsigned char *)bus_to_virt(attr_mem))[COR_OFFSET] = COR_VALUE; /* Write COR to enable PC card */
92
+  return found;
93
+}
94
+
95
+static int prism2_plx_probe ( struct dev *dev ) {
96
+  struct nic *nic = nic_device ( dev );
97
+  struct pci_device *pci = pci_device ( dev );
98
+  hfa384x_t *hw = &hw_global;
99
+
100
+  if ( ! find_pci_device ( pci, &prism2_plx_driver ) )
101
+	  return 0;
102
+
103
+  /* Find and intialise PLX Prism2 card */
104
+  if ( ! prism2_find_plx ( hw, pci ) ) return 0;
105
+  nic->ioaddr = hw->iobase;
106
+
107
+  return prism2_probe ( nic, hw );
108
+}
109
+
37 110
 BOOT_DRIVER ( "Prism2_PLX", prism2_plx_probe );
38 111
 

Loading…
Откажи
Сачувај