3 #include <gpxe/errortab.h>
7 * Error codes and descriptions.
9 * This file provides the global variable #errno and the function
10 * strerror(). These function much like their standard C library
13 * The error numbers used by Etherboot are a superset of those defined
14 * by the PXE specification version 2.1. See errno.h for a listing of
17 * To save space in ROM images, error string tables are optional. Use
18 * the ERRORMSG_XXX options in config.h to select which error string
19 * tables you want to include. If an error string table is omitted,
20 * strerror() will simply return the text "Error 0x<errno>".
25 * Global "last error" number.
27 * This is valid only when a function has just returned indicating a
33 static struct errortab errortab_start[0] __table_start(errortab);
34 static struct errortab errortab_end[0] __table_end(errortab);
37 * Retrieve string representation of error number.
39 * @v errno Error number
40 * @ret strerror Pointer to error text
42 * If the error is not found in the linked-in error tables, generates
43 * a generic "Error 0x<errno>" message.
45 * The pointer returned by strerror() is valid only until the next
49 const char * strerror ( int errno ) {
50 static char *generic_message = "Error 0x0000";
51 struct errortab *errortab;
53 for ( errortab = errortab_start ; errortab < errortab_end ;
55 if ( errortab->errno == errno )
56 return errortab->text;
59 sprintf ( generic_message + 8, "%hx", errno );
60 return generic_message;