xref: /rk3399_ARM-atf/plat/common/plat_bl_common.c (revision 03987d01e9effe2b896e1ddb16894238d37e099a)
1 /*
2  * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <arch_helpers.h>
8 #include <assert.h>
9 #include <bl_common.h>
10 #include <debug.h>
11 #include <errno.h>
12 #if TRUSTED_BOARD_BOOT
13 #include <mbedtls_config.h>
14 #endif
15 #include <platform.h>
16 #include <xlat_tables_compat.h>
17 
18 /*
19  * The following platform functions are weakly defined. The Platforms
20  * may redefine with strong definition.
21  */
22 #pragma weak bl2_el3_plat_prepare_exit
23 #pragma weak plat_error_handler
24 #pragma weak bl2_plat_preload_setup
25 #pragma weak bl2_plat_handle_pre_image_load
26 #pragma weak bl2_plat_handle_post_image_load
27 #pragma weak plat_try_next_boot_source
28 #pragma weak plat_get_mbedtls_heap
29 
30 void bl2_el3_plat_prepare_exit(void)
31 {
32 }
33 
34 void __dead2 plat_error_handler(int err)
35 {
36 	while (1)
37 		wfi();
38 }
39 
40 void bl2_plat_preload_setup(void)
41 {
42 }
43 
44 int bl2_plat_handle_pre_image_load(unsigned int image_id)
45 {
46 	return 0;
47 }
48 
49 int bl2_plat_handle_post_image_load(unsigned int image_id)
50 {
51 	return 0;
52 }
53 
54 int plat_try_next_boot_source(void)
55 {
56 	return 0;
57 }
58 
59 #if TRUSTED_BOARD_BOOT
60 /*
61  * The following default implementation of the function simply returns the
62  * by-default allocated heap.
63  */
64 int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
65 {
66 	static unsigned char heap[TF_MBEDTLS_HEAP_SIZE];
67 
68 	assert(heap_addr != NULL);
69 	assert(heap_size != NULL);
70 
71 	*heap_addr = heap;
72 	*heap_size = sizeof(heap);
73 	return 0;
74 }
75 #endif /* TRUSTED_BOARD_BOOT */
76