]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pxe] Convert external PXE API errors into iPXE platform-generated errors
authorMichael Brown <mcb30@ipxe.org>
Mon, 29 Apr 2013 18:58:25 +0000 (19:58 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 29 Apr 2013 18:58:25 +0000 (19:58 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/drivers/net/undiload.c
src/arch/i386/interface/pxe/pxe_call.c
src/arch/i386/interface/pxeparent/pxeparent.c
src/arch/x86/include/bits/errfile.h

index 0edfa35dc607715d56f4fcd6430703ca0e3fc97e..f0f15e6a2fc40cb89706a1e2fd966cb71dcadaf9 100644 (file)
@@ -38,6 +38,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
  *
  */
 
+/* Disambiguate the various error causes */
+#define EINFO_EUNDILOAD                                                        \
+       __einfo_uniqify ( EINFO_EPLATFORM, 0x01,                        \
+                         "UNDI loader error" )
+#define EUNDILOAD( status ) EPLATFORM ( EINFO_EUNDILOAD, status )
+
 /** Parameter block for calling UNDI loader */
 static struct s_UNDI_LOADER __bss16 ( undi_loader );
 #define undi_loader __use_data16 ( undi_loader )
@@ -109,9 +115,7 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
                /* Clear entry point */
                memset ( &undi_loader_entry, 0, sizeof ( undi_loader_entry ) );
 
-               rc = -undi_loader.Status;
-               if ( rc == 0 ) /* Paranoia */
-                       rc = -EIO;
+               rc = -EUNDILOAD ( undi_loader.Status );
                DBGC ( undi, "UNDI %p loader failed: %s\n",
                       undi, strerror ( rc ) );
                return rc;
index b8e73a0615230c99c3faac12599ad2021d6e4f76..7fce75a9337ea06c5c6ddbf4132327ee164a9ac0 100644 (file)
@@ -32,6 +32,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
  * PXE API entry point
  */
 
+/* Disambiguate the various error causes */
+#define EINFO_EPXENBP                                                  \
+       __einfo_uniqify ( EINFO_EPLATFORM, 0x01,                        \
+                         "External PXE NBP error" )
+#define EPXENBP( status ) EPLATFORM ( EINFO_EPXENBP, status )
+
 /** Vector for chaining INT 1A */
 extern struct segoff __text16 ( pxe_int_1a_vector );
 #define pxe_int_1a_vector __use_text16 ( pxe_int_1a_vector )
@@ -257,7 +263,7 @@ rmjmp_buf pxe_restart_nbp;
 int pxe_start_nbp ( void ) {
        int jmp;
        int discard_b, discard_c, discard_d, discard_D;
-       uint16_t rc;
+       uint16_t status;
 
        /* Allow restarting NBP via PXENV_RESTART_TFTP */
        jmp = rmsetjmp ( pxe_restart_nbp );
@@ -271,7 +277,7 @@ int pxe_start_nbp ( void ) {
                                           "sti\n\t"
                                           "lcall $0, $0x7c00\n\t"
                                           "addw $4, %%sp\n\t" )
-                              : "=a" ( rc ), "=b" ( discard_b ),
+                              : "=a" ( status ), "=b" ( discard_b ),
                                 "=c" ( discard_c ), "=d" ( discard_d ),
                                 "=D" ( discard_D )
                               : "a" ( 0 ), "b" ( __from_text16 ( &pxenv ) ),
@@ -279,8 +285,10 @@ int pxe_start_nbp ( void ) {
                                 "d" ( virt_to_phys ( &pxenv ) ),
                                 "D" ( __from_text16 ( &ppxe ) )
                               : "esi", "ebp", "memory" );
+       if ( status )
+               return -EPXENBP ( status );
 
-       return rc;
+       return 0;
 }
 
 REQUIRE_OBJECT ( pxe_preboot );
index 8b2a2c880408b8787c4281fde76be5389a7c2785..b2c6ffbaae7e3d790027e90c106e12bffda99f4e 100644 (file)
@@ -31,6 +31,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
  *
  */
 
+/* Disambiguate the various error causes */
+#define EINFO_EPXECALL                                                 \
+       __einfo_uniqify ( EINFO_EPLATFORM, 0x01,                        \
+                         "External PXE API error" )
+#define EPXECALL( status ) EPLATFORM ( EINFO_EPXECALL, status )
+
 /**
  * Name PXE API call
  *
@@ -151,16 +157,8 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
        /* Determine return status code based on PXENV_EXIT and
         * PXENV_STATUS
         */
-       if ( exit == PXENV_EXIT_SUCCESS ) {
-               rc = 0;
-       } else {
-               rc = -pxeparent_params.Status;
-               /* Paranoia; don't return success for the combination
-                * of PXENV_EXIT_FAILURE but PXENV_STATUS_SUCCESS
-                */
-               if ( rc == 0 )
-                       rc = -EIO;
-       }
+       rc = ( ( exit == PXENV_EXIT_SUCCESS ) ?
+              0 : -EPXECALL ( pxeparent_params.Status ) );
 
        /* If anything goes wrong, print as much debug information as
         * it's possible to give.
index 7b9f3702e8e2698e8472e4e1f63a5b8d5efc01d0..5f676c8710d5e92a3623db34d40e18e8e3322393 100644 (file)
@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define ERRFILE_comboot_call   ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000a0000 )
 #define ERRFILE_sdi           ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000b0000 )
 #define ERRFILE_initrd        ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000c0000 )
+#define ERRFILE_pxe_call       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000d0000 )
 
 #define ERRFILE_undi            ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
 #define ERRFILE_undiload        ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )