From 78460a05e4504c861708f19812f8cb1710a99edc Mon Sep 17 00:00:00 2001 From: Juan Castillo Date: Thu, 1 Oct 2015 18:37:40 +0100 Subject: [PATCH] Use standard errno definitions in load_auth_image() This patch replaces custom definitions used as return values for the load_auth_image() function with standard error codes defined in errno.h. The custom definitions have been removed. It also replaces the usage of IO framework error custom definitions, which have been deprecated. Standard errno definitions are used instead. Change-Id: I1228477346d3876151c05b470d9669c37fd231be --- bl2/bl2_main.c | 3 ++- common/bl_common.c | 20 ++++++++++---------- include/common/bl_common.h | 9 --------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c index 71940a62c..404744b78 100644 --- a/bl2/bl2_main.c +++ b/bl2/bl2_main.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -239,7 +240,7 @@ void bl2_main(void) e = load_bl32(bl2_to_bl31_params); if (e) { - if (e == LOAD_AUTH_ERR) { + if (e == -EAUTH) { ERROR("Failed to authenticate BL3-2\n"); panic(); } else { diff --git a/common/bl_common.c b/common/bl_common.c index 73c615e5e..91a0ae8c4 100644 --- a/common/bl_common.c +++ b/common/bl_common.c @@ -207,7 +207,7 @@ int load_image(meminfo_t *mem_layout, uintptr_t image_spec; size_t image_size; size_t bytes_read; - int io_result = IO_FAIL; + int io_result; assert(mem_layout != NULL); assert(image_data != NULL); @@ -215,7 +215,7 @@ int load_image(meminfo_t *mem_layout, /* Obtain a reference to the image by querying the platform layer */ io_result = plat_get_image_source(image_id, &dev_handle, &image_spec); - if (io_result != IO_SUCCESS) { + if (io_result != 0) { WARN("Failed to obtain reference to image id=%u (%i)\n", image_id, io_result); return io_result; @@ -223,7 +223,7 @@ int load_image(meminfo_t *mem_layout, /* Attempt to access the image */ io_result = io_open(dev_handle, image_spec, &image_handle); - if (io_result != IO_SUCCESS) { + if (io_result != 0) { WARN("Failed to access image id=%u (%i)\n", image_id, io_result); return io_result; @@ -233,7 +233,7 @@ int load_image(meminfo_t *mem_layout, /* Find the size of the image */ io_result = io_size(image_handle, &image_size); - if ((io_result != IO_SUCCESS) || (image_size == 0)) { + if ((io_result != 0) || (image_size == 0)) { WARN("Failed to determine the size of the image id=%u (%i)\n", image_id, io_result); goto exit; @@ -252,7 +252,7 @@ int load_image(meminfo_t *mem_layout, /* We have enough space so load the image now */ /* TODO: Consider whether to try to recover/retry a partially successful read */ io_result = io_read(image_handle, image_base, image_size, &bytes_read); - if ((io_result != IO_SUCCESS) || (bytes_read < image_size)) { + if ((io_result != 0) || (bytes_read < image_size)) { WARN("Failed to load image id=%u (%i)\n", image_id, io_result); goto exit; } @@ -319,7 +319,7 @@ int load_auth_image(meminfo_t *mem_layout, if (rc == 0) { rc = load_auth_image(mem_layout, parent_id, image_base, image_data, NULL); - if (rc != LOAD_SUCCESS) { + if (rc != 0) { return rc; } } @@ -328,8 +328,8 @@ int load_auth_image(meminfo_t *mem_layout, /* Load the image */ rc = load_image(mem_layout, image_id, image_base, image_data, entry_point_info); - if (rc != IO_SUCCESS) { - return LOAD_ERR; + if (rc != 0) { + return rc; } #if TRUSTED_BOARD_BOOT @@ -342,7 +342,7 @@ int load_auth_image(meminfo_t *mem_layout, image_data->image_size); flush_dcache_range(image_data->image_base, image_data->image_size); - return LOAD_AUTH_ERR; + return -EAUTH; } /* After working with data, invalidate the data cache */ @@ -350,5 +350,5 @@ int load_auth_image(meminfo_t *mem_layout, (size_t)image_data->image_size); #endif /* TRUSTED_BOARD_BOOT */ - return LOAD_SUCCESS; + return 0; } diff --git a/include/common/bl_common.h b/include/common/bl_common.h index 164377f6f..c687b3543 100644 --- a/include/common/bl_common.h +++ b/include/common/bl_common.h @@ -202,15 +202,6 @@ typedef struct bl31_params { image_info_t *bl33_image_info; } bl31_params_t; -/* - * load_auth_image() return values - */ -enum { - LOAD_SUCCESS, /* Load + authentication success */ - LOAD_ERR, /* Load error */ - LOAD_AUTH_ERR /* Authentication error */ -}; - /* * Compile time assertions related to the 'entry_point_info' structure to