Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 1 | /* |
Soby Mathew | 96a1c6b | 2018-01-15 14:45:33 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <common/bl_common.h> |
| 9 | #include <common/desc_image_load.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 10 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <plat/common/platform.h> |
| 12 | |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 13 | #pragma weak plat_flush_next_bl_params |
| 14 | #pragma weak plat_get_bl_image_load_info |
| 15 | #pragma weak plat_get_next_bl_params |
| 16 | |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 17 | static bl_params_t *next_bl_params_cpy_ptr; |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 18 | |
| 19 | /******************************************************************************* |
| 20 | * This function flushes the data structures so that they are visible |
| 21 | * in memory for the next BL image. |
| 22 | ******************************************************************************/ |
| 23 | void plat_flush_next_bl_params(void) |
| 24 | { |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 25 | assert(next_bl_params_cpy_ptr != NULL); |
| 26 | |
| 27 | flush_bl_params_desc_args(bl_mem_params_desc_ptr, |
| 28 | bl_mem_params_desc_num, |
| 29 | next_bl_params_cpy_ptr); |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | /******************************************************************************* |
| 33 | * This function returns the list of loadable images. |
| 34 | ******************************************************************************/ |
Sandrine Bailleux | b3b6e22 | 2018-07-11 12:44:22 +0200 | [diff] [blame] | 35 | struct bl_load_info *plat_get_bl_image_load_info(void) |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 36 | { |
| 37 | return get_bl_load_info_from_mem_params_desc(); |
| 38 | } |
| 39 | |
| 40 | /******************************************************************************* |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 41 | * ARM helper function to return the list of executable images.Since the default |
| 42 | * descriptors are allocated within BL2 RW memory, this prevents BL31/BL32 |
| 43 | * overlay of BL2 memory. Hence this function also copies the descriptors to a |
| 44 | * pre-allocated memory indicated by ARM_BL2_MEM_DESC_BASE. |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 45 | ******************************************************************************/ |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 46 | struct bl_params *arm_get_next_bl_params(void) |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 47 | { |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 48 | bl_mem_params_node_t *bl2_mem_params_descs_cpy |
| 49 | = (bl_mem_params_node_t *)ARM_BL2_MEM_DESC_BASE; |
| 50 | const bl_params_t *next_bl_params; |
| 51 | |
| 52 | next_bl_params_cpy_ptr = |
| 53 | (bl_params_t *)(ARM_BL2_MEM_DESC_BASE + |
| 54 | (bl_mem_params_desc_num * sizeof(bl_mem_params_node_t))); |
| 55 | |
| 56 | /* |
| 57 | * Copy the memory descriptors to ARM_BL2_MEM_DESC_BASE area. |
| 58 | */ |
| 59 | (void) memcpy(bl2_mem_params_descs_cpy, bl_mem_params_desc_ptr, |
| 60 | (bl_mem_params_desc_num * sizeof(bl_mem_params_node_t))); |
Soby Mathew | 96a1c6b | 2018-01-15 14:45:33 +0000 | [diff] [blame] | 61 | |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 62 | /* |
| 63 | * Modify the global 'bl_mem_params_desc_ptr' to point to the |
| 64 | * copied location. |
| 65 | */ |
| 66 | bl_mem_params_desc_ptr = bl2_mem_params_descs_cpy; |
| 67 | |
| 68 | next_bl_params = get_next_bl_params_from_mem_params_desc(); |
| 69 | assert(next_bl_params != NULL); |
| 70 | |
| 71 | /* |
| 72 | * Copy 'next_bl_params' to the reserved location after the copied |
| 73 | * memory descriptors. |
| 74 | */ |
| 75 | (void) memcpy(next_bl_params_cpy_ptr, next_bl_params, |
| 76 | (sizeof(bl_params_t))); |
| 77 | |
| 78 | populate_next_bl_params_config(next_bl_params_cpy_ptr); |
| 79 | |
| 80 | return next_bl_params_cpy_ptr; |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 81 | } |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 82 | |
| 83 | /******************************************************************************* |
| 84 | * This function returns the list of executable images |
| 85 | ******************************************************************************/ |
| 86 | struct bl_params *plat_get_next_bl_params(void) |
| 87 | { |
| 88 | return arm_get_next_bl_params(); |
| 89 | } |
| 90 | |