Browse Source

[libc] Redefine low 8 bits of error code as "platform error code"

The low 8 bits of an iPXE error code are currently defined as the
closest equivalent PXE error code.  Generalise this scheme to
platforms other than PC-BIOS by extending this definition to "closest
equivalent platform error code".  This allows for the possibility of
returning meaningful errors via EFI APIs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
7348035231

+ 115
- 0
src/arch/i386/include/ipxe/errno/pcbios.h View File

@@ -0,0 +1,115 @@
1
+#ifndef _IPXE_ERRNO_PCBIOS_H
2
+#define _IPXE_ERRNO_PCBIOS_H
3
+
4
+/**
5
+ * @file
6
+ *
7
+ * PC-BIOS platform error codes
8
+ *
9
+ * We use the PXE-specified error codes as the platform error codes
10
+ * for the PC-BIOS platform.
11
+ */
12
+
13
+FILE_LICENCE ( GPL2_OR_LATER );
14
+
15
+#include <pxe_error.h>
16
+
17
+/**
18
+ * Convert platform error code to platform component of iPXE error code
19
+ *
20
+ * @v platform		Platform error code
21
+ * @ret errno		Platform component of iPXE error code
22
+ */
23
+#define PLATFORM_TO_ERRNO( platform ) ( (platform) & 0xff )
24
+
25
+/**
26
+ * Convert iPXE error code to platform error code
27
+ *
28
+ * @v errno		iPXE error code
29
+ * @ret platform	Platform error code
30
+ */
31
+#define ERRNO_TO_PLATFORM( errno ) ( (errno) & 0xff )
32
+
33
+/* Platform-specific error codes */
34
+#define PLATFORM_ENOERR		PXENV_STATUS_SUCCESS
35
+#define PLATFORM_E2BIG		PXENV_STATUS_BAD_FUNC
36
+#define PLATFORM_EACCES		PXENV_STATUS_TFTP_ACCESS_VIOLATION
37
+#define PLATFORM_EADDRINUSE	PXENV_STATUS_UDP_OPEN
38
+#define PLATFORM_EADDRNOTAVAIL	PXENV_STATUS_UDP_OPEN
39
+#define PLATFORM_EAFNOSUPPORT	PXENV_STATUS_UNSUPPORTED
40
+#define PLATFORM_EAGAIN		PXENV_STATUS_FAILURE
41
+#define PLATFORM_EALREADY	PXENV_STATUS_UDP_OPEN
42
+#define PLATFORM_EBADF		PXENV_STATUS_TFTP_CLOSED
43
+#define PLATFORM_EBADMSG	PXENV_STATUS_FAILURE
44
+#define PLATFORM_EBUSY		PXENV_STATUS_OUT_OF_RESOURCES
45
+#define PLATFORM_ECANCELED	PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE
46
+#define PLATFORM_ECHILD		PXENV_STATUS_TFTP_FILE_NOT_FOUND
47
+#define PLATFORM_ECONNABORTED	PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION
48
+#define PLATFORM_ECONNREFUSED	PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION
49
+#define PLATFORM_ECONNRESET	PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION
50
+#define PLATFORM_EDEADLK	PXENV_STATUS_FAILURE
51
+#define PLATFORM_EDESTADDRREQ	PXENV_STATUS_BAD_FUNC
52
+#define PLATFORM_EDOM		PXENV_STATUS_FAILURE
53
+#define PLATFORM_EDQUOT		PXENV_STATUS_FAILURE
54
+#define PLATFORM_EEXIST		PXENV_STATUS_FAILURE
55
+#define PLATFORM_EFAULT		PXENV_STATUS_MCOPY_PROBLEM
56
+#define PLATFORM_EFBIG		PXENV_STATUS_MCOPY_PROBLEM
57
+#define PLATFORM_EHOSTUNREACH	PXENV_STATUS_ARP_TIMEOUT
58
+#define PLATFORM_EIDRM		PXENV_STATUS_FAILURE
59
+#define PLATFORM_EILSEQ		PXENV_STATUS_FAILURE
60
+#define PLATFORM_EINPROGRESS	PXENV_STATUS_FAILURE
61
+#define PLATFORM_EINTR		PXENV_STATUS_FAILURE
62
+#define PLATFORM_EINVAL		PXENV_STATUS_BAD_FUNC
63
+#define PLATFORM_EIO		PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION
64
+#define PLATFORM_EISCONN	PXENV_STATUS_UDP_OPEN
65
+#define PLATFORM_EISDIR		PXENV_STATUS_FAILURE
66
+#define PLATFORM_ELOOP		PXENV_STATUS_FAILURE
67
+#define PLATFORM_EMFILE		PXENV_STATUS_OUT_OF_RESOURCES
68
+#define PLATFORM_EMLINK		PXENV_STATUS_FAILURE
69
+#define PLATFORM_EMSGSIZE	PXENV_STATUS_BAD_FUNC
70
+#define PLATFORM_EMULTIHOP	PXENV_STATUS_FAILURE
71
+#define PLATFORM_ENAMETOOLONG	PXENV_STATUS_FAILURE
72
+#define PLATFORM_ENETDOWN	PXENV_STATUS_ARP_TIMEOUT
73
+#define PLATFORM_ENETRESET	PXENV_STATUS_FAILURE
74
+#define PLATFORM_ENETUNREACH	PXENV_STATUS_ARP_TIMEOUT
75
+#define PLATFORM_ENFILE		PXENV_STATUS_OUT_OF_RESOURCES
76
+#define PLATFORM_ENOBUFS	PXENV_STATUS_OUT_OF_RESOURCES
77
+#define PLATFORM_ENODATA	PXENV_STATUS_FAILURE
78
+#define PLATFORM_ENODEV		PXENV_STATUS_TFTP_FILE_NOT_FOUND
79
+#define PLATFORM_ENOENT		PXENV_STATUS_TFTP_FILE_NOT_FOUND
80
+#define PLATFORM_ENOEXEC	PXENV_STATUS_FAILURE
81
+#define PLATFORM_ENOLCK		PXENV_STATUS_FAILURE
82
+#define PLATFORM_ENOLINK	PXENV_STATUS_FAILURE
83
+#define PLATFORM_ENOMEM		PXENV_STATUS_OUT_OF_RESOURCES
84
+#define PLATFORM_ENOMSG		PXENV_STATUS_FAILURE
85
+#define PLATFORM_ENOPROTOOPT	PXENV_STATUS_UNSUPPORTED
86
+#define PLATFORM_ENOSPC		PXENV_STATUS_OUT_OF_RESOURCES
87
+#define PLATFORM_ENOSR		PXENV_STATUS_OUT_OF_RESOURCES
88
+#define PLATFORM_ENOSTR		PXENV_STATUS_FAILURE
89
+#define PLATFORM_ENOSYS		PXENV_STATUS_UNSUPPORTED
90
+#define PLATFORM_ENOTCONN	PXENV_STATUS_FAILURE
91
+#define PLATFORM_ENOTDIR	PXENV_STATUS_FAILURE
92
+#define PLATFORM_ENOTEMPTY	PXENV_STATUS_FAILURE
93
+#define PLATFORM_ENOTSOCK	PXENV_STATUS_FAILURE
94
+#define PLATFORM_ENOTSUP	PXENV_STATUS_UNSUPPORTED
95
+#define PLATFORM_ENOTTY		PXENV_STATUS_FAILURE
96
+#define PLATFORM_ENXIO		PXENV_STATUS_TFTP_FILE_NOT_FOUND
97
+#define PLATFORM_EOPNOTSUPP	PXENV_STATUS_UNSUPPORTED
98
+#define PLATFORM_EOVERFLOW	PXENV_STATUS_FAILURE
99
+#define PLATFORM_EPERM		PXENV_STATUS_TFTP_ACCESS_VIOLATION
100
+#define PLATFORM_EPIPE		PXENV_STATUS_FAILURE
101
+#define PLATFORM_EPROTO		PXENV_STATUS_FAILURE
102
+#define PLATFORM_EPROTONOSUPPORT PXENV_STATUS_UNSUPPORTED
103
+#define PLATFORM_EPROTOTYPE	PXENV_STATUS_FAILURE
104
+#define PLATFORM_ERANGE		PXENV_STATUS_FAILURE
105
+#define PLATFORM_EROFS		PXENV_STATUS_FAILURE
106
+#define PLATFORM_ESPIPE		PXENV_STATUS_FAILURE
107
+#define PLATFORM_ESRCH		PXENV_STATUS_TFTP_FILE_NOT_FOUND
108
+#define PLATFORM_ESTALE		PXENV_STATUS_FAILURE
109
+#define PLATFORM_ETIME		PXENV_STATUS_FAILURE
110
+#define PLATFORM_ETIMEDOUT	PXENV_STATUS_TFTP_READ_TIMEOUT
111
+#define PLATFORM_ETXTBSY	PXENV_STATUS_FAILURE
112
+#define PLATFORM_EWOULDBLOCK	PXENV_STATUS_TFTP_OPEN
113
+#define PLATFORM_EXDEV		PXENV_STATUS_FAILURE
114
+
115
+#endif /* _IPXE_ERRNO_PCBIOS_H */

+ 1
- 0
src/arch/i386/include/pxe.h View File

@@ -4,6 +4,7 @@
4 4
 FILE_LICENCE ( GPL2_OR_LATER );
5 5
 
6 6
 #include "pxe_types.h"
7
+#include "pxe_error.h"
7 8
 #include "pxe_api.h"
8 9
 #include <ipxe/device.h>
9 10
 #include <ipxe/tables.h>

+ 123
- 0
src/arch/i386/include/pxe_error.h View File

