Przeglądaj źródła

Use "struct undi_device" instead of "struct pxe_device", and use the

function prefix "undinet_" and the variable name "undinic" in undinet.c,
so that we can reserve the variable name "undi" for a struct undi_device.

The idea is that we preserve the Etherboot 5.4 convention that the "UNDI"
code refers to our using an underlying UNDI stack, while the "PXE" code
refers to our providing a PXE API.
tags/v0.9.3
Michael Brown 18 lat temu
rodzic
commit
675fe200e5

+ 134
- 151
src/arch/i386/drivers/net/undinet.c Wyświetl plik

26
 #include <gpxe/netdevice.h>
26
 #include <gpxe/netdevice.h>
27
 #include <gpxe/if_ether.h>
27
 #include <gpxe/if_ether.h>
28
 #include <gpxe/ethernet.h>
28
 #include <gpxe/ethernet.h>
29
+#include <undi.h>
30
+#include <undinet.h>
31
+
29
 
32
 
30
 /** @file
33
 /** @file
31
  *
34
  *
41
 	unsigned int irq;
44
 	unsigned int irq;
42
 };
45
 };
43
 
46
 
44
-static void undi_close ( struct net_device *netdev );
47
+static void undinet_close ( struct net_device *netdev );
45
 
48
 
46
 /*****************************************************************************
49
 /*****************************************************************************
47
  *
50
  *
57
  * @ret name		API call name
60
  * @ret name		API call name
58
  */
61
  */
59
 static inline __attribute__ (( always_inline )) const char *
62
 static inline __attribute__ (( always_inline )) const char *
