aboutsummaryrefslogtreecommitdiffstats
path: root/include/common/bl_common.h
diff options
context:
space:
mode:
authorYatharth Kochar <yatharth.kochar@arm.com>2016-09-12 16:08:41 +0100
committerYatharth Kochar <yatharth.kochar@arm.com>2016-09-20 16:16:42 +0100
commit7260022636e3b0d3ef641cbda135d98f9a7df177 (patch)
tree6b6e59c23ca8242a4798230a34e8b7286ff91054 /include/common/bl_common.h
parent131f7cd4016732a572c4341fc4e13dbf3ceae82a (diff)
downloadplatform_external_arm-trusted-firmware-7260022636e3b0d3ef641cbda135d98f9a7df177.tar.gz
platform_external_arm-trusted-firmware-7260022636e3b0d3ef641cbda135d98f9a7df177.tar.bz2
platform_external_arm-trusted-firmware-7260022636e3b0d3ef641cbda135d98f9a7df177.zip
Add new version of image loading.
This patch adds capability to load BL images based on image descriptors instead of hard coded way of loading BL images. This framework is designed such that it can be readily adapted by any BL stage that needs to load images. In order to provide the above capability the following new platform functions are introduced: bl_load_info_t *plat_get_bl_image_load_info(void); This function returns pointer to the list of images that the platform has populated to load. bl_params_t *plat_get_next_bl_params(void); This function returns a pointer to the shared memory that the platform has kept aside to pass trusted firmware related information that next BL image needs. void plat_flush_next_bl_params(void); This function flushes to main memory all the params that are passed to next image. int bl2_plat_handle_post_image_load(unsigned int image_id) This function can be used by the platforms to update/use image information for given `image_id`. `desc_image_load.c` contains utility functions which can be used by the platforms to generate, load and executable, image list based on the registered image descriptors. This patch also adds new version of `load_image/load_auth_image` functions in-order to achieve the above capability. Following are the changes for the new version as compared to old: - Refactor the signature and only keep image_id and image_info_t arguments. Removed image_base argument as it is already passed through image_info_t. Given that the BL image base addresses and limit/size are already provided by the platforms, the meminfo_t and entry_point_info arguments are not needed to provide/reserve the extent of free memory for the given BL image. - Added check for the image size against the defined max size. This is needed because the image size could come from an unauthenticated source (e.g. the FIP header). To make this check, new member is added to the image_info_t struct for identifying the image maximum size. New flag `LOAD_IMAGE_V2` is added in the Makefile. Default value is 0. NOTE: `TRUSTED_BOARD_BOOT` is currently not supported when `LOAD_IMAGE_V2` is enabled. Change-Id: Ia7b643f4817a170d5a2fbf479b9bc12e63112e79
Diffstat (limited to 'include/common/bl_common.h')
-rw-r--r--include/common/bl_common.h70
1 files changed, 65 insertions, 5 deletions
diff --git a/include/common/bl_common.h b/include/common/bl_common.h
index 942843cf1..9fa2a810e 100644
--- a/include/common/bl_common.h
+++ b/include/common/bl_common.h
@@ -93,11 +93,22 @@
#define EP_GET_EXE(x) (x & EP_EXE_MASK)
#define EP_SET_EXE(x, ee) ((x) = ((x) & ~EP_EXE_MASK) | (ee))
+#define EP_FIRST_EXE_MASK 0x10
+#define EP_FIRST_EXE 0x10
+#define EP_GET_FIRST_EXE(x) ((x) & EP_FIRST_EXE_MASK)
+#define EP_SET_FIRST_EXE(x, ee) ((x) = ((x) & ~EP_FIRST_EXE_MASK) | (ee))
+
#define PARAM_EP 0x01
#define PARAM_IMAGE_BINARY 0x02
#define PARAM_BL31 0x03
+#define PARAM_BL_LOAD_INFO 0x04
+#define PARAM_BL_PARAMS 0x05
+
+#define IMAGE_ATTRIB_SKIP_LOADING 0x02
+#define IMAGE_ATTRIB_PLAT_SETUP 0x04
#define VERSION_1 0x01
+#define VERSION_2 0x02
#define INVALID_IMAGE_ID (0xFFFFFFFF)
@@ -181,8 +192,10 @@ extern uintptr_t __COHERENT_RAM_END__;
typedef struct meminfo {
uintptr_t total_base;
size_t total_size;
+#if !LOAD_IMAGE_V2
uintptr_t free_base;
size_t free_size;
+#endif
} meminfo_t;
typedef struct aapcs64_params {
@@ -245,6 +258,9 @@ typedef struct image_info {
param_header_t h;
uintptr_t image_base; /* physical address of base of image */
uint32_t image_size; /* bytes read from image file */
+#if LOAD_IMAGE_V2
+ uint32_t image_max_size;
+#endif
} image_info_t;
/*****************************************************************************
@@ -263,6 +279,39 @@ typedef struct image_desc {
entry_point_info_t ep_info;
} image_desc_t;
+#if LOAD_IMAGE_V2
+/* BL image node in the BL image loading sequence */
+typedef struct bl_load_info_node {
+ unsigned int image_id;
+ image_info_t *image_info;
+ struct bl_load_info_node *next_load_info;
+} bl_load_info_node_t;
+
+/* BL image head node in the BL image loading sequence */
+typedef struct bl_load_info {
+ param_header_t h;
+ bl_load_info_node_t *head;
+} bl_load_info_t;
+
+/* BL image node in the BL image execution sequence */
+typedef struct bl_params_node {
+ unsigned int image_id;
+ image_info_t *image_info;
+ entry_point_info_t *ep_info;
+ struct bl_params_node *next_params_info;
+} bl_params_node_t;
+
+/*
+ * BL image head node in the BL image execution sequence
+ * It is also used to pass information to next BL image.
+ */
+typedef struct bl_params {
+ param_header_t h;
+ bl_params_node_t *head;
+} bl_params_t;
+
+#else /* LOAD_IMAGE_V2 */
+
/*******************************************************************************
* This structure represents the superset of information that can be passed to
* BL31 e.g. while passing control to it from BL2. The BL32 parameters will be
@@ -286,6 +335,7 @@ typedef struct bl31_params {
image_info_t *bl33_image_info;
} bl31_params_t;
+#endif /* LOAD_IMAGE_V2 */
/*
* Compile time assertions related to the 'entry_point_info' structure to
@@ -308,24 +358,34 @@ CASSERT(sizeof(uintptr_t) ==
/*******************************************************************************
* Function & variable prototypes
******************************************************************************/
-uintptr_t page_align(uintptr_t, unsigned);
size_t image_size(unsigned int image_id);
+
+#if LOAD_IMAGE_V2
+
+int load_image(unsigned int image_id, image_info_t *image_data);
+int load_auth_image(unsigned int image_id, image_info_t *image_data);
+
+#else
+
+uintptr_t page_align(uintptr_t, unsigned);
int load_image(meminfo_t *mem_layout,
unsigned int image_id,
uintptr_t image_base,
image_info_t *image_data,
entry_point_info_t *entry_point_info);
int load_auth_image(meminfo_t *mem_layout,
- unsigned int image_name,
+ unsigned int image_id,
uintptr_t image_base,
image_info_t *image_data,
entry_point_info_t *entry_point_info);
-extern const char build_message[];
-extern const char version_string[];
-
void reserve_mem(uintptr_t *free_base, size_t *free_size,
uintptr_t addr, size_t size);
+#endif /* LOAD_IMAGE_V2 */
+
+extern const char build_message[];
+extern const char version_string[];
+
void print_entry_point_info(const entry_point_info_t *ep_info);
#endif /*__ASSEMBLY__*/