@@ -0,0 +1,123 @@
1
+#ifndef PXE_ERROR_H
2
+#define PXE_ERROR_H
3
+
4
+/** @file
5
+ *
6
+ * Preboot eXecution Environment (PXE) error definitions
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER );
11
+
12
+/**
13
+ * @defgroup pxeerrors PXE error codes
14
+ *
15
+ * @{
16
+ */
17
+
18
+/* Generic errors */
19
+#define	PXENV_STATUS_SUCCESS					       0x0000
20
+#define	PXENV_STATUS_FAILURE					       0x0001
21
+#define	PXENV_STATUS_BAD_FUNC					       0x0002
22
+#define	PXENV_STATUS_UNSUPPORTED				       0x0003
23
+#define	PXENV_STATUS_KEEP_UNDI					       0x0004
24
+#define	PXENV_STATUS_KEEP_ALL					       0x0005
25
+#define	PXENV_STATUS_OUT_OF_RESOURCES				       0x0006
26
+
27
+/* ARP errors (0x0010 to 0x001f) */
28
+#define	PXENV_STATUS_ARP_TIMEOUT				       0x0011
29
+
30
+/* Base-Code state errors */
31
+#define	PXENV_STATUS_UDP_CLOSED					       0x0018
32
+#define	PXENV_STATUS_UDP_OPEN					       0x0019
33
+#define	PXENV_STATUS_TFTP_CLOSED				       0x001a
34
+#define	PXENV_STATUS_TFTP_OPEN					       0x001b
35
+
36
+/* BIOS/system errors (0x0020 to 0x002f) */
37
+#define	PXENV_STATUS_MCOPY_PROBLEM				       0x0020
38
+#define	PXENV_STATUS_BIS_INTEGRITY_FAILURE			       0x0021
39
+#define	PXENV_STATUS_BIS_VALIDATE_FAILURE			       0x0022
40
+#define	PXENV_STATUS_BIS_INIT_FAILURE				       0x0023
41
+#define	PXENV_STATUS_BIS_SHUTDOWN_FAILURE			       0x0024
42
+#define	PXENV_STATUS_BIS_GBOA_FAILURE				       0x0025
43
+#define	PXENV_STATUS_BIS_FREE_FAILURE				       0x0026
44
+#define	PXENV_STATUS_BIS_GSI_FAILURE				       0x0027
45
+#define	PXENV_STATUS_BIS_BAD_CKSUM				       0x0028
46
+
47
+/* TFTP/MTFTP errors (0x0030 to 0x003f) */
48
+#define	PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS			       0x0030
49
+#define	PXENV_STATUS_TFTP_OPEN_TIMEOUT				       0x0032
50
+#define	PXENV_STATUS_TFTP_UNKNOWN_OPCODE			       0x0033
51
+#define	PXENV_STATUS_TFTP_READ_TIMEOUT				       0x0035
52
+#define	PXENV_STATUS_TFTP_ERROR_OPCODE				       0x0036
53
+#define	PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION		       0x0038
54
+#define	PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION		       0x0039
55
+#define	PXENV_STATUS_TFTP_TOO_MANY_PACKAGES			       0x003a
56
+#define	PXENV_STATUS_TFTP_FILE_NOT_FOUND			       0x003b
57
+#define	PXENV_STATUS_TFTP_ACCESS_VIOLATION			       0x003c
58
+#define	PXENV_STATUS_TFTP_NO_MCAST_ADDRESS			       0x003d
59
+#define	PXENV_STATUS_TFTP_NO_FILESIZE				       0x003e
60
+#define	PXENV_STATUS_TFTP_INVALID_PACKET_SIZE			       0x003f
61
+
62
+/* Reserved errors 0x0040 to 0x004f) */
63
+
64
+/* DHCP/BOOTP errors (0x0050 to 0x005f) */
65
+#define	PXENV_STATUS_DHCP_TIMEOUT				       0x0051
66
+#define	PXENV_STATUS_DHCP_NO_IP_ADDRESS				       0x0052
67
+#define	PXENV_STATUS_DHCP_NO_BOOTFILE_NAME			       0x0053
68
+#define	PXENV_STATUS_DHCP_BAD_IP_ADDRESS			       0x0054
69
+
70
+/* Driver errors (0x0060 to 0x006f) */
71
+#define	PXENV_STATUS_UNDI_INVALID_FUNCTION			       0x0060
72
+#define	PXENV_STATUS_UNDI_MEDIATEST_FAILED			       0x0061
73
+#define	PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST		       0x0062
74
+#define	PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC			       0x0063
75
+#define	PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY			       0x0064
76
+#define	PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA		       0x0065
77
+#define	PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA			       0x0066
78
+#define	PXENV_STATUS_UNDI_BAD_MAC_ADDRESS			       0x0067
79
+#define	PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM			       0x0068
80
+#define	PXENV_STATUS_UNDI_ERROR_SETTING_ISR			       0x0069
81
+#define	PXENV_STATUS_UNDI_INVALID_STATE				       0x006a
82
+#define	PXENV_STATUS_UNDI_TRANSMIT_ERROR			       0x006b
83
+#define	PXENV_STATUS_UNDI_INVALID_PARAMETER			       0x006c
84
+
85
+/* ROM and NBP bootstrap errors (0x0070 to 0x007f) */
86
+#define	PXENV_STATUS_BSTRAP_PROMPT_MENU				       0x0074
87
+#define	PXENV_STATUS_BSTRAP_MCAST_ADDR				       0x0076
88
+#define	PXENV_STATUS_BSTRAP_MISSING_LIST			       0x0077
89
+#define	PXENV_STATUS_BSTRAP_NO_RESPONSE				       0x0078
90
+#define	PXENV_STATUS_BSTRAP_FILE_TOO_BIG			       0x0079
91
+
92
+/* Environment NBP errors (0x0080 to 0x008f) */
93
+
94
+/* Reserved errors (0x0090 to 0x009f) */
95
+
96
+/* Miscellaneous errors (0x00a0 to 0x00af) */
97
+#define	PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE			       0x00a0
98
+#define	PXENV_STATUS_BINL_NO_PXE_SERVER				       0x00a1
99
+#define	PXENV_STATUS_NOT_AVAILABLE_IN_PMODE			       0x00a2
100
+#define	PXENV_STATUS_NOT_AVAILABLE_IN_RMODE			       0x00a3
101
+
102
+/* BUSD errors (0x00b0 to 0x00bf) */
103
+#define	PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED			       0x00b0
104
+
105
+/* Loader errors (0x00c0 to 0x00cf) */
106
+#define	PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY			       0x00c0
107
+#define	PXENV_STATUS_LOADER_NO_BC_ROMID				       0x00c1
108
+#define	PXENV_STATUS_LOADER_BAD_BC_ROMID			       0x00c2
109
+#define	PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE		       0x00c3
110
+#define	PXENV_STATUS_LOADER_NO_UNDI_ROMID			       0x00c4
111
+#define	PXENV_STATUS_LOADER_BAD_UNDI_ROMID			       0x00c5
112
+#define	PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE		       0x00c6
113
+#define	PXENV_STATUS_LOADER_NO_PXE_STRUCT			       0x00c8
114
+#define	PXENV_STATUS_LOADER_NO_PXENV_STRUCT			       0x00c9
115
+#define	PXENV_STATUS_LOADER_UNDI_START				       0x00ca
116
+#define	PXENV_STATUS_LOADER_BC_START				       0x00cb
117
+
118
+/** @} */
119
+
120
+/** Derive PXENV_STATUS code from iPXE error number */
121
+#define PXENV_STATUS( rc ) ( (-(rc)) & 0x00ff )
122
+
123
+#endif /* PXE_ERROR_H */

+ 162
- 234
src/include/errno.h View File

@@ -30,16 +30,16 @@ FILE_LICENCE ( GPL2_OR_LATER );
30 30
  * maximum visibility into the source of an error even in an end-user
31 31
  * build with no debugging.  They are constructed as follows:
32 32
  *
33
- * Bits 7-0 : PXE error code
33
+ * Bits 7-0 : Platform-specific error code
34 34
  *
35
- * This is the closest equivalent PXE error code
36
- * (e.g. PXENV_STATUS_OUT_OF_RESOURCES), and is the only part of the
37
- * error that will be returned via the PXE API, since PXE has
38
- * predefined error codes.
35
+ * This is a losslessly compressed representation of the closest
36
+ * equivalent error code defined by the platform (e.g. BIOS/PXE or
37
+ * EFI).  It is used to generate errors to be returned to external
38
+ * code.
39 39
  *
40 40
  * Bits 12-8 : Per-file disambiguator
41 41
  *
42
- * When the same error number can be generated from multiple points
42
+ * When the same error code can be generated from multiple points
43 43
  * within a file, this field can be used to identify the unique
44 44
  * instance.
45 45
  *
@@ -54,7 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
54 54
  *
55 55
  * Bit 31 : Reserved
56 56
  *
57
- * Errors are usually return as negative error numbers (e.g. -EINVAL);
57
+ * Errors are usually return as negative error codes (e.g. -EINVAL);
58 58
  * bit 31 is therefore unusable.
59 59
  *
60 60
  *
@@ -63,9 +63,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
63 63
  *
64 64
  *     return -EINVAL;
65 65
  *
66
- * By various bits of preprocessor magic, the PXE error code and file
67
- * identifier are already incorporated into the definition of the
68
- * POSIX error macro, which keeps the code relatively clean.
66
+ * By various bits of preprocessor magic, the platform-specific error
67
+ * code and file identifier are already incorporated into the
68
+ * definition of the POSIX error macro, which keeps the code
69
+ * relatively clean.
69 70
  *
70 71
  *
71 72
  * Functions that wish to return failures should be declared as
@@ -99,6 +100,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
99 100
  *
100 101
  */
101 102
 
103
+/* Get definitions for platform-specific error codes */
104
+#define PLATFORM_ERRNO(_platform) <ipxe/errno/_platform.h>
105
+#include PLATFORM_ERRNO(PLATFORM)
106
+
102 107
 /* Get definitions for file identifiers */
103 108
 #include <ipxe/errfile.h>
104 109
 
@@ -110,37 +115,37 @@ FILE_LICENCE ( GPL2_OR_LATER );
110 115
 #if ! ERRFILE
111 116
 extern char missing_errfile_declaration[] __attribute__ (( deprecated ));
112 117
 #undef ERRFILE
113
-#define ERRFILE ( 0 * ( ( int ) missing_errfile_declaration ) )
118
+#define ERRFILE ( ( int ) ( 0 * ( ( intptr_t ) missing_errfile_declaration ) ) )
114 119
 #endif
115 120
 
116 121
 /**
117 122
  * Declare error information
118 123
  *
119
- * @v pxe		PXE error number (0x00-0xff)
120
- * @v posix		POSIX error number (0x00-0x7f)
124
+ * @v platform		Platform error code (uncompressed)
125
+ * @v posix		POSIX error code (0x00-0x7f)
121 126
  * @v uniq		Error disambiguator (0x00-0x1f)
122 127
  * @v desc		Error description
123 128
  * @ret einfo		Error information
124 129
  */
