|
@@ -14,18 +14,45 @@ Skeleton NIC driver for Etherboot
|
14
|
14
|
#include "etherboot.h"
|
15
|
15
|
/* to get the interface to the body of the program */
|
16
|
16
|
#include "nic.h"
|
17
|
|
-/* to get the PCI support functions, if this is a PCI NIC */
|
|
17
|
+/* Drag in support for whichever bus(es) we want for this NIC */
|
18
|
18
|
#include "pci.h"
|
19
|
|
-/* to get the ISA support functions, if this is an ISA NIC */
|
20
|
19
|
#include "isa.h"
|
|
20
|
+#include "eisa.h"
|
|
21
|
+#include "isapnp.h"
|
|
22
|
+#include "mca.h"
|
21
|
23
|
|
22
|
|
-/* NIC specific static variables go here */
|
|
24
|
+/* NIC specific static variables go here. Try to avoid using static
|
|
25
|
+ * variables wherever possible. In particular, the I/O address can
|
|
26
|
+ * always be accessed via nic->ioaddr.
|
|
27
|
+ */
|
|
28
|
+
|
|
29
|
+/*
|
|
30
|
+ * Don't forget to remove "__unused" from all the function parameters!
|
|
31
|
+ *
|
|
32
|
+ */
|
23
|
33
|
|
24
|
34
|
/**************************************************************************
|
25
|
|
-POLL - Wait for a frame
|
26
|
|
-***************************************************************************/
|
27
|
|
-static int skel_poll(struct nic *nic, int retrieve)
|
28
|
|
-{
|
|
35
|
+ * CONNECT - Connect to the network
|
|
36
|
+ **************************************************************************
|
|
37
|
+*/
|
|
38
|
+static int skel_connect ( struct nic *nic __unused ) {
|
|
39
|
+ /*
|
|
40
|
+ * Connect to the network. For most NICs, this will probably
|
|
41
|
+ * be a no-op. For wireless NICs, this should be the point at
|
|
42
|
+ * which you attempt to join to an access point.
|
|
43
|
+ *
|
|
44
|
+ * Return 0 if the connection failed (e.g. no cable plugged
|
|
45
|
+ * in), 1 for success.
|
|
46
|
+ *
|
|
47
|
+ */
|
|
48
|
+ return 1;
|
|
49
|
+}
|
|
50
|
+
|
|
51
|
+/**************************************************************************
|
|
52
|
+ * POLL - Wait for a frame
|
|
53
|
+ **************************************************************************
|
|
54
|
+*/
|
|
55
|
+static int skel_poll ( struct nic *nic __unused, int retrieve __unused ) {
|
29
|
56
|
/* Work out whether or not there's an ethernet packet ready to
|
30
|
57
|
* read. Return 0 if not.
|
31
|
58
|
*/
|
|
@@ -37,7 +64,7 @@ static int skel_poll(struct nic *nic, int retrieve)
|
37
|
64
|
* presence of a packet but don't want to read it just yet.
|
38
|
65
|
*/
|
39
|
66
|
/*
|
40
|
|
- if ( ! retrieve ) return 1;
|
|
67
|
+ if ( ! retrieve ) return 1;
|
41
|
68
|
*/
|
42
|
69
|
|
43
|
70
|
/* Copy data to nic->packet. Data should include the
|
|
@@ -55,33 +82,33 @@ static int skel_poll(struct nic *nic, int retrieve)
|
55
|
82
|
}
|
56
|
83
|
|
57
|
84
|
/**************************************************************************
|
58
|
|
-TRANSMIT - Transmit a frame
|
59
|
|
-***************************************************************************/
|
60
|
|
-static void skel_transmit(
|
61
|
|
- struct nic *nic,
|
62
|
|
- const char *dest, /* Destination */
|
63
|
|
- unsigned int type, /* Type */
|
64
|
|
- unsigned int size, /* size */
|
65
|
|
- const char *packet) /* Packet */
|
66
|
|
-{
|
|
85
|
+ * TRANSMIT - Transmit a frame
|
|
86
|
+ **************************************************************************
|
|
87
|
+*/
|
|
88
|
+static void skel_transmit ( struct nic *nic __unused,
|
|
89
|
+ const char *dest __unused,
|
|
90
|
+ unsigned int type __unused,
|
|
91
|
+ unsigned int size __unused,
|
|
92
|
+ const char *packet __unused ) {
|
67
|
93
|
/* Transmit packet to dest MAC address. You will need to
|
68
|
94
|
* construct the link-layer header (dest MAC, source MAC,
|
69
|
95
|
* type).
|
70
|
96
|
*/
|
71
|
97
|
/*
|
72
|
|
- unsigned int nstype = htons ( type );
|
73
|
|
- memcpy ( <tx_buffer>, dest, ETH_ALEN );
|
74
|
|
- memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN );
|
75
|
|
- memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 );
|
76
|
|
- memcpy ( <tx_buffer> + ETH_HLEN, data, size );
|
77
|
|
- <transmit_data> ( <tx_buffer>, size + ETH_HLEN );
|
|
98
|
+ unsigned int nstype = htons ( type );
|
|
99
|
+ memcpy ( <tx_buffer>, dest, ETH_ALEN );
|
|
100
|
+ memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN );
|
|
101
|
+ memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 );
|
|
102
|
+ memcpy ( <tx_buffer> + ETH_HLEN, data, size );
|
|
103
|
+ <transmit_data> ( <tx_buffer>, size + ETH_HLEN );
|
78
|
104
|
*/
|
79
|
105
|
}
|
80
|
106
|
|
81
|
107
|
/**************************************************************************
|
82
|
|
-DISABLE - Turn off ethernet interface
|
83
|
|
-***************************************************************************/
|
84
|
|
-static void skel_disable ( struct nic *nic ) {
|
|
108
|
+ * DISABLE - Turn off ethernet interface
|
|
109
|
+ **************************************************************************
|
|
110
|
+ */
|
|
111
|
+static void skel_disable ( struct nic *nic __unused ) {
|
85
|
112
|
/* put the card in its initial state */
|
86
|
113
|
/* This function serves 3 purposes.
|
87
|
114
|
* This disables DMA and interrupts so we don't receive
|
|
@@ -95,10 +122,10 @@ static void skel_disable ( struct nic *nic ) {
|
95
|
122
|
}
|
96
|
123
|
|
97
|
124
|
/**************************************************************************
|
98
|
|
-IRQ - handle interrupts
|
99
|
|
-***************************************************************************/
|
100
|
|
-static void skel_irq(struct nic *nic, irq_action_t action)
|
101
|
|
-{
|
|
125
|
+ * IRQ - handle interrupts
|
|
126
|
+ **************************************************************************
|
|
127
|
+*/
|
|
128
|
+static void skel_irq ( struct nic *nic __unused, irq_action_t action ) {
|
102
|
129
|
/* This routine is somewhat optional. Etherboot itself
|
103
|
130
|
* doesn't use interrupts, but they are required under some
|
104
|
131
|
* circumstances when we're acting as a PXE stack.
|
|
@@ -127,8 +154,12 @@ static void skel_irq(struct nic *nic, irq_action_t action)
|
127
|
154
|
}
|
128
|
155
|
}
|
129
|
156
|
|
|
157
|
+/**************************************************************************
|
|
158
|
+ * OPERATIONS TABLE - Pointers to all the above methods
|
|
159
|
+ **************************************************************************
|
|
160
|
+ */
|
130
|
161
|
static struct nic_operations skel_operations = {
|
131
|
|
- .connect = dummy_connect,
|
|
162
|
+ .connect = skel_connect,
|
132
|
163
|
.poll = skel_poll,
|
133
|
164
|
.transmit = skel_transmit,
|
134
|
165
|
.irq = skel_irq,
|
|
@@ -136,70 +167,50 @@ static struct nic_operations skel_operations = {
|
136
|
167
|
};
|
137
|
168
|
|
138
|
169
|
/**************************************************************************
|
139
|
|
-PROBE - Look for an adapter, this routine's visible to the outside
|
140
|
|
-***************************************************************************/
|
141
|
|
-
|
142
|
|
-#define board_found 1
|
143
|
|
-#define valid_link 0
|
144
|
|
-static int skel_probe ( struct dev *dev, struct pci_device *pci ) {
|
|
170
|
+ * PROBE - Look for an adapter
|
|
171
|
+ *
|
|
172
|
+ * You need to define a probe routine for each bus type that your
|
|
173
|
+ * driver supports, together with tables that enable Etherboot to
|
|
174
|
+ * identify that your driver should be used for a particular device.
|
|
175
|
+ *
|
|
176
|
+ * Delete whichever of the following sections you don't need. For
|
|
177
|
+ * example, most PCI devices will only need the PCI probing section;
|
|
178
|
+ * ISAPnP, EISA, etc. can all be deleted.
|
|
179
|
+ *
|
|
180
|
+ **************************************************************************
|
|
181
|
+ */
|
145
|
182
|
|
|
183
|
+/**************************************************************************
|
|
184
|
+ * PCI PROBE - Look for an adapter
|
|
185
|
+ **************************************************************************
|
|
186
|
+ */
|
|
187
|
+static int skel_pci_probe ( struct dev *dev, struct pci_device *pci ) {
|
146
|
188
|
struct nic *nic = nic_device ( dev );
|
147
|
189
|
|
148
|
|
- if (board_found && valid_link)
|
149
|
|
- {
|
150
|
|
- /* store NIC parameters */
|
151
|
|
- nic->ioaddr = pci->ioaddr;
|
152
|
|
- nic->irqno = pci->irq;
|
153
|
|
- /* point to NIC specific routines */
|
154
|
|
- nic->nic_op = &skel_operations;
|
155
|
|
- return 1;
|
156
|
|
- }
|
157
|
|
- /* else */
|
158
|
|
- return 0;
|
159
|
|
-}
|
160
|
|
-
|
161
|
|
-static struct pci_id skel_nics[] = {
|
162
|
|
-PCI_ROM(0x0000, 0x0000, "skel-pci", "Skeleton PCI Adaptor"),
|
163
|
|
-};
|
164
|
|
-
|
165
|
|
-static struct pci_driver skel_driver =
|
166
|
|
- PCI_DRIVER ( "SKELETON/PCI", skel_nics, PCI_NO_CLASS );
|
167
|
|
-
|
168
|
|
-BOOT_DRIVER ( "SKELETON/PCI", find_pci_boot_device, skel_driver, skel_probe );
|
|
190
|
+ /* store NIC parameters */
|
|
191
|
+ nic->ioaddr = pci->ioaddr;
|
|
192
|
+ nic->irqno = pci->irq;
|
169
|
193
|
|
170
|
|
-/**************************************************************************
|
171
|
|
-PROBE - Look for an adapter, this routine's visible to the outside
|
172
|
|
-***************************************************************************/
|
173
|
|
-static int skel_isa_probe(struct dev *dev, unsigned short *probe_addrs)
|
174
|
|
-{
|
175
|
|
- struct nic *nic = (struct nic *)dev;
|
176
|
|
- /* if probe_addrs is 0, then routine can use a hardwired default */
|
177
|
|
- if (board_found && valid_link)
|
178
|
|
- {
|
179
|
|
- /* point to NIC specific routines */
|
180
|
|
-static struct nic_operations skel_operations;
|
181
|
|
-static struct nic_operations skel_operations = {
|
182
|
|
- .connect = dummy_connect,
|
183
|
|
- .poll = skel_poll,
|
184
|
|
- .transmit = skel_transmit,
|
185
|
|
- .irq = skel_irq,
|
186
|
|
- .disable = skel_disable,
|
187
|
|
-}; nic->nic_op = &skel_operations;
|
|
194
|
+ /* Test for physical presence of NIC */
|
|
195
|
+ /*
|
|
196
|
+ if ( ! my_tests ) {
|
|
197
|
+ DBG ( "Could not find NIC: my explanation\n" );
|
|
198
|
+ return 0;
|
|
199
|
+ }
|
|
200
|
+ */
|
188
|
201
|
|
189
|
|
- /* Report the ISA pnp id of the board */
|
190
|
|
- dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
|
191
|
|
- dev->devid.vendor_id = htons(0x1234);
|
192
|
|
- return 1;
|
193
|
|
- }
|
194
|
|
- /* else */
|
195
|
|
- return 0;
|
|
202
|
+ /* point to NIC specific routines */
|
|
203
|
+ nic->nic_op = &skel_operations;
|
|
204
|
+ return 1;
|
196
|
205
|
}
|
197
|
206
|
|
198
|
|
-ISA_ROM("skel-isa", "Skeleton ISA driver")
|
199
|
|
-static struct isa_driver skel_isa_driver __isa_driver = {
|
200
|
|
- .type = NIC_DRIVER,
|
201
|
|
- .name = "SKELETON/ISA",
|
202
|
|
- .probe = skel_isa_probe,
|
203
|
|
- .ioaddrs = 0,
|
|
207
|
+static struct pci_id skel_pci_nics[] = {
|
|
208
|
+PCI_ROM ( 0x0000, 0x0000, "skel-pci", "Skeleton PCI Adaptor" ),
|
204
|
209
|
};
|
205
|
210
|
|
|
211
|
+static struct pci_driver skel_pci_driver =
|
|
212
|
+ PCI_DRIVER ( "SKELETON/PCI", skel_pci_nics, PCI_NO_CLASS );
|
|
213
|
+
|
|
214
|
+BOOT_DRIVER ( "SKELETON/PCI", find_pci_boot_device,
|
|
215
|
+ skel_pci_driver, skel_pci_probe );
|
|
216
|
+
|