Procházet zdrojové kódy

Separate out pxe_start_nbp() from pxe_image.c into pxe_call.c

Implement PXENV_RESTART_TFTP.
tags/v0.9.3
Michael Brown před 17 roky
rodič
revize
8130443f9f

+ 1
- 22
src/arch/i386/image/pxe_image.c Zobrazit soubor

@@ -30,12 +30,6 @@
30 30
 #include <gpxe/segment.h>
31 31
 #include <gpxe/netdevice.h>
32 32
 
33
-/** PXE load address segment */
34
-#define PXE_LOAD_SEGMENT 0
35
-
36
-/** PXE load address offset */
37
-#define PXE_LOAD_OFFSET 0x7c00
38
-
39 33
 struct image_type pxe_image_type __image_type ( PROBE_PXE );
40 34
 
41 35
 /**
@@ -46,8 +40,6 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
46 40
  */
47 41
 static int pxe_exec ( struct image *image __unused ) {
48 42
 	struct net_device *netdev;
49
-	int discard_b, discard_c;
50
-	uint16_t rc;
51 43
 
52 44
 	/* Ensure that PXE stack is ready to use */
53 45
 	pxe_init_structures();
@@ -59,20 +51,7 @@ static int pxe_exec ( struct image *image __unused ) {
59 51
 		break;
60 52
 	}
61 53
 
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
-					   "addw $4, %%sp\n\t" )
68
-			       : "=a" ( rc ), "=b" ( discard_b ),
69
-			         "=c" ( discard_c )
70
-			       :  "a" ( & __from_text16 ( ppxe ) ),
71
-			          "b" ( & __from_text16 ( pxenv ) ),
72
-			          "c" ( rm_cs )
73
-			       : "edx", "esi", "edi", "ebp", "memory" );
74
-
75
-	return rc;
54
+	return pxe_start_nbp();
76 55
 }
77 56
 
78 57
 /**

+ 10
- 0
src/arch/i386/include/pxe_call.h Zobrazit soubor

@@ -9,6 +9,15 @@
9 9
 #include <pxe_api.h>
10 10
 #include <realmode.h>
11 11
 
12
+/** PXE load address segment */
13
+#define PXE_LOAD_SEGMENT 0
14
+
15
+/** PXE load address offset */
16
+#define PXE_LOAD_OFFSET 0x7c00
17
+
18
+/** PXE physical load address */
19
+#define PXE_LOAD_PHYS ( ( PXE_LOAD_SEGMENT << 4 ) + PXE_LOAD_OFFSET )
20
+
12 21
 /** !PXE structure */
13 22
 extern struct s_PXE __text16 ( ppxe );
14 23
 #define ppxe __use_text16 ( ppxe )
@@ -20,5 +29,6 @@ extern struct s_PXENV __text16 ( pxenv );
20 29
 extern void pxe_hook_int1a ( void );
21 30
 extern int pxe_unhook_int1a ( void );
22 31
 extern void pxe_init_structures ( void );
32
+extern int pxe_start_nbp ( void );
23 33
 
24 34
 #endif /* _PXE_CALL_H */

+ 0
- 32
src/arch/i386/include/pxe_callbacks.h Zobrazit soubor

@@ -1,32 +0,0 @@
1
-/* Header for pxe_callbacks.c.
2
- */
3
-
4
-#ifndef PXE_CALLBACKS_H
5
-#define PXE_CALLBACKS_H
6
-
7
-#include "etherboot.h"
8
-#include "pxe_types.h"
9
-
10
-typedef struct {
11
-	SEGOFF16_t	orig_retaddr;
12
-	UINT16_t	opcode;
13
-	SEGOFF16_t	segoff;
14
-} PACKED pxe_call_params_t;
15
-
16
-/*
17
- * These values are hard-coded into the PXE spec
18
- */
19
-#define PXE_LOAD_SEGMENT	(0x0000)
20
-#define PXE_LOAD_OFFSET		(0x7c00)
21
-#define PXE_LOAD_ADDRESS	( ( PXE_LOAD_SEGMENT << 4 ) + PXE_LOAD_OFFSET )
22
-
23
-/* Function prototypes
24
- */
25
-extern struct pxe_stack * install_pxe_stack ( void *base );
26
-extern void use_undi_ds_for_rm_stack ( uint16_t ds );
27
-extern int hook_pxe_stack ( void );
28
-extern int unhook_pxe_stack ( void );
29
-extern void remove_pxe_stack ( void );
30
-extern int xstartpxe ( void );
31
-
32
-#endif /* PXE_CALLBACKS_H */

