Browse Source

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 17 years ago
parent
commit
675fe200e5
3 changed files with 208 additions and 151 deletions
  1. 134
    151
      src/arch/i386/drivers/net/undinet.c
  2. 59
    0
      src/arch/i386/include/undi.h
  3. 15
    0
      src/arch/i386/include/undinet.h

+ 134
- 151
src/arch/i386/drivers/net/undinet.c View File

@@ -26,6 +26,9 @@
26 26
 #include <gpxe/netdevice.h>
27 27
 #include <gpxe/if_ether.h>
28 28
 #include <gpxe/ethernet.h>
29
+#include <undi.h>
30
+#include <undinet.h>
31
+
29 32
 
30 33
 /** @file
31 34
  *
@@ -41,7 +44,7 @@ struct undi_nic {
41 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,40 +60,12 @@ static void undi_close ( struct net_device *netdev );
57 60
  * @ret name		API call name
58 61
  */
59 62
 static inline __attribute__ (( always_inline )) const char *
60
-undi_function_name ( unsigned int function ) {
63
+undinet_function_name ( unsigned int function ) {
61 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 65
 	case PXENV_START_UNDI:
69 66
 		return "PXENV_START_UNDI";
70 67
 	case PXENV_STOP_UNDI:
71 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 69
 	case PXENV_UNDI_STARTUP:
95 70
 		return "PXENV_UNDI_STARTUP";
96 71
 	case PXENV_UNDI_CLEANUP:
@@ -148,37 +123,37 @@ undi_function_name ( unsigned int function ) {
148 123
  * Used as the paramter block for all UNDI API calls.  Resides in base
149 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 129
 /** UNDI entry point
155 130
  *
156 131
  * Used as the indirection vector for all UNDI API calls.  Resides in
157 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 138
  * Issue UNDI API call
164 139
  *
165
- * @v undi		UNDI NIC
140
+ * @v undinic		UNDI NIC
166 141
  * @v function		API call number
167 142
  * @v params		UNDI parameter block
168 143
  * @v params_len	Length of UNDI parameter block
169 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 148
 	union u_PXENV_ANY *pxenv_any = params;
174 149
 	PXENV_EXIT_t exit;
175 150
 	int discard_b, discard_D;
176 151
 	int rc;
177 152
 
178 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 158
 	/* Call real-mode entry point.  This calling convention will
184 159
 	 * work with both the !PXE and the PXENV+ entry points.
@@ -190,9 +165,9 @@ static int undi_call ( struct undi_nic *undi, unsigned int function,
190 165
 					   "addw $6, %%sp\n\t" )
191 166
 			       : "=a" ( exit ), "=b" ( discard_b ),
192 167
 			         "=D" ( discard_D )
193
-			       : "p" ( & __from_data16 ( undi_entry_point ) ),
168
+			       : "p" ( &__from_data16 ( undinet_entry_point )),
194 169
 			         "b" ( function ),
195
-			         "D" ( & __from_data16 ( undi_params ) )
170
+			         "D" ( &__from_data16 ( undinet_params ) )
196 171
 			       : "ecx", "edx", "esi", "ebp" );
197 172
 
198 173
 	/* UNDI API calls may rudely change the status of A20 and not
@@ -206,7 +181,7 @@ static int undi_call ( struct undi_nic *undi, unsigned int function,
206 181
 	gateA20_set();
207 182
 
208 183
 	/* Copy parameter block back */
209
-	memcpy ( params, &undi_params, params_len );
184
+	memcpy ( params, &undinet_params, params_len );
210 185
 
211 186
 	/* Determine return status code based on PXENV_EXIT and
212 187
 	 * PXENV_STATUS
@@ -223,8 +198,8 @@ static int undi_call ( struct undi_nic *undi, unsigned int function,
223 198
 	}
224 199
 
225 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 204
 	return rc;
230 205
 }
@@ -242,7 +217,7 @@ static int undi_call ( struct undi_nic *undi, unsigned int function,
242 217
  * The UNDI ISR simply increments a counter (@c trigger_count) and
243 218
  * exits.
244 219
  */
245
-extern void undi_isr ( void );
220
+extern void undinet_isr ( void );
246 221
 
247 222
 /** Dummy chain vector */
248 223
 static struct segoff prev_handler[ IRQ_MAX + 1 ];
@@ -263,16 +238,17 @@ static volatile uint8_t __text16 ( trigger_count ) = 0;
263 238
  * interrupting device) and some disable the interrupt at the PIC (and
264 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 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 246
 					     "incb %%cs:%c0\n\t"
272 247
 					     "iret\n\t" )
273 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 252
 			      &prev_handler[irq] );
277 253
 
278 254
 }