125
-#define __einfo( pxe, posix, uniq, desc ) ( pxe, posix, uniq, desc )
130
+#define __einfo( platform, posix, uniq, desc ) ( platform, posix, uniq, desc )
126 131
 
127 132
 /**
128
- * Get PXE error number
133
+ * Get platform error code
129 134
  *
130 135
  * @v einfo		Error information
131
- * @ret pxe		PXE error number
136
+ * @ret platform	Platform error code (uncompressed)
132 137
  */
133
-#define __einfo_pxe( einfo ) __einfo_extract_pxe einfo
134
-#define __einfo_extract_pxe( pxe, posix, uniq, desc ) pxe
138
+#define __einfo_platform( einfo ) __einfo_extract_platform einfo
139
+#define __einfo_extract_platform( platform, posix, uniq, desc ) platform
135 140
 
136 141
 /**
137
- * Get POSIX error number
142
+ * Get POSIX error code
138 143
  *
139 144
  * @v einfo		Error information
140
- * @ret posix		POSIX error number
145
+ * @ret posix		POSIX error code
141 146
  */
142 147
 #define __einfo_posix( einfo ) __einfo_extract_posix einfo
143
-#define __einfo_extract_posix( pxe, posix, uniq, desc ) posix
148
+#define __einfo_extract_posix( platform, posix, uniq, desc ) posix
144 149
 
145 150
 /**
146 151
  * Get error disambiguator
@@ -149,7 +154,7 @@ extern char missing_errfile_declaration[] __attribute__ (( deprecated ));
149 154
  * @ret uniq		Error disambiguator
150 155
  */
151 156
 #define __einfo_uniq( einfo ) __einfo_extract_uniq einfo
152
-#define __einfo_extract_uniq( pxe, posix, uniq, desc ) uniq
157
+#define __einfo_extract_uniq( platform, posix, uniq, desc ) uniq
153 158
 
154 159
 /**
155 160
  * Get error description
@@ -158,31 +163,44 @@ extern char missing_errfile_declaration[] __attribute__ (( deprecated ));
158 163
  * @ret desc		Error description
159 164
  */
160 165
 #define __einfo_desc( einfo ) __einfo_extract_desc einfo
161
-#define __einfo_extract_desc( pxe, posix, uniq, desc ) desc
166
+#define __einfo_extract_desc( platform, posix, uniq, desc ) desc
162 167
 
163 168
 /**
164 169
  * Declare disambiguated error
165 170
  *
166 171
  * @v einfo_base	Base error information
167
- * @v uniq		Error disambiguator
172
+ * @v uniq		Error disambiguator (0x00-0x1f)
168 173
  * @v desc		Error description
169 174
  * @ret einfo		Error information
170 175
  */
171 176
 #define __einfo_uniqify( einfo_base, uniq, desc )			\
172
-	__einfo ( __einfo_pxe ( einfo_base ),				\
177
+	__einfo ( __einfo_platform ( einfo_base ),			\
173 178
 		  __einfo_posix ( einfo_base ),				\
174 179
 		  uniq, desc )
175 180
 
176 181
 /**
177
- * Get error number
182
+ * Declare platform-generated error
183
+ *
184
+ * @v einfo_base	Base error information
185
+ * @v platform		Platform error code (uncompressed)
186
+ * @v desc		Error description
187
+ * @ret einfo		Error information
188
+ */
189
+#define __einfo_platformify( einfo_base, platform, desc )		\
190
+	__einfo ( platform, __einfo_posix ( einfo_base ),		\
191
+		  __einfo_uniq ( einfo_base ), desc )
192
+
193
+/**
194
+ * Get error code
178 195
  *
179 196
  * @v einfo		Error information
180
- * @ret errno		Error number
197
+ * @ret errno		Error code
181 198
  */
182 199
 #define __einfo_errno( einfo )						\
183
-	( ( __einfo_posix ( einfo ) << 24 ) | ( ERRFILE ) |		\
184
-	  ( __einfo_uniq ( einfo ) << 8 ) |				\
185
-	  ( __einfo_pxe ( einfo ) << 0 ) )
200
+	( ( int )							\
201
+	  ( ( __einfo_posix ( einfo ) << 24 ) | ( ERRFILE ) |		\
202
+	    ( __einfo_uniq ( einfo ) << 8 ) |				\
203
+	    ( PLATFORM_TO_ERRNO ( __einfo_platform ( einfo ) ) << 0 ) ) )
186 204
 
187 205
 /**
188 206
  * Disambiguate a base error based on non-constant information
@@ -206,6 +224,29 @@ extern char missing_errfile_declaration[] __attribute__ (( deprecated ));
206 224
 		    ( (uniq) << 8 ) ) ); } )
207 225
 static inline void euniq_discard ( int dummy __unused, ... ) {}
208 226
 
227
+/**
228
+ * Generate an error based on an external platform error code
229
+ *
230
+ * @v einfo_base	Base error information
231
+ * @v platform		Platform error code (uncompressed)
232
+ * @v ...		List of expected possible platform-generated errors
233
+ * @ret error		Error
234
+ *
235
+ * EPLATFORM() should be used when a platform error code resulting
236
+ * from an external platform API call is being incorporated into an
237
+ * error.  For example, EFI code uses EPLATFORM() to generate errors
238
+ * resulting from calls to EFI APIs such as
239
+ * InstallMultipleProtocolInterfaces().
240
+ *
241
+ * EPLATFORM() should not be used for constant platform-generated
242
+ * errors; use __einfo_platformify() instead.
243
+ */
244
+#define EPLATFORM( einfo_base, platform, ... ) ( {			\
245
+	eplatform_discard ( 0, ##__VA_ARGS__ );				\
246
+	( ( int ) ( __einfo_error ( einfo_base ) |			\
247
+		    PLATFORM_TO_ERRNO ( platform ) ) ); } )
248
+static inline void eplatform_discard ( int dummy __unused, ... ) {}
249
+
209 250
 /**
210 251
  * Declare error
211 252
  *
@@ -226,124 +267,10 @@ static inline void euniq_discard ( int dummy __unused, ... ) {}
226 267
 		  ".align 8\n\t"					\
227 268
 		  "\n4:\n\t"						\
228 269
 		  ".previous\n\t" : :					\
229
-		  "i" ( __einfo_errno ( einfo) ),			\
270
+		  "i" ( __einfo_errno ( einfo ) ),			\
230 271
 		  "i" ( __LINE__ ) );					\
231 272
 	__einfo_errno ( einfo ); } )
232 273
 
233
-/**
234
- * @defgroup pxeerrors PXE error codes
235
- *
236
- * The names, meanings and values of these error codes are defined by
237
- * the PXE specification.
238
- *
239
- * @{
240
- */
241
-
242
-/* Generic errors */
243
-#define	PXENV_STATUS_SUCCESS					       0x0000
244
-#define	PXENV_STATUS_FAILURE					       0x0001
245
-#define	PXENV_STATUS_BAD_FUNC					       0x0002
246
-#define	PXENV_STATUS_UNSUPPORTED				       0x0003
247
-#define	PXENV_STATUS_KEEP_UNDI					       0x0004
248
-#define	PXENV_STATUS_KEEP_ALL					       0x0005
249
-#define	PXENV_STATUS_OUT_OF_RESOURCES				       0x0006
250
-
251
-/* ARP errors (0x0010 to 0x001f) */
252
-#define	PXENV_STATUS_ARP_TIMEOUT				       0x0011
253
-
254
-/* Base-Code state errors */
255
-#define	PXENV_STATUS_UDP_CLOSED					       0x0018
256
-#define	PXENV_STATUS_UDP_OPEN					       0x0019
257
-#define	PXENV_STATUS_TFTP_CLOSED				       0x001a
258
-#define	PXENV_STATUS_TFTP_OPEN					       0x001b
259
-
260
-/* BIOS/system errors (0x0020 to 0x002f) */
261
-#define	PXENV_STATUS_MCOPY_PROBLEM				       0x0020
262
-#define	PXENV_STATUS_BIS_INTEGRITY_FAILURE			       0x0021
263
-#define	PXENV_STATUS_BIS_VALIDATE_FAILURE			       0x0022
264
-#define	PXENV_STATUS_BIS_INIT_FAILURE				       0x0023
265
-#define	PXENV_STATUS_BIS_SHUTDOWN_FAILURE			       0x0024
266
-#define	PXENV_STATUS_BIS_GBOA_FAILURE				       0x0025
267
-#define	PXENV_STATUS_BIS_FREE_FAILURE				       0x0026
268
-#define	PXENV_STATUS_BIS_GSI_FAILURE				       0x0027
269
-#define	PXENV_STATUS_BIS_BAD_CKSUM				       0x0028
270
-
271
-/* TFTP/MTFTP errors (0x0030 to 0x003f) */
272
-#define	PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS			       0x0030
273
-#define	PXENV_STATUS_TFTP_OPEN_TIMEOUT				       0x0032
274
-#define	PXENV_STATUS_TFTP_UNKNOWN_OPCODE			       0x0033
275
-#define	PXENV_STATUS_TFTP_READ_TIMEOUT				       0x0035
276
-#define	PXENV_STATUS_TFTP_ERROR_OPCODE				       0x0036
277
-#define	PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION		       0x0038
278
-#define	PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION		       0x0039
279
-#define	PXENV_STATUS_TFTP_TOO_MANY_PACKAGES			       0x003a
280
-#define	PXENV_STATUS_TFTP_FILE_NOT_FOUND			       0x003b
281
-#define	PXENV_STATUS_TFTP_ACCESS_VIOLATION			       0x003c
282
-#define	PXENV_STATUS_TFTP_NO_MCAST_ADDRESS			       0x003d
283
-#define	PXENV_STATUS_TFTP_NO_FILESIZE				       0x003e
284
-#define	PXENV_STATUS_TFTP_INVALID_PACKET_SIZE			       0x003f
285
-
286
-/* Reserved errors 0x0040 to 0x004f) */
287
-
288
-/* DHCP/BOOTP errors (0x0050 to 0x005f) */
289
-#define	PXENV_STATUS_DHCP_TIMEOUT				       0x0051
290
-#define	PXENV_STATUS_DHCP_NO_IP_ADDRESS				       0x0052
291
-#define	PXENV_STATUS_DHCP_NO_BOOTFILE_NAME			       0x0053
292
-#define	PXENV_STATUS_DHCP_BAD_IP_ADDRESS			       0x0054
293
-
294
-/* Driver errors (0x0060 to 0x006f) */
295
-#define	PXENV_STATUS_UNDI_INVALID_FUNCTION			       0x0060
296
-#define	PXENV_STATUS_UNDI_MEDIATEST_FAILED			       0x0061
297
-#define	PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST		       0x0062
298
-#define	PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC			       0x0063
299
-#define	PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY			       0x0064
300
-#define	PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA		       0x0065
301
-#define	PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA			       0x0066
302
-#define	PXENV_STATUS_UNDI_BAD_MAC_ADDRESS			       0x0067
303
-#define	PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM			       0x0068
304
-#define	PXENV_STATUS_UNDI_ERROR_SETTING_ISR			       0x0069
305
-#define	PXENV_STATUS_UNDI_INVALID_STATE				       0x006a
306
-#define	PXENV_STATUS_UNDI_TRANSMIT_ERROR			       0x006b
307
-#define	PXENV_STATUS_UNDI_INVALID_PARAMETER			       0x006c
308
-
309
-/* ROM and NBP bootstrap errors (0x0070 to 0x007f) */
310
-#define	PXENV_STATUS_BSTRAP_PROMPT_MENU				       0x0074
311
-#define	PXENV_STATUS_BSTRAP_MCAST_ADDR				       0x0076
312
-#define	PXENV_STATUS_BSTRAP_MISSING_LIST			       0x0077
313
-#define	PXENV_STATUS_BSTRAP_NO_RESPONSE				       0x0078
314
-#define	PXENV_STATUS_BSTRAP_FILE_TOO_BIG			       0x0079
315
-
316
-/* Environment NBP errors (0x0080 to 0x008f) */
317
-
318
-/* Reserved errors (0x0090 to 0x009f) */
319
-
320
-/* Miscellaneous errors (0x00a0 to 0x00af) */
321
-#define	PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE			       0x00a0
322
-#define	PXENV_STATUS_BINL_NO_PXE_SERVER				       0x00a1
323
-#define	PXENV_STATUS_NOT_AVAILABLE_IN_PMODE			       0x00a2
324
-#define	PXENV_STATUS_NOT_AVAILABLE_IN_RMODE			       0x00a3
325
-
326
-/* BUSD errors (0x00b0 to 0x00bf) */
327
-#define	PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED			       0x00b0
328
-
329
-/* Loader errors (0x00c0 to 0x00cf) */
330
-#define	PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY			       0x00c0
331
-#define	PXENV_STATUS_LOADER_NO_BC_ROMID				       0x00c1
332
-#define	PXENV_STATUS_LOADER_BAD_BC_ROMID			       0x00c2
333
-#define	PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE		       0x00c3
334
-#define	PXENV_STATUS_LOADER_NO_UNDI_ROMID			       0x00c4
335
-#define	PXENV_STATUS_LOADER_BAD_UNDI_ROMID			       0x00c5
336
-#define	PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE		       0x00c6
337
-#define	PXENV_STATUS_LOADER_NO_PXE_STRUCT			       0x00c8
338
-#define	PXENV_STATUS_LOADER_NO_PXENV_STRUCT			       0x00c9
339
-#define	PXENV_STATUS_LOADER_UNDI_START				       0x00ca
340
-#define	PXENV_STATUS_LOADER_BC_START				       0x00cb
341
-
342
-/** @} */
343
-
344
-/** Derive PXENV_STATUS code from iPXE error number */
345
-#define PXENV_STATUS( rc ) ( (-(rc)) & 0x00ff )
346
-
347 274
 /**
348 275
  * @defgroup posixerrors POSIX error codes
349 276
  *
@@ -355,409 +282,410 @@ static inline void euniq_discard ( int dummy __unused, ... ) {}
355 282
 
356 283
 /** Operation completed successfully */
