Browse Source

Added a very quick and dirty compatibility layer, to allow

not-yet-updated drivers to at least function.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
286bf68faf

+ 2
- 9
src/core/nic.c View File

388
 	.load			= nic_load,
388
 	.load			= nic_load,
389
 };
389
 };
390
 
390
 
391
+#if 0
391
 /* Careful.  We need an aligned buffer to avoid problems on machines
392
 /* Careful.  We need an aligned buffer to avoid problems on machines
392
  * that care about alignment.  To trivally align the ethernet data
393
  * that care about alignment.  To trivally align the ethernet data
393
  * (the ip hdr and arp requests) we offset the packet by 2 bytes.
394
  * (the ip hdr and arp requests) we offset the packet by 2 bytes.
400
 	.node_addr = arptable[ARP_CLIENT].node,
401
 	.node_addr = arptable[ARP_CLIENT].node,
401
 	.packet = packet + ETH_DATA_ALIGN,
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
 DEFAULT_NETMASK - Return default netmask for IP address
408
 DEFAULT_NETMASK - Return default netmask for IP address
416
 **************************************************************************/
409
 **************************************************************************/

+ 1
- 0
src/drivers/net/3c509.c View File

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

+ 0
- 1
src/drivers/net/3c595.c View File

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

+ 0
- 1
src/drivers/net/3c90x.c View File

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

+ 0
- 1
src/drivers/net/davicom.c View File

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

+ 0
- 1
src/drivers/net/dmfe.c View File

189
 
189
 
190
 /* Global variable declaration ----------------------------- */
190
 /* Global variable declaration ----------------------------- */
191
 static struct nic_operations dmfe_operations;
191
 static struct nic_operations dmfe_operations;
192
-static struct pci_driver dmfe_driver;
193
 
192
 
194
 static unsigned char dmfe_media_mode = DMFE_AUTO;
193
 static unsigned char dmfe_media_mode = DMFE_AUTO;
195
 static u32 dmfe_cr6_user_set;
194
 static u32 dmfe_cr6_user_set;

+ 0
- 1
src/drivers/net/e1000.c View File

89
 
89
 
90
 /* NIC specific static variables go here */
90
 /* NIC specific static variables go here */
91
 static struct nic_operations e1000_operations;
91
 static struct nic_operations e1000_operations;
92
-static struct pci_driver e1000_driver;
93
 
92
 
94
 static struct e1000_hw hw;
93
 static struct e1000_hw hw;
95
 
94
 

+ 0
- 1
src/drivers/net/eepro100.c View File

252
 };
252
 };
253
 
253
 
254
 static struct nic_operations eepro100_operations;
254
 static struct nic_operations eepro100_operations;
255
-static struct pci_driver eepro100_driver;
256
 
255
 
257
 #define RXFD_COUNT 4
256
 #define RXFD_COUNT 4
258
 struct {
257
 struct {

+ 0
- 1
src/drivers/net/epic100.c View File

61
 static void     epic100_irq(struct nic *nic, irq_action_t action);
61
 static void     epic100_irq(struct nic *nic, irq_action_t action);
62
 
62
 
63
 static struct nic_operations epic100_operations;
63
 static struct nic_operations epic100_operations;
64
-static struct pci_driver epic100_driver;
65
 
64
 
66
 static int	ioaddr;
65
 static int	ioaddr;
67
 
66
 

+ 104
- 0
src/drivers/net/legacy.c View File

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 View File

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

+ 0
- 1
src/drivers/net/pcnet32.c View File

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

+ 1
- 0
src/drivers/net/sis900.c View File

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

+ 0
- 1
src/drivers/net/sundance.c View File

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

+ 0
- 2
src/drivers/net/tlan.c View File

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

+ 0
- 1
src/drivers/net/via-rhine.c View File

957
 }
957
 }
958
 
958
 
959
 static struct nic_operations rhine_operations;
959
 static struct nic_operations rhine_operations;
960
-static struct pci_driver rhine_driver;
961
 
960
 
962
 static int
961
 static int
963
 rhine_probe ( struct nic *nic, struct pci_device *pci ) {
962
 rhine_probe ( struct nic *nic, struct pci_device *pci ) {

+ 37
- 27
src/include/nic.h View File

8
 #ifndef	NIC_H
8
 #ifndef	NIC_H
9
 #define NIC_H
9
 #define NIC_H
10
 
10
 
11
-#include "dev.h"
12
-#include "byteswap.h"
11
+#include <byteswap.h>
12
+#include <gpxe/pci.h>
13
 #include "dhcp.h"
13
 #include "dhcp.h"
14
 
14
 
15
 typedef enum {
15
 typedef enum {
49
 	void ( *irq ) ( struct nic *, irq_action_t );
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
 extern struct nic nic;
52
 extern struct nic nic;
68
 
53
 
69
-static inline int eth_connect ( void ) {
70
-	return nic.nic_op->connect ( &nic );
71
-}
72
-
73
 static inline int eth_poll ( int retrieve ) {
54
 static inline int eth_poll ( int retrieve ) {
74
 	return nic.nic_op->poll ( &nic, retrieve );
55
 	return nic.nic_op->poll ( &nic, retrieve );
75
 }
56
 }
79
 	nic.nic_op->transmit ( &nic, dest, type, size, packet );
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
 #endif	/* NIC_H */
99
 #endif	/* NIC_H */

Loading…
Cancel
Save