mirror of https://github.com/ipxe/ipxe.git
Added a very quick and dirty compatibility layer, to allow
not-yet-updated drivers to at least function.pull/1/head
parent
c3e41e6fd1
commit
286bf68faf
|
@ -388,6 +388,7 @@ struct type_driver nic_driver = {
|
||||||
.load = nic_load,
|
.load = nic_load,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Careful. We need an aligned buffer to avoid problems on machines
|
/* Careful. We need an aligned buffer to avoid problems on machines
|
||||||
* that care about alignment. To trivally align the ethernet data
|
* that care about alignment. To trivally align the ethernet data
|
||||||
* (the ip hdr and arp requests) we offset the packet by 2 bytes.
|
* (the ip hdr and arp requests) we offset the packet by 2 bytes.
|
||||||
|
@ -400,17 +401,9 @@ struct nic nic = {
|
||||||
.node_addr = arptable[ARP_CLIENT].node,
|
.node_addr = arptable[ARP_CLIENT].node,
|
||||||
.packet = packet + ETH_DATA_ALIGN,
|
.packet = packet + ETH_DATA_ALIGN,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int dummy_connect ( struct nic *nic __unused ) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dummy_irq ( struct nic *nic __unused, irq_action_t irq_action __unused ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
DEFAULT_NETMASK - Return default netmask for IP address
|
DEFAULT_NETMASK - Return default netmask for IP address
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
#include "dev.h"
|
||||||
#include "3c509.h"
|
#include "3c509.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
static struct nic_operations t595_operations;
|
static struct nic_operations t595_operations;
|
||||||
static struct pci_driver t595_driver;
|
|
||||||
|
|
||||||
static unsigned short eth_nic_base;
|
static unsigned short eth_nic_base;
|
||||||
static unsigned short vx_connector, vx_connectors;
|
static unsigned short vx_connector, vx_connectors;
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
static struct nic_operations a3c90x_operations;
|
static struct nic_operations a3c90x_operations;
|
||||||
static struct pci_driver a3c90x_driver;
|
|
||||||
|
|
||||||
#define XCVR_MAGIC (0x5A00)
|
#define XCVR_MAGIC (0x5A00)
|
||||||
/** any single transmission fails after 16 collisions or other errors
|
/** any single transmission fails after 16 collisions or other errors
|
||||||
|
|
|
@ -123,7 +123,6 @@ struct rxdesc {
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
static struct nic_operations davicom_operations;
|
static struct nic_operations davicom_operations;
|
||||||
static struct pci_driver davicom_driver;
|
|
||||||
|
|
||||||
/* PCI Bus parameters */
|
/* PCI Bus parameters */
|
||||||
static unsigned short vendor, dev_id;
|
static unsigned short vendor, dev_id;
|
||||||
|
|
|
@ -189,7 +189,6 @@ enum dmfe_CR6_bits {
|
||||||
|
|
||||||
/* Global variable declaration ----------------------------- */
|
/* Global variable declaration ----------------------------- */
|
||||||
static struct nic_operations dmfe_operations;
|
static struct nic_operations dmfe_operations;
|
||||||
static struct pci_driver dmfe_driver;
|
|
||||||
|
|
||||||
static unsigned char dmfe_media_mode = DMFE_AUTO;
|
static unsigned char dmfe_media_mode = DMFE_AUTO;
|
||||||
static u32 dmfe_cr6_user_set;
|
static u32 dmfe_cr6_user_set;
|
||||||
|
|
|
@ -89,7 +89,6 @@ typedef enum {
|
||||||
|
|
||||||
/* NIC specific static variables go here */
|
/* NIC specific static variables go here */
|
||||||
static struct nic_operations e1000_operations;
|
static struct nic_operations e1000_operations;
|
||||||
static struct pci_driver e1000_driver;
|
|
||||||
|
|
||||||
static struct e1000_hw hw;
|
static struct e1000_hw hw;
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,6 @@ struct RxFD { /* Receive frame descriptor. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct nic_operations eepro100_operations;
|
static struct nic_operations eepro100_operations;
|
||||||
static struct pci_driver eepro100_driver;
|
|
||||||
|
|
||||||
#define RXFD_COUNT 4
|
#define RXFD_COUNT 4
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -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 void epic100_irq(struct nic *nic, irq_action_t action);
|
||||||
|
|
||||||
static struct nic_operations epic100_operations;
|
static struct nic_operations epic100_operations;
|
||||||
static struct pci_driver epic100_driver;
|
|
||||||
|
|
||||||
static int ioaddr;
|
static int ioaddr;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -175,7 +175,6 @@ enum desc_status_bits {
|
||||||
/* Globals */
|
/* Globals */
|
||||||
|
|
||||||
static struct nic_operations natsemi_operations;
|
static struct nic_operations natsemi_operations;
|
||||||
static struct pci_driver natsemi_driver;
|
|
||||||
|
|
||||||
static int natsemi_debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */
|
static int natsemi_debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
|
|
||||||
static u32 ioaddr; /* Globally used for the card's io address */
|
static u32 ioaddr; /* Globally used for the card's io address */
|
||||||
static struct nic_operations pcnet32_operations;
|
static struct nic_operations pcnet32_operations;
|
||||||
static struct pci_driver pcnet32_driver;
|
|
||||||
|
|
||||||
#ifdef EDEBUG
|
#ifdef EDEBUG
|
||||||
#define dprintf(x) printf x
|
#define dprintf(x) printf x
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "nic.h"
|
#include "nic.h"
|
||||||
#include <gpxe/pci.h>
|
#include <gpxe/pci.h>
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
#include "dev.h"
|
||||||
|
|
||||||
#include "sis900.h"
|
#include "sis900.h"
|
||||||
|
|
||||||
|
|
|
@ -572,7 +572,6 @@ static struct nic_operations sundance_operations = {
|
||||||
.irq = sundance_irq,
|
.irq = sundance_irq,
|
||||||
|
|
||||||
};
|
};
|
||||||
static struct pci_driver sundance_driver;
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
PROBE - Look for an adapter, this routine's visible to the outside
|
PROBE - Look for an adapter, this routine's visible to the outside
|
||||||
|
|
|
@ -65,8 +65,6 @@
|
||||||
#define dprintf(x)
|
#define dprintf(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct pci_driver tlan_driver;
|
|
||||||
|
|
||||||
static void TLan_ResetLists(struct nic *nic __unused);
|
static void TLan_ResetLists(struct nic *nic __unused);
|
||||||
static void TLan_ResetAdapter(struct nic *nic __unused);
|
static void TLan_ResetAdapter(struct nic *nic __unused);
|
||||||
static void TLan_FinishReset(struct nic *nic __unused);
|
static void TLan_FinishReset(struct nic *nic __unused);
|
||||||
|
|
|
@ -957,7 +957,6 @@ void rhine_irq ( struct nic *nic, irq_action_t action ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nic_operations rhine_operations;
|
static struct nic_operations rhine_operations;
|
||||||
static struct pci_driver rhine_driver;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rhine_probe ( struct nic *nic, struct pci_device *pci ) {
|
rhine_probe ( struct nic *nic, struct pci_device *pci ) {
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
#ifndef NIC_H
|
#ifndef NIC_H
|
||||||
#define NIC_H
|
#define NIC_H
|
||||||
|
|
||||||
#include "dev.h"
|
#include <byteswap.h>
|
||||||
#include "byteswap.h"
|
#include <gpxe/pci.h>
|
||||||
#include "dhcp.h"
|
#include "dhcp.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -49,27 +49,8 @@ struct nic_operations {
|
||||||
void ( *irq ) ( struct nic *, irq_action_t );
|
void ( *irq ) ( struct nic *, irq_action_t );
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct type_driver nic_driver;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function prototypes
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
extern int dummy_connect ( struct nic *nic );
|
|
||||||
extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
|
|
||||||
extern void nic_disable ( struct nic *nic );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions that implicitly operate on the current boot device
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern struct nic nic;
|
extern struct nic nic;
|
||||||
|
|
||||||
static inline int eth_connect ( void ) {
|
|
||||||
return nic.nic_op->connect ( &nic );
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int eth_poll ( int retrieve ) {
|
static inline int eth_poll ( int retrieve ) {
|
||||||
return nic.nic_op->poll ( &nic, retrieve );
|
return nic.nic_op->poll ( &nic, retrieve );
|
||||||
}
|
}
|
||||||
|
@ -79,11 +60,40 @@ static inline void eth_transmit ( const char *dest, unsigned int type,
|
||||||
nic.nic_op->transmit ( &nic, dest, type, size, packet );
|
nic.nic_op->transmit ( &nic, dest, type, size, packet );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void eth_irq ( irq_action_t action ) {
|
/*
|
||||||
nic.nic_op->irq ( &nic, action );
|
* Function prototypes
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
|
extern int dummy_connect ( struct nic *nic );
|
||||||
|
extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
|
||||||
|
extern int legacy_probe ( struct pci_device *pci,
|
||||||
|
const struct pci_device_id *id,
|
||||||
|
int ( * probe ) ( struct nic *nic,
|
||||||
|
struct pci_device *pci ),
|
||||||
|
void ( * disable ) ( struct nic *nic ) );
|
||||||
|
extern void legacy_remove ( struct pci_device *pci,
|
||||||
|
void ( * disable ) ( struct nic *nic ) );
|
||||||
|
extern void pci_fill_nic ( struct nic *nic, struct pci_device *pci );
|
||||||
|
|
||||||
/* Should be using disable() rather than eth_disable() */
|
#define PCI_DRIVER(_name,_ids,_class) \
|
||||||
extern void eth_disable ( void ) __attribute__ (( deprecated ));
|
static int _name ## _legacy_probe ( struct pci_device *pci, \
|
||||||
|
const struct pci_device_id *id ); \
|
||||||
|
static void _name ## _legacy_remove ( struct pci_device *pci ); \
|
||||||
|
struct pci_driver _name __pci_driver = { \
|
||||||
|
.ids = _ids, \
|
||||||
|
.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
|
||||||
|
.probe = _name ## _legacy_probe, \
|
||||||
|
.remove = _name ## _legacy_remove, \
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef DRIVER
|
||||||
|
#define DRIVER(_unused1,_unused2,_unused3,_name,_probe,_disable) \
|
||||||
|
static int _name ## _legacy_probe ( struct pci_device *pci, \
|
||||||
|
const struct pci_device_id *id ) {\
|
||||||
|
return legacy_probe ( pci, id, _probe, _disable ); \
|
||||||
|
} \
|
||||||
|
static void _name ## _legacy_remove ( struct pci_device *pci ) {\
|
||||||
|
return legacy_remove ( pci, _disable ); \
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* NIC_H */
|
#endif /* NIC_H */
|
||||||
|
|
Loading…
Reference in New Issue