xref: /rk3399_ARM-atf/plat/common/plat_bl_common.c (revision ed51b51f7a9163a7fc48289c5ed97a3fe4fe504f)
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 
17 /*
18  * The following platform functions are weakly defined. The Platforms
19  * may redefine with strong definition.
20  */
21 #pragma weak bl2_el3_plat_prepare_exit
22 #pragma weak plat_error_handler
23 #pragma weak bl2_plat_preload_setup
24 #pragma weak bl2_plat_handle_pre_image_load
25 #pragma weak bl2_plat_handle_post_image_load
26 #pragma weak plat_try_next_boot_source
27 #pragma weak plat_get_mbedtls_heap
28 
29 void bl2_el3_plat_prepare_exit(void)
30 {
31 }
32 
33 void __dead2 plat_error_handler(int err)
34 {
35 	while (1)
36 		wfi();
37 }
38 
39 void bl2_plat_preload_setup(void)
40 {
41 }
42 
43 int bl2_plat_handle_pre_image_load(unsigned int image_id)
44 {
45 	return 0;
46 }
47 
48 int bl2_plat_handle_post_image_load(unsigned int image_id)
49 {
50 	return 0;
51 }
52 
53 int plat_try_next_boot_source(void)
54 {
55 	return 0;
56 }
57 
58 #if !ERROR_DEPRECATED
59 #pragma weak bl2_early_platform_setup2
60 
61 /*
62  * The following platform API implementation that allow compatibility for
63  * the older platform APIs.
64  */
65 void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1,
66 			u_register_t arg2, u_register_t arg3)
67 {
68 	bl2_early_platform_setup((void *)arg1);
69 }
70 #endif
71 
72 
73 #if TRUSTED_BOARD_BOOT
74 /*
75  * The following default implementation of the function simply returns the
76  * by-default allocated heap.
77  */
78 int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
79 {
80 	static unsigned char heap[TF_MBEDTLS_HEAP_SIZE];
81 
82 	assert(heap_addr != NULL);
83 	assert(heap_size != NULL);
84 
85 	*heap_addr = heap;
86 	*heap_size = sizeof(heap);
87 	return 0;
88 }
89 #endif /* TRUSTED_BOARD_BOOT */
90