Преглед на файлове

[efi] Add sample platform-generated error disambiguations

Add disambiguated errors for LoadImage() and StartImage(), primarily
to demonstrate how to use __einfo_uniqify() and __einfo_platformify()
in the context of EFI platform errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown преди 11 години
родител
ревизия
9cb60c8a21
променени са 1 файла, в които са добавени 19 реда и са изтрити 3 реда
  1. 19
    3
      src/image/efi_image.c

+ 19
- 3
src/image/efi_image.c Целия файл

@@ -35,6 +35,22 @@ FILE_LICENCE ( GPL2_OR_LATER );
35 35
 
36 36
 FEATURE ( FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1 );
37 37
 
38
+/* Disambiguate the various error causes */
39
+#define EINFO_EEFI_LOAD							\
40
+	__einfo_uniqify ( EINFO_EPLATFORM, 0x01,			\
41
+			  "Could not load image" )
42
+#define EINFO_EEFI_LOAD_PROHIBITED					\
43
+	__einfo_platformify ( EINFO_EEFI_LOAD, EFI_SECURITY_VIOLATION,	\
44
+			      "Image prohibited by security policy" )
45
+#define EEFI_LOAD_PROHIBITED						\
46
+	__einfo_error ( EINFO_EEFI_LOAD_PROHIBITED )
47
+#define EEFI_LOAD( efirc ) EPLATFORM ( EINFO_EEFI_LOAD, efirc,		\
48
+				       EEFI_LOAD_PROHIBITED )
49
+#define EINFO_EEFI_START						\
50
+	__einfo_uniqify ( EINFO_EPLATFORM, 0x02,			\
51
+			  "Could not start image" )
52
+#define EEFI_START( efirc ) EPLATFORM ( EINFO_EEFI_START, efirc )
53
+
38 54
 /** EFI loaded image protocol GUID */
39 55
 static EFI_GUID efi_loaded_image_protocol_guid =
40 56
 	EFI_LOADED_IMAGE_PROTOCOL_GUID;
@@ -176,7 +192,7 @@ static int efi_image_exec ( struct image *image ) {
176 192
 				       user_to_virt ( image->data, 0 ),
177 193
 				       image->len, &handle ) ) != 0 ) {
178 194
 		/* Not an EFI image */
179
-		rc = -EEFI ( efirc );
195
+		rc = -EEFI_LOAD ( efirc );
180 196
 		DBGC ( image, "EFIIMAGE %p could not load: %s\n",
181 197
 		       image, strerror ( rc ) );
182 198
 		goto err_load_image;
@@ -205,7 +221,7 @@ static int efi_image_exec ( struct image *image ) {
205 221
 
206 222
 	/* Start the image */
207 223
 	if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
208
-		rc = -EEFI ( efirc );
224
+		rc = -EEFI_START ( efirc );
209 225
 		DBGC ( image, "EFIIMAGE %p returned with status %s\n",
210 226
 		       image, strerror ( rc ) );
211 227
 		goto err_start_image;
@@ -254,7 +270,7 @@ static int efi_image_probe ( struct image *image ) {
254 270
 				       user_to_virt ( image->data, 0 ),
255 271
 				       image->len, &handle ) ) != 0 ) {
256 272
 		/* Not an EFI image */
257
-		rc = -EEFI ( efirc );
273
+		rc = -EEFI_LOAD ( efirc );
258 274
 		DBGC ( image, "EFIIMAGE %p could not load: %s\n",
259 275
 		       image, strerror ( rc ) );
260 276
 		return rc;

Loading…
Отказ
Запис