not-yet-updated drivers to at least function.
.load = nic_load,
};
+#if 0
/* Careful. We need an aligned buffer to avoid problems on machines
* that care about alignment. To trivally align the ethernet data
* (the ip hdr and arp requests) we offset the packet by 2 bytes.
.node_addr = arptable[ARP_CLIENT].node,
.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
**************************************************************************/
#include "timer.h"
#include "string.h"
#include "console.h"
+#include "dev.h"
#include "3c509.h"
/*
#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;
#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
/*********************************************************************/
static struct nic_operations davicom_operations;
-static struct pci_driver davicom_driver;
/* PCI Bus parameters */
static unsigned short vendor, dev_id;
/* 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;
/* NIC specific static variables go here */
static struct nic_operations e1000_operations;
-static struct pci_driver e1000_driver;
static struct e1000_hw hw;
};
static struct nic_operations eepro100_operations;
-static struct pci_driver eepro100_driver;
#define RXFD_COUNT 4
struct {
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;
--- /dev/null
+#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;
+}
/* 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. */
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
#include "nic.h"
#include <gpxe/pci.h>
#include "timer.h"
+#include "dev.h"
#include "sis900.h"
.irq = sundance_irq,
};
-static struct pci_driver sundance_driver;
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
#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);
}
static struct nic_operations rhine_operations;
-static struct pci_driver rhine_driver;
static int
rhine_probe ( struct nic *nic, struct pci_device *pci ) {
#ifndef NIC_H
#define NIC_H
-#include "dev.h"
-#include "byteswap.h"
+#include <byteswap.h>
+#include <gpxe/pci.h>
#include "dhcp.h"
typedef enum {
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;
-static inline int eth_connect ( void ) {
- return nic.nic_op->connect ( &nic );
-}
-
static inline int eth_poll ( int retrieve ) {
return nic.nic_op->poll ( &nic, retrieve );
}
nic.nic_op->transmit ( &nic, dest, type, size, packet );
}
-static inline void eth_irq ( irq_action_t action ) {
- nic.nic_op->irq ( &nic, action );
-}
-
-/* Should be using disable() rather than eth_disable() */
-extern void eth_disable ( void ) __attribute__ (( deprecated ));
+/*
+ * 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 );
+
+#define PCI_DRIVER(_name,_ids,_class) \
+ 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 */