|
@@ -21,11 +21,33 @@ Skeleton NIC driver for Etherboot
|
21
|
21
|
#include "isapnp.h"
|
22
|
22
|
#include "mca.h"
|
23
|
23
|
|
24
|
|
-/* NIC specific static variables go here. Try to avoid using static
|
|
24
|
+/*
|
|
25
|
+ * NIC specific static variables go here. Try to avoid using static
|
25
|
26
|
* variables wherever possible. In particular, the I/O address can
|
26
|
27
|
* always be accessed via nic->ioaddr.
|
27
|
28
|
*/
|
28
|
29
|
|
|
30
|
+/*
|
|
31
|
+ * If you have large static variables (e.g. transmit and receive
|
|
32
|
+ * buffers), you should place them together in a single structure and
|
|
33
|
+ * mark the structure as "shared". This enables this space to be
|
|
34
|
+ * shared between drivers in multi-driver images, which can easily
|
|
35
|
+ * reduce the runtime size by 50%.
|
|
36
|
+ *
|
|
37
|
+ */
|
|
38
|
+#define SKEL_RX_BUFS 1
|
|
39
|
+#define SKEL_TX_BUFS 1
|
|
40
|
+#define SKEL_RX_BUFSIZE 0
|
|
41
|
+#define SKEL_TX_BUFSIZE 0
|
|
42
|
+struct skel_rx_desc {};
|
|
43
|
+struct skel_tx_desc {};
|
|
44
|
+struct {
|
|
45
|
+ struct skel_rx_desc rxd[SKEL_RX_BUFS];
|
|
46
|
+ unsigned char rxb[SKEL_RX_BUFS][SKEL_RX_BUFSIZE];
|
|
47
|
+ struct skel_tx_desc txd[SKEL_TX_BUFS];
|
|
48
|
+ unsigned char txb[SKEL_TX_BUFS][SKEL_TX_BUFSIZE];
|
|
49
|
+} skel_bufs __shared;
|
|
50
|
+
|
29
|
51
|
/*
|
30
|
52
|
* Don't forget to remove "__unused" from all the function parameters!
|
31
|
53
|
*
|
|
@@ -48,6 +70,29 @@ static int skel_connect ( struct nic *nic __unused ) {
|
48
|
70
|
return 1;
|
49
|
71
|
}
|
50
|
72
|
|
|
73
|
+/**************************************************************************
|
|
74
|
+ * TRANSMIT - Transmit a frame
|
|
75
|
+ **************************************************************************
|
|
76
|
+*/
|
|
77
|
+static void skel_transmit ( struct nic *nic __unused,
|
|
78
|
+ const char *dest __unused,
|
|
79
|
+ unsigned int type __unused,
|
|
80
|
+ unsigned int size __unused,
|
|
81
|
+ const char *packet __unused ) {
|
|
82
|
+ /* Transmit packet to dest MAC address. You will need to
|
|
83
|
+ * construct the link-layer header (dest MAC, source MAC,
|
|
84
|
+ * type).
|
|
85
|
+ */
|
|
86
|
+ /*
|
|
87
|
+ unsigned int nstype = htons ( type );
|
|
88
|
+ memcpy ( <tx_buffer>, dest, ETH_ALEN );
|
|
89
|
+ memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN );
|
|
90
|
+ memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 );
|
|
91
|
+ memcpy ( <tx_buffer> + ETH_HLEN, data, size );
|
|
92
|
+ <transmit_data> ( <tx_buffer>, size + ETH_HLEN );
|
|
93
|
+ */
|
|
94
|
+}
|
|
95
|
+
|
51
|
96
|
/**************************************************************************
|
52
|
97
|
* POLL - Wait for a frame
|
53
|
98
|
**************************************************************************
|
|
@@ -81,29 +126,6 @@ static int skel_poll ( struct nic *nic __unused, int retrieve __unused ) {
|
81
|
126
|
return 0; /* Remove this line once this method is implemented */
|
82
|
127
|
}
|
83
|
128
|
|
84
|
|
-/**************************************************************************
|
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 ) {
|
93
|
|
- /* Transmit packet to dest MAC address. You will need to
|
94
|
|
- * construct the link-layer header (dest MAC, source MAC,
|
95
|
|
- * type).
|
96
|
|
- */
|
97
|
|
- /*
|
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 );
|
104
|
|
- */
|
105
|
|
-}
|
106
|
|
-
|
107
|
129
|
/**************************************************************************
|
108
|
130
|
* IRQ - handle interrupts
|
109
|
131
|
**************************************************************************
|
|
@@ -143,8 +165,8 @@ static void skel_irq ( struct nic *nic __unused, irq_action_t action ) {
|
143
|
165
|
*/
|
144
|
166
|
static struct nic_operations skel_operations = {
|
145
|
167
|
.connect = skel_connect,
|
146
|
|
- .poll = skel_poll,
|
147
|
168
|
.transmit = skel_transmit,
|
|
169
|
+ .poll = skel_poll,
|
148
|
170
|
.irq = skel_irq,
|
149
|
171
|
};
|
150
|
172
|
|