Gave up on adding POSIX errno's as required, and just added (almost) all

of them in one go.

EBADIMG has been replaced by ENOEXEC, and EIMGRET by ECANCELED.
pull/1/head
Michael Brown 2006-04-28 13:44:34 +00:00
parent 82c4afcb32
commit d8e99bf28f
2 changed files with 67 additions and 27 deletions

View File

@ -95,7 +95,7 @@ static struct ebinfo loaderinfo = {
* @v context NBI image context
* @ret True Image is a valid NBI image
* @ret False Image is not a valid NBI image
* @err EBADIMG Image is not a valid NBI image
* @err ENOEXEC Image is not a valid NBI image
*
* "context" is filled in with a context pointer suitable for passing to
* nbi_load() and nbi_boot().
@ -106,14 +106,14 @@ static int nbi_probe ( physaddr_t start, off_t len, void **context ) {
if ( (unsigned)len < sizeof ( imgheader ) ) {
DBG ( "NBI image too small\n" );
errno = EBADIMG;
errno = ENOEXEC;
return 0;
}
copy_from_phys ( &imgheader, start, sizeof ( imgheader ) );
if ( imgheader.magic != NBI_MAGIC ) {
errno = EBADIMG;
errno = ENOEXEC;
return 0;
}
@ -168,7 +168,7 @@ static int nbi_load_segment ( physaddr_t dest, off_t imglen,
* @v process Function to call for each segment
* @ret True All segments were processed successfully
* @ret False An error occurred processing a segment
* @err EBADIMG Image is not a valid NBI image
* @err ENOEXEC Image is not a valid NBI image
* @err other As returned by the "process" function
*
*/
@ -200,7 +200,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
if ( sh.length == 0 ) {
/* Avoid infinite loop? */
DBG ( "NBI invalid segheader length 0\n" );
errno = EBADIMG;
errno = ENOEXEC;
return 0;
}
@ -240,7 +240,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
sh_off += NBI_LENGTH ( sh.length );
if ( sh_off >= NBI_HEADER_LENGTH ) {
DBG ( "NBI header overflow\n" );
errno = EBADIMG;
errno = ENOEXEC;
return 0;
}
@ -249,7 +249,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
if ( offset != len ) {
DBG ( "NBI length mismatch (file %d, metadata %d)\n",
len, offset );
errno = EBADIMG;
errno = ENOEXEC;
return 0;
}
@ -264,7 +264,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
* @v context NBI context (as returned by nbi_probe())
* @ret True Image loaded into memory
* @ret False Image not loaded into memory
* @err EBADIMG Image is not a valid NBI image
* @err ENOEXEC Image is not a valid NBI image
* @err other As returned by nbi_process_segments()
* @err other As returned by nbi_prepare_segment()
* @err other As returned by nbi_load_segment()
@ -275,7 +275,7 @@ static int nbi_load ( physaddr_t start, off_t len, void *context ) {
/* If we don't have enough data give up */
if ( len < NBI_HEADER_LENGTH ) {
errno = EBADIMG;
errno = ENOEXEC;
return 0;
}
@ -305,7 +305,7 @@ static int nbi_load ( physaddr_t start, off_t len, void *context ) {
* @v imgheader Image header information
* @ret Never NBI program booted successfully
* @ret False NBI program returned
* @err EIMGRET NBI program returned
* @err ECANCELED NBI program returned
*
*/
static int nbi_boot16 ( struct imgheader *imgheader ) {
@ -340,7 +340,7 @@ static int nbi_boot16 ( struct imgheader *imgheader ) {
CLOBBER ( "eax", "ecx", "edx", "ebp" ) );
BASEMEM_PARAMETER_DONE ( bootp_data );
errno = EIMGRET;
errno = ECANCELED;
return 0;
}
@ -350,11 +350,11 @@ static int nbi_boot16 ( struct imgheader *imgheader ) {
* @v imgheader Image header information
* @ret False NBI program should not have returned
* @ret other As returned by NBI program
* @err EIMGRET NBI program should not have returned
* @err ECANCELED NBI program should not have returned
*
* To distinguish between the case of an NBI program returning false,
* and an NBI program that should not have returned, check errno.
* errno will be set to EIMGRET only if the NBI program should not
* errno will be set to ECANCELED only if the NBI program should not
* have returned.
*
*/
@ -374,7 +374,7 @@ static int nbi_boot32 ( struct imgheader *imgheader ) {
printf ( "Secondary program returned %d\n", rc );
if ( ! NBI_PROGRAM_RETURNS ( imgheader->flags ) ) {
/* We shouldn't have returned */
errno = EIMGRET;
errno = ECANCELED;
rc = 0;
}
@ -388,7 +388,7 @@ static int nbi_boot32 ( struct imgheader *imgheader ) {
* @ret Never NBI program booted successfully
* @ret False NBI program should not have returned
* @ret other As returned by NBI program
* @err EIMGRET NBI program should not have returned
* @err ECANCELED NBI program should not have returned
*
* See also nbi_boot16() and nbi_boot32().
*

View File

@ -111,21 +111,61 @@
/*
* The range 0xd0 to 0xff is defined as "Vendor errors" by the PXE
* spec. We place all our Etherboot-specific errors in this range.
* We also define some generic errors as aliases to the PXE errors.
*
* spec. We use this space for POSIX-like errors that aren't
* accounted for by the (somewhat implementation-specific) PXE error
* list.
*/
#define ENOERR 0x00
#define ENOERR 0x00 /**< Operation completed successfully */
#define EACCES 0xd0 /**< Permission denied */
#define EADDRNOTAVAIL 0xd1 /**< Cannot assign requested address */
#define EADDRINUSE EADDRNOTAVAIL /**< Address already in use */
#define EAFNOSUPPORT 0xd2 /**< Address family not supported by protocol*/
#define EAGAIN 0xd3 /**< Resource temporarily unavailable */
#define EBUSY 0xd4 /**< Device or resource busy */
/** Operation cancelled */
#define ECANCELED PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE
#define ECONNABORTED 0xd5 /**< Software caused connection abort */
#define ECONNREFUSED 0xd6 /**< Connection refused */
#define ECONNRESET 0xd7 /**< Connection reset by peer */
#define EDESTADDRREQ 0xd8 /**< Destination address required */
#define EFBIG 0xd9 /**< File too large */
#define EHOSTUNREACH 0xda /**< No route to host */
#define EINPROGRESS 0xdb /**< Operation now in progress */
#define EINTR 0xdc /**< Interrupted system call */
#define EINVAL 0xdd /**< Invalid argument */
#define EIO 0xde /**< Input/output error */
#define EISCONN 0xdf /**< Transport endpoint is already connected */
#define EMFILE 0xe0 /**< Too many open files */
#define EMSGSIZE 0xe1 /**< Message too long */
#define ENAMETOOLONG 0xe2 /**< File name too long */
#define ENETDOWN 0xe3 /**< Network is down */
#define ENETRESET 0xe4 /**< Network dropped connection on reset */
#define ENETUNREACH 0xe5 /**< Network is unreachable */
#define ENFILE EMFILE /**< Too many open files in system */
/** Cannot allocate memory */
#define ENOMEM PXENV_STATUS_OUT_OF_RESOURCES
#define EBADIMG 0xd0
#define EIMGRET 0xd1
#define ETIMEDOUT 0xd2
#define EINVAL 0xd3
#define ENOENT 0xd4
#define EAFNOSUPPORT 0xd5
#define EAGAIN 0xd6
#define EIO 0xd7
#define ENOBUFS ENOMEM /**< No buffer space available */
#define ENODATA 0xe6 /**< No data available */
#define ENODEV 0xe7 /**< No such device */
#define ENOENT 0xe8 /**< No such file or directory */
#define ENOEXEC 0xe9 /**< Exec format error */
#define ENOMSG ENODATA /**< No message of the desired type */
#define ENOSR 0xea /**< No stream resources */
#define ENOSTR 0xeb /**< Not a stream */
#define ENOSYS 0xec /**< Function not implemented */
#define ENOTCONN 0xed /**< Transport endpoint is not connected */
#define ENOTSOCK 0xee /**< Socket operation on non-socket */
#define EOPNOTSUPP 0xef /**< Operation not supported */
#define ENOTSUP EOPNOTSUPP /**< Not supported */
#define ENOTTY 0xf0 /**< Inappropriate ioctl for device */
#define ENXIO ENODEV /**< No such device or address */
#define EPERM EACCES /**< Operation not permitted */
#define EPROTO 0xf1 /**< Protocol error */
#define EPROTONOSUPPORT 0xf2 /**< Protocol not supported */
#define EPROTOTYPE 0xf3 /**< Protocol wrong type for socket */
#define ETIMEDOUT 0xf4 /**< Connection timed out */
#define EWOULDBLOCK EAGAIN /**< Resource temporarily unavailable */
/* Data structures and declarations */