Added a very quick and dirty compatibility layer, to allow

not-yet-updated drivers to at least function.
This commit is contained in:
Michael Brown
2006-06-05 15:45:21 +00:00
parent c3e41e6fd1
commit 286bf68faf
17 changed files with 144 additions and 48 deletions

View File

@@ -9,6 +9,7 @@
#include "timer.h"
#include "string.h"
#include "console.h"
#include "dev.h"
#include "3c509.h"
/*

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

104
src/drivers/net/legacy.c Normal file
View File

@@ -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;
}

View File

@@ -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. */

View File

@@ -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

View File

@@ -47,6 +47,7 @@
#include "nic.h"
#include <gpxe/pci.h>
#include "timer.h"
#include "dev.h"
#include "sis900.h"

View File

@@ -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

View File

@@ -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);

View File

@@ -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 ) {