2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-13 23:01:31 +00:00

Updated to new PCI bus interface.

This commit is contained in:
Michael Brown 2005-04-15 16:08:10 +00:00
parent a26edc2eec
commit 38ea910098

View File

@ -14,18 +14,45 @@ Skeleton NIC driver for Etherboot
#include "etherboot.h"
/* to get the interface to the body of the program */
#include "nic.h"
/* to get the PCI support functions, if this is a PCI NIC */
/* Drag in support for whichever bus(es) we want for this NIC */
#include "pci.h"
/* to get the ISA support functions, if this is an ISA NIC */
#include "isa.h"
#include "eisa.h"
#include "isapnp.h"
#include "mca.h"
/* NIC specific static variables go here */
/* NIC specific static variables go here. Try to avoid using static
* variables wherever possible. In particular, the I/O address can
* always be accessed via nic->ioaddr.
*/
/*
* Don't forget to remove "__unused" from all the function parameters!
*
*/
/**************************************************************************
POLL - Wait for a frame
***************************************************************************/
static int skel_poll(struct nic *nic, int retrieve)
{
* CONNECT - Connect to the network
**************************************************************************
*/
static int skel_connect ( struct nic *nic __unused ) {
/*
* Connect to the network. For most NICs, this will probably
* be a no-op. For wireless NICs, this should be the point at
* which you attempt to join to an access point.
*
* Return 0 if the connection failed (e.g. no cable plugged
* in), 1 for success.
*
*/
return 1;
}
/**************************************************************************
* POLL - Wait for a frame
**************************************************************************
*/
static int skel_poll ( struct nic *nic __unused, int retrieve __unused ) {
/* Work out whether or not there's an ethernet packet ready to
* read. Return 0 if not.
*/
@ -37,7 +64,7 @@ static int skel_poll(struct nic *nic, int retrieve)
* presence of a packet but don't want to read it just yet.
*/
/*
if ( ! retrieve ) return 1;
if ( ! retrieve ) return 1;
*/
/* Copy data to nic->packet. Data should include the
@ -55,33 +82,33 @@ static int skel_poll(struct nic *nic, int retrieve)
}
/**************************************************************************
TRANSMIT - Transmit a frame
***************************************************************************/
static void skel_transmit(
struct nic *nic,
const char *dest, /* Destination */
unsigned int type, /* Type */
unsigned int size, /* size */
const char *packet) /* Packet */
{
* TRANSMIT - Transmit a frame
**************************************************************************
*/
static void skel_transmit ( struct nic *nic __unused,
const char *dest __unused,
unsigned int type __unused,
unsigned int size __unused,
const char *packet __unused ) {
/* Transmit packet to dest MAC address. You will need to
* construct the link-layer header (dest MAC, source MAC,
* type).
*/
/*
unsigned int nstype = htons ( type );
memcpy ( <tx_buffer>, dest, ETH_ALEN );
memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN );
memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 );
memcpy ( <tx_buffer> + ETH_HLEN, data, size );
<transmit_data> ( <tx_buffer>, size + ETH_HLEN );
unsigned int nstype = htons ( type );
memcpy ( <tx_buffer>, dest, ETH_ALEN );
memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN );
memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 );
memcpy ( <tx_buffer> + ETH_HLEN, data, size );
<transmit_data> ( <tx_buffer>, size + ETH_HLEN );
*/
}
/**************************************************************************
DISABLE - Turn off ethernet interface
***************************************************************************/
static void skel_disable ( struct nic *nic ) {
* DISABLE - Turn off ethernet interface
**************************************************************************
*/
static void skel_disable ( struct nic *nic __unused ) {
/* put the card in its initial state */
/* This function serves 3 purposes.
* This disables DMA and interrupts so we don't receive
@ -95,10 +122,10 @@ static void skel_disable ( struct nic *nic ) {
}
/**************************************************************************
IRQ - handle interrupts
***************************************************************************/
static void skel_irq(struct nic *nic, irq_action_t action)
{
* IRQ - handle interrupts
**************************************************************************
*/
static void skel_irq ( struct nic *nic __unused, irq_action_t action ) {
/* This routine is somewhat optional. Etherboot itself
* doesn't use interrupts, but they are required under some
* circumstances when we're acting as a PXE stack.
@ -127,8 +154,12 @@ static void skel_irq(struct nic *nic, irq_action_t action)
}
}
/**************************************************************************
* OPERATIONS TABLE - Pointers to all the above methods
**************************************************************************
*/
static struct nic_operations skel_operations = {
.connect = dummy_connect,
.connect = skel_connect,
.poll = skel_poll,
.transmit = skel_transmit,
.irq = skel_irq,
@ -136,70 +167,50 @@ static struct nic_operations skel_operations = {
};
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/
#define board_found 1
#define valid_link 0
static int skel_probe ( struct dev *dev, struct pci_device *pci ) {
* PROBE - Look for an adapter
*
* You need to define a probe routine for each bus type that your
* driver supports, together with tables that enable Etherboot to
* identify that your driver should be used for a particular device.
*
* Delete whichever of the following sections you don't need. For
* example, most PCI devices will only need the PCI probing section;
* ISAPnP, EISA, etc. can all be deleted.
*
**************************************************************************
*/
/**************************************************************************
* PCI PROBE - Look for an adapter
**************************************************************************
*/
static int skel_pci_probe ( struct dev *dev, struct pci_device *pci ) {
struct nic *nic = nic_device ( dev );
if (board_found && valid_link)
{
/* store NIC parameters */
nic->ioaddr = pci->ioaddr;
nic->irqno = pci->irq;
/* point to NIC specific routines */
nic->nic_op = &skel_operations;
return 1;
}
/* else */
return 0;
/* store NIC parameters */
nic->ioaddr = pci->ioaddr;
nic->irqno = pci->irq;
/* Test for physical presence of NIC */
/*
if ( ! my_tests ) {
DBG ( "Could not find NIC: my explanation\n" );
return 0;
}
*/
/* point to NIC specific routines */
nic->nic_op = &skel_operations;
return 1;
}
static struct pci_id skel_nics[] = {
PCI_ROM(0x0000, 0x0000, "skel-pci", "Skeleton PCI Adaptor"),
static struct pci_id skel_pci_nics[] = {
PCI_ROM ( 0x0000, 0x0000, "skel-pci", "Skeleton PCI Adaptor" ),
};
static struct pci_driver skel_driver =
PCI_DRIVER ( "SKELETON/PCI", skel_nics, PCI_NO_CLASS );
static struct pci_driver skel_pci_driver =
PCI_DRIVER ( "SKELETON/PCI", skel_pci_nics, PCI_NO_CLASS );
BOOT_DRIVER ( "SKELETON/PCI", find_pci_boot_device, skel_driver, skel_probe );
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/
static int skel_isa_probe(struct dev *dev, unsigned short *probe_addrs)
{
struct nic *nic = (struct nic *)dev;
/* if probe_addrs is 0, then routine can use a hardwired default */
if (board_found && valid_link)
{
/* point to NIC specific routines */
static struct nic_operations skel_operations;
static struct nic_operations skel_operations = {
.connect = dummy_connect,
.poll = skel_poll,
.transmit = skel_transmit,
.irq = skel_irq,
.disable = skel_disable,
}; nic->nic_op = &skel_operations;
/* Report the ISA pnp id of the board */
dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
dev->devid.vendor_id = htons(0x1234);
return 1;
}
/* else */
return 0;
}
ISA_ROM("skel-isa", "Skeleton ISA driver")
static struct isa_driver skel_isa_driver __isa_driver = {
.type = NIC_DRIVER,
.name = "SKELETON/ISA",
.probe = skel_isa_probe,
.ioaddrs = 0,
};
BOOT_DRIVER ( "SKELETON/PCI", find_pci_boot_device,
skel_pci_driver, skel_pci_probe );