Yann Gautier | ece4c25 | 2023-06-13 18:45:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
| 8 | #include <stdint.h> |
| 9 | |
| 10 | #include <common/bl_common.h> |
| 11 | #include <drivers/st/stm32_console.h> |
| 12 | #include <lib/xlat_tables/xlat_tables_v2.h> |
| 13 | #include <plat/common/platform.h> |
| 14 | |
| 15 | #include <platform_def.h> |
| 16 | |
| 17 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 18 | u_register_t arg2, u_register_t arg3) |
| 19 | { |
| 20 | bl_params_t *params_from_bl2; |
| 21 | int ret; |
| 22 | |
| 23 | /* |
| 24 | * Invalidate remaining data from second half of SYSRAM (used by BL2) as this area will |
| 25 | * be later used as non-secure. |
| 26 | */ |
| 27 | inv_dcache_range(STM32MP_SYSRAM_BASE + STM32MP_SYSRAM_SIZE / 2U, |
| 28 | STM32MP_SYSRAM_SIZE / 2U); |
| 29 | |
| 30 | mmap_add_region(BL_CODE_BASE, BL_CODE_BASE, |
| 31 | BL_CODE_END - BL_CODE_BASE, |
| 32 | MT_CODE | MT_SECURE); |
| 33 | |
| 34 | #if USE_COHERENT_MEM |
| 35 | /* Map coherent memory */ |
| 36 | mmap_add_region(BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_BASE, |
| 37 | BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, |
| 38 | MT_DEVICE | MT_RW | MT_SECURE); |
| 39 | #endif |
| 40 | |
| 41 | configure_mmu(); |
| 42 | |
| 43 | /* |
| 44 | * Map upper SYSRAM where bl_params_t are stored in BL2 |
| 45 | */ |
| 46 | ret = mmap_add_dynamic_region(STM32MP_SYSRAM_BASE + STM32MP_SYSRAM_SIZE / 2U, |
| 47 | STM32MP_SYSRAM_BASE + STM32MP_SYSRAM_SIZE / 2U, |
| 48 | STM32MP_SYSRAM_SIZE / 2U, MT_RO_DATA | MT_SECURE); |
| 49 | if (ret < 0) { |
| 50 | ERROR("BL2 params area mapping: %d\n", ret); |
| 51 | panic(); |
| 52 | } |
| 53 | |
| 54 | assert(arg0 != 0UL); |
| 55 | params_from_bl2 = (bl_params_t *)arg0; |
| 56 | assert(params_from_bl2 != NULL); |
| 57 | assert(params_from_bl2->h.type == PARAM_BL_PARAMS); |
| 58 | assert(params_from_bl2->h.version >= VERSION_2); |
| 59 | |
| 60 | bl_params_node_t *bl_params = params_from_bl2->head; |
| 61 | |
| 62 | while (bl_params != NULL) { |
| 63 | bl_params = bl_params->next_params_info; |
| 64 | } |
| 65 | |
| 66 | ret = mmap_remove_dynamic_region(STM32MP_SYSRAM_BASE + STM32MP_SYSRAM_SIZE / 2U, |
| 67 | STM32MP_SYSRAM_SIZE / 2U); |
| 68 | if (ret < 0) { |
| 69 | ERROR("BL2 params area unmapping: %d\n", ret); |
| 70 | panic(); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | void bl31_plat_arch_setup(void) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | void bl31_platform_setup(void) |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | entry_point_info_t *bl31_plat_get_next_image_ep_info(unsigned int type) |
| 83 | { |
| 84 | return NULL; |
| 85 | } |