60
-undi_function_name ( unsigned int function ) {
63
+undinet_function_name ( unsigned int function ) {
61
 	switch ( function ) {
64
 	switch ( function ) {
62
-	case PXENV_UNLOAD_STACK:
63
-		return "PXENV_UNLOAD_STACK";
64
-	case PXENV_GET_CACHED_INFO:
65
-		return "PXENV_GET_CACHED_INFO";
66
-	case PXENV_RESTART_TFTP:
67
-		return "PXENV_RESTART_TFTP";
68
 	case PXENV_START_UNDI:
65
 	case PXENV_START_UNDI:
69
 		return "PXENV_START_UNDI";
66
 		return "PXENV_START_UNDI";
70
 	case PXENV_STOP_UNDI:
67
 	case PXENV_STOP_UNDI:
71
 		return "PXENV_STOP_UNDI";
68
 		return "PXENV_STOP_UNDI";
72
-	case PXENV_START_BASE:
73
-		return "PXENV_START_BASE";
74
-	case PXENV_STOP_BASE:
75
-		return "PXENV_STOP_BASE";
76
-	case PXENV_TFTP_OPEN:
77
-		return "PXENV_TFTP_OPEN";
78
-	case PXENV_TFTP_CLOSE:
79
-		return "PXENV_TFTP_CLOSE";
80
-	case PXENV_TFTP_READ:
81
-		return "PXENV_TFTP_READ";
82
-	case PXENV_TFTP_READ_FILE:
83
-		return "PXENV_TFTP_READ_FILE";
84
-	case PXENV_TFTP_GET_FSIZE:
85
-		return "PXENV_TFTP_GET_FSIZE";
86
-	case PXENV_UDP_OPEN:
87
-		return "PXENV_UDP_OPEN";
88
-	case PXENV_UDP_CLOSE:
89
-		return "PXENV_UDP_CLOSE";
90
-	case PXENV_UDP_WRITE:
91
-		return "PXENV_UDP_WRITE";
92
-	case PXENV_UDP_READ:
93
-		return "PXENV_UDP_READ";
94
 	case PXENV_UNDI_STARTUP:
69
 	case PXENV_UNDI_STARTUP:
95
 		return "PXENV_UNDI_STARTUP";
70
 		return "PXENV_UNDI_STARTUP";
96
 	case PXENV_UNDI_CLEANUP:
71
 	case PXENV_UNDI_CLEANUP:
148
  * Used as the paramter block for all UNDI API calls.  Resides in base
123
  * Used as the paramter block for all UNDI API calls.  Resides in base
149
  * memory.
124
  * memory.
150
  */
125
  */
151
-static union u_PXENV_ANY __data16 ( undi_params );
152
-#define undi_params __use_data16 ( undi_params )
126
+static union u_PXENV_ANY __data16 ( undinet_params );
127
+#define undinet_params __use_data16 ( undinet_params )
153
 
128
 
154
 /** UNDI entry point
129
 /** UNDI entry point
155
  *
130
  *
156
  * Used as the indirection vector for all UNDI API calls.  Resides in
131
  * Used as the indirection vector for all UNDI API calls.  Resides in
157
  * base memory.
132
  * base memory.
158
  */
133
  */
159
-static SEGOFF16_t __data16 ( undi_entry_point );
160
-#define undi_entry_point __use_data16 ( undi_entry_point )
134
+static SEGOFF16_t __data16 ( undinet_entry_point );
135
+#define undinet_entry_point __use_data16 ( undinet_entry_point )
161
 
136
 
162
 /**
137
 /**
163
  * Issue UNDI API call
138
  * Issue UNDI API call
164
  *
139
  *
165
- * @v undi		UNDI NIC
140
+ * @v undinic		UNDI NIC
166
  * @v function		API call number
141
  * @v function		API call number
167
  * @v params		UNDI parameter block
142
  * @v params		UNDI parameter block
168
  * @v params_len	Length of UNDI parameter block
143
  * @v params_len	Length of UNDI parameter block
169
  * @ret rc		Return status code
144
  * @ret rc		Return status code
170
  */
145
  */
171
-static int undi_call ( struct undi_nic *undi, unsigned int function,
172
-		       void *params, size_t params_len ) {
146
+static int undinet_call ( struct undi_nic *undinic, unsigned int function,
147
+			  void *params, size_t params_len ) {
173
 	union u_PXENV_ANY *pxenv_any = params;
148
 	union u_PXENV_ANY *pxenv_any = params;
174
 	PXENV_EXIT_t exit;
149
 	PXENV_EXIT_t exit;
175
 	int discard_b, discard_D;
150
 	int discard_b, discard_D;
176
 	int rc;
151
 	int rc;
177
 
152
 
178
 	/* Copy parameter block and entry point */
153
 	/* Copy parameter block and entry point */
179
-	assert ( params_len <= sizeof ( undi_params ) );
180
-	memcpy ( &undi_params, params, params_len );
181
-	undi_entry_point = undi->entry;
154
+	assert ( params_len <= sizeof ( undinet_params ) );
155
+	memcpy ( &undinet_params, params, params_len );
156
+	undinet_entry_point = undinic->entry;
182
 
157
 
183
 	/* Call real-mode entry point.  This calling convention will
158
 	/* Call real-mode entry point.  This calling convention will
184
 	 * work with both the !PXE and the PXENV+ entry points.
159
 	 * work with both the !PXE and the PXENV+ entry points.
190
 					   "addw $6, %%sp\n\t" )
165
 					   "addw $6, %%sp\n\t" )
191
 			       : "=a" ( exit ), "=b" ( discard_b ),
166
 			       : "=a" ( exit ), "=b" ( discard_b ),
192
 			         "=D" ( discard_D )
167
 			         "=D" ( discard_D )
193
-			       : "p" ( & __from_data16 ( undi_entry_point ) ),
168
+			       : "p" ( &__from_data16 ( undinet_entry_point )),
194
 			         "b" ( function ),
169
 			         "b" ( function ),
195
-			         "D" ( & __from_data16 ( undi_params ) )
170
+			         "D" ( &__from_data16 ( undinet_params ) )
196
 			       : "ecx", "edx", "esi", "ebp" );
171
 			       : "ecx", "edx", "esi", "ebp" );
197
 
172
 
198
 	/* UNDI API calls may rudely change the status of A20 and not
173
 	/* UNDI API calls may rudely change the status of A20 and not
206
 	gateA20_set();
181
 	gateA20_set();
207
 
182
 
208
 	/* Copy parameter block back */
183
 	/* Copy parameter block back */
209
-	memcpy ( params, &undi_params, params_len );
184
+	memcpy ( params, &undinet_params, params_len );
210
 
185
 
211
 	/* Determine return status code based on PXENV_EXIT and
186
 	/* Determine return status code based on PXENV_EXIT and
212
 	 * PXENV_STATUS
187
 	 * PXENV_STATUS
223
 	}
198
 	}
224
 
199
 
225
 	if ( rc != 0 ) {
200
 	if ( rc != 0 ) {
226
-		DBGC ( undi, "UNDI %p %s failed: %s\n", undi,
227
-		       undi_function_name ( function ), strerror ( rc ) );
201
+		DBGC ( undinic, "UNDINIC %p %s failed: %s\n", undinic,
202
+		       undinet_function_name ( function ), strerror ( rc ) );
228
 	}
203
 	}
229
 	return rc;
204
 	return rc;
230
 }
205
 }
242
  * The UNDI ISR simply increments a counter (@c trigger_count) and
217
  * The UNDI ISR simply increments a counter (@c trigger_count) and
243
  * exits.
218
  * exits.
244
  */
219
  */
245
-extern void undi_isr ( void );
220
+extern void undinet_isr ( void );
246
 
221
 
247
 /** Dummy chain vector */
222
 /** Dummy chain vector */
248
 static struct segoff prev_handler[ IRQ_MAX + 1 ];
223
 static struct segoff prev_handler[ IRQ_MAX + 1 ];
263
  * interrupting device) and some disable the interrupt at the PIC (and
238
  * interrupting device) and some disable the interrupt at the PIC (and
264
  * so will bring our own interrupts to a shuddering halt).
239
  * so will bring our own interrupts to a shuddering halt).
265
  */
240
  */
266
-static void undi_hook_isr ( unsigned int irq ) {
241
+static void undinet_hook_isr ( unsigned int irq ) {
267
 
242
 
268
 	assert ( irq <= IRQ_MAX );
243
 	assert ( irq <= IRQ_MAX );
269
 
244
 
270
-	__asm__ __volatile__ ( TEXT16_CODE ( "\nundi_isr:\n\t"
245
+	__asm__ __volatile__ ( TEXT16_CODE ( "\nundinet_isr:\n\t"
271
 					     "incb %%cs:%c0\n\t"
246
 					     "incb %%cs:%c0\n\t"
272
 					     "iret\n\t" )
247
 					     "iret\n\t" )
273
 			       : : "p" ( & __from_text16 ( trigger_count ) ) );
248
 			       : : "p" ( & __from_text16 ( trigger_count ) ) );
274
 
249
 
275
-	hook_bios_interrupt ( IRQ_INT ( irq ), ( ( unsigned int ) undi_isr ),
250
+	hook_bios_interrupt ( IRQ_INT ( irq ),
251
+			      ( ( unsigned int ) undinet_isr ),
276
 			      &prev_handler[irq] );
252
 			      &prev_handler[irq] );
277
 
253
 
278
 }
254
 }
282
  *
258
  *
283
  * @v irq		IRQ number
259
  * @v irq		IRQ number
284
  */
260
  */
285
-static void undi_unhook_isr ( unsigned int irq ) {
261
+static void undinet_unhook_isr ( unsigned int irq ) {
286
 
262
 
287
 	assert ( irq <= IRQ_MAX );
263
 	assert ( irq <= IRQ_MAX );
288
 
264
 
289
-	unhook_bios_interrupt ( IRQ_INT ( irq ), ( ( unsigned int ) undi_isr ),
265
+	unhook_bios_interrupt ( IRQ_INT ( irq ),
266
+				( ( unsigned int ) undinet_isr ),
290
 				&prev_handler[irq] );
267
 				&prev_handler[irq] );
291
 }
268
 }
292
 
269
 
295
  *
272
  *
296
  * @ret triggered	ISR has been triggered since last check
273
  * @ret triggered	ISR has been triggered since last check
297
  */
274
  */
298
-static int undi_isr_triggered ( void ) {
275
+static int undinet_isr_triggered ( void ) {
299
 	static unsigned int last_trigger_count = 0;
276
 	static unsigned int last_trigger_count = 0;
300
 	unsigned int this_trigger_count;
277
 	unsigned int this_trigger_count;
301
 
278
 
328
 };
305
 };
329
 
306
 
330
 /** UNDI packet buffer */
307
 /** UNDI packet buffer */
331
-static struct undi_packet __data16 ( undi_pkb );
332
-#define undi_pkb __use_data16 ( undi_pkb )
308
+static struct undi_packet __data16 ( undinet_pkb );
309
+#define undinet_pkb __use_data16 ( undinet_pkb )
333
 
310
 
334
 /** UNDI transmit buffer descriptor */
311
 /** UNDI transmit buffer descriptor */
335
-static struct s_PXENV_UNDI_TBD __data16 ( undi_tbd );
336
-#define undi_tbd __use_data16 ( undi_tbd )
312
+static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
313
+#define undinet_tbd __use_data16 ( undinet_tbd )
337
 
314
 
338
 /**
315
 /**
339
  * Transmit packet
316
  * Transmit packet
342
  * @v pkb		Packet buffer
319
  * @v pkb		Packet buffer
343
  * @ret rc		Return status code
320
  * @ret rc		Return status code
344
  */
321
  */
345
-static int undi_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
346
-	struct undi_nic *undi = netdev->priv;
322
+static int undinet_transmit ( struct net_device *netdev,
323
+			      struct pk_buff *pkb ) {
324
+	struct undi_nic *undinic = netdev->priv;
347
 	struct s_PXENV_UNDI_TRANSMIT undi_transmit;
325
 	struct s_PXENV_UNDI_TRANSMIT undi_transmit;
348
 	size_t len = pkb_len ( pkb );
326
 	size_t len = pkb_len ( pkb );
349
 	int rc;
327
 	int rc;
350
 
328
 
351
 	/* Copy packet to UNDI packet buffer */
329
 	/* Copy packet to UNDI packet buffer */
352
-	if ( len > sizeof ( undi_pkb ) )
353
-		len = sizeof ( undi_pkb );
354
-	memcpy ( &undi_pkb, pkb->data, len );
330
+	if ( len > sizeof ( undinet_pkb ) )
331
+		len = sizeof ( undinet_pkb );
332
+	memcpy ( &undinet_pkb, pkb->data, len );
355
 
333
 
356
 	/* Create PXENV_UNDI_TRANSMIT data structure */
334
 	/* Create PXENV_UNDI_TRANSMIT data structure */
357
 	memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
335
 	memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
358
 	undi_transmit.DestAddr.segment = rm_ds;
336
 	undi_transmit.DestAddr.segment = rm_ds;
359
 	undi_transmit.DestAddr.offset
337
 	undi_transmit.DestAddr.offset
360
-		= ( ( unsigned ) & __from_data16 ( undi_tbd ) );
338
+		= ( ( unsigned ) & __from_data16 ( undinet_tbd ) );
361
 	undi_transmit.TBD.segment = rm_ds;
339
 	undi_transmit.TBD.segment = rm_ds;
362
 	undi_transmit.TBD.offset
340
 	undi_transmit.TBD.offset
363
-		= ( ( unsigned ) & __from_data16 ( undi_tbd ) );
341
+		= ( ( unsigned ) & __from_data16 ( undinet_tbd ) );
364
 
342
 
365
 	/* Create PXENV_UNDI_TBD data structure */
343
 	/* Create PXENV_UNDI_TBD data structure */
366
-	undi_tbd.ImmedLength = len;
367
-	undi_tbd.Xmit.segment = rm_ds;
368
-	undi_tbd.Xmit.offset 
369
-		= ( ( unsigned ) & __from_data16 ( undi_pkb ) );
344
+	undinet_tbd.ImmedLength = len;
345
+	undinet_tbd.Xmit.segment = rm_ds;
346
+	undinet_tbd.Xmit.offset 
347
+		= ( ( unsigned ) & __from_data16 ( undinet_pkb ) );
370
 
348
 
371
 	/* Issue PXE API call */
349
 	/* Issue PXE API call */
372
-	rc = undi_call ( undi, PXENV_UNDI_TRANSMIT, &undi_transmit,
373
-			 sizeof ( undi_transmit ) );
350
+	rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT, &undi_transmit,
351
+			    sizeof ( undi_transmit ) );
374
 
352
 
375
 	/* Free packet buffer and return */
353
 	/* Free packet buffer and return */
376
 	free_pkb ( pkb );
354
 	free_pkb ( pkb );
384
  *
362
  *
385
  * Fun, fun, fun.  UNDI drivers don't use polling; they use
363
  * Fun, fun, fun.  UNDI drivers don't use polling; they use
386
  * interrupts.  We therefore cheat and pretend that an interrupt has
364
  * interrupts.  We therefore cheat and pretend that an interrupt has
387
- * occurred every time undi_poll() is called.  This isn't too much of
388
- * a hack; PCI devices share IRQs and so the first thing that a proper
389
- * ISR should do is call PXENV_UNDI_ISR to determine whether or not
390
- * the UNDI NIC generated the interrupt; there is no harm done by
365
+ * occurred every time undinet_poll() is called.  This isn't too much
366
+ * of a hack; PCI devices share IRQs and so the first thing that a
367
+ * proper ISR should do is call PXENV_UNDI_ISR to determine whether or
368
+ * not the UNDI NIC generated the interrupt; there is no harm done by
391
  * spurious calls to PXENV_UNDI_ISR.  Similarly, we wouldn't be
369
  * spurious calls to PXENV_UNDI_ISR.  Similarly, we wouldn't be
392
- * handling them any more rapidly than the usual rate of undi_poll()
393
- * being called even if we did implement a full ISR.  So it should
394
- * work.  Ha!
370
+ * handling them any more rapidly than the usual rate of
371
+ * undinet_poll() being called even if we did implement a full ISR.
372
+ * So it should work.  Ha!
395
  *
373
  *
396
  * Addendum (21/10/03).  Some cards don't play nicely with this trick,
374
  * Addendum (21/10/03).  Some cards don't play nicely with this trick,
397
  * so instead of doing it the easy way we have to go to all the hassle
375
  * so instead of doing it the easy way we have to go to all the hassle
398
  * of installing a genuine interrupt service routine and dealing with
376
  * of installing a genuine interrupt service routine and dealing with
399
  * the wonderful 8259 Programmable Interrupt Controller.  Joy.
377
  * the wonderful 8259 Programmable Interrupt Controller.  Joy.
400
  */
378
  */
401
-static void undi_poll ( struct net_device *netdev ) {
402
-	struct undi_nic *undi = netdev->priv;
379
+static void undinet_poll ( struct net_device *netdev ) {
380
+	struct undi_nic *undinic = netdev->priv;
403
 	struct s_PXENV_UNDI_ISR undi_isr;
381
 	struct s_PXENV_UNDI_ISR undi_isr;
404
 	struct pk_buff *pkb = NULL;
382
 	struct pk_buff *pkb = NULL;
405
 	size_t len;
383
 	size_t len;
407
 	int rc;
385
 	int rc;
408
 
386
 
409
 	/* Do nothing unless ISR has been triggered */
387
 	/* Do nothing unless ISR has been triggered */
410
-	if ( ! undi_isr_triggered() )
388
+	if ( ! undinet_isr_triggered() )
411
 		return;
389
 		return;
412
 
390
 
413
 	/* See if this was our interrupt */
391
 	/* See if this was our interrupt */
414
 	memset ( &undi_isr, 0, sizeof ( undi_isr ) );
392
 	memset ( &undi_isr, 0, sizeof ( undi_isr ) );
415
 	undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_START;
393
 	undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_START;
416
-	if ( ( rc = undi_call ( undi, PXENV_UNDI_ISR, &undi_isr,
417
-				sizeof ( undi_isr ) ) ) != 0 )
394
+	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_ISR, &undi_isr,
395
+				   sizeof ( undi_isr ) ) ) != 0 )
418
 		return;
396
 		return;
419
 	if ( undi_isr.FuncFlag != PXENV_UNDI_ISR_OUT_OURS )
397
 	if ( undi_isr.FuncFlag != PXENV_UNDI_ISR_OUT_OURS )
420
 		return;
398
 		return;
421
 
399
 
422
 	/* Send EOI */
400
 	/* Send EOI */
423
-	send_eoi ( undi->irq );
401
+	send_eoi ( undinic->irq );
424
 
402
 
425
 	/* Run through the ISR loop */
403
 	/* Run through the ISR loop */
426
 	undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_PROCESS;
404
 	undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_PROCESS;
427
 	while ( 1 ) {
405
 	while ( 1 ) {
428
-		if ( ( rc = undi_call ( undi, PXENV_UNDI_ISR, &undi_isr,
429
-					sizeof ( undi_isr ) ) ) != 0 )
406
+		if ( ( rc = undinet_call ( undinic, PXENV_UNDI_ISR, &undi_isr,
407
+					   sizeof ( undi_isr ) ) ) != 0 )
430
 			break;
408
 			break;
431
 		switch ( undi_isr.FuncFlag ) {
409
 		switch ( undi_isr.FuncFlag ) {
432
 		case PXENV_UNDI_ISR_OUT_TRANSMIT:
410
 		case PXENV_UNDI_ISR_OUT_TRANSMIT:
439
 			if ( ! pkb )
417
 			if ( ! pkb )
440
 				pkb = alloc_pkb ( len );
418
 				pkb = alloc_pkb ( len );
441
 			if ( ! pkb ) {
419
 			if ( ! pkb ) {
442
-				DBGC ( undi, "UNDI %p could not allocate %zd "
443
-				       "bytes for receive buffer\n",
444
-				       undi, len );
420
+				DBGC ( undinic, "UNDINIC %p could not "
421
+				       "allocate %zd bytes for RX buffer\n",
422
+				       undinic, len );
445
 				break;
423
 				break;
446
 			}
424
 			}
447
 			if ( frag_len > pkb_available ( pkb ) ) {
425
 			if ( frag_len > pkb_available ( pkb ) ) {
448
-				DBGC ( undi, "UNDI %p fragment too large\n",
449
-				       undi );
426
+				DBGC ( undinic, "UNDINIC %p fragment too "
427
+				       "large\n", undinic );
450
 				frag_len = pkb_available ( pkb );
428
 				frag_len = pkb_available ( pkb );
451
 			}
429
 			}
452
 			copy_from_real ( pkb_put ( pkb, frag_len ),
430
 			copy_from_real ( pkb_put ( pkb, frag_len ),
462
 			goto done;
440
 			goto done;
463
 		default:
441
 		default:
464
 			/* Should never happen */
442
 			/* Should never happen */
465
-			DBGC ( undi, "UNDI %p ISR returned invalid FuncFlag "
466
-			       "%04x\n", undi, undi_isr.FuncFlag );
443
+			DBGC ( undinic, "UNDINIC %p ISR returned invalid "
444
+			       "FuncFlag %04x\n", undinic, undi_isr.FuncFlag );
467
 			goto done;
445
 			goto done;
468
 		}
446
 		}
469
 		undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;
447
 		undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;
471
 
449
 
472
  done:
450
  done:
473
 	if ( pkb ) {
451
 	if ( pkb ) {
474
-		DBGC ( undi, "UNDI %p returned incomplete packet\n", undi );
452
+		DBGC ( undinic, "UNDINIC %p returned incomplete packet\n",
453
+		       undinic );
475
 		netdev_rx ( netdev, pkb );
454
 		netdev_rx ( netdev, pkb );
476
 	}
455
 	}
477
 }
456
 }
482
  * @v netdev		Net device
461
  * @v netdev		Net device
483
  * @ret rc		Return status code
462
  * @ret rc		Return status code
484
  */
463
  */
485
-static int undi_open ( struct net_device *netdev ) {
486
-	struct undi_nic *undi = netdev->priv;
464
+static int undinet_open ( struct net_device *netdev ) {
465
+	struct undi_nic *undinic = netdev->priv;
487
 	struct s_PXENV_UNDI_SET_STATION_ADDRESS set_address;
466
 	struct s_PXENV_UNDI_SET_STATION_ADDRESS set_address;
488
 	struct s_PXENV_UNDI_OPEN open;
467
 	struct s_PXENV_UNDI_OPEN open;
489
 	int rc;
468
 	int rc;
490
 
469
 
491
 	/* Hook interrupt service routine and enable interrupt */
470
 	/* Hook interrupt service routine and enable interrupt */
492
-	undi_hook_isr ( undi->irq );
493
-	enable_irq ( undi->irq );
471
+	undinet_hook_isr ( undinic->irq );
472
+	enable_irq ( undinic->irq );
494
 
473
 
495
 	/* Set station address.  Required for some PXE stacks; will
474
 	/* Set station address.  Required for some PXE stacks; will
496
 	 * spuriously fail on others.  Ignore failures.  We only ever
475
 	 * spuriously fail on others.  Ignore failures.  We only ever
499
 	 */
478
 	 */
500
 	memcpy ( set_address.StationAddress, netdev->ll_addr,
479
 	memcpy ( set_address.StationAddress, netdev->ll_addr,
501
 		 sizeof ( set_address.StationAddress ) );
480
 		 sizeof ( set_address.StationAddress ) );
502
-	undi_call ( undi, PXENV_UNDI_SET_STATION_ADDRESS,
503
-		    &set_address, sizeof ( set_address ) );
481
+	undinet_call ( undinic, PXENV_UNDI_SET_STATION_ADDRESS,
482
+		       &set_address, sizeof ( set_address ) );
504
 
483
 
505
 	/* Open NIC */
484
 	/* Open NIC */
506
 	memset ( &open, 0, sizeof ( open ) );
485
 	memset ( &open, 0, sizeof ( open ) );
507
 	open.PktFilter = ( FLTR_DIRECTED | FLTR_BRDCST );
486
 	open.PktFilter = ( FLTR_DIRECTED | FLTR_BRDCST );
508
-	if ( ( rc = undi_call ( undi, PXENV_UNDI_OPEN, &open,
509
-				sizeof ( open ) ) ) != 0 )
487
+	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_OPEN, &open,
488
+				   sizeof ( open ) ) ) != 0 )
510
 		goto err;
489
 		goto err;
511
 
490
 
512
 	return 0;
491
 	return 0;
513
 
492
 
514
  err:
493
  err:
515
-	undi_close ( netdev );
494
+	undinet_close ( netdev );
516
 	return rc;
495
 	return rc;
517
 }
496
 }
518
 
497
 
521
  *
500
  *
522
  * @v netdev		Net device
501
  * @v netdev		Net device
523
  */
502
  */
524
-static void undi_close ( struct net_device *netdev ) {
525
-	struct undi_nic *undi = netdev->priv;
503
+static void undinet_close ( struct net_device *netdev ) {
504
+	struct undi_nic *undinic = netdev->priv;
526
 	struct s_PXENV_UNDI_CLOSE close;
505
 	struct s_PXENV_UNDI_CLOSE close;
527
 
506
 
528
 	/* Close NIC */
507
 	/* Close NIC */
529
-	undi_call ( undi, PXENV_UNDI_CLOSE, &close, sizeof ( close ) );
508
+	undinet_call ( undinic, PXENV_UNDI_CLOSE, &close, sizeof ( close ) );
530
 
509
 
531
 	/* Disable interrupt and unhook ISR */
510
 	/* Disable interrupt and unhook ISR */
532
-	disable_irq ( undi->irq );
533
-	undi_unhook_isr ( undi->irq );
511
+	disable_irq ( undinic->irq );
512
+	undinet_unhook_isr ( undinic->irq );
534
 }
513
 }
535
 
514
 
536
 /**
515
 /**
537
- * Probe PXE device
516
+ * Probe UNDI device
538
  *
517
  *
539
- * @v pxe		PXE device
518
+ * @v undi		UNDI device
540
  * @ret rc		Return status code
519
  * @ret rc		Return status code
541
  */
520
  */
542
-int undi_probe ( struct pxe_device *pxe ) {
521
+int undinet_probe ( struct undi_device *undi ) {
543
 	struct net_device *netdev;
522
 	struct net_device *netdev;
544
-	struct undi_nic *undi;
523
+	struct undi_nic *undinic;
545
 	struct s_PXENV_START_UNDI start_undi;
524
 	struct s_PXENV_START_UNDI start_undi;
546
 	struct s_PXENV_UNDI_STARTUP undi_startup;
525
 	struct s_PXENV_UNDI_STARTUP undi_startup;
547
 	struct s_PXENV_UNDI_INITIALIZE undi_initialize;
526
 	struct s_PXENV_UNDI_INITIALIZE undi_initialize;
552
 	int rc;
531
 	int rc;
553
 
532
 
554
 	/* Allocate net device */
533
 	/* Allocate net device */
555
-	netdev = alloc_etherdev ( sizeof ( *undi ) );
534
+	netdev = alloc_etherdev ( sizeof ( *undinic ) );
556
 	if ( ! netdev )
535
 	if ( ! netdev )
557
 		return -ENOMEM;
536
 		return -ENOMEM;
558
-	undi = netdev->priv;
559
-	pxe_set_drvdata ( pxe, netdev );
560
-	memset ( undi, 0, sizeof ( *undi ) );
561
-	undi->entry = pxe->entry;
537
+	undinic = netdev->priv;
538
+	undi_set_drvdata ( undi, netdev );
539
+	memset ( undinic, 0, sizeof ( *undinic ) );
540
+	undinic->entry = undi->entry;
562
 
541
 
563
 	/* Hook in UNDI stack */
542
 	/* Hook in UNDI stack */
564
 	memset ( &start_undi, 0, sizeof ( start_undi ) );
543
 	memset ( &start_undi, 0, sizeof ( start_undi ) );
565
-	start_undi.AX = pxe->pci_busdevfn;
566
-	start_undi.BX = pxe->isapnp_csn;
567
-	start_undi.DX = pxe->isapnp_read_port;
544
+	start_undi.AX = undi->pci_busdevfn;
545
+	start_undi.BX = undi->isapnp_csn;
546
+	start_undi.DX = undi->isapnp_read_port;
568
 	start_undi.ES = BIOS_SEG;
547
 	start_undi.ES = BIOS_SEG;
569
 	start_undi.DI = find_pnp_bios();
548
 	start_undi.DI = find_pnp_bios();
570
-	if ( ( rc = undi_call ( undi, PXENV_START_UNDI, &start_undi,
571
-				sizeof ( start_undi ) ) ) != 0 )
549
+	if ( ( rc = undinet_call ( undinic, PXENV_START_UNDI, &start_undi,
550
+				   sizeof ( start_undi ) ) ) != 0 )
572
 		goto err_start_undi;
551
 		goto err_start_undi;
573
 
552
 
574
 	/* Bring up UNDI stack */
553
 	/* Bring up UNDI stack */
575
 	memset ( &undi_startup, 0, sizeof ( undi_startup ) );
554
 	memset ( &undi_startup, 0, sizeof ( undi_startup ) );
576
-	if ( ( rc = undi_call ( undi, PXENV_UNDI_STARTUP, &undi_startup,
577
-				sizeof ( undi_startup ) ) ) != 0 )
555
+	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP, &undi_startup,
556
+				   sizeof ( undi_startup ) ) ) != 0 )
578
 		goto err_undi_startup;
557
 		goto err_undi_startup;
579
 	memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
558
 	memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
580
-	if ( ( rc = undi_call ( undi, PXENV_UNDI_INITIALIZE, &undi_initialize,
581
-				sizeof ( undi_initialize ) ) ) != 0 )
559
+	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
560
+				   &undi_initialize,
561
+				   sizeof ( undi_initialize ) ) ) != 0 )
582
 		goto err_undi_initialize;
