summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
authorMichael Brown2005-04-15 18:08:10 +0200
committerMichael Brown2005-04-15 18:08:10 +0200
commit38ea910098ea7644f95e29c4b49152348aef597f (patch)
treec37fde05ba92037a6865cc1141a1bfbc22989599 /src/drivers
parentUpdated to work with new ISAPnP bus code. (diff)
downloadipxe-38ea910098ea7644f95e29c4b49152348aef597f.tar.gz
ipxe-38ea910098ea7644f95e29c4b49152348aef597f.tar.xz
ipxe-38ea910098ea7644f95e29c4b49152348aef597f.zip
Updated to new PCI bus interface.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/net/skel.c189
1 files changed, 100 insertions, 89 deletions
diff --git a/src/drivers/net/skel.c b/src/drivers/net/skel.c
index 093966206..bab9bfdd7 100644
--- a/src/drivers/net/skel.c
+++ b/src/drivers/net/skel.c
@@ -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;
-}
-
-static struct pci_id skel_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 );
-
-BOOT_DRIVER ( "SKELETON/PCI", find_pci_boot_device, skel_driver, skel_probe );
+ /* store NIC parameters */
+ nic->ioaddr = pci->ioaddr;
+ nic->irqno = pci->irq;
-/**************************************************************************
-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;
+ /* Test for physical presence of NIC */
+ /*
+ if ( ! my_tests ) {
+ DBG ( "Could not find NIC: my explanation\n" );
+ return 0;
+ }
+ */
- /* 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;
+ /* point to NIC specific routines */
+ nic->nic_op = &skel_operations;
+ return 1;
}
-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,
+static struct pci_id skel_pci_nics[] = {
+PCI_ROM ( 0x0000, 0x0000, "skel-pci", "Skeleton PCI Adaptor" ),
};
+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_pci_driver, skel_pci_probe );
+