8 * Return status codes as used within gPXE are designed to allow for
9 * maximum visibility into the source of an error even in an end-user
10 * build with no debugging. They are constructed in three parts: a
11 * PXE error code, a POSIX error code, and a gPXE-specific error code.
13 * The low byte is the closest equivalent PXE error code
14 * (e.g. PXENV_STATUS_OUT_OF_RESOURCES), and is the only part of the
15 * error that will be returned via the PXE API, since PXE has
16 * predefined error codes.
18 * The next byte is the closest equivalent POSIX error code
21 * The remaining bytes are the gPXE-specific error code, which allow
22 * us to disambiguate between errors which should have the same POSIX
23 * error code but which mean very different things to the user
24 * (e.g. ENOENT due to a DNS name not existing versus ENOENT due to
25 * a web server returning HTTP/404 Not Found).
27 * The convention within the code is that errors are negative and
28 * expressed as the bitwise OR of a POSIX error code and (optionally)
29 * a gPXE error code, as in
31 * return -( ENOENT | NO_SUCH_FILE );
33 * The POSIX error code is #defined to include the closest matching
34 * PXE error code (which, in most cases, is just
35 * PXENV_STATUS_FAILURE), so we don't need to litter the codebase with
38 * Functions that wish to return failure should be declared as
39 * returning an integer @c rc "Return status code". A return value of
40 * zero indicates success, a non-zero value indicates failure. The
41 * return value can be passed directly to strerror() in order to
42 * generate a human-readable error message, e.g.
44 * if ( ( rc = some_function ( ... ) ) != 0 ) {
45 * DBG ( "Whatever I was trying to do failed: %s\n", strerror ( rc ) );
49 * As illustrated in the above example, error returns should generally
50 * be directly propagated upward to the calling function.
54 /** Derive PXENV_STATUS code from gPXE error number */
55 #define PXENV_STATUS( rc ) ( (-(rc)) & 0x00ff )
58 * @defgroup pxeerrors PXE error codes
60 * The names, meanings and values of these error codes are defined by
61 * the PXE specification.
67 #define PXENV_STATUS_SUCCESS 0x0000
68 #define PXENV_STATUS_FAILURE 0x0001
69 #define PXENV_STATUS_BAD_FUNC 0x0002
70 #define PXENV_STATUS_UNSUPPORTED 0x0003
71 #define PXENV_STATUS_KEEP_UNDI 0x0004
72 #define PXENV_STATUS_KEEP_ALL 0x0005
73 #define PXENV_STATUS_OUT_OF_RESOURCES 0x0006
75 /* ARP errors (0x0010 to 0x001f) */
76 #define PXENV_STATUS_ARP_TIMEOUT 0x0011
78 /* Base-Code state errors */
79 #define PXENV_STATUS_UDP_CLOSED 0x0018
80 #define PXENV_STATUS_UDP_OPEN 0x0019
81 #define PXENV_STATUS_TFTP_CLOSED 0x001a
82 #define PXENV_STATUS_TFTP_OPEN 0x001b
84 /* BIOS/system errors (0x0020 to 0x002f) */
85 #define PXENV_STATUS_MCOPY_PROBLEM 0x0020
86 #define PXENV_STATUS_BIS_INTEGRITY_FAILURE 0x0021
87 #define PXENV_STATUS_BIS_VALIDATE_FAILURE 0x0022
88 #define PXENV_STATUS_BIS_INIT_FAILURE 0x0023
89 #define PXENV_STATUS_BIS_SHUTDOWN_FAILURE 0x0024
90 #define PXENV_STATUS_BIS_GBOA_FAILURE 0x0025
91 #define PXENV_STATUS_BIS_FREE_FAILURE 0x0026
92 #define PXENV_STATUS_BIS_GSI_FAILURE 0x0027
93 #define PXENV_STATUS_BIS_BAD_CKSUM 0x0028
95 /* TFTP/MTFTP errors (0x0030 to 0x003f) */
96 #define PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS 0x0030
97 #define PXENV_STATUS_TFTP_OPEN_TIMEOUT 0x0032
98 #define PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x0033
99 #define PXENV_STATUS_TFTP_READ_TIMEOUT 0x0035
100 #define PXENV_STATUS_TFTP_ERROR_OPCODE 0x0036
101 #define PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION 0x0038
102 #define PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION 0x0039
103 #define PXENV_STATUS_TFTP_TOO_MANY_PACKAGES 0x003a
104 #define PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x003b
105 #define PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x003c
106 #define PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x003d
107 #define PXENV_STATUS_TFTP_NO_FILESIZE 0x003e
108 #define PXENV_STATUS_TFTP_INVALID_PACKET_SIZE 0x003f
110 /* Reserved errors 0x0040 to 0x004f) */
112 /* DHCP/BOOTP errors (0x0050 to 0x005f) */
113 #define PXENV_STATUS_DHCP_TIMEOUT 0x0051
114 #define PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x0052
115 #define PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x0053
116 #define PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x0054
118 /* Driver errors (0x0060 to 0x006f) */
119 #define PXENV_STATUS_UNDI_INVALID_FUNCTION 0x0060
120 #define PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x0061
121 #define PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x0062
122 #define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC 0x0063
123 #define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY 0x0064
124 #define PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA 0x0065
125 #define PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA 0x0066
126 #define PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x0067
127 #define PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM 0x0068
128 #define PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x0069
129 #define PXENV_STATUS_UNDI_INVALID_STATE 0x006a
130 #define PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x006b
131 #define PXENV_STATUS_UNDI_INVALID_PARAMETER 0x006c
133 /* ROM and NBP bootstrap errors (0x0070 to 0x007f) */
134 #define PXENV_STATUS_BSTRAP_PROMPT_MENU 0x0074
135 #define PXENV_STATUS_BSTRAP_MCAST_ADDR 0x0076
136 #define PXENV_STATUS_BSTRAP_MISSING_LIST 0x0077
137 #define PXENV_STATUS_BSTRAP_NO_RESPONSE 0x0078
138 #define PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x0079
140 /* Environment NBP errors (0x0080 to 0x008f) */
142 /* Reserved errors (0x0090 to 0x009f) */
144 /* Miscellaneous errors (0x00a0 to 0x00af) */
145 #define PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE 0x00a0
146 #define PXENV_STATUS_BINL_NO_PXE_SERVER 0x00a1
147 #define PXENV_STATUS_NOT_AVAILABLE_IN_PMODE 0x00a2
148 #define PXENV_STATUS_NOT_AVAILABLE_IN_RMODE 0x00a3
150 /* BUSD errors (0x00b0 to 0x00bf) */
151 #define PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED 0x00b0
153 /* Loader errors (0x00c0 to 0x00cf) */
154 #define PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY 0x00c0
155 #define PXENV_STATUS_LOADER_NO_BC_ROMID 0x00c1
156 #define PXENV_STATUS_LOADER_BAD_BC_ROMID 0x00c2
157 #define PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE 0x00c3
158 #define PXENV_STATUS_LOADER_NO_UNDI_ROMID 0x00c4
159 #define PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0x00c5
160 #define PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE 0x00c6
161 #define PXENV_STATUS_LOADER_NO_PXE_STRUCT 0x00c8
162 #define PXENV_STATUS_LOADER_NO_PXENV_STRUCT 0x00c9
163 #define PXENV_STATUS_LOADER_UNDI_START 0x00ca
164 #define PXENV_STATUS_LOADER_BC_START 0x00cb
169 * @defgroup posixerrors POSIX error codes
171 * The names and meanings (but not the values) of these error codes
172 * are defined by POSIX. We choose to assign unique values which
173 * incorporate the closest equivalent PXE error code, so that code may
174 * simply use ENOMEM, rather than having to use the cumbersome
175 * (ENOMEM|PXENV_STATUS_OUT_OF_RESOURCES).
180 /** Operation completed successfully */
181 #define ENOERR ( PXENV_STATUS_SUCCESS | 0x0000 )
183 /** Arg list too long */
184 #define E2BIG ( PXENV_STATUS_BAD_FUNC | 0x0100 )
186 /** Permission denied */
187 #define EACCES ( PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x0200 )
189 /** Address in use */
190 #define EADDRINUSE ( PXENV_STATUS_UDP_OPEN | 0x0300 )
192 /** Address not available */
193 #define EADDRNOTAVAIL ( PXENV_STATUS_UDP_OPEN | 0x0400 )
195 /** Address family not supported */
196 #define EAFNOSUPPORT ( PXENV_STATUS_UNSUPPORTED | 0x0500 )
198 /** Resource temporarily unavailable */
199 #define EAGAIN ( PXENV_STATUS_FAILURE | 0x0600 )
201 /** Connection already in progress */
202 #define EALREADY ( PXENV_STATUS_UDP_OPEN | 0x0700 )
204 /** Bad file descriptor */
205 #define EBADF ( PXENV_STATUS_TFTP_CLOSED | 0x0800 )
208 #define EBADMSG ( PXENV_STATUS_FAILURE | 0x0900 )
211 #define EBUSY ( PXENV_STATUS_OUT_OF_RESOURCES | 0x0a00 )
213 /** Operation canceled */
214 #define ECANCELED ( PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE | 0x0b00 )
216 /** No child processes */
217 #define ECHILD ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x0c00 )
219 /** Connection aborted */
220 #define ECONNABORTED ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0d00 )
222 /** Connection refused */
223 #define ECONNREFUSED ( PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION | 0x0e00 )
225 /** Connection reset */
226 #define ECONNRESET ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0f00 )
228 /** Resource deadlock avoided */
229 #define EDEADLK ( PXENV_STATUS_FAILURE | 0x1000 )
231 /** Destination address required */
232 #define EDESTADDRREQ ( PXENV_STATUS_BAD_FUNC | 0x1100 )
235 #define EDOM ( PXENV_STATUS_FAILURE | 0x1200 )
238 #define EDQUOT ( PXENV_STATUS_FAILURE | 0x1300 )
241 #define EEXIST ( PXENV_STATUS_FAILURE | 0x1400 )
244 #define EFAULT ( PXENV_STATUS_MCOPY_PROBLEM | 0x1500 )
246 /** File too large */
247 #define EFBIG ( PXENV_STATUS_MCOPY_PROBLEM | 0x1600 )
249 /** Host is unreachable */
250 #define EHOSTUNREACH ( PXENV_STATUS_ARP_TIMEOUT | 0x1700 )
252 /** Identifier removed */
253 #define EIDRM ( PXENV_STATUS_FAILURE | 0x1800 )
255 /** Illegal byte sequence */
256 #define EILSEQ ( PXENV_STATUS_FAILURE | 0x1900 )
258 /** Operation in progress */
259 #define EINPROGRESS ( PXENV_STATUS_FAILURE | 0x1a00 )
261 /** Interrupted function call */
262 #define EINTR ( PXENV_STATUS_FAILURE | 0x1b00 )
264 /** Invalid argument */
265 #define EINVAL ( PXENV_STATUS_BAD_FUNC | 0x1c00 )
267 /** Input/output error */
268 #define EIO ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x1d00 )
270 /** Socket is connected */
271 #define EISCONN ( PXENV_STATUS_UDP_OPEN | 0x1e00 )
273 /** Is a directory */
274 #define EISDIR ( PXENV_STATUS_FAILURE | 0x1f00 )
276 /** Too many levels of symbolic links */
277 #define ELOOP ( PXENV_STATUS_FAILURE | 0x2000 )
279 /** Too many open files */
280 #define EMFILE ( PXENV_STATUS_OUT_OF_RESOURCES | 0x2100 )
282 /** Too many links */
283 #define EMLINK ( PXENV_STATUS_FAILURE | 0x2200 )
285 /** Inappropriate message buffer length */
286 #define EMSGSIZE ( PXENV_STATUS_BAD_FUNC | 0x2300 )
289 #define EMULTIHOP ( PXENV_STATUS_FAILURE | 0x2400 )
291 /** Filename too long */
292 #define ENAMETOOLONG ( PXENV_STATUS_FAILURE | 0x2500 )
294 /** Network is down */
295 #define ENETDOWN ( PXENV_STATUS_ARP_TIMEOUT | 0x2600 )
297 /** Connection aborted by network */
298 #define ENETRESET ( PXENV_STATUS_FAILURE | 0x2700 )
300 /** Network unreachable */
301 #define ENETUNREACH ( PXENV_STATUS_ARP_TIMEOUT | 0x2800 )
303 /** Too many open files in system */
304 #define ENFILE ( PXENV_STATUS_OUT_OF_RESOURCES | 0x2900 )
306 /** No buffer space available */
307 #define ENOBUFS ( PXENV_STATUS_OUT_OF_RESOURCES | 0x2a00 )
309 /** No message is available on the STREAM head read queue */
310 #define ENODATA ( PXENV_STATUS_FAILURE | 0x2b00 )
312 /** No such device */
313 #define ENODEV ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2c00 )
315 /** No such file or directory */
316 #define ENOENT ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2d00 )
318 /** Exec format error */
319 #define ENOEXEC ( PXENV_STATUS_FAILURE | 0x2e00 )
321 /** No locks available */
322 #define ENOLCK ( PXENV_STATUS_FAILURE | 0x2f00 )
325 #define ENOLINK ( PXENV_STATUS_FAILURE | 0x3000 )
327 /** Not enough space */
328 #define ENOMEM ( PXENV_STATUS_OUT_OF_RESOURCES | 0x3100 )
330 /** No message of the desired type */
331 #define ENOMSG ( PXENV_STATUS_FAILURE | 0x3200 )
333 /** Protocol not available */
334 #define ENOPROTOOPT ( PXENV_STATUS_UNSUPPORTED | 0x3300 )
336 /** No space left on device */
337 #define ENOSPC ( PXENV_STATUS_OUT_OF_RESOURCES | 0x3400 )
339 /** No STREAM resources */
340 #define ENOSR ( PXENV_STATUS_OUT_OF_RESOURCES | 0x3500 )
343 #define ENOSTR ( PXENV_STATUS_FAILURE | 0x3600 )
345 /** Function not implemented */
346 #define ENOSYS ( PXENV_STATUS_UNSUPPORTED | 0x3700 )
348 /** The socket is not connected */
349 #define ENOTCONN ( PXENV_STATUS_FAILURE | 0x3800 )
351 /** Not a directory */
352 #define ENOTDIR ( PXENV_STATUS_FAILURE | 0x3900 )
354 /** Directory not empty */
355 #define ENOTEMPTY ( PXENV_STATUS_FAILURE | 0x3a00 )
358 #define ENOTSOCK ( PXENV_STATUS_FAILURE | 0x3b00 )
361 #define ENOTSUP ( PXENV_STATUS_UNSUPPORTED | 0x3c00 )
363 /** Inappropriate I/O control operation */
364 #define ENOTTY ( PXENV_STATUS_FAILURE | 0x3d00 )
366 /** No such device or address */
367 #define ENXIO ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x3e00 )
369 /** Operation not supported on socket */
370 #define EOPNOTSUPP ( PXENV_STATUS_UNSUPPORTED | 0x3f00 )
372 /** Value too large to be stored in data type */
373 #define EOVERFLOW ( PXENV_STATUS_FAILURE | 0x4000 )
375 /** Operation not permitted */
376 #define EPERM ( PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x4100 )
379 #define EPIPE ( PXENV_STATUS_FAILURE | 0x4200 )
381 /** Protocol error */
382 #define EPROTO ( PXENV_STATUS_FAILURE | 0x4300 )
384 /** Protocol not supported */
385 #define EPROTONOSUPPORT ( PXENV_STATUS_UNSUPPORTED | 0x4400 )
387 /** Protocol wrong type for socket */
388 #define EPROTOTYPE ( PXENV_STATUS_FAILURE | 0x4500 )
390 /** Result too large */
391 #define ERANGE ( PXENV_STATUS_FAILURE | 0x4600 )
393 /** Read-only file system */
394 #define EROFS ( PXENV_STATUS_FAILURE | 0x4700 )
397 #define ESPIPE ( PXENV_STATUS_FAILURE | 0x4800 )
399 /** No such process */
400 #define ESRCH ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x4900 )
402 /** Stale file handle */
403 #define ESTALE ( PXENV_STATUS_FAILURE | 0x4a00 )
405 /** STREAM ioctl() timeout */
406 #define ETIME ( PXENV_STATUS_FAILURE | 0x4b00 )
408 /** Operation timed out */
409 #define ETIMEDOUT ( PXENV_STATUS_TFTP_READ_TIMEOUT | 0x4c00 )
411 /** Text file busy */
412 #define ETXTBSY ( PXENV_STATUS_FAILURE | 0x4d00 )
414 /** Operation would block */
415 #define EWOULDBLOCK ( PXENV_STATUS_FAILURE | 0x4e00 )
418 #define EXDEV ( PXENV_STATUS_FAILURE | 0x4f00 )
423 * @defgroup gpxeerrors gPXE-specific error codes
425 * The names, meanings, and values of these error codes are defined by
426 * this file. A gPXE-specific error code should be defined only where
427 * the POSIX error code does not identify the error with sufficient
428 * specificity. For example, ENOMEM probably encapsulates everything
429 * that needs to be known about the error (we've run out of heap
430 * space), while EACCES does not (did the server refuse the
431 * connection, or did we decide that the server failed to provide a
432 * valid SSL/TLS certificate?).