562
 		goto err_undi_initialize;
583
 
563
 
584
 	/* Get device information */
564
 	/* Get device information */
585
 	memset ( &undi_info, 0, sizeof ( undi_info ) );
565
 	memset ( &undi_info, 0, sizeof ( undi_info ) );
586
-	if ( ( rc = undi_call ( undi, PXENV_UNDI_GET_INFORMATION, &undi_info,
587
-				sizeof ( undi_info ) ) ) != 0 )
566
+	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_INFORMATION,
567
+				   &undi_info, sizeof ( undi_info ) ) ) != 0 )
588
 		goto err_undi_get_information;
568
 		goto err_undi_get_information;
589
 	memcpy ( netdev->ll_addr, undi_info.PermNodeAddress, ETH_ALEN );
569
 	memcpy ( netdev->ll_addr, undi_info.PermNodeAddress, ETH_ALEN );
590
-	undi->irq = undi_info.IntNumber;
591
-	if ( undi->irq > IRQ_MAX ) {
592
-		DBGC ( undi, "UNDI %p invalid IRQ %d\n", undi, undi->irq );
570
+	undinic->irq = undi_info.IntNumber;
571
+	if ( undinic->irq > IRQ_MAX ) {
572
+		DBGC ( undinic, "UNDINIC %p invalid IRQ %d\n",
573
+		       undinic, undinic->irq );
593
 		goto err_bad_irq;
574
 		goto err_bad_irq;
594
 	}
575
 	}