357 284
 #define ENOERR __einfo_error ( EINFO_ENOERR )
358
-#define EINFO_ENOERR __einfo ( PXENV_STATUS_SUCCESS, 0x00, 0, \
285
+#define EINFO_ENOERR __einfo ( PLATFORM_ENOERR, 0x00, 0, \
359 286
 			       "Operation completed successfully" )
360 287
 
361 288
 /** Argument list too long */
362 289
 #define E2BIG __einfo_error ( EINFO_E2BIG )
363
-#define EINFO_E2BIG __einfo ( PXENV_STATUS_BAD_FUNC, 0x01, 0, \
290
+#define EINFO_E2BIG __einfo ( PLATFORM_E2BIG, 0x01, 0, \
364 291
 			      "Argument list too long" )
365 292
 
366 293
 /** Permission denied */
367 294
 #define EACCES __einfo_error ( EINFO_EACCES )
368
-#define EINFO_EACCES __einfo ( PXENV_STATUS_TFTP_ACCESS_VIOLATION, 0x02, 0, \
295
+#define EINFO_EACCES __einfo ( PLATFORM_EACCES, 0x02, 0, \
369 296
 			       "Permission denied" )
370 297
 
371 298
 /** Address already in use */
372 299
 #define EADDRINUSE __einfo_error ( EINFO_EADDRINUSE )
373
-#define EINFO_EADDRINUSE __einfo ( PXENV_STATUS_UDP_OPEN, 0x03, 0, \
300
+#define EINFO_EADDRINUSE __einfo ( PLATFORM_EADDRINUSE, 0x03, 0, \
374 301
 				   "Address already in use" )
375 302
 
376 303
 /** Address not available */
377 304
 #define EADDRNOTAVAIL __einfo_error ( EINFO_EADDRNOTAVAIL )
378
-#define EINFO_EADDRNOTAVAIL __einfo ( PXENV_STATUS_UDP_OPEN, 0x04, 0, \
305
+#define EINFO_EADDRNOTAVAIL __einfo ( PLATFORM_EADDRNOTAVAIL, 0x04, 0, \
379 306
 				      "Address not available" )
380 307
 
381 308
 /** Address family not supported */
382 309
 #define EAFNOSUPPORT __einfo_error ( EINFO_EAFNOSUPPORT )
383
-#define EINFO_EAFNOSUPPORT __einfo ( PXENV_STATUS_UNSUPPORTED, 0x05, 0, \
310
+#define EINFO_EAFNOSUPPORT __einfo ( PLATFORM_EAFNOSUPPORT, 0x05, 0, \
384 311
 				     "Address family not supported" )
385 312
 
386 313
 /** Resource temporarily unavailable */
387 314
 #define EAGAIN __einfo_error ( EINFO_EAGAIN )
388
-#define EINFO_EAGAIN __einfo ( PXENV_STATUS_FAILURE, 0x06, 0, \
315
+#define EINFO_EAGAIN __einfo ( PLATFORM_EAGAIN, 0x06, 0, \
389 316
 			       "Resource temporarily unavailable" )
390 317
 
391 318
 /** Connection already in progress */
392 319
 #define EALREADY __einfo_error ( EINFO_EALREADY )
393
-#define EINFO_EALREADY __einfo ( PXENV_STATUS_UDP_OPEN, 0x07, 0, \
320
+#define EINFO_EALREADY __einfo ( PLATFORM_EALREADY, 0x07, 0, \
394 321
 				 "Connection already in progress" )
395 322
 
396 323
 /** Bad file descriptor */
397 324
 #define EBADF __einfo_error ( EINFO_EBADF )
398
-#define EINFO_EBADF __einfo ( PXENV_STATUS_TFTP_CLOSED, 0x08, 0, \
325
+#define EINFO_EBADF __einfo ( PLATFORM_EBADF, 0x08, 0, \
399 326
 			      "Bad file descriptor" )
400 327
 
401 328
 /** Bad message */
402 329
 #define EBADMSG __einfo_error ( EINFO_EBADMSG )
403
-#define EINFO_EBADMSG __einfo ( PXENV_STATUS_FAILURE, 0x09, 0, \
330
+#define EINFO_EBADMSG __einfo ( PLATFORM_EBADMSG, 0x09, 0, \
404 331
 				"Bad message" )
405 332
 
406 333
 /** Device or resource busy */
407 334
 #define EBUSY __einfo_error ( EINFO_EBUSY )
408
-#define EINFO_EBUSY __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x0a, 0, \
335
+#define EINFO_EBUSY __einfo ( PLATFORM_EBUSY, 0x0a, 0, \
409 336
 			      "Device or resource busy" )
410 337
 
411 338
 /** Operation canceled */
412 339
 #define ECANCELED __einfo_error ( EINFO_ECANCELED )
413
-#define EINFO_ECANCELED __einfo ( PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE, \
414
-				  0x0b, 0, "Operation canceled" )
340
+#define EINFO_ECANCELED __einfo ( PLATFORM_ECANCELED, 0x0b, 0, \
341
+				  "Operation canceled" )
415 342
 
416 343
 /** No child processes */
417 344
 #define ECHILD __einfo_error ( EINFO_ECHILD )
418
-#define EINFO_ECHILD __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x0c, 0, \
345
+#define EINFO_ECHILD __einfo ( PLATFORM_ECHILD, 0x0c, 0, \
419 346
 			       "No child processes" )
420 347
 
421 348
 /** Connection aborted */
422 349
 #define ECONNABORTED __einfo_error ( EINFO_ECONNABORTED )
423
-#define EINFO_ECONNABORTED						  \
424
-	__einfo ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION, 0x0d, 0, \
425
-		  "Connection aborted" )
350
+#define EINFO_ECONNABORTED __einfo ( PLATFORM_ECONNABORTED, 0x0d, 0, \
351
+				     "Connection aborted" )
426 352
 
427 353
 /** Connection refused */
428 354
 #define ECONNREFUSED __einfo_error ( EINFO_ECONNREFUSED )
429
-#define EINFO_ECONNREFUSED __einfo ( PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION, \
430
-				     0x0e, 0, "Connection refused" )
355
+#define EINFO_ECONNREFUSED __einfo ( PLATFORM_ECONNREFUSED, 0x0e, 0, \
356
+				     "Connection refused" )
431 357
 
432 358
 /** Connection reset */
433 359
 #define ECONNRESET __einfo_error ( EINFO_ECONNRESET )
434
-#define EINFO_ECONNRESET						  \
435
-	__einfo ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION, 0x0f, 0, \
436
-		  "Connection reset" )
360
+#define EINFO_ECONNRESET __einfo ( PLATFORM_ECONNRESET, 0x0f, 0, \
361
+				   "Connection reset" )
437 362
 
438 363
 /** Resource deadlock avoided */
439 364
 #define EDEADLK __einfo_error ( EINFO_EDEADLK )
