Quellcode durchsuchen

Added a very quick and dirty compatibility layer, to allow

not-yet-updated drivers to at least function.
tags/v0.9.3
Michael Brown vor 18 Jahren
Ursprung
Commit
286bf68faf

+ 2
- 9
src/core/nic.c Datei anzeigen

@@ -388,6 +388,7 @@ struct type_driver nic_driver = {
388 388
 	.load			= nic_load,
389 389
 };
390 390
 
391
+#if 0
391 392
 /* Careful.  We need an aligned buffer to avoid problems on machines
392 393
  * that care about alignment.  To trivally align the ethernet data
393 394
  * (the ip hdr and arp requests) we offset the packet by 2 bytes.
@@ -400,17 +401,9 @@ struct nic nic = {
400 401
 	.node_addr = arptable[ARP_CLIENT].node,
401 402
 	.packet = packet + ETH_DATA_ALIGN,
402 403
 };
404
+#endif
403 405
 
404 406
 
405
-
406
-int dummy_connect ( struct nic *nic __unused ) {
407
-	return 1;
408
-}
409
-
410
-void dummy_irq ( struct nic *nic __unused, irq_action_t irq_action __unused ) {
411
-	return;
412
-}
413
-
414 407
 /**************************************************************************
415 408
 DEFAULT_NETMASK - Return default netmask for IP address
416 409
 **************************************************************************/

+ 1
- 0
src/drivers/net/3c509.c Datei anzeigen

@@ -9,6 +9,7 @@
9 9
 #include "timer.h"
10 10
 #include "string.h"
11 11
 #include "console.h"
12
+#include "dev.h"
12 13
 #include "3c509.h"
13 14
 
14 15
 /*

+ 0
- 1
src/drivers/net/3c595.c Datei anzeigen

@@ -32,7 +32,6 @@
32 32
 #include "timer.h"
33 33
 
34 34
 static struct nic_operations t595_operations;
35
-static struct pci_driver t595_driver;
36 35
 
37 36
 static unsigned short	eth_nic_base;
38 37
 static unsigned short	vx_connector, vx_connectors;

+ 0
- 1
src/drivers/net/3c90x.c Datei anzeigen

@@ -43,7 +43,6 @@
43 43
 #include "timer.h"
44 44
 
45 45
 static struct nic_operations a3c90x_operations;
46
-static struct pci_driver a3c90x_driver;
47 46
 
48 47
 #define	XCVR_MAGIC	(0x5A00)
49 48
 /** any single transmission fails after 16 collisions or other errors

+ 0
- 1
src/drivers/net/davicom.c Datei anzeigen

@@ -123,7 +123,6 @@ struct rxdesc {
123 123
 /*********************************************************************/
124 124
 
125 125
 static struct nic_operations davicom_operations;
126
-static struct pci_driver davicom_driver;
127 126
 
128 127
 /* PCI Bus parameters */
129 128
 static unsigned short vendor, dev_id;

+ 0
- 1
src/drivers/net/dmfe.c Datei anzeigen

