Ver código fonte

[pxe] Convert external PXE API errors into iPXE platform-generated errors

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 anos atrás
pai
commit
e411b37eb1

+ 7
- 3
src/arch/i386/drivers/net/undiload.c Ver arquivo

@@ -38,6 +38,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
38 38
  *
39 39
  */
40 40
 
41
+/* Disambiguate the various error causes */
42
+#define EINFO_EUNDILOAD							\
43
+	__einfo_uniqify ( EINFO_EPLATFORM, 0x01,			\
44
+			  "UNDI loader error" )
45
+#define EUNDILOAD( status ) EPLATFORM ( EINFO_EUNDILOAD, status )
46
+
41 47
 /** Parameter block for calling UNDI loader */
42 48
 static struct s_UNDI_LOADER __bss16 ( undi_loader );
43 49
 #define undi_loader __use_data16 ( undi_loader )
@@ -109,9 +115,7 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
109 115
 		/* Clear entry point */
110 116
 		memset ( &undi_loader_entry, 0, sizeof ( undi_loader_entry ) );
111 117
 
112
-		rc = -undi_loader.Status;
113
-		if ( rc == 0 ) /* Paranoia */
114
-			rc = -EIO;
118
+		rc = -EUNDILOAD ( undi_loader.Status );
115 119
 		DBGC ( undi, "UNDI %p loader failed: %s\n",
116 120
 		       undi, strerror ( rc ) );
117 121
 		return rc;

+ 11
- 3
src/arch/i386/interface/pxe/pxe_call.c Ver arquivo

@@ -32,6 +32,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
32 32
  * PXE API entry point
33 33
  */
34 34
 
35
+/* Disambiguate the various error causes */
36
+#define EINFO_EPXENBP							\
37
+	__einfo_uniqify ( EINFO_EPLATFORM, 0x01,			\
38
+			  "External PXE NBP error" )
39
+#define EPXENBP( status ) EPLATFORM ( EINFO_EPXENBP, status )
40
+
35 41
 /** Vector for chaining INT 1A */
36 42
 extern struct segoff __text16 ( pxe_int_1a_vector );
37 43
 #define pxe_int_1a_vector __use_text16 ( pxe_int_1a_vector )
@@ -257,7 +263,7 @@ rmjmp_buf pxe_restart_nbp;
257 263
 int pxe_start_nbp ( void ) {
258 264
 	int jmp;
259 265
 	int discard_b, discard_c, discard_d, discard_D;
260
-	uint16_t rc;
266
+	uint16_t status;
261 267
 
262 268
 	/* Allow restarting NBP via PXENV_RESTART_TFTP */
263 269
 	jmp = rmsetjmp ( pxe_restart_nbp );
@@ -271,7 +277,7 @@ int pxe_start_nbp ( void ) {
271 277
 					   "sti\n\t"
272 278
 					   "lcall $0, $0x7c00\n\t"
273 279
 					   "addw $4, %%sp\n\t" )
274
-			       : "=a" ( rc ), "=b" ( discard_b ),
280
+			       : "=a" ( status ), "=b" ( discard_b ),
275 281
 				 "=c" ( discard_c ), "=d" ( discard_d ),
276 282
 				 "=D" ( discard_D )
277 283
 			       : "a" ( 0 ), "b" ( __from_text16 ( &pxenv ) ),
@@ -279,8 +285,10 @@ int pxe_start_nbp ( void ) {
279 285
 			         "d" ( virt_to_phys ( &pxenv ) ),
280 286
 				 "D" ( __from_text16 ( &ppxe ) )
281 287
 			       : "esi", "ebp", "memory" );
288
+	if ( status )
289
+		return -EPXENBP ( status );
282 290
 
283
-	return rc;
291
+	return 0;
284 292
 }
285 293
 
286 294
 REQUIRE_OBJECT ( pxe_preboot );

+ 8
- 10
src/arch/i386/interface/pxeparent/pxeparent.c Ver arquivo

@@ -31,6 +31,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
31 31
  *
32 32
  */
33 33
 
34
+/* Disambiguate the various error causes */
35
+#define EINFO_EPXECALL							\
36
+	__einfo_uniqify ( EINFO_EPLATFORM, 0x01,			\
37
+			  "External PXE API error" )
38
+#define EPXECALL( status ) EPLATFORM ( EINFO_EPXECALL, status )
39
+
34 40
 /**
35 41
  * Name PXE API call
36 42
  *
@@ -151,16 +157,8 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
151 157
 	/* Determine return status code based on PXENV_EXIT and
152 158
 	 * PXENV_STATUS
153 159
 	 */
154
-	if ( exit == PXENV_EXIT_SUCCESS ) {
155
-		rc = 0;
156
-	} else {
157
-		rc = -pxeparent_params.Status;
158
-		/* Paranoia; don't return success for the combination
159
-		 * of PXENV_EXIT_FAILURE but PXENV_STATUS_SUCCESS
160
-		 */
161
-		if ( rc == 0 )
162
-			rc = -EIO;
163
-	}
160
+	rc = ( ( exit == PXENV_EXIT_SUCCESS ) ?
161
+	       0 : -EPXECALL ( pxeparent_params.Status ) );
164 162
 
165 163
 	/* If anything goes wrong, print as much debug information as
166 164
 	 * it's possible to give.

+ 1
- 0
src/arch/x86/include/bits/errfile.h Ver arquivo

@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 #define ERRFILE_comboot_call   ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000a0000 )
34 34
 #define ERRFILE_sdi	       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000b0000 )
35 35
 #define ERRFILE_initrd	       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000c0000 )
36
+#define ERRFILE_pxe_call       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000d0000 )
36 37
 
37 38
 #define ERRFILE_undi		 ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
38 39
 #define ERRFILE_undiload	 ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )

Carregando…
Cancelar
Salvar