595
-	DBGC ( undi, "UNDI %p (%s) using IRQ %d\n",
596
-	       undi, eth_ntoa ( netdev->ll_addr ), undi->irq );
576
+	DBGC ( undinic, "UNDINIC %p (%s) using IRQ %d\n",
577
+	       undinic, eth_ntoa ( netdev->ll_addr ), undinic->irq );
597
 
578
 
598
 	/* Point to NIC specific routines */
579
 	/* Point to NIC specific routines */
599
-	netdev->open	 = undi_open;
600
-	netdev->close	 = undi_close;
601
-	netdev->transmit = undi_transmit;
602
-	netdev->poll	 = undi_poll;
580
+	netdev->open	 = undinet_open;
581
+	netdev->close	 = undinet_close;
582
+	netdev->transmit = undinet_transmit;
583
+	netdev->poll	 = undinet_poll;
603
 
584
 
604
 	/* Register network device */
585
 	/* Register network device */
605
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
586
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
613
  err_undi_initialize:
594
  err_undi_initialize:
614
 	/* Shut down UNDI stack */
595
 	/* Shut down UNDI stack */
615
 	memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
596
 	memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
616
-	undi_call ( undi, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
617
-		    sizeof ( undi_shutdown ) );
597
+	undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
598
+		       sizeof ( undi_shutdown ) );
618
 	memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