@@ -189,7 +189,6 @@ enum dmfe_CR6_bits {
189 189
 
190 190
 /* Global variable declaration ----------------------------- */
191 191
 static struct nic_operations dmfe_operations;
192
-static struct pci_driver dmfe_driver;
193 192
 
194 193
 static unsigned char dmfe_media_mode = DMFE_AUTO;
195 194
 static u32 dmfe_cr6_user_set;

+ 0
- 1
src/drivers/net/e1000.c Datei anzeigen

@@ -89,7 +89,6 @@ typedef enum {
89 89
 
90 90
 /* NIC specific static variables go here */
91 91
 static struct nic_operations e1000_operations;
92
-static struct pci_driver e1000_driver;
93 92
 
94 93
 static struct e1000_hw hw;
95 94
 

+ 0
- 1
src/drivers/net/eepro100.c Datei anzeigen

@@ -252,7 +252,6 @@ struct RxFD {               /* Receive frame descriptor. */
252 252
 };
253 253
 
254 254
 static struct nic_operations eepro100_operations;
255
-static struct pci_driver eepro100_driver;
256 255
 
257 256
 #define RXFD_COUNT 4
258 257
 struct {

+ 0
- 1
src/drivers/net/epic100.c Datei anzeigen

@@ -61,7 +61,6 @@ static int	mii_read(int phy_id, int location);
61 61
 static void     epic100_irq(struct nic *nic, irq_action_t action);
62 62
 
63 63
 static struct nic_operations epic100_operations;
64
-static struct pci_driver epic100_driver;
65 64
 
66 65
 static int	ioaddr;
67 66
 

+ 104
- 0
src/drivers/net/legacy.c Datei anzeigen

@@ -0,0 +1,104 @@
1
+#include <stdint.h>
2
+#include <errno.h>
3
+#include <gpxe/if_ether.h>
4
+#include <gpxe/netdevice.h>
5
+#include <gpxe/ethernet.h>
6
+#include <gpxe/pkbuff.h>
7
+#include <nic.h>
8
+
9
+/*
10
+ * Quick and dirty compatibility layer
11
+ *
12
+ * This should allow old-API PCI drivers to at least function until
13
+ * they are updated.  It will not help non-PCI drivers.
14
+ *
15
+ * No drivers should rely on this code.  It will be removed asap.
16
+ *
17
+ */
18
+
19
+struct nic nic;
20
+
21
+static int legacy_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
22
+	struct nic *nic = netdev->priv;
23
+	struct ethhdr *ethhdr = pkb->data;
24
+
25
+	pkb_pull ( pkb, sizeof ( *ethhdr ) );
26
+	nic->nic_op->transmit ( nic, ( const char * ) ethhdr->h_dest,
27
+				ntohs ( ethhdr->h_protocol ),
28
+				pkb_len ( pkb ), pkb->data );
29
+	free_pkb ( pkb );
30
+	return 0;
31
+}
32
+
33
+static void legacy_poll ( struct net_device *netdev ) {
34
+	struct nic *nic = netdev->priv;
35
+	struct pk_buff *pkb;
36
+
37
+	pkb = alloc_pkb ( ETH_FRAME_LEN );
38
+	if ( ! pkb )
39
+		return;
40
+
41
+	nic->packet = pkb->data;
42
+	if ( nic->nic_op->poll ( nic, 1 ) ) {
43
+		pkb_put ( pkb, nic->packetlen );
44
+		netdev_rx ( netdev, pkb );
45
+	} else {
46
+		free_pkb ( pkb );
47
+	}
48
+}
49
+
50
+int legacy_probe ( struct pci_device *pci,
51
+		   const struct pci_device_id *id __unused,
52
+		   int ( * probe ) ( struct nic *nic,
53
+				     struct pci_device *pci ),
54
+		   void ( * disable ) ( struct nic *nic ) ) {
55
+	struct net_device *netdev;
56
+	int rc;
57
+	
58
+	netdev = alloc_etherdev ( 0 );
59
+	if ( ! netdev )
60
+		return -ENOMEM;
61
+	netdev->priv = &nic;
62
+	memset ( &nic, 0, sizeof ( nic ) );
63
+	pci_set_drvdata ( pci, netdev );
64
+
65
+	netdev->transmit = legacy_transmit;
66
+	netdev->poll = legacy_poll;
67
+	nic.node_addr = netdev->ll_addr;
68
+
69
+	if ( ! probe ( &nic, pci ) ) {
70
+		free_netdev ( netdev );
71
+		return -ENODEV;
72
+	}
73
+
74
+	if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
75
+		disable ( &nic );
76
+		free_netdev ( netdev );
77
+		return rc;
78
+	}
79
+
80
+	return 0;
81
+}
82
+
83
+void legacy_remove ( struct pci_device *pci,
84
+		     void ( * disable ) ( struct nic *nic ) ) {
85
+	struct net_device *netdev = pci_get_drvdata ( pci );
86
+	struct nic *nic = netdev->priv;
87
+
88
+	unregister_netdev ( netdev );
89
+	disable ( nic );
90
+	free_netdev ( netdev );
91
+}
92
+
93
+void pci_fill_nic ( struct nic *nic, struct pci_device *pci ) {
94
+	nic->ioaddr = pci->ioaddr;
95
+	nic->irqno = pci->irq;
96
+}
97
+
98
+int dummy_connect ( struct nic *nic __unused ) {
99
+	return 1;
100
+}
101
+
102
+void dummy_irq ( struct nic *nic __unused, irq_action_t irq_action __unused ) {
103
+	return;
104
+}

+ 0
- 1
src/drivers/net/natsemi.c Datei anzeigen

@@ -175,7 +175,6 @@ enum desc_status_bits {
175 175
 /* Globals */
176 176
 
177 177
 static struct nic_operations natsemi_operations;
178
-static struct pci_driver natsemi_driver;
179 178
 
180 179
 static int natsemi_debug = 1;			/* 1 normal messages, 0 quiet .. 7 verbose. */
181 180
 

+ 0
- 1
src/drivers/net/pcnet32.c Datei anzeigen

@@ -56,7 +56,6 @@
56 56
 
57 57
 static u32 ioaddr;		/* Globally used for the card's io address */
58 58
 static struct nic_operations pcnet32_operations;
59
-static struct pci_driver pcnet32_driver;
60 59
 
61 60
 #ifdef EDEBUG
62 61
 #define dprintf(x) printf x

+ 1
- 0
src/drivers/net/sis900.c Datei anzeigen

@@ -47,6 +47,7 @@
47 47
 #include "nic.h"
48 48
 #include <gpxe/pci.h>
49 49
 #include "timer.h"
50
+#include "dev.h"
50 51
 
51 52
 #include "sis900.h"
52 53
 

+ 0
- 1
src/drivers/net/sundance.c Datei anzeigen

@@ -572,7 +572,6 @@ static struct nic_operations sundance_operations = {
572 572
 	.irq		= sundance_irq,
573 573
 
574 574
 };
575
-static struct pci_driver sundance_driver;
576 575
 
577 576
 /**************************************************************************
578 577
 PROBE - Look for an adapter, this routine's visible to the outside

+ 0
- 2
src/drivers/net/tlan.c Datei anzeigen

@@ -65,8 +65,6 @@
65 65
 #define dprintf(x)
66 66
 #endif
67 67
 
68
-static struct pci_driver tlan_driver;
69
-
70 68
 static void TLan_ResetLists(struct nic *nic __unused);
71 69
 static void TLan_ResetAdapter(struct nic *nic __unused);
72 70
 static void TLan_FinishReset(struct nic *nic __unused);

+ 0
- 1
src/drivers/net/via-rhine.c Datei anzeigen

@@ -957,7 +957,6 @@ void rhine_irq ( struct nic *nic, irq_action_t action ) {
957 957
 }
958 958
 
959 959
 static struct nic_operations rhine_operations;
960
-static struct pci_driver rhine_driver;
961 960
 
962 961
 static int
963 962
 rhine_probe ( struct nic *nic, struct pci_device *pci ) {

+ 37
- 27
src/include/nic.h Datei anzeigen

@@ -8,8 +8,8 @@
8 8
 #ifndef	NIC_H
9 9
 #define NIC_H
10 10
 
11
-#include "dev.h"
12
-#include "byteswap.h"
11
+#include <byteswap.h>
12
+#include <gpxe/pci.h>
13 13
 #include "dhcp.h"
14 14
 
15 15
 typedef enum {
@@ -49,27 +49,8 @@ struct nic_operations {
49 49
 	void ( *irq ) ( struct nic *, irq_action_t );
50 50
 };
51 51
 
52
-extern struct type_driver nic_driver;
53
-
54
-/*
55
- * Function prototypes
56
- *
57
- */
58
-extern int dummy_connect ( struct nic *nic );
59
-extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
60
-extern void nic_disable ( struct nic *nic );
61
-
62
-/*
63
- * Functions that implicitly operate on the current boot device
64
- *
65
- */
66
-
67 52
 extern struct nic nic;
68 53
 
69
-static inline int eth_connect ( void ) {
70
-	return nic.nic_op->connect ( &nic );
71
-}
72
-
73 54
 static inline int eth_poll ( int retrieve ) {
74 55
 	return nic.nic_op->poll ( &nic, retrieve );
75 56
 }
@@ -79,11 +60,40 @@ static inline void eth_transmit ( const char *dest, unsigned int type,
79 60
 	nic.nic_op->transmit ( &nic, dest, type, size, packet );
80 61
 }
81 62
 
82
-static inline void eth_irq ( irq_action_t action ) {
83
-	nic.nic_op->irq ( &nic, action );
84
-}
85
-
86
-/* Should be using disable() rather than eth_disable() */
87
-extern void eth_disable ( void ) __attribute__ (( deprecated ));
63
+/*
64
+ * Function prototypes
65
+ *
66
+ */
67
+extern int dummy_connect ( struct nic *nic );
68
+extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
69
+extern int legacy_probe ( struct pci_device *pci,
70
+			  const struct pci_device_id *id,
71
+			  int ( * probe ) ( struct nic *nic,
72
+					    struct pci_device *pci ),
73
+			  void ( * disable ) ( struct nic *nic ) );
74
+extern void legacy_remove ( struct pci_device *pci,
75
+			    void ( * disable ) ( struct nic *nic ) );
76
+extern void pci_fill_nic ( struct nic *nic, struct pci_device *pci );
77
+
78
+#define PCI_DRIVER(_name,_ids,_class) 					\
79
+	static int _name ## _legacy_probe ( struct pci_device *pci,	\
80
+					    const struct pci_device_id *id ); \
81
+	static void _name ## _legacy_remove ( struct pci_device *pci );	\
82
+	struct pci_driver _name __pci_driver = {			\
83
+		.ids = _ids,						\
84
+		.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
85
+		.probe = _name ## _legacy_probe,			\
86
+		.remove = _name ## _legacy_remove,			\
87
+	};
88
+
89
+#undef DRIVER
90
+#define DRIVER(_unused1,_unused2,_unused3,_name,_probe,_disable)	\
91
+	static int _name ## _legacy_probe ( struct pci_device *pci,	\
92
+					    const struct pci_device_id *id ) {\
93
+		return legacy_probe ( pci, id, _probe, _disable );	\
94
+	}								\
95
+	static void _name ## _legacy_remove ( struct pci_device *pci ) {\
96
+		return legacy_remove ( pci, _disable );			\
97
+	}
88 98
 
89 99
 #endif	/* NIC_H */

Laden…
Abbrechen
Speichern