4 #include <gpxe/errortab.h>
10 * The error numbers used by Etherboot are a superset of those defined
11 * by the PXE specification version 2.1. See errno.h for a listing of
14 * To save space in ROM images, error string tables are optional. Use
15 * the ERRORMSG_XXX options in config.h to select which error string
16 * tables you want to include. If an error string table is omitted,
17 * strerror() will simply return the text "Error 0x<errno>".
21 static struct errortab errortab_start[0]
22 __table_start ( struct errortab, errortab );
23 static struct errortab errortab_end[0]
24 __table_end ( struct errortab, errortab );
27 * Retrieve string representation of error number.
29 * @v errno Error number
30 * @ret strerror Pointer to error text
32 * If the error is not found in the linked-in error tables, generates
33 * a generic "Error 0x<errno>" message.
35 * The pointer returned by strerror() is valid only until the next
39 const char * strerror ( int errno ) {
40 static char *generic_message = "Error 0x0000";
41 struct errortab *errortab;
43 /* Allow for strerror(rc) as well as strerror(errno) */
47 for ( errortab = errortab_start ; errortab < errortab_end ;
49 if ( errortab->errno == errno )
50 return errortab->text;
53 sprintf ( generic_message + 8, "%hx", errno );
54 return generic_message;
57 /** The most common errors */
58 struct errortab enoerr __errortab = { 0, "No error" };
59 struct errortab enoem __errortab = { ENOMEM, "Out of memory" };
60 struct errortab einval __errortab = { EINVAL, "Invalid argument" };
61 struct errortab enospc __errortab = { ENOSPC, "No space left on device" };
62 struct errortab eio __errortab = { EIO, "Input/output error" };
63 struct errortab eacces __errortab = { EACCES, "Permission denied" };