blob: 74018d2d07978c2f105155dcc2efbf59cc7b6220 [file] [log] [blame]
Yatharth Kocharf9a0f162016-09-13 17:07:57 +01001/*
Soby Mathew96a1c6b2018-01-15 14:45:33 +00002 * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
Yatharth Kocharf9a0f162016-09-13 17:07:57 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kocharf9a0f162016-09-13 17:07:57 +01005 */
6
Sathees Balya90950092018-11-15 14:22:30 +00007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/bl_common.h>
9#include <common/desc_image_load.h>
10#include <plat/common/platform.h>
11
Soby Mathew96a1c6b2018-01-15 14:45:33 +000012#include <plat_arm.h>
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010013
14#pragma weak plat_flush_next_bl_params
15#pragma weak plat_get_bl_image_load_info
16#pragma weak plat_get_next_bl_params
17
Sathees Balya90950092018-11-15 14:22:30 +000018static bl_params_t *next_bl_params_cpy_ptr;
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010019
20/*******************************************************************************
21 * This function flushes the data structures so that they are visible
22 * in memory for the next BL image.
23 ******************************************************************************/
24void plat_flush_next_bl_params(void)
25{
Sathees Balya90950092018-11-15 14:22:30 +000026 assert(next_bl_params_cpy_ptr != NULL);
27
28 flush_bl_params_desc_args(bl_mem_params_desc_ptr,
29 bl_mem_params_desc_num,
30 next_bl_params_cpy_ptr);
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010031}
32
33/*******************************************************************************
34 * This function returns the list of loadable images.
35 ******************************************************************************/
Sandrine Bailleuxb3b6e222018-07-11 12:44:22 +020036struct bl_load_info *plat_get_bl_image_load_info(void)
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010037{
38 return get_bl_load_info_from_mem_params_desc();
39}
40
41/*******************************************************************************
Sathees Balya90950092018-11-15 14:22:30 +000042 * ARM helper function to return the list of executable images.Since the default
43 * descriptors are allocated within BL2 RW memory, this prevents BL31/BL32
44 * overlay of BL2 memory. Hence this function also copies the descriptors to a
45 * pre-allocated memory indicated by ARM_BL2_MEM_DESC_BASE.
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010046 ******************************************************************************/
Sathees Balya90950092018-11-15 14:22:30 +000047struct bl_params *arm_get_next_bl_params(void)
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010048{
Sathees Balya90950092018-11-15 14:22:30 +000049 bl_mem_params_node_t *bl2_mem_params_descs_cpy
50 = (bl_mem_params_node_t *)ARM_BL2_MEM_DESC_BASE;
51 const bl_params_t *next_bl_params;
52
53 next_bl_params_cpy_ptr =
54 (bl_params_t *)(ARM_BL2_MEM_DESC_BASE +
55 (bl_mem_params_desc_num * sizeof(bl_mem_params_node_t)));
56
57 /*
58 * Copy the memory descriptors to ARM_BL2_MEM_DESC_BASE area.
59 */
60 (void) memcpy(bl2_mem_params_descs_cpy, bl_mem_params_desc_ptr,
61 (bl_mem_params_desc_num * sizeof(bl_mem_params_node_t)));
Soby Mathew96a1c6b2018-01-15 14:45:33 +000062
Sathees Balya90950092018-11-15 14:22:30 +000063 /*
64 * Modify the global 'bl_mem_params_desc_ptr' to point to the
65 * copied location.
66 */
67 bl_mem_params_desc_ptr = bl2_mem_params_descs_cpy;
68
69 next_bl_params = get_next_bl_params_from_mem_params_desc();
70 assert(next_bl_params != NULL);
71
72 /*
73 * Copy 'next_bl_params' to the reserved location after the copied
74 * memory descriptors.
75 */
76 (void) memcpy(next_bl_params_cpy_ptr, next_bl_params,
77 (sizeof(bl_params_t)));
78
79 populate_next_bl_params_config(next_bl_params_cpy_ptr);
80
81 return next_bl_params_cpy_ptr;
Yatharth Kocharf9a0f162016-09-13 17:07:57 +010082}
Sathees Balya90950092018-11-15 14:22:30 +000083
84/*******************************************************************************
85 * This function returns the list of executable images
86 ******************************************************************************/
87struct bl_params *plat_get_next_bl_params(void)
88{
89 return arm_get_next_bl_params();
90}
91