2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-22 17:41:55 +00:00

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2013-04-29 19:58:25 +01:00
parent de1fafd2f8
commit e411b37eb1
4 changed files with 27 additions and 16 deletions

View 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;

View 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 );

View 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.

View 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 )