599
 	memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
619
-	undi_call ( undi, PXENV_UNDI_CLEANUP, &undi_cleanup,
620
-		    sizeof ( undi_cleanup ) );
600
+	undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
601
+		       sizeof ( undi_cleanup ) );
621
  err_undi_startup:
602
  err_undi_startup:
622
 	/* Unhook UNDI stack */
603
 	/* Unhook UNDI stack */
623
 	memset ( &stop_undi, 0, sizeof ( stop_undi ) );
604
 	memset ( &stop_undi, 0, sizeof ( stop_undi ) );
624
-	undi_call ( undi, PXENV_STOP_UNDI, &stop_undi, sizeof ( stop_undi ) );
605
+	undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
606
+		       sizeof ( stop_undi ) );
625
  err_start_undi:
607
  err_start_undi:
626
 	free_netdev ( netdev );
608
 	free_netdev ( netdev );
627
-	pxe_set_drvdata ( pxe, NULL );
609
+	undi_set_drvdata ( undi, NULL );
628
 	return rc;
610
 	return rc;
629
 }
611
 }
630
 
612
 
631
 /**
613
 /**
632
- * Remove PXE device
614
+ * Remove UNDI device
633
  *
615
  *
634
- * @v pxe		PXE device
616
+ * @v undi		UNDI device
635
  */