+ 25
- 0
src/arch/i386/interface/pxe/pxe_call.c Zobrazit soubor

@@ -363,3 +363,28 @@ void pxe_init_structures ( void ) {
363 363
 	ppxe.StructCksum -= pxe_checksum ( &ppxe, sizeof ( ppxe ) );
364 364
 	pxenv.Checksum -= pxe_checksum ( &pxenv, sizeof ( pxenv ) );
365 365
 }
366
+
367
+/**
368
+ * Start PXE NBP at 0000:7c00
369
+ *
370
+ * @ret rc		Return status code
371
+ */
372
+int pxe_start_nbp ( void ) {
373
+	int discard_b, discard_c;
374
+	uint16_t rc;
375
+
376
+	/* Far call to PXE NBP */
377
+	__asm__ __volatile__ ( REAL_CODE ( "pushw %%cx\n\t"
378
+					   "pushw %%ax\n\t"
379
+					   "movw %%cx, %%es\n\t"
380
+					   "lcall $0, $0x7c00\n\t"
381
+					   "addw $4, %%sp\n\t" )
382
+			       : "=a" ( rc ), "=b" ( discard_b ),
383
+			         "=c" ( discard_c )
384
+			       :  "a" ( & __from_text16 ( ppxe ) ),
385
+			          "b" ( & __from_text16 ( pxenv ) ),
386
+			          "c" ( rm_cs )
387
+			       : "edx", "esi", "edi", "ebp", "memory" );
388
+
389
+	return rc;
390
+}

+ 10
- 11
src/interface/pxe/pxe_preboot.c Zobrazit soubor

@@ -30,7 +30,7 @@
30 30
 #include <gpxe/dhcp.h>
31 31
 #include <dhcp_basemem.h>
32 32
 #include "pxe.h"
33
-#include "pxe_callbacks.h"
33
+#include "pxe_call.h"
34 34
 
35 35
 /**
36 36
  * UNLOAD BASE CODE STACK
@@ -146,22 +146,21 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
146 146
  */
147 147
 PXENV_EXIT_t pxenv_restart_tftp ( struct s_PXENV_TFTP_READ_FILE
148 148
 				  *restart_tftp ) {
149
-	DBG ( "PXENV_RESTART_TFTP" );
149
+	PXENV_EXIT_t tftp_exit;
150
+
151
+	DBG ( "PXENV_RESTART_TFTP " );
150 152
 
151
-#if 0
152 153
 	/* Words cannot describe the complete mismatch between the PXE
153 154
 	 * specification and any possible version of reality...
154 155
 	 */
155
-	restart_tftp->Buffer = PXE_LOAD_ADDRESS; /* Fixed by spec, apparently */
156
-	restart_tftp->BufferSize = get_free_base_memory() - PXE_LOAD_ADDRESS; /* Near enough */
157
-	DBG ( "(" );
158
-	tftp_exit = pxe_api_call ( PXENV_TFTP_READ_FILE, (union u_PXENV_ANY*)restart_tftp );
159
-	DBG ( ")" );
160
-	if ( tftp_exit != PXENV_EXIT_SUCCESS ) return tftp_exit;
156
+	restart_tftp->Buffer = PXE_LOAD_PHYS; /* Fixed by spec, apparently */
157
+	restart_tftp->BufferSize = ( 0xa0000 - PXE_LOAD_PHYS ); /* Near enough */
158
+	tftp_exit = pxenv_tftp_read_file ( restart_tftp );
159
+	if ( tftp_exit != PXENV_EXIT_SUCCESS )
160
+		return tftp_exit;
161 161
 
162 162
 	/* Fire up the new NBP */
163
-	restart_tftp->Status = xstartpxe();
164
-#endif
163
+	restart_tftp->Status = pxe_start_nbp();
165 164
 
166 165
 	/* Not sure what "SUCCESS" actually means, since we can only
167 166
 	 * return if the new NBP failed to boot...

Načítá se…
Zrušit
Uložit