440
-#define EINFO_EDEADLK __einfo ( PXENV_STATUS_FAILURE, 0x10, 0, \
365
+#define EINFO_EDEADLK __einfo ( PLATFORM_EDEADLK, 0x10, 0, \
441 366
 				"Resource deadlock avoided" )
442 367
 
443 368
 /** Destination address required */
444 369
 #define EDESTADDRREQ __einfo_error ( EINFO_EDESTADDRREQ )
445
-#define EINFO_EDESTADDRREQ __einfo ( PXENV_STATUS_BAD_FUNC, 0x11, 0, \
370
+#define EINFO_EDESTADDRREQ __einfo ( PLATFORM_EDESTADDRREQ, 0x11, 0, \
446 371
 				     "Destination address required" )
447 372
 
448 373
 /** Mathematics argument out of domain of function */
449 374
 #define EDOM __einfo_error ( EINFO_EDOM )
450
-#define EINFO_EDOM __einfo ( PXENV_STATUS_FAILURE, 0x12, 0, \
375
+#define EINFO_EDOM __einfo ( PLATFORM_EDOM, 0x12, 0, \
451 376
 			     "Mathematics argument out of domain of function" )
452 377
 
453 378
 /** Disk quota exceeded */
454 379
 #define EDQUOT __einfo_error ( EINFO_EDQUOT )
455
-#define EINFO_EDQUOT __einfo ( PXENV_STATUS_FAILURE, 0x13, 0, \
380
+#define EINFO_EDQUOT __einfo ( PLATFORM_EDQUOT, 0x13, 0, \
456 381
 			       "Disk quote exceeded" )
457 382
 
458 383
 /** File exists */
459 384
 #define EEXIST __einfo_error ( EINFO_EEXIST )
460
-#define EINFO_EEXIST __einfo ( PXENV_STATUS_FAILURE, 0x14, 0, \
385
+#define EINFO_EEXIST __einfo ( PLATFORM_EEXIST, 0x14, 0, \
461 386
 			       "File exists" )
462 387
 
463 388
 /** Bad address */
464 389
 #define EFAULT __einfo_error ( EINFO_EFAULT )
465
-#define EINFO_EFAULT __einfo ( PXENV_STATUS_MCOPY_PROBLEM, 0x15, 0, \
390
+#define EINFO_EFAULT __einfo ( PLATFORM_EFAULT, 0x15, 0, \
466 391
 			       "Bad address" )
467 392
 
468 393
 /** File too large */
469 394
 #define EFBIG __einfo_error ( EINFO_EFBIG )
470
-#define EINFO_EFBIG __einfo ( PXENV_STATUS_MCOPY_PROBLEM, 0x16, 0, \
395
+#define EINFO_EFBIG __einfo ( PLATFORM_EFBIG, 0x16, 0, \
471 396
 			      "File too large" )
472 397
 
473 398
 /** Host is unreachable */
474 399
 #define EHOSTUNREACH __einfo_error ( EINFO_EHOSTUNREACH )
475
-#define EINFO_EHOSTUNREACH __einfo ( PXENV_STATUS_ARP_TIMEOUT, 0x17, 0, \
400
+#define EINFO_EHOSTUNREACH __einfo ( PLATFORM_EHOSTUNREACH, 0x17, 0, \
476 401
 				     "Host is unreachable" )
477 402
 
478 403
 /** Identifier removed */
479 404
 #define EIDRM __einfo_error ( EINFO_EIDRM )
480
-#define EINFO_EIDRM __einfo ( PXENV_STATUS_FAILURE, 0x18, 0, \
405
+#define EINFO_EIDRM __einfo ( PLATFORM_EIDRM, 0x18, 0, \
481 406
 			      "Identifier removed" )
482 407
 
483 408
 /** Illegal byte sequence */
484 409
 #define EILSEQ __einfo_error ( EINFO_EILSEQ )
485
-#define EINFO_EILSEQ __einfo ( PXENV_STATUS_FAILURE, 0x19, 0, \
410
+#define EINFO_EILSEQ __einfo ( PLATFORM_EILSEQ, 0x19, 0, \
486 411
 			       "Illegal byte sequence" )
487 412
 
488 413
 /** Operation in progress */
489 414
 #define EINPROGRESS __einfo_error ( EINFO_EINPROGRESS )
490
-#define EINFO_EINPROGRESS __einfo ( PXENV_STATUS_FAILURE, 0x1a, 0, \
415
+#define EINFO_EINPROGRESS __einfo ( PLATFORM_EINPROGRESS, 0x1a, 0, \
491 416
 				    "Operation in progress" )
492 417
 
493 418
 /** Interrupted function call */
494 419
 #define EINTR __einfo_error ( EINFO_EINTR )
495
-#define EINFO_EINTR __einfo ( PXENV_STATUS_FAILURE, 0x1b, 0, \
420
+#define EINFO_EINTR __einfo ( PLATFORM_EINTR, 0x1b, 0, \
496 421
 			      "Interrupted function call" )
497 422
 
498 423
 /** Invalid argument */
499 424
 #define EINVAL __einfo_error ( EINFO_EINVAL )
500
-#define EINFO_EINVAL __einfo ( PXENV_STATUS_BAD_FUNC, 0x1c, 0, \
425
+#define EINFO_EINVAL __einfo ( PLATFORM_EINVAL, 0x1c, 0, \
501 426
 			       "Invalid argument" )
502 427
 
503 428
 /** Input/output error */
504 429
 #define EIO __einfo_error ( EINFO_EIO )
505
-#define EINFO_EIO __einfo ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION, \
506
-			    0x1d, 0, "Input/output error" )
430
+#define EINFO_EIO __einfo ( PLATFORM_EIO, 0x1d, 0, \
431
+			    "Input/output error" )
507 432
 
508 433
 /** Socket is connected */
509 434
 #define EISCONN __einfo_error ( EINFO_EISCONN )
510
-#define EINFO_EISCONN __einfo ( PXENV_STATUS_UDP_OPEN, 0x1e, 0, \
435
+#define EINFO_EISCONN __einfo ( PLATFORM_EISCONN, 0x1e, 0, \
511 436
 				"Socket is connected" )
512 437
 
513 438
 /** Is a directory */
514 439
 #define EISDIR __einfo_error ( EINFO_EISDIR )
515
-#define EINFO_EISDIR __einfo ( PXENV_STATUS_FAILURE, 0x1f, 0, \
440
+#define EINFO_EISDIR __einfo ( PLATFORM_EISDIR, 0x1f, 0, \
516 441
 			       "Is a directory" )
517 442
 
518 443
 /** Too many levels of symbolic links */
519 444
 #define ELOOP __einfo_error ( EINFO_ELOOP )
520
-#define EINFO_ELOOP __einfo ( PXENV_STATUS_FAILURE, 0x20, 0, \
445
+#define EINFO_ELOOP __einfo ( PLATFORM_ELOOP, 0x20, 0, \
521 446
 			      "Too many levels of symbolic links" )
522 447
 
523 448
 /** Too many open files */
524 449
 #define EMFILE __einfo_error ( EINFO_EMFILE )
525
-#define EINFO_EMFILE __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x21, 0, \
450
+#define EINFO_EMFILE __einfo ( PLATFORM_EMFILE, 0x21, 0, \
526 451
 			       "Too many open files" )
527 452
 
528 453
 /** Too many links */
529 454
 #define EMLINK __einfo_error ( EINFO_EMLINK )
530
-#define EINFO_EMLINK __einfo ( PXENV_STATUS_FAILURE, 0x22, 0, \
455
+#define EINFO_EMLINK __einfo ( PLATFORM_EMLINK, 0x22, 0, \
531 456
 			       "Too many links" )
532 457
 
533 458
 /** Message too long */
534 459
 #define EMSGSIZE __einfo_error ( EINFO_EMSGSIZE )
535
-#define EINFO_EMSGSIZE __einfo ( PXENV_STATUS_BAD_FUNC, 0x23, 0, \
460
+#define EINFO_EMSGSIZE __einfo ( PLATFORM_EMSGSIZE, 0x23, 0, \
536 461
 				 "Message too long" )
537 462
 
538 463
 /** Multihop attempted */
539 464
 #define EMULTIHOP __einfo_error ( EINFO_EMULTIHOP )
540
-#define EINFO_EMULTIHOP __einfo ( PXENV_STATUS_FAILURE, 0x24, 0, \
465
+#define EINFO_EMULTIHOP __einfo ( PLATFORM_EMULTIHOP, 0x24, 0, \
541 466
 				  "Multihop attempted" )
542 467
 
543 468
 /** Filename too long */
544 469
 #define ENAMETOOLONG __einfo_error ( EINFO_ENAMETOOLONG )
545
-#define EINFO_ENAMETOOLONG __einfo ( PXENV_STATUS_FAILURE, 0x25, 0, \
470
+#define EINFO_ENAMETOOLONG __einfo ( PLATFORM_ENAMETOOLONG, 0x25, 0, \
546 471
 				     "Filename too long" )
547 472
 
548 473
 /** Network is down */
549 474
 #define ENETDOWN __einfo_error ( EINFO_ENETDOWN )
550
-#define EINFO_ENETDOWN __einfo ( PXENV_STATUS_ARP_TIMEOUT, 0x26, 0, \
475
+#define EINFO_ENETDOWN __einfo ( PLATFORM_ENETDOWN, 0x26, 0, \
551 476
 				 "Network is down" )
552 477
 
553 478
 /** Connection aborted by network */
554 479
 #define ENETRESET __einfo_error ( EINFO_ENETRESET )
555
-#define EINFO_ENETRESET __einfo ( PXENV_STATUS_FAILURE, 0x27, 0, \
480
+#define EINFO_ENETRESET __einfo ( PLATFORM_ENETRESET, 0x27, 0, \
556 481
 				  "Connection aborted by network" )
557 482
 
558 483
 /** Network unreachable */
559 484
 #define ENETUNREACH __einfo_error ( EINFO_ENETUNREACH )
560
-#define EINFO_ENETUNREACH __einfo ( PXENV_STATUS_ARP_TIMEOUT, 0x28, 0, \
485
+#define EINFO_ENETUNREACH __einfo ( PLATFORM_ENETUNREACH, 0x28, 0, \
561 486
 				    "Network unreachable" )
562 487
 
563 488
 /** Too many open files in system */
564 489
 #define ENFILE __einfo_error ( EINFO_ENFILE )
