plat_bl_common.c 1.77 KB
Newer Older
1
/*
2
 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch_helpers.h>
8
9
10
11
#include <assert.h>
#include <bl_common.h>
#include <debug.h>
#include <errno.h>
12
13
14
#if TRUSTED_BOARD_BOOT
#include <mbedtls_config.h>
#endif
15
#include <platform.h>
16
17

/*
18
19
 * The following platform functions are weakly defined. The Platforms
 * may redefine with strong definition.
20
 */
21
#pragma weak bl2_el3_plat_prepare_exit
22
23
#pragma weak plat_error_handler
#pragma weak bl2_plat_preload_setup
24
25
#pragma weak bl2_plat_handle_pre_image_load
#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
36
	while (1)
		wfi();
37
38
}

39
40
41
42
void bl2_plat_preload_setup(void)
{
}

43
#if LOAD_IMAGE_V2
44
45
46
47
48
49
50
51
52
int bl2_plat_handle_pre_image_load(unsigned int image_id)
{
	return 0;
}

int bl2_plat_handle_post_image_load(unsigned int image_id)
{
	return 0;
}
53
#endif
54

55
56
57
58
int plat_try_next_boot_source(void)
{
	return 0;
}
59
60
61
62
63
64
65
66
67
68
69
70
71
72

#if !ERROR_DEPRECATED
#pragma weak bl2_early_platform_setup2

/*
 * The following platform API implementation that allow compatibility for
 * the older platform APIs.
 */
void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1,
			u_register_t arg2, u_register_t arg3)
{
	bl2_early_platform_setup((void *)arg1);
}
#endif
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91


#if TRUSTED_BOARD_BOOT
/*
 * The following default implementation of the function simply returns the
 * by-default allocated heap.
 */
int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
{
	static unsigned char heap[TF_MBEDTLS_HEAP_SIZE];

	assert(heap_addr != NULL);
	assert(heap_size != NULL);

	*heap_addr = heap;
	*heap_size = sizeof(heap);
	return 0;
}
#endif /* TRUSTED_BOARD_BOOT */