1566034fcSSoby Mathew /* 2566034fcSSoby Mathew * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. 3566034fcSSoby Mathew * 4566034fcSSoby Mathew * SPDX-License-Identifier: BSD-3-Clause 5566034fcSSoby Mathew */ 6566034fcSSoby Mathew 7566034fcSSoby Mathew #include <arch_helpers.h> 8566034fcSSoby Mathew #include <assert.h> 9566034fcSSoby Mathew #include <bl_common.h> 10566034fcSSoby Mathew #include <debug.h> 11566034fcSSoby Mathew #include <errno.h> 126d01a463SJohn Tsichritzis #if TRUSTED_BOARD_BOOT 136d01a463SJohn Tsichritzis #include <mbedtls_config.h> 146d01a463SJohn Tsichritzis #endif 15a6f340feSSoby Mathew #include <platform.h> 16*03987d01SAntonio Nino Diaz #include <xlat_tables_compat.h> 17566034fcSSoby Mathew 18566034fcSSoby Mathew /* 19566034fcSSoby Mathew * The following platform functions are weakly defined. The Platforms 20566034fcSSoby Mathew * may redefine with strong definition. 21566034fcSSoby Mathew */ 22566034fcSSoby Mathew #pragma weak bl2_el3_plat_prepare_exit 23566034fcSSoby Mathew #pragma weak plat_error_handler 24566034fcSSoby Mathew #pragma weak bl2_plat_preload_setup 25566034fcSSoby Mathew #pragma weak bl2_plat_handle_pre_image_load 26566034fcSSoby Mathew #pragma weak bl2_plat_handle_post_image_load 27566034fcSSoby Mathew #pragma weak plat_try_next_boot_source 286d01a463SJohn Tsichritzis #pragma weak plat_get_mbedtls_heap 29566034fcSSoby Mathew 30566034fcSSoby Mathew void bl2_el3_plat_prepare_exit(void) 31566034fcSSoby Mathew { 32566034fcSSoby Mathew } 33566034fcSSoby Mathew 34566034fcSSoby Mathew void __dead2 plat_error_handler(int err) 35566034fcSSoby Mathew { 36566034fcSSoby Mathew while (1) 37566034fcSSoby Mathew wfi(); 38566034fcSSoby Mathew } 39566034fcSSoby Mathew 40566034fcSSoby Mathew void bl2_plat_preload_setup(void) 41566034fcSSoby Mathew { 42566034fcSSoby Mathew } 43566034fcSSoby Mathew 44566034fcSSoby Mathew int bl2_plat_handle_pre_image_load(unsigned int image_id) 45566034fcSSoby Mathew { 46566034fcSSoby Mathew return 0; 47566034fcSSoby Mathew } 48566034fcSSoby Mathew 49566034fcSSoby Mathew int bl2_plat_handle_post_image_load(unsigned int image_id) 50566034fcSSoby Mathew { 51566034fcSSoby Mathew return 0; 52566034fcSSoby Mathew } 53566034fcSSoby Mathew 54566034fcSSoby Mathew int plat_try_next_boot_source(void) 55566034fcSSoby Mathew { 56566034fcSSoby Mathew return 0; 57566034fcSSoby Mathew } 58a6f340feSSoby Mathew 596d01a463SJohn Tsichritzis #if TRUSTED_BOARD_BOOT 606d01a463SJohn Tsichritzis /* 616d01a463SJohn Tsichritzis * The following default implementation of the function simply returns the 626d01a463SJohn Tsichritzis * by-default allocated heap. 636d01a463SJohn Tsichritzis */ 646d01a463SJohn Tsichritzis int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) 656d01a463SJohn Tsichritzis { 666d01a463SJohn Tsichritzis static unsigned char heap[TF_MBEDTLS_HEAP_SIZE]; 676d01a463SJohn Tsichritzis 686d01a463SJohn Tsichritzis assert(heap_addr != NULL); 696d01a463SJohn Tsichritzis assert(heap_size != NULL); 706d01a463SJohn Tsichritzis 716d01a463SJohn Tsichritzis *heap_addr = heap; 726d01a463SJohn Tsichritzis *heap_size = sizeof(heap); 736d01a463SJohn Tsichritzis return 0; 746d01a463SJohn Tsichritzis } 756d01a463SJohn Tsichritzis #endif /* TRUSTED_BOARD_BOOT */ 76