Explorar el Código

Gave up on adding POSIX errno's as required, and just added (almost) all

of them in one go.

EBADIMG has been replaced by ENOEXEC, and EIMGRET by ECANCELED.
tags/v0.9.3
Michael Brown hace 18 años
padre
commit
d8e99bf28f
Se han modificado 2 ficheros con 67 adiciones y 27 borrados
  1. 15
    15
      src/arch/i386/image/nbi.c
  2. 52
    12
      src/include/errno.h

+ 15
- 15
src/arch/i386/image/nbi.c Ver fichero

@@ -95,7 +95,7 @@ static struct ebinfo loaderinfo = {
95 95
  * @v context		NBI image context
96 96
  * @ret	True		Image is a valid NBI image
97 97
  * @ret	False		Image is not a valid NBI image
98
- * @err	EBADIMG		Image is not a valid NBI image
98
+ * @err	ENOEXEC		Image is not a valid NBI image
99 99
  * 
100 100
  * "context" is filled in with a context pointer suitable for passing to
101 101
  * nbi_load() and nbi_boot().
@@ -106,14 +106,14 @@ static int nbi_probe ( physaddr_t start, off_t len, void **context ) {
106 106
 
107 107
 	if ( (unsigned)len < sizeof ( imgheader ) ) {
108 108
 		DBG ( "NBI image too small\n" );
109
-		errno = EBADIMG;
109
+		errno = ENOEXEC;
110 110
 		return 0;
111 111
 	}
112 112
 
113 113
 	copy_from_phys ( &imgheader, start, sizeof ( imgheader ) );
114 114
 
115 115
 	if ( imgheader.magic != NBI_MAGIC ) {
116
-		errno = EBADIMG;
116
+		errno = ENOEXEC;
117 117
 		return 0;
118 118
 	}
119 119
 
@@ -168,7 +168,7 @@ static int nbi_load_segment ( physaddr_t dest, off_t imglen,
168 168
  * @v process		Function to call for each segment
169 169
  * @ret True		All segments were processed successfully
170 170
  * @ret False		An error occurred processing a segment
171
- * @err EBADIMG		Image is not a valid NBI image
171
+ * @err ENOEXEC		Image is not a valid NBI image
172 172
  * @err other		As returned by the "process" function
173 173
  *
174 174
  */
@@ -200,7 +200,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
200 200
 		if ( sh.length == 0 ) {
201 201
 			/* Avoid infinite loop? */
202 202
 			DBG ( "NBI invalid segheader length 0\n" );
203
-			errno = EBADIMG;
203
+			errno = ENOEXEC;
204 204
 			return 0;
205 205
 		}
206 206
 		
@@ -240,7 +240,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
240 240
 		sh_off += NBI_LENGTH ( sh.length );
241 241
 		if ( sh_off >= NBI_HEADER_LENGTH ) {
242 242
 			DBG ( "NBI header overflow\n" );
243
-			errno = EBADIMG;
243
+			errno = ENOEXEC;
244 244
 			return 0;
245 245
 		}
246 246
 
@@ -249,7 +249,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
249 249
 	if ( offset != len ) {
250 250
 		DBG ( "NBI length mismatch (file %d, metadata %d)\n",
251 251
 		      len, offset );
252
-		errno = EBADIMG;
252
+		errno = ENOEXEC;
253 253
 		return 0;
254 254
 	}
255 255
 
@@ -264,7 +264,7 @@ static int nbi_process_segments ( physaddr_t start, off_t len,
264 264
  * @v context		NBI context (as returned by nbi_probe())
265 265
  * @ret True		Image loaded into memory
266 266
  * @ret False		Image not loaded into memory
267
- * @err EBADIMG		Image is not a valid NBI image
267
+ * @err ENOEXEC		Image is not a valid NBI image
268 268
  * @err other		As returned by nbi_process_segments()
269 269
  * @err other		As returned by nbi_prepare_segment()
270 270
  * @err other		As returned by nbi_load_segment()
@@ -275,7 +275,7 @@ static int nbi_load ( physaddr_t start, off_t len, void *context ) {
275 275
 
276 276
 	/* If we don't have enough data give up */
277 277
 	if ( len < NBI_HEADER_LENGTH ) {
278
-		errno = EBADIMG;
278
+		errno = ENOEXEC;
279 279
 		return 0;
280 280
 	}
281 281
 	
@@ -305,7 +305,7 @@ static int nbi_load ( physaddr_t start, off_t len, void *context ) {
305 305
  * @v imgheader		Image header information
306 306
  * @ret Never		NBI program booted successfully
307 307
  * @ret False		NBI program returned
308
- * @err EIMGRET		NBI program returned
308
+ * @err ECANCELED	NBI program returned
309 309
  *
310 310
  */
311 311
 static int nbi_boot16 ( struct imgheader *imgheader ) {
@@ -340,7 +340,7 @@ static int nbi_boot16 ( struct imgheader *imgheader ) {
340 340
 		    CLOBBER ( "eax", "ecx", "edx", "ebp" ) );
341 341
 	BASEMEM_PARAMETER_DONE ( bootp_data );
342 342
 	
343
-	errno = EIMGRET;
343
+	errno = ECANCELED;
344 344
 	return 0;
345 345
 }
346 346
 
@@ -350,11 +350,11 @@ static int nbi_boot16 ( struct imgheader *imgheader ) {
350 350
  * @v imgheader		Image header information
351 351
  * @ret False		NBI program should not have returned
352 352
  * @ret other		As returned by NBI program
353
- * @err EIMGRET		NBI program should not have returned
353
+ * @err ECANCELED	NBI program should not have returned
354 354
  *
355 355
  * To distinguish between the case of an NBI program returning false,
356 356
  * and an NBI program that should not have returned, check errno.
357
- * errno will be set to EIMGRET only if the NBI program should not
357
+ * errno will be set to ECANCELED only if the NBI program should not
358 358
  * have returned.
359 359
  *
360 360
  */
@@ -374,7 +374,7 @@ static int nbi_boot32 ( struct imgheader *imgheader ) {
374 374
 	printf ( "Secondary program returned %d\n", rc );
375 375
 	if ( ! NBI_PROGRAM_RETURNS ( imgheader->flags ) ) {
376 376
 		/* We shouldn't have returned */
377
-		errno = EIMGRET;
377
+		errno = ECANCELED;
378 378
 		rc = 0;
379 379
 	}
380 380
 
@@ -388,7 +388,7 @@ static int nbi_boot32 ( struct imgheader *imgheader ) {
388 388
  * @ret Never		NBI program booted successfully
389 389
  * @ret False		NBI program should not have returned
390 390
  * @ret other		As returned by NBI program
391
- * @err EIMGRET		NBI program should not have returned
391
+ * @err ECANCELED	NBI program should not have returned
392 392
  *
393 393
  * See also nbi_boot16() and nbi_boot32().
394 394
  *

+ 52
- 12
src/include/errno.h Ver fichero

@@ -111,21 +111,61 @@
111 111
 
112 112
 /*
113 113
  * The range 0xd0 to 0xff is defined as "Vendor errors" by the PXE
114
- * spec.  We place all our Etherboot-specific errors in this range.
115
- * We also define some generic errors as aliases to the PXE errors.
116
- *
114
+ * spec.  We use this space for POSIX-like errors that aren't
115
+ * accounted for by the (somewhat implementation-specific) PXE error
116
+ * list.
117 117
  */
118 118
 
119
-#define ENOERR		0x00
119
+#define ENOERR		0x00	/**< Operation completed successfully */
120
+#define EACCES		0xd0	/**< Permission denied */
121
+#define EADDRNOTAVAIL	0xd1	/**< Cannot assign requested address */
122
+#define EADDRINUSE	EADDRNOTAVAIL /**< Address already in use */
123
+#define EAFNOSUPPORT	0xd2	/**< Address family not supported by protocol*/
124
+#define EAGAIN		0xd3	/**< Resource temporarily unavailable */
125
+#define EBUSY		0xd4	/**< Device or resource busy */
126
+/** Operation cancelled */
127
+#define ECANCELED	PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE
128
+#define ECONNABORTED	0xd5	/**< Software caused connection abort */
129
+#define ECONNREFUSED	0xd6	/**< Connection refused */
130
+#define ECONNRESET	0xd7	/**< Connection reset by peer */
131
+#define EDESTADDRREQ	0xd8	/**< Destination address required */
132
+#define EFBIG		0xd9	/**< File too large */
133
+#define EHOSTUNREACH	0xda	/**< No route to host */
134
+#define EINPROGRESS	0xdb	/**< Operation now in progress */
135
+#define EINTR		0xdc	/**< Interrupted system call */
136
+#define EINVAL		0xdd	/**< Invalid argument */
137
+#define EIO		0xde	/**< Input/output error */
138
+#define EISCONN		0xdf	/**< Transport endpoint is already connected */
139
+#define EMFILE		0xe0	/**< Too many open files */
140
+#define EMSGSIZE	0xe1	/**< Message too long */
141
+#define ENAMETOOLONG	0xe2	/**< File name too long */
142
+#define ENETDOWN	0xe3	/**< Network is down */
143
+#define ENETRESET	0xe4	/**< Network dropped connection on reset */
144
+#define ENETUNREACH	0xe5	/**< Network is unreachable */
145
+#define ENFILE		EMFILE	/**< Too many open files in system */
146
+/** Cannot allocate memory */
120 147
 #define ENOMEM		PXENV_STATUS_OUT_OF_RESOURCES
121
-#define	EBADIMG		0xd0
122
-#define EIMGRET		0xd1
123
-#define ETIMEDOUT	0xd2
124
-#define EINVAL		0xd3
125
-#define ENOENT		0xd4
126
-#define EAFNOSUPPORT	0xd5
127
-#define EAGAIN		0xd6
128
-#define EIO		0xd7
148
+#define ENOBUFS		ENOMEM	/**< No buffer space available */
149
+#define ENODATA		0xe6	/**< No data available */
150
+#define ENODEV		0xe7	/**< No such device */
151
+#define ENOENT		0xe8	/**< No such file or directory */
152
+#define ENOEXEC		0xe9	/**< Exec format error */
153
+#define ENOMSG		ENODATA	/**< No message of the desired type */
154
+#define ENOSR		0xea	/**< No stream resources */
155
+#define ENOSTR		0xeb	/**< Not a stream */
156
+#define ENOSYS		0xec	/**< Function not implemented */
157
+#define ENOTCONN	0xed	/**< Transport endpoint is not connected */
158
+#define ENOTSOCK	0xee	/**< Socket operation on non-socket */
159
+#define EOPNOTSUPP	0xef	/**< Operation not supported */
160
+#define ENOTSUP		EOPNOTSUPP /**< Not supported */
161
+#define ENOTTY		0xf0	/**< Inappropriate ioctl for device */
162
+#define ENXIO		ENODEV	/**< No such device or address */
163
+#define EPERM		EACCES	/**< Operation not permitted */
164
+#define EPROTO		0xf1	/**< Protocol error */
165
+#define EPROTONOSUPPORT	0xf2	/**< Protocol not supported */
166
+#define EPROTOTYPE	0xf3	/**< Protocol wrong type for socket */
167
+#define ETIMEDOUT	0xf4	/**< Connection timed out */
168
+#define EWOULDBLOCK	EAGAIN	/**< Resource temporarily unavailable */
129 169
 
130 170
 /* Data structures and declarations */
131 171
 

Loading…
Cancelar
Guardar