617
  */
636
-void undi_remove ( struct pxe_device *pxe ) {
637
-	struct net_device *netdev = pxe_get_drvdata ( pxe );
638
-	struct undi_nic *undi = netdev->priv;
618
+void undinet_remove ( struct undi_device *undi ) {
619
+	struct net_device *netdev = undi_get_drvdata ( undi );
620
+	struct undi_nic *undinic = netdev->priv;
639
 	struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
621
 	struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
640
 	struct s_PXENV_UNDI_CLEANUP undi_cleanup;
622
 	struct s_PXENV_UNDI_CLEANUP undi_cleanup;
641
 	struct s_PXENV_STOP_UNDI stop_undi;
623
 	struct s_PXENV_STOP_UNDI stop_undi;
645
 
627
 
646
 	/* Shut down UNDI stack */
628
 	/* Shut down UNDI stack */
647
 	memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
629
 	memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
648
-	undi_call ( undi, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
649
-		    sizeof ( undi_shutdown ) );
630
+	undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
631
+		       sizeof ( undi_shutdown ) );
650
 	memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
632
 	memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
651
-	undi_call ( undi, PXENV_UNDI_CLEANUP, &undi_cleanup,
652
-		    sizeof ( undi_cleanup ) );
633
+	undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
634
+		       sizeof ( undi_cleanup ) );
653
 
