Browse Source

Select a PXE network device before starting PXE NBP.

Move pxe_boot() code to pxe_image.c
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
7bc03d37a2

+ 30
- 2
src/arch/i386/image/pxe_image.c View File

@@ -23,10 +23,12 @@
23 23
  *
24 24
  */
25 25
 
26
+#include <pxe.h>
27
+#include <pxe_call.h>
26 28
 #include <gpxe/uaccess.h>
27 29
 #include <gpxe/image.h>
28 30
 #include <gpxe/segment.h>
29
-#include <pxe_call.h>
31
+#include <gpxe/netdevice.h>
30 32
 
31 33
 /** PXE load address segment */
32 34
 #define PXE_LOAD_SEGMENT 0
@@ -43,7 +45,33 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
43 45
  * @ret rc		Return status code
44 46
  */
45 47
 static int pxe_exec ( struct image *image __unused ) {
46
-	return pxe_boot();
48
+	struct net_device *netdev;
49
+	int discard_b, discard_c;
50
+	uint16_t rc;
51
+
52
+	/* Ensure that PXE stack is ready to use */
53
+	pxe_init_structures();
54
+	pxe_hook_int1a();
55
+
56
+	/* Arbitrarily pick the first open network device to use for PXE */
57
+	for_each_netdev ( netdev ) {
58
+		pxe_netdev = netdev;
59
+		break;
60
+	}
61
+
62
+	/* Far call to PXE NBP */
63
+	__asm__ __volatile__ ( REAL_CODE ( "pushw %%cx\n\t"
64
+					   "pushw %%ax\n\t"
65
+					   "movw %%cx, %%es\n\t"
66
+					   "lcall $0, $0x7c00\n\t" )
67
+			       : "=a" ( rc ), "=b" ( discard_b ),
68
+			         "=c" ( discard_c )
69
+			       :  "a" ( & __from_text16 ( ppxe ) ),
70
+			          "b" ( & __from_text16 ( pxenv ) ),
71
+			          "c" ( rm_cs )
72
+			       : "edx", "esi", "edi", "ebp", "memory" );
73
+
74
+	return rc;
47 75
 }
48 76
 
49 77
 /**

+ 14
- 1
src/arch/i386/include/pxe_call.h View File

@@ -6,6 +6,19 @@
6 6
  * PXE API entry point
7 7
  */
8 8
 
9
-extern int pxe_boot ( void );
9
+#include <pxe_api.h>
10
+#include <realmode.h>
11
+
12
+/** !PXE structure */
13
+extern struct s_PXE __text16 ( ppxe );
14
+#define ppxe __use_text16 ( ppxe )
15
+
16
+/** PXENV+ structure */
17
+extern struct s_PXENV __text16 ( pxenv );
18
+#define pxenv __use_text16 ( pxenv )
19
+
20
+extern void pxe_hook_int1a ( void );
21
+extern int pxe_unhook_int1a ( void );
22
+extern void pxe_init_structures ( void );
10 23
 
11 24
 #endif /* _PXE_CALL_H */

+ 15
- 51
src/arch/i386/interface/pxe/pxe_call.c View File

@@ -34,14 +34,6 @@ extern struct segoff __text16 ( pxe_int_1a_vector );
34 34
 /** INT 1A handler */
35 35
 extern void pxe_int_1a ( void );
36 36
 
37
-/** !PXE structure */
38
-extern struct s_PXE __text16 ( pxe );
39
-#define pxe __use_text16 ( pxe )
40
-
41
-/** PXENV+ structure */
42
-extern struct s_PXENV __text16 ( pxenv );
43
-#define pxenv __use_text16 ( pxenv )
44
-
45 37
 /** A function pointer to hold any PXE API call
46 38
  *
47 39
  * Used by pxe_api_call() to avoid large swathes of duplicated code.
@@ -310,7 +302,7 @@ void pxe_api_call ( struct i386_all_regs *ix86 ) {
310 302
  * Hook INT 1A for PXE
311 303
  *
312 304
  */
313
-void pxe_hook_int ( void ) {
305
+void pxe_hook_int1a ( void ) {
314 306
 	hook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
315 307
 			      &pxe_int_1a_vector );
316 308
 }
