summaryrefslogtreecommitdiffstats
path: root/src/drivers/net
diff options
context:
space:
mode:
authorMichael Brown2006-06-05 17:45:21 +0200
committerMichael Brown2006-06-05 17:45:21 +0200
commit286bf68faf8c712c1d5a9fd5dbedbcf142fb8cb5 (patch)
treeec6b5bc6cb4c839f7e8c428f5d3e9fa6e48a9231 /src/drivers/net
parentAdded soon-to-be-requisite missing include. (diff)
downloadipxe-286bf68faf8c712c1d5a9fd5dbedbcf142fb8cb5.tar.gz
ipxe-286bf68faf8c712c1d5a9fd5dbedbcf142fb8cb5.tar.xz
ipxe-286bf68faf8c712c1d5a9fd5dbedbcf142fb8cb5.zip
Added a very quick and dirty compatibility layer, to allow
not-yet-updated drivers to at least function.
Diffstat (limited to 'src/drivers/net')
-rw-r--r--src/drivers/net/3c509.c1
-rw-r--r--src/drivers/net/3c595.c1
-rw-r--r--src/drivers/net/3c90x.c1
-rw-r--r--src/drivers/net/davicom.c1
-rw-r--r--src/drivers/net/dmfe.c1
-rw-r--r--src/drivers/net/e1000.c1
-rw-r--r--src/drivers/net/eepro100.c1
-rw-r--r--src/drivers/net/epic100.c1
-rw-r--r--src/drivers/net/legacy.c104
-rw-r--r--src/drivers/net/natsemi.c1
-rw-r--r--src/drivers/net/pcnet32.c1
-rw-r--r--src/drivers/net/sis900.c1
-rw-r--r--src/drivers/net/sundance.c1
-rw-r--r--src/drivers/net/tlan.c2
-rw-r--r--src/drivers/net/via-rhine.c1
15 files changed, 106 insertions, 13 deletions
diff --git a/src/drivers/net/3c509.c b/src/drivers/net/3c509.c
index b27ee1f6..29701713 100644
--- a/src/drivers/net/3c509.c
+++ b/src/drivers/net/3c509.c
@@ -9,6 +9,7 @@
#include "timer.h"
#include "string.h"
#include "console.h"
+#include "dev.h"
#include "3c509.h"
/*
diff --git a/src/drivers/net/3c595.c b/src/drivers/net/3c595.c
index 8db1285e..464f080f 100644
--- a/src/drivers/net/3c595.c
+++ b/src/drivers/net/3c595.c
@@ -32,7 +32,6 @@
#include "timer.h"
static struct nic_operations t595_operations;
-static struct pci_driver t595_driver;
static unsigned short eth_nic_base;
static unsigned short vx_connector, vx_connectors;
diff --git a/src/drivers/net/3c90x.c b/src/drivers/net/3c90x.c
index 0fb79a49..b7ac4cfb 100644
--- a/src/drivers/net/3c90x.c
+++ b/src/drivers/net/3c90x.c
@@ -43,7 +43,6 @@
#include "timer.h"
static struct nic_operations a3c90x_operations;
-static struct pci_driver a3c90x_driver;
#define XCVR_MAGIC (0x5A00)
/** any single transmission fails after 16 collisions or other errors
diff --git a/src/drivers/net/davicom.c b/src/drivers/net/davicom.c
index 0931d13f..3a470c83 100644
--- a/src/drivers/net/davicom.c
+++ b/src/drivers/net/davicom.c
@@ -123,7 +123,6 @@ struct rxdesc {
/*********************************************************************/
static struct nic_operations davicom_operations;
-static struct pci_driver davicom_driver;
/* PCI Bus parameters */
static unsigned short vendor, dev_id;
diff --git a/src/drivers/net/dmfe.c b/src/drivers/net/dmfe.c
index 4c822724..50d96ece 100644
--- a/src/drivers/net/dmfe.c
+++ b/src/drivers/net/dmfe.c
@@ -189,7 +189,6 @@ enum dmfe_CR6_bits {
/* Global variable declaration ----------------------------- */
static struct nic_operations dmfe_operations;
-static struct pci_driver dmfe_driver;
static unsigned char dmfe_media_mode = DMFE_AUTO;
static u32 dmfe_cr6_user_set;
diff --git a/src/drivers/net/e1000.c b/src/drivers/net/e1000.c
index b9f9d8f9..d89deb7a 100644
--- a/src/drivers/net/e1000.c
+++ b/src/drivers/net/e1000.c
@@ -89,7 +89,6 @@ typedef enum {
/* NIC specific static variables go here */
static struct nic_operations e1000_operations;
-static struct pci_driver e1000_driver;
static struct e1000_hw hw;
diff --git a/src/drivers/net/eepro100.c b/src/drivers/net/eepro100.c
index c1ff2e76..46346c71 100644
--- a/src/drivers/net/eepro100.c
+++ b/src/drivers/net/eepro100.c
@@ -252,7 +252,6 @@ struct RxFD { /* Receive frame descriptor. */
};
static struct nic_operations eepro100_operations;
-static struct pci_driver eepro100_driver;
#define RXFD_COUNT 4
struct {
diff --git a/src/drivers/net/epic100.c b/src/drivers/net/epic100.c
index 32f2dff4..ac9b2597 100644
--- a/src/drivers/net/epic100.c
+++ b/src/drivers/net/epic100.c
@@ -61,7 +61,6 @@ static int mii_read(int phy_id, int location);
static void epic100_irq(struct nic *nic, irq_action_t action);
static struct nic_operations epic100_operations;
-static struct pci_driver epic100_driver;
static int ioaddr;
diff --git a/src/drivers/net/legacy.c b/src/drivers/net/legacy.c
new file mode 100644
index 00000000..1b36c0de
--- /dev/null
+++ b/src/drivers/net/legacy.c
@@ -0,0 +1,104 @@
+#include <stdint.h>
+#include <errno.h>
+#include <gpxe/if_ether.h>
+#include <gpxe/netdevice.h>
+#include <gpxe/ethernet.h>
+#include <gpxe/pkbuff.h>
+#include <nic.h>
+
+/*
+ * Quick and dirty compatibility layer
+ *
+ * This should allow old-API PCI drivers to at least function until
+ * they are updated. It will not help non-PCI drivers.
+ *
+ * No drivers should rely on this code. It will be removed asap.
+ *
+ */
+
+struct nic nic;
+
+static int legacy_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
+ struct nic *nic = netdev->priv;
+ struct ethhdr *ethhdr = pkb->data;
+
+ pkb_pull ( pkb, sizeof ( *ethhdr ) );
+ nic->nic_op->transmit ( nic, ( const char * ) ethhdr->h_dest,
+ ntohs ( ethhdr->h_protocol ),
+ pkb_len ( pkb ), pkb->data );
+ free_pkb ( pkb );
+ return 0;
+}
+
+static void legacy_poll ( struct net_device *netdev ) {
+ struct nic *nic = netdev->priv;
+ struct pk_buff *pkb;
+
+ pkb = alloc_pkb ( ETH_FRAME_LEN );
+ if ( ! pkb )
+ return;
+
+ nic->packet = pkb->data;
+ if ( nic->nic_op->poll ( nic, 1 ) ) {
+ pkb_put ( pkb, nic->packetlen );
+ netdev_rx ( netdev, pkb );
+ } else {
+ free_pkb ( pkb );
+ }
+}
+
+int legacy_probe ( struct pci_device *pci,
+ const struct pci_device_id *id __unused,
+ int ( * probe ) ( struct nic *nic,
+ struct pci_device *pci ),
+ void ( * disable ) ( struct nic *nic ) ) {
+ struct net_device *netdev;
+ int rc;
+
+ netdev = alloc_etherdev ( 0 );
+ if ( ! netdev )
+ return -ENOMEM;
+ netdev->priv = &nic;
+ memset ( &nic, 0, sizeof ( nic ) );
+ pci_set_drvdata ( pci, netdev );
+
+ netdev->transmit = legacy_transmit;
+ netdev->poll = legacy_poll;
+ nic.node_addr = netdev->ll_addr;
+
+ if ( ! probe ( &nic, pci ) ) {
+ free_netdev ( netdev );
+ return -ENODEV;
+ }
+
+ if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
+ disable ( &nic );
+ free_netdev ( netdev );
+ return rc;
+ }
+
+ return 0;
+}
+
+void legacy_remove ( struct pci_device *pci,
+ void ( * disable ) ( struct nic *nic ) ) {
+ struct net_device *netdev = pci_get_drvdata ( pci );
+ struct nic *nic = netdev->priv;
+
+ unregister_netdev ( netdev );
+ disable ( nic );
+ free_netdev ( netdev );
+}
+
+void pci_fill_nic ( struct nic *nic, struct pci_device *pci ) {
+ nic->ioaddr = pci->ioaddr;
+ nic->irqno = pci->irq;
+}
+
+int dummy_connect ( struct nic *nic __unused ) {
+ return 1;
+}
+
+void dummy_irq ( struct nic *nic __unused, irq_action_t irq_action __unused ) {
+ return;
+}
diff --git a/src/drivers/net/natsemi.c b/src/drivers/net/natsemi.c
index c34d611f..b40fb131 100644
--- a/src/drivers/net/natsemi.c
+++ b/src/drivers/net/natsemi.c
@@ -175,7 +175,6 @@ enum desc_status_bits {
/* Globals */
static struct nic_operations natsemi_operations;
-static struct pci_driver natsemi_driver;
static int natsemi_debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */
diff --git a/src/drivers/net/pcnet32.c b/src/drivers/net/pcnet32.c
index 51efe39e..c0345bcd 100644
--- a/src/drivers/net/pcnet32.c
+++ b/src/drivers/net/pcnet32.c
@@ -56,7 +56,6 @@
static u32 ioaddr; /* Globally used for the card's io address */
static struct nic_operations pcnet32_operations;
-static struct pci_driver pcnet32_driver;
#ifdef EDEBUG
#define dprintf(x) printf x
diff --git a/src/drivers/net/sis900.c b/src/drivers/net/sis900.c
index c6b53d81..8040ddd5 100644
--- a/src/drivers/net/sis900.c
+++ b/src/drivers/net/sis900.c
@@ -47,6 +47,7 @@
#include "nic.h"
#include <gpxe/pci.h>
#include "timer.h"
+#include "dev.h"
#include "sis900.h"
diff --git a/src/drivers/net/sundance.c b/src/drivers/net/sundance.c
index d3cb7506..01b27d36 100644
--- a/src/drivers/net/sundance.c
+++ b/src/drivers/net/sundance.c
@@ -572,7 +572,6 @@ static struct nic_operations sundance_operations = {
.irq = sundance_irq,
};
-static struct pci_driver sundance_driver;
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
diff --git a/src/drivers/net/tlan.c b/src/drivers/net/tlan.c
index bebc07a9..cc97423e 100644
--- a/src/drivers/net/tlan.c
+++ b/src/drivers/net/tlan.c
@@ -65,8 +65,6 @@
#define dprintf(x)
#endif
-static struct pci_driver tlan_driver;
-
static void TLan_ResetLists(struct nic *nic __unused);
static void TLan_ResetAdapter(struct nic *nic __unused);
static void TLan_FinishReset(struct nic *nic __unused);
diff --git a/src/drivers/net/via-rhine.c b/src/drivers/net/via-rhine.c
index ca3212ad..b72c13bb 100644
--- a/src/drivers/net/via-rhine.c
+++ b/src/drivers/net/via-rhine.c
@@ -957,7 +957,6 @@ void rhine_irq ( struct nic *nic, irq_action_t action ) {
}
static struct nic_operations rhine_operations;
-static struct pci_driver rhine_driver;
static int
rhine_probe ( struct nic *nic, struct pci_device *pci ) {