瀏覽代碼

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 19 年之前
父節點
當前提交
d8e99bf28f
共有 2 個檔案被更改,包括 67 行新增27 行删除
  1. 15
    15
      src/arch/i386/image/nbi.c
  2. 52
    12
      src/include/errno.h

+ 15
- 15
src/arch/i386/image/nbi.c 查看文件

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

+ 52
- 12
src/include/errno.h 查看文件

111
 
111
 
112
 /*
112
 /*
113
  * The range 0xd0 to 0xff is defined as "Vendor errors" by the PXE
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
 #define ENOMEM		PXENV_STATUS_OUT_OF_RESOURCES
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
 /* Data structures and declarations */
170
 /* Data structures and declarations */
131
 
171
 

Loading…
取消
儲存