635
 
654
 	/* Unhook UNDI stack */
636
 	/* Unhook UNDI stack */
655
 	memset ( &stop_undi, 0, sizeof ( stop_undi ) );
637
 	memset ( &stop_undi, 0, sizeof ( stop_undi ) );
656
-	undi_call ( undi, PXENV_STOP_UNDI, &stop_undi, sizeof ( stop_undi ) );
638
+	undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
639
+		       sizeof ( stop_undi ) );
657
 
640
 
658
 	/* Free network device */
641
 	/* Free network device */
659
 	free_netdev ( netdev );
642
 	free_netdev ( netdev );

+ 59
- 0
src/arch/i386/include/undi.h Wyświetl plik

1
+#ifndef _UNDI_H
2
+#define _UNDI_H
3
+
4
+/** @file
5
+ *
6
+ * UNDI driver
7
+ *
8
+ */
9
+
10
+/** An UNDI device */
11
+struct undi_device {
12
+	/** Generic device */
13
+	struct device dev;
14
+	/** Driver-private data
15
+	 *
16
+	 * Use undi_set_drvdata() and undi_get_drvdata() to access this
17
+	 * field.
18
+	 */
19
+	void *priv;
20
+
21
+	/** PXENV+ structure address */
22
+	SEGOFF16_t pxenv;
23
+	/** !PXE structure address */
24
+	SEGOFF16_t ppxe;
25
+	/** Entry point */
26
+	SEGOFF16_t entry;
27
+	/** PCI bus:dev.fn, or 0 */
28
+	unsigned int pci_busdevfn;
29
+	/** ISAPnP card select number, or -1U */
30
+	unsigned int isapnp_csn;
31
+	/** ISAPnP read port, or -1U */
32
+	unsigned int isapnp_read_port;
33
+	/** Free base memory prior to load */
34
+	unsigned int restore_fbms;
35
+	/** Free base memory after load */
36
+	unsigned int fbms;
37
+};
38
+
39
+/**
40
+ * Set UNDI driver-private data
41
+ *
42
+ * @v undi		UNDI device
43
+ * @v priv		Private data
44
+ */
45
+static inline void undi_set_drvdata ( struct undi_device *undi, void *priv ) {
46
+	undi->priv = priv;
47
+}
48
+
49
+/**
50
+ * Get UNDI driver-private data
51
+ *
52
+ * @v undi		UNDI device
53
+ * @ret priv		Private data
54
+ */
55
+static inline void * undi_get_drvdata ( struct undi_device *undi ) {
56
+	return undi->priv;
57
+}
58
+
59
+#endif /* _UNDI_H */

+ 15
- 0
src/arch/i386/include/undinet.h Wyświetl plik

1
+#ifndef _UNDINET_H
2
+#define _UNDINET_H
3
+
4
+/** @file
5
+ *
6
+ * UNDI network device driver
7
+ *
8
+ */
9
+
10
+struct undi_device;
11
+
12
+extern int undinet_probe ( struct undi_device *undi );
13
+extern void undinet_remove ( struct undi_device *undi );
14
+
15
+#endif /* _UNDINET_H */

Ładowanie…
Anuluj
Zapisz