565
-#define EINFO_ENFILE __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x29, 0, \
490
+#define EINFO_ENFILE __einfo ( PLATFORM_ENFILE, 0x29, 0, \
566 491
 			       "Too many open files in system" )
567 492
 
568 493
 /** No buffer space available */
569 494
 #define ENOBUFS __einfo_error ( EINFO_ENOBUFS )
570
-#define EINFO_ENOBUFS __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x2a, 0, \
495
+#define EINFO_ENOBUFS __einfo ( PLATFORM_ENOBUFS, 0x2a, 0, \
571 496
 				"No buffer space available" )
572 497
 
573 498
 /** No message is available on the STREAM head read queue */
574 499
 #define ENODATA __einfo_error ( EINFO_ENODATA )
575
-#define EINFO_ENODATA				 \
576
-	__einfo ( PXENV_STATUS_FAILURE, 0x2b, 0, \
577
-		  "No message is available on the STREAM head read queue" )
500
+#define EINFO_ENODATA __einfo ( PLATFORM_ENODATA, 0x2b, 0, \
501
+				"No message is available on the STREAM " \
502
+				"head read queue" )
578 503
 
579 504
 /** No such device */
580 505
 #define ENODEV __einfo_error ( EINFO_ENODEV )
581
-#define EINFO_ENODEV __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x2c, 0, \
506
+#define EINFO_ENODEV __einfo ( PLATFORM_ENODEV, 0x2c, 0, \
582 507
 			       "No such device" )
583 508
 
584 509
 /** No such file or directory */
585 510
 #define ENOENT __einfo_error ( EINFO_ENOENT )
586
-#define EINFO_ENOENT __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x2d, 0, \
511
+#define EINFO_ENOENT __einfo ( PLATFORM_ENOENT, 0x2d, 0, \
587 512
 			       "No such file or directory" )
588 513
 
589 514
 /** Exec format error */
590 515
 #define ENOEXEC __einfo_error ( EINFO_ENOEXEC )
591
-#define EINFO_ENOEXEC __einfo ( PXENV_STATUS_FAILURE, 0x2e, 0, \
516
+#define EINFO_ENOEXEC __einfo ( PLATFORM_ENOEXEC, 0x2e, 0, \
592 517
 				"Exec format error" )
593 518
 
594 519
 /** No locks available */
595 520
 #define ENOLCK __einfo_error ( EINFO_ENOLCK )
596
-#define EINFO_ENOLCK __einfo ( PXENV_STATUS_FAILURE, 0x2f, 0, \
521
+#define EINFO_ENOLCK __einfo ( PLATFORM_ENOLCK, 0x2f, 0, \
597 522
 			       "No locks available" )
598 523
 
599 524
 /** Link has been severed */
600 525
 #define ENOLINK __einfo_error ( EINFO_ENOLINK )
601
-#define EINFO_ENOLINK __einfo ( PXENV_STATUS_FAILURE, 0x30, 0, \
526
+#define EINFO_ENOLINK __einfo ( PLATFORM_ENOLINK, 0x30, 0, \
602 527
 				"Link has been severed" )
603 528
 
604 529
 /** Not enough space */
605 530
 #define ENOMEM __einfo_error ( EINFO_ENOMEM )
606
-#define EINFO_ENOMEM __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x31, 0, \
531
+#define EINFO_ENOMEM __einfo ( PLATFORM_ENOMEM, 0x31, 0, \
607 532
 			       "Not enough space" )
608 533
 
609 534
 /** No message of the desired type */
610 535
 #define ENOMSG __einfo_error ( EINFO_ENOMSG )
611
-#define EINFO_ENOMSG __einfo ( PXENV_STATUS_FAILURE, 0x32, 0, \
536
+#define EINFO_ENOMSG __einfo ( PLATFORM_ENOMSG, 0x32, 0, \
612 537
 			       "No message of the desired type" )
613 538
 
614 539
 /** Protocol not available */
615 540
 #define ENOPROTOOPT __einfo_error ( EINFO_ENOPROTOOPT )
616
-#define EINFO_ENOPROTOOPT __einfo ( PXENV_STATUS_UNSUPPORTED, 0x33, 0, \
541
+#define EINFO_ENOPROTOOPT __einfo ( PLATFORM_ENOPROTOOPT, 0x33, 0, \
617 542
 				    "Protocol not available" )
618 543
 
619 544
 /** No space left on device */
620 545
 #define ENOSPC __einfo_error ( EINFO_ENOSPC )
621
-#define EINFO_ENOSPC __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x34, 0, \
546
+#define EINFO_ENOSPC __einfo ( PLATFORM_ENOSPC, 0x34, 0, \
622 547
 			       "No space left on device" )
623 548
 
624 549
 /** No STREAM resources */
625 550
 #define ENOSR __einfo_error ( EINFO_ENOSR )
626
-#define EINFO_ENOSR __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x35, 0, \
551
+#define EINFO_ENOSR __einfo ( PLATFORM_ENOSR, 0x35, 0, \
627 552
 			      "No STREAM resources" )
628 553
 
629 554
 /** Not a STREAM */
630 555
 #define ENOSTR __einfo_error ( EINFO_ENOSTR )
631
-#define EINFO_ENOSTR __einfo ( PXENV_STATUS_FAILURE, 0x36, 0, \
556
+#define EINFO_ENOSTR __einfo ( PLATFORM_ENOSTR, 0x36, 0, \
632 557
 			       "Not a STREAM" )
633 558
 
634 559
 /** Function not implemented */
635 560
 #define ENOSYS __einfo_error ( EINFO_ENOSYS )
636
-#define EINFO_ENOSYS __einfo ( PXENV_STATUS_UNSUPPORTED, 0x37, 0, \
561
+#define EINFO_ENOSYS __einfo ( PLATFORM_ENOSYS, 0x37, 0, \
637 562
 			       "Function not implemented" )
638 563
 
639 564
 /** The socket is not connected */
640 565
 #define ENOTCONN __einfo_error ( EINFO_ENOTCONN )
641
-#define EINFO_ENOTCONN __einfo ( PXENV_STATUS_FAILURE, 0x38, 0, \
566
+#define EINFO_ENOTCONN __einfo ( PLATFORM_ENOTCONN, 0x38, 0, \
642 567
 				 "The socket is not connected" )
643 568
 
644 569
 /** Not a directory */
645 570
 #define ENOTDIR __einfo_error ( EINFO_ENOTDIR )
646
-#define EINFO_ENOTDIR __einfo ( PXENV_STATUS_FAILURE, 0x39, 0, \
571
+#define EINFO_ENOTDIR __einfo ( PLATFORM_ENOTDIR, 0x39, 0, \
647 572
 				"Not a directory" )
648 573
 
649 574
 /** Directory not empty */
650 575
 #define ENOTEMPTY __einfo_error ( EINFO_ENOTEMPTY )
651
-#define EINFO_ENOTEMPTY __einfo ( PXENV_STATUS_FAILURE, 0x3a, 0, \
576
+#define EINFO_ENOTEMPTY __einfo ( PLATFORM_ENOTEMPTY, 0x3a, 0, \
652 577
 				  "Directory not empty" )
653 578
 
654 579
 /** Not a socket */
655 580
 #define ENOTSOCK __einfo_error ( EINFO_ENOTSOCK )
656
-#define EINFO_ENOTSOCK __einfo ( PXENV_STATUS_FAILURE, 0x3b, 0, \
581
+#define EINFO_ENOTSOCK __einfo ( PLATFORM_ENOTSOCK, 0x3b, 0, \
657 582
 				 "Not a socket" )
658 583
 
659 584
 /** Operation not supported */
660 585
 #define ENOTSUP __einfo_error ( EINFO_ENOTSUP )
661
-#define EINFO_ENOTSUP __einfo ( PXENV_STATUS_UNSUPPORTED, 0x3c, 0, \
586
+#define EINFO_ENOTSUP __einfo ( PLATFORM_ENOTSUP, 0x3c, 0, \
662 587
 				"Operation not supported" )
663 588
 
664 589
 /** Inappropriate I/O control operation */
665 590
 #define ENOTTY __einfo_error ( EINFO_ENOTTY )
666
-#define EINFO_ENOTTY __einfo ( PXENV_STATUS_FAILURE, 0x3d, 0, \
591
+#define EINFO_ENOTTY __einfo ( PLATFORM_ENOTTY, 0x3d, 0, \
667 592
 			       "Inappropriate I/O control operation" )
668 593
 
669 594
 /** No such device or address */
670 595
 #define ENXIO __einfo_error ( EINFO_ENXIO )
671
-#define EINFO_ENXIO __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x3e, 0, \
596
+#define EINFO_ENXIO __einfo ( PLATFORM_ENXIO, 0x3e, 0, \
672 597
 			      "No such device or address" )
673 598
 
674 599
 /** Operation not supported on socket */
675 600
 #define EOPNOTSUPP __einfo_error ( EINFO_EOPNOTSUPP )
676
-#define EINFO_EOPNOTSUPP __einfo ( PXENV_STATUS_UNSUPPORTED, 0x3f, 0, \
601
+#define EINFO_EOPNOTSUPP __einfo ( PLATFORM_EOPNOTSUPP, 0x3f, 0, \
677 602
 				   "Operation not supported on socket" )
678 603
 
679 604
 /** Value too large to be stored in data type */
680 605
 #define EOVERFLOW __einfo_error ( EINFO_EOVERFLOW )
681
-#define EINFO_EOVERFLOW __einfo ( PXENV_STATUS_FAILURE, 0x40, 0, \
606
+#define EINFO_EOVERFLOW __einfo ( PLATFORM_EOVERFLOW, 0x40, 0, \
682 607
 				  "Value too large to be stored in data type" )
683 608
 
684 609
 /** Operation not permitted */
685 610
 #define EPERM __einfo_error ( EINFO_EPERM )
686
-#define EINFO_EPERM __einfo ( PXENV_STATUS_TFTP_ACCESS_VIOLATION, 0x41, 0, \
611
+#define EINFO_EPERM __einfo ( PLATFORM_EPERM, 0x41, 0, \
687 612
 			      "Operation not permitted" )
688 613
 
689 614
 /** Broken pipe */
690 615
 #define EPIPE __einfo_error ( EINFO_EPIPE )
691
-#define EINFO_EPIPE __einfo ( PXENV_STATUS_FAILURE, 0x42, 0, \
616
+#define EINFO_EPIPE __einfo ( PLATFORM_EPIPE, 0x42, 0, \
692 617
 			      "Broken pipe" )