@@ -282,11 +258,12 @@ static void undi_hook_isr ( unsigned int irq ) {
282 258
  *
283 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 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 267
 				&prev_handler[irq] );
291 268
 }
292 269
 
@@ -295,7 +272,7 @@ static void undi_unhook_isr ( unsigned int irq ) {
295 272
  *
296 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 276
 	static unsigned int last_trigger_count = 0;
300 277
 	unsigned int this_trigger_count;
301 278
 
@@ -328,12 +305,12 @@ struct undi_packet {
328 305
 };
329 306
 
330 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 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 316
  * Transmit packet
@@ -342,35 +319,36 @@ static struct s_PXENV_UNDI_TBD __data16 ( undi_tbd );
342 319
  * @v pkb		Packet buffer
343 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 325
 	struct s_PXENV_UNDI_TRANSMIT undi_transmit;
348 326
 	size_t len = pkb_len ( pkb );
349 327
 	int rc;
350 328
 
351 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 334
 	/* Create PXENV_UNDI_TRANSMIT data structure */
357 335
 	memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
358 336
 	undi_transmit.DestAddr.segment = rm_ds;
359 337
 	undi_transmit.DestAddr.offset
360
-		= ( ( unsigned ) & __from_data16 ( undi_tbd ) );
338
+		= ( ( unsigned ) & __from_data16 ( undinet_tbd ) );
361 339
 	undi_transmit.TBD.segment = rm_ds;
362 340
 	undi_transmit.TBD.offset
363
-		= ( ( unsigned ) & __from_data16 ( undi_tbd ) );
341
+		= ( ( unsigned ) & __from_data16 ( undinet_tbd ) );
364 342
 
365 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 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 353
 	/* Free packet buffer and return */
376 354
 	free_pkb ( pkb );
@@ -384,22 +362,22 @@ static int undi_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
384 362
  *
385 363
  * Fun, fun, fun.  UNDI drivers don't use polling; they use
386 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 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 374
  * Addendum (21/10/03).  Some cards don't play nicely with this trick,
397 375
  * so instead of doing it the easy way we have to go to all the hassle
398 376
  * of installing a genuine interrupt service routine and dealing with
399 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 381
 	struct s_PXENV_UNDI_ISR undi_isr;
404 382
 	struct pk_buff *pkb = NULL;
405 383
 	size_t len;
@@ -407,26 +385,26 @@ static void undi_poll ( struct net_device *netdev ) {
407 385
 	int rc;
408 386
 
409 387
 	/* Do nothing unless ISR has been triggered */
410
-	if ( ! undi_isr_triggered() )
388
+	if ( ! undinet_isr_triggered() )
411 389
 		return;
412 390
 
413 391
 	/* See if this was our interrupt */
414 392
 	memset ( &undi_isr, 0, sizeof ( undi_isr ) );
415 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 396
 		return;
419 397
 	if ( undi_isr.FuncFlag != PXENV_UNDI_ISR_OUT_OURS )
420 398
 		return;
421 399
 
422 400
 	/* Send EOI */
423
-	send_eoi ( undi->irq );
401
+	send_eoi ( undinic->irq );
424 402
 
425 403
 	/* Run through the ISR loop */
426 404
 	undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_PROCESS;
427 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 408
 			break;
431 409
 		switch ( undi_isr.FuncFlag ) {
432 410
 		case PXENV_UNDI_ISR_OUT_TRANSMIT:
@@ -439,14 +417,14 @@ static void undi_poll ( struct net_device *netdev ) {
439 417
 			if ( ! pkb )
440 418
 				pkb = alloc_pkb ( len );
441 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 423
 				break;
446 424
 			}
447 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 428
 				frag_len = pkb_available ( pkb );
451 429
 			}
452 430
 			copy_from_real ( pkb_put ( pkb, frag_len ),
@@ -462,8 +440,8 @@ static void undi_poll ( struct net_device *netdev ) {
462 440
 			goto done;
463 441
 		default:
464 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 445
 			goto done;
468 446
 		}
469 447
 		undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;
@@ -471,7 +449,8 @@ static void undi_poll ( struct net_device *netdev ) {
471 449
 
472 450
  done:
473 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 454
 		netdev_rx ( netdev, pkb );
476 455
 	}
477 456
 }
@@ -482,15 +461,15 @@ static void undi_poll ( struct net_device *netdev ) {
482 461
  * @v netdev		Net device
483 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 466
 	struct s_PXENV_UNDI_SET_STATION_ADDRESS set_address;
488 467
 	struct s_PXENV_UNDI_OPEN open;
489 468
 	int rc;
490 469
 
491 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 474
 	/* Set station address.  Required for some PXE stacks; will
496 475
 	 * spuriously fail on others.  Ignore failures.  We only ever
@@ -499,20 +478,20 @@ static int undi_open ( struct net_device *netdev ) {
499 478
 	 */
500 479
 	memcpy ( set_address.StationAddress, netdev->ll_addr,
501 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 484
 	/* Open NIC */
506 485
 	memset ( &open, 0, sizeof ( open ) );
507 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 489
 		goto err;
511 490
 
512 491
 	return 0;
513 492
 
514 493
  err:
515
-	undi_close ( netdev );
494
+	undinet_close ( netdev );
516 495
 	return rc;
517 496
 }
518 497
 
@@ -521,27 +500,27 @@ static int undi_open ( struct net_device *netdev ) {
521 500
  *
522 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 505
 	struct s_PXENV_UNDI_CLOSE close;
527 506
 
528 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 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 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 522
 	struct net_device *netdev;
544
-	struct undi_nic *undi;
523
+	struct undi_nic *undinic;
545 524
 	struct s_PXENV_START_UNDI start_undi;
546 525
 	struct s_PXENV_UNDI_STARTUP undi_startup;
547 526
 	struct s_PXENV_UNDI_INITIALIZE undi_initialize;
@@ -552,54 +531,56 @@ int undi_probe ( struct pxe_device *pxe ) {
552 531
 	int rc;
553 532
 
554 533
 	/* Allocate net device */
555
-	netdev = alloc_etherdev ( sizeof ( *undi ) );
534
+	netdev = alloc_etherdev ( sizeof ( *undinic ) );
556 535
 	if ( ! netdev )
557 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 542
 	/* Hook in UNDI stack */
564 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 547
 	start_undi.ES = BIOS_SEG;
569 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 551
 		goto err_start_undi;
573 552
 
574 553
 	/* Bring up UNDI stack */
575 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 557
 		goto err_undi_startup;
579 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 562
 		goto err_undi_initialize;
583 563
 
584 564
 	/* Get device information */
585 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 568
 		goto err_undi_get_information;
589 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 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 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 585
 	/* Register network device */
605 586
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
@@ -613,29 +594,30 @@ int undi_probe ( struct pxe_device *pxe ) {
613 594
  err_undi_initialize:
614 595
 	/* Shut down UNDI stack */
615 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 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 602
  err_undi_startup:
622 603
 	/* Unhook UNDI stack */
623 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 607
  err_start_undi:
626 608
 	free_netdev ( netdev );
627
-	pxe_set_drvdata ( pxe, NULL );
609
+	undi_set_drvdata ( undi, NULL );
628 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 621
 	struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
640 622
 	struct s_PXENV_UNDI_CLEANUP undi_cleanup;
641 623
 	struct s_PXENV_STOP_UNDI stop_undi;
@@ -645,15 +627,16 @@ void undi_remove ( struct pxe_device *pxe ) {
645 627
 
646 628
 	/* Shut down UNDI stack */
647 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 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 636
 	/* Unhook UNDI stack */
655 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 641
 	/* Free network device */
659 642
 	free_netdev ( netdev );

+ 59
- 0
src/arch/i386/include/undi.h View File

@@ -0,0 +1,59 @@
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 View File

@@ -0,0 +1,15 @@
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 */

Loading…
Cancel
Save