You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

errno.h 15KB

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