693 618
 
694 619
 /** Protocol error */
695 620
 #define EPROTO __einfo_error ( EINFO_EPROTO )
696
-#define EINFO_EPROTO __einfo ( PXENV_STATUS_FAILURE, 0x43, 0, \
621
+#define EINFO_EPROTO __einfo ( PLATFORM_EPROTO, 0x43, 0, \
697 622
 			       "Protocol error" )
698 623
 
699 624
 /** Protocol not supported */
700 625
 #define EPROTONOSUPPORT __einfo_error ( EINFO_EPROTONOSUPPORT )
701
-#define EINFO_EPROTONOSUPPORT __einfo ( PXENV_STATUS_UNSUPPORTED, 0x44, 0, \
626
+#define EINFO_EPROTONOSUPPORT __einfo ( PLATFORM_EPROTONOSUPPORT, 0x44, 0, \
702 627
 					"Protocol not supported" )
703 628
 
704 629
 /** Protocol wrong type for socket */
705 630
 #define EPROTOTYPE __einfo_error ( EINFO_EPROTOTYPE )
706
-#define EINFO_EPROTOTYPE __einfo ( PXENV_STATUS_FAILURE, 0x45, 0, \
631
+#define EINFO_EPROTOTYPE __einfo ( PLATFORM_EPROTOTYPE, 0x45, 0, \
707 632
 				   "Protocol wrong type for socket" )
708 633
 
709 634
 /** Result too large */
710 635
 #define ERANGE __einfo_error ( EINFO_ERANGE )
711
-#define EINFO_ERANGE __einfo ( PXENV_STATUS_FAILURE, 0x46, 0, \
636
+#define EINFO_ERANGE __einfo ( PLATFORM_ERANGE, 0x46, 0, \
712 637
 			       "Result too large" )
713 638
 
714 639
 /** Read-only file system */
715 640
 #define EROFS __einfo_error ( EINFO_EROFS )
716
-#define EINFO_EROFS __einfo ( PXENV_STATUS_FAILURE, 0x47, 0, \
641
+#define EINFO_EROFS __einfo ( PLATFORM_EROFS, 0x47, 0, \
717 642
 			      "Read-only file system" )
718 643
 
719 644
 /** Invalid seek */
720 645
 #define ESPIPE __einfo_error ( EINFO_ESPIPE )
721
-#define EINFO_ESPIPE __einfo ( PXENV_STATUS_FAILURE, 0x48, 0, \
646
+#define EINFO_ESPIPE __einfo ( PLATFORM_ESPIPE, 0x48, 0, \
722 647
 			       "Invalid seek" )
723 648
 
724 649
 /** No such process */
725 650
 #define ESRCH __einfo_error ( EINFO_ESRCH )
726
-#define EINFO_ESRCH __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x49, 0, \
651
+#define EINFO_ESRCH __einfo ( PLATFORM_ESRCH, 0x49, 0, \
727 652
 			      "No such process" )
728 653
 
729 654
 /** Stale file handle */
730 655
 #define ESTALE __einfo_error ( EINFO_ESTALE )
731
-#define EINFO_ESTALE __einfo ( PXENV_STATUS_FAILURE, 0x4a, 0, \
656
+#define EINFO_ESTALE __einfo ( PLATFORM_ESTALE, 0x4a, 0, \
732 657
 			       "Stale file handle" )
733 658
 
734 659
 /** Timer expired */
735 660
 #define ETIME __einfo_error ( EINFO_ETIME )
736
-#define EINFO_ETIME __einfo ( PXENV_STATUS_FAILURE, 0x4b, 0, \
661
+#define EINFO_ETIME __einfo ( PLATFORM_ETIME, 0x4b, 0, \
737 662
 			      "Timer expired" )
738 663
 
739 664
 /** Connection timed out */
740 665
 #define ETIMEDOUT __einfo_error ( EINFO_ETIMEDOUT )
741
-#define EINFO_ETIMEDOUT __einfo ( PXENV_STATUS_TFTP_READ_TIMEOUT, 0x4c, 0, \
666
+#define EINFO_ETIMEDOUT __einfo ( PLATFORM_ETIMEDOUT, 0x4c, 0, \
742 667
 				  "Connection timed out" )
743 668
 
744 669
 /** Text file busy */
745 670
 #define ETXTBSY __einfo_error ( EINFO_ETXTBSY )
746
-#define EINFO_ETXTBSY __einfo ( PXENV_STATUS_FAILURE, 0x4d, 0, \
671
+#define EINFO_ETXTBSY __einfo ( PLATFORM_ETXTBSY, 0x4d, 0, \
747 672
 				"Text file busy" )
748 673
 
749 674
 /** Operation would block */
750 675
 #define EWOULDBLOCK __einfo_error ( EINFO_EWOULDBLOCK )
751
-#define EINFO_EWOULDBLOCK __einfo ( PXENV_STATUS_TFTP_OPEN, 0x4e, 0, \
676
+#define EINFO_EWOULDBLOCK __einfo ( PLATFORM_EWOULDBLOCK, 0x4e, 0, \
752 677
 				    "Operation would block" )
753 678
 
754 679
 /** Improper link */
755 680
 #define EXDEV __einfo_error ( EINFO_EXDEV )
756
-#define EINFO_EXDEV __einfo ( PXENV_STATUS_FAILURE, 0x4f, 0, \
681
+#define EINFO_EXDEV __einfo ( PLATFORM_EXDEV, 0x4f, 0, \
757 682
 			      "Improper link" )
758 683
 
759 684
 /** @} */
760 685
 
686
+/** Platform-generated base error */
687
+#define EINFO_EPLATFORM __einfo ( 0, 0x7f, 0, "Platform-generated error" )
688
+
761 689
 extern int errno;
762 690
 
763 691
 #endif /* ERRNO_H */

+ 129
- 0
src/include/ipxe/errno/efi.h View File

@@ -0,0 +1,129 @@
1
+#ifndef _IPXE_ERRNO_EFI_H
2
+#define _IPXE_ERRNO_EFI_H
3
+
4
+/**
5
+ * @file
6
+ *
7
+ * EFI platform error codes
8
+ *
9
+ * We derive our platform error codes from the possible values for
10
+ * EFI_STATUS defined in the UEFI specification.
11
+ *
12
+ * EFI_STATUS codes are 32-bit values consisting of a top bit which is
13
+ * set for errors and clear for warnings, and a mildly undefined
14
+ * code of low bits indicating the precise error/warning code.
15
+ * Errors and warnings have completely separate namespaces.
16
+ *
17
+ * We assume that no EFI_STATUS code will ever be defined which uses
18
+ * more than bits 0-6 of the low bits.  We then choose to encode our
19
+ * platform-specific error by mapping bit 31 of the EFI_STATUS to bit
20
+ * 7 of the platform-specific error code, and preserving bits 0-6
21
+ * as-is.
22
+ */
23
+
24
+FILE_LICENCE ( GPL2_OR_LATER );
25
+
26
+#include <ipxe/efi/efi.h>
27
+#include <ipxe/efi/Uefi/UefiBaseType.h>
28
+
29
+/**
30
+ * Convert platform error code to platform component of iPXE error code
31
+ *
32
+ * @v platform		Platform error code
33
+ * @ret errno		Platform component of iPXE error code
34
+ */
35
+#define PLATFORM_TO_ERRNO( platform ) \
36
+	( ( (platform) | ( (platform) >> 24 ) ) & 0xff )
37
+
38
+/**
39
+ * Convert iPXE error code to platform error code
40
+ *
41
+ * @v errno		iPXE error code
42
+ * @ret platform	Platform error code
43
+ */
44
+#define ERRNO_TO_PLATFORM( errno ) \
45
+	( ( ( (errno) << 24 ) | (errno) ) & 0x8000007f )
46
+
47
+/* Platform-specific error codes */
48
+#define PLATFORM_ENOERR		EFI_SUCCESS
49
+#define PLATFORM_E2BIG		EFI_BUFFER_TOO_SMALL
50
+#define PLATFORM_EACCES		EFI_ACCESS_DENIED
51
+#define PLATFORM_EADDRINUSE	EFI_ALREADY_STARTED
52
+#define PLATFORM_EADDRNOTAVAIL	EFI_NOT_READY
53
+#define PLATFORM_EAFNOSUPPORT	EFI_UNSUPPORTED
54
+#define PLATFORM_EAGAIN		EFI_NOT_READY
55
+#define PLATFORM_EALREADY	EFI_ALREADY_STARTED
56
+#define PLATFORM_EBADF		EFI_INVALID_PARAMETER
57
+#define PLATFORM_EBADMSG	EFI_PROTOCOL_ERROR
58
+#define PLATFORM_EBUSY		EFI_NO_RESPONSE
59
+#define PLATFORM_ECANCELED	EFI_ABORTED
60
+#define PLATFORM_ECHILD		EFI_NOT_FOUND
61
+#define PLATFORM_ECONNABORTED	EFI_ABORTED
62
+#define PLATFORM_ECONNREFUSED	EFI_NO_RESPONSE
63
+#define PLATFORM_ECONNRESET	EFI_ABORTED
64
+#define PLATFORM_EDEADLK	EFI_NOT_READY
65
+#define PLATFORM_EDESTADDRREQ	EFI_PROTOCOL_ERROR
66
+#define PLATFORM_EDOM		EFI_INVALID_PARAMETER
67
+#define PLATFORM_EDQUOT		EFI_VOLUME_FULL
68
+#define PLATFORM_EEXIST		EFI_WRITE_PROTECTED
69
+#define PLATFORM_EFAULT		EFI_INVALID_PARAMETER
70
+#define PLATFORM_EFBIG		EFI_END_OF_MEDIA
71
+#define PLATFORM_EHOSTUNREACH	EFI_NO_RESPONSE
72
+#define PLATFORM_EIDRM		EFI_INVALID_PARAMETER
73
+#define PLATFORM_EILSEQ		EFI_INVALID_PARAMETER
74
+#define PLATFORM_EINPROGRESS	EFI_ALREADY_STARTED
75
+#define PLATFORM_EINTR		EFI_NOT_READY
76
+#define PLATFORM_EINVAL		EFI_INVALID_PARAMETER
77
+#define PLATFORM_EIO		EFI_PROTOCOL_ERROR
78
+#define PLATFORM_EISCONN	EFI_ALREADY_STARTED
79
+#define PLATFORM_EISDIR		EFI_PROTOCOL_ERROR
80
+#define PLATFORM_ELOOP		EFI_VOLUME_CORRUPTED
81
+#define PLATFORM_EMFILE		EFI_OUT_OF_RESOURCES
82
+#define PLATFORM_EMLINK		EFI_OUT_OF_RESOURCES
83
+#define PLATFORM_EMSGSIZE	EFI_BAD_BUFFER_SIZE
84
+#define PLATFORM_EMULTIHOP	EFI_INVALID_PARAMETER
85
+#define PLATFORM_ENAMETOOLONG	EFI_INVALID_PARAMETER
86
+#define PLATFORM_ENETDOWN	EFI_NO_RESPONSE
87
+#define PLATFORM_ENETRESET	EFI_ABORTED
88
+#define PLATFORM_ENETUNREACH	EFI_NO_RESPONSE
89
+#define PLATFORM_ENFILE		EFI_OUT_OF_RESOURCES
90
+#define PLATFORM_ENOBUFS	EFI_OUT_OF_RESOURCES
91
+#define PLATFORM_ENODATA	EFI_NO_RESPONSE
92
+#define PLATFORM_ENODEV		EFI_DEVICE_ERROR
93
+#define PLATFORM_ENOENT		EFI_NOT_FOUND
94
+#define PLATFORM_ENOEXEC	EFI_LOAD_ERROR
95
+#define PLATFORM_ENOLCK		EFI_OUT_OF_RESOURCES
96
+#define PLATFORM_ENOLINK	EFI_OUT_OF_RESOURCES
97
+#define PLATFORM_ENOMEM		EFI_OUT_OF_RESOURCES
98
+#define PLATFORM_ENOMSG		EFI_PROTOCOL_ERROR
99
+#define PLATFORM_ENOPROTOOPT	EFI_UNSUPPORTED
100
+#define PLATFORM_ENOSPC		EFI_VOLUME_FULL
101
+#define PLATFORM_ENOSR		EFI_OUT_OF_RESOURCES
102
+#define PLATFORM_ENOSTR		EFI_PROTOCOL_ERROR
103
+#define PLATFORM_ENOSYS		EFI_UNSUPPORTED
104
+#define PLATFORM_ENOTCONN	EFI_NOT_STARTED
105
+#define PLATFORM_ENOTDIR	EFI_VOLUME_CORRUPTED
106
+#define PLATFORM_ENOTEMPTY	EFI_VOLUME_CORRUPTED
107
+#define PLATFORM_ENOTSOCK	EFI_INVALID_PARAMETER
108
+#define PLATFORM_ENOTSUP	EFI_UNSUPPORTED
109
+#define PLATFORM_ENOTTY		EFI_UNSUPPORTED
110
+#define PLATFORM_ENXIO		EFI_NOT_FOUND
111
+#define PLATFORM_EOPNOTSUPP	EFI_UNSUPPORTED
112
+#define PLATFORM_EOVERFLOW	EFI_BUFFER_TOO_SMALL
113
+#define PLATFORM_EPERM		EFI_ACCESS_DENIED
114
+#define PLATFORM_EPIPE		EFI_ABORTED
115
+#define PLATFORM_EPROTO		EFI_PROTOCOL_ERROR
116
+#define PLATFORM_EPROTONOSUPPORT EFI_UNSUPPORTED
117
+#define PLATFORM_EPROTOTYPE	EFI_INVALID_PARAMETER
118
+#define PLATFORM_ERANGE		EFI_BUFFER_TOO_SMALL
119
+#define PLATFORM_EROFS		EFI_WRITE_PROTECTED
120
+#define PLATFORM_ESPIPE		EFI_END_OF_FILE
121
+#define PLATFORM_ESRCH		EFI_NOT_STARTED
122
+#define PLATFORM_ESTALE		EFI_PROTOCOL_ERROR
123
+#define PLATFORM_ETIME		EFI_TIMEOUT
124
+#define PLATFORM_ETIMEDOUT	EFI_TIMEOUT
125
+#define PLATFORM_ETXTBSY	EFI_MEDIA_CHANGED
126
+#define PLATFORM_EWOULDBLOCK	EFI_NOT_READY
127
+#define PLATFORM_EXDEV		EFI_VOLUME_CORRUPTED
128
+
129
+#endif /* _IPXE_ERRNO_EFI_H */