@@ -320,7 +312,7 @@ void pxe_hook_int ( void ) {
320 312
  *
321 313
  * @ret rc		Return status code
322 314
  */
323
-int pxe_unhook_int ( void ) {
315
+int pxe_unhook_int1a ( void ) {
324 316
 	return unhook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
325 317
 				       &pxe_int_1a_vector );
326 318
 }
@@ -343,24 +335,24 @@ static uint8_t pxe_checksum ( void *data, size_t size ) {
343 335
 }
344 336
 
345 337
 /**
346
- * Initialise PXE stack
338
+ * Initialise !PXE and PXENV+ structures
347 339
  *
348 340
  */
349
-void init_pxe ( void ) {
341
+void pxe_init_structures ( void ) {
350 342
 	uint32_t rm_cs_phys = ( rm_cs << 4 );
351 343
 	uint32_t rm_ds_phys = ( rm_ds << 4 );
352 344
 
353 345
 	/* Fill in missing segment fields */
354
-	pxe.EntryPointSP.segment = rm_cs;
355
-	pxe.EntryPointESP.segment = rm_cs;
356
-	pxe.Stack.segment_address = rm_ds;
357
-	pxe.Stack.Physical_address = rm_ds_phys;
358
-	pxe.UNDIData.segment_address = rm_ds;
359
-	pxe.UNDIData.Physical_address = rm_ds_phys;
360
-	pxe.UNDICode.segment_address = rm_cs;
361
-	pxe.UNDICode.Physical_address = rm_cs_phys;
362
-	pxe.UNDICodeWrite.segment_address = rm_cs;
363
-	pxe.UNDICodeWrite.Physical_address = rm_cs_phys;
346
+	ppxe.EntryPointSP.segment = rm_cs;
347
+	ppxe.EntryPointESP.segment = rm_cs;
348
+	ppxe.Stack.segment_address = rm_ds;
349
+	ppxe.Stack.Physical_address = rm_ds_phys;
350
+	ppxe.UNDIData.segment_address = rm_ds;
351
+	ppxe.UNDIData.Physical_address = rm_ds_phys;
352
+	ppxe.UNDICode.segment_address = rm_cs;
353
+	ppxe.UNDICode.Physical_address = rm_cs_phys;
354
+	ppxe.UNDICodeWrite.segment_address = rm_cs;
355
+	ppxe.UNDICodeWrite.Physical_address = rm_cs_phys;
364 356
 	pxenv.RMEntry.segment = rm_cs;
365 357
 	pxenv.StackSeg = rm_ds;
366 358
 	pxenv.UNDIDataSeg = rm_ds;
@@ -368,34 +360,6 @@ void init_pxe ( void ) {
368 360
 	pxenv.PXEPtr.segment = rm_cs;
369 361
 
370 362
 	/* Update checksums */
371
-	pxe.StructCksum -= pxe_checksum ( &pxe, sizeof ( pxe ) );
363
+	ppxe.StructCksum -= pxe_checksum ( &ppxe, sizeof ( ppxe ) );
372 364
 	pxenv.Checksum -= pxe_checksum ( &pxenv, sizeof ( pxenv ) );
373 365
 }
374
-
375
-/**
376
- * Boot via PXE NBP
377
- *
378
- * @ret rc		Return status code
379
- */
380
-int pxe_boot ( void ) {
381
-	int discard_b, discard_c;
382
-	uint16_t rc;
383
-
384
-	/* Ensure that PXE stack is ready to use */
385
-	init_pxe();
386
-	pxe_hook_int();
387
-
388
-	/* Far call to PXE NBP */
389
-	__asm__ __volatile__ ( REAL_CODE ( "pushw %%cx\n\t"
390
-					   "pushw %%ax\n\t"
391
-					   "movw %%cx, %%es\n\t"
392
-					   "lcall $0, $0x7c00\n\t" )
393
-			       : "=a" ( rc ), "=b" ( discard_b ),
394
-			         "=c" ( discard_c )
395
-			       :  "a" ( & __from_text16 ( pxe ) ),
396
-			          "b" ( & __from_text16 ( pxenv ) ),
397
-			          "c" ( rm_cs )
398
-			       : "edx", "esi", "edi", "ebp", "memory" );
399
-
400
-	return rc;
401
-}

+ 5
- 5
src/arch/i386/interface/pxe/pxe_entry.S View File

@@ -27,9 +27,9 @@
27 27
  ****************************************************************************
28 28
  */
29 29
 	.section ".text16.data"
30
-	.globl pxe
30
+	.globl ppxe
31 31
 	.align 16
32
-pxe:
32
+ppxe:
33 33
 	.ascii "!PXE"			/* Signature */
34 34
 	.byte pxe_length		/* StructLength */
35 35
 	.byte 0				/* StructCksum */
@@ -52,8 +52,8 @@ pxe_segments:
52 52
 	.word 0, 0, 0, 0		/* BC_Code */
53 53
 	.word 0, 0, 0, 0		/* BC_CodeWrite */
54 54
 	.equ	SegDescCnt, ( ( . - pxe_segments ) / 8 )
55
-	.equ	pxe_length, . - pxe
56
-	.size	pxe, . - pxe
55
+	.equ	pxe_length, . - ppxe
56
+	.size	ppxe, . - ppxe
57 57
 
58 58
 /****************************************************************************
59 59
  * PXENV+ structure
@@ -80,7 +80,7 @@ pxenv:
80 80
 	.word _data16_size		/* UNDIDataSize */
81 81
 	.word 0				/* UNDICodeSeg */
82 82
 	.word _text16_size		/* UNDICodeSize */
83
-	.word pxe, 0			/* PXEPtr */
83
+	.word ppxe, 0			/* PXEPtr */
84 84
 	.equ	pxenv_length, . - pxenv
85 85
 	.size	pxenv, . - pxenv
86 86
  

Loading…
Cancel
Save