+ 113
- 0
src/include/ipxe/errno/linux.h View File

@@ -0,0 +1,113 @@
1
+#ifndef _IPXE_ERRNO_LINUX_H
2
+#define _IPXE_ERRNO_LINUX_H
3
+
4
+/**
5
+ * @file
6
+ *
7
+ * Linux platform error codes
8
+ *
9
+ * Linux error codes all fit inside 8 bits, so we just use them
10
+ * directly as our platform error codes.
11
+ */
12
+
13
+FILE_LICENCE ( GPL2_OR_LATER );
14
+
15
+/**
16
+ * Convert platform error code to platform component of iPXE error code
17
+ *
18
+ * @v platform		Platform error code
19
+ * @ret errno		Platform component of iPXE error code
20
+ */
21
+#define PLATFORM_TO_ERRNO( platform ) ( (platform) & 0xff )
22
+
23
+/**
24
+ * Convert iPXE error code to platform error code
25
+ *
26
+ * @v errno		iPXE error code
27
+ * @ret platform	Platform error code
28
+ */
29
+#define ERRNO_TO_PLATFORM( errno ) ( (errno) & 0xff )
30
+
31
+/* Platform-specific error codes */
32
+#define PLATFORM_ENOERR 0
33
+#define PLATFORM_E2BIG 7
34
+#define PLATFORM_EACCES 13
35
+#define PLATFORM_EADDRINUSE 98
36
+#define PLATFORM_EADDRNOTAVAIL 99
37
+#define PLATFORM_EAFNOSUPPORT 97
38
+#define PLATFORM_EAGAIN 11
39
+#define PLATFORM_EALREADY 114
40
+#define PLATFORM_EBADF 9
41
+#define PLATFORM_EBADMSG 74
42
+#define PLATFORM_EBUSY 16
43
+#define PLATFORM_ECANCELED 125
44
+#define PLATFORM_ECHILD 10
45
+#define PLATFORM_ECONNABORTED 103
46
+#define PLATFORM_ECONNREFUSED 111
47
+#define PLATFORM_ECONNRESET 104
48
+#define PLATFORM_EDEADLK 35
49
+#define PLATFORM_EDESTADDRREQ 89
50
+#define PLATFORM_EDOM 33
51
+#define PLATFORM_EDQUOT 122
52
+#define PLATFORM_EEXIST 17
53
+#define PLATFORM_EFAULT 14
54
+#define PLATFORM_EFBIG 27
55
+#define PLATFORM_EHOSTUNREACH 113
56
+#define PLATFORM_EIDRM 43
57
+#define PLATFORM_EILSEQ 84
58
+#define PLATFORM_EINPROGRESS 115
59
+#define PLATFORM_EINTR 4
60
+#define PLATFORM_EINVAL 22
61
+#define PLATFORM_EIO 5
62
+#define PLATFORM_EISCONN 106
63
+#define PLATFORM_EISDIR 21
64
+#define PLATFORM_ELOOP 40
65
+#define PLATFORM_EMFILE 24
66
+#define PLATFORM_EMLINK 31
67
+#define PLATFORM_EMSGSIZE 90
68
+#define PLATFORM_EMULTIHOP 72
69
+#define PLATFORM_ENAMETOOLONG 36
70
+#define PLATFORM_ENETDOWN 100
71
+#define PLATFORM_ENETRESET 102
72
+#define PLATFORM_ENETUNREACH 101
73
+#define PLATFORM_ENFILE 23
74
+#define PLATFORM_ENOBUFS 105
75
+#define PLATFORM_ENODATA 61
76
+#define PLATFORM_ENODEV 19
77
+#define PLATFORM_ENOENT 2
78
+#define PLATFORM_ENOEXEC 8
79
+#define PLATFORM_ENOLCK 37
80
+#define PLATFORM_ENOLINK 67
81
+#define PLATFORM_ENOMEM 12
82
+#define PLATFORM_ENOMSG 42
83
+#define PLATFORM_ENOPROTOOPT 92
84
+#define PLATFORM_ENOSPC 28
85
+#define PLATFORM_ENOSR 63
86
+#define PLATFORM_ENOSTR 60
87
+#define PLATFORM_ENOSYS 38
88
+#define PLATFORM_ENOTCONN 107
89
+#define PLATFORM_ENOTDIR 20
90
+#define PLATFORM_ENOTEMPTY 39
91
+#define PLATFORM_ENOTSOCK 88
92
+#define PLATFORM_ENOTSUP PLATFORM_EOPNOTSUPP
93
+#define PLATFORM_ENOTTY 25
94
+#define PLATFORM_ENXIO 6
95
+#define PLATFORM_EOPNOTSUPP 95
96
+#define PLATFORM_EOVERFLOW 75
97
+#define PLATFORM_EPERM 1
98
+#define PLATFORM_EPIPE 32
99
+#define PLATFORM_EPROTO 71
100
+#define PLATFORM_EPROTONOSUPPORT 93
101
+#define PLATFORM_EPROTOTYPE 91
102
+#define PLATFORM_ERANGE 34
103
+#define PLATFORM_EROFS 30
104
+#define PLATFORM_ESPIPE 29
105
+#define PLATFORM_ESRCH 3
106
+#define PLATFORM_ESTALE 116
107
+#define PLATFORM_ETIME 62
108
+#define PLATFORM_ETIMEDOUT 110
109
+#define PLATFORM_ETXTBSY 26
110
+#define PLATFORM_EWOULDBLOCK PLATFORM_EAGAIN
111
+#define PLATFORM_EXDEV 18
112
+
113
+#endif /* _IPXE_ERRNO_LINUX_H */

+ 5
- 0
src/util/einfo.c View File

@@ -38,10 +38,15 @@ struct options {
38 38
 
39 39
 /** Error usage information */
40 40
 struct einfo {
41
+	/** Size of error information record */
41 42
 	uint32_t size;
43
+	/** Error number */
42 44
 	uint32_t error;
45
+	/** Offset to error description (NUL-terminated) */
43 46
 	uint32_t desc;
47
+	/** Offset to file name (NUL-terminated) */
44 48
 	uint32_t file;
49
+	/** Line number */
45 50
 	uint32_t line;
46 51
 } __attribute__ (( packed ));
47 52
 

Loading…
Cancel
Save