blob: 264d5180d3a3c58e64d769f2975e93e72275ad13 [file] [log] [blame]
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +09001/*
Soby Mathew2f38ce32018-02-08 17:45:12 +00002 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
Soby Mathew2f38ce32018-02-08 17:45:12 +00008#include <assert.h>
9#include <bl_common.h>
10#include <debug.h>
11#include <errno.h>
John Tsichritzis30f89642018-06-07 16:31:34 +010012#if TRUSTED_BOARD_BOOT
13#include <mbedtls_config.h>
14#endif
Soby Mathew73308d02018-01-09 14:36:14 +000015#include <platform.h>
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090016
17/*
Soby Mathew2f38ce32018-02-08 17:45:12 +000018 * The following platform functions are weakly defined. The Platforms
19 * may redefine with strong definition.
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090020 */
Soby Mathew2f38ce32018-02-08 17:45:12 +000021#pragma weak bl2_el3_plat_prepare_exit
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090022#pragma weak plat_error_handler
23#pragma weak bl2_plat_preload_setup
Masahiro Yamada02a0d3d2018-02-01 16:45:51 +090024#pragma weak bl2_plat_handle_pre_image_load
25#pragma weak bl2_plat_handle_post_image_load
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090026#pragma weak plat_try_next_boot_source
John Tsichritzis30f89642018-06-07 16:31:34 +010027#pragma weak plat_get_mbedtls_heap
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090028
Soby Mathew2f38ce32018-02-08 17:45:12 +000029void bl2_el3_plat_prepare_exit(void)
Masahiro Yamada43d20b32018-02-01 16:46:18 +090030{
Masahiro Yamada43d20b32018-02-01 16:46:18 +090031}
32
Soby Mathew2f38ce32018-02-08 17:45:12 +000033void __dead2 plat_error_handler(int err)
Masahiro Yamada43d20b32018-02-01 16:46:18 +090034{
Soby Mathew2f38ce32018-02-08 17:45:12 +000035 while (1)
36 wfi();
Masahiro Yamada43d20b32018-02-01 16:46:18 +090037}
38
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090039void bl2_plat_preload_setup(void)
40{
41}
42
Masahiro Yamada02a0d3d2018-02-01 16:45:51 +090043int bl2_plat_handle_pre_image_load(unsigned int image_id)
44{
45 return 0;
46}
47
48int bl2_plat_handle_post_image_load(unsigned int image_id)
49{
50 return 0;
51}
52
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090053int plat_try_next_boot_source(void)
54{
55 return 0;
56}
Soby Mathew73308d02018-01-09 14:36:14 +000057
John Tsichritzis30f89642018-06-07 16:31:34 +010058#if TRUSTED_BOARD_BOOT
59/*
60 * The following default implementation of the function simply returns the
61 * by-default allocated heap.
62 */
63int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
64{
65 static unsigned char heap[TF_MBEDTLS_HEAP_SIZE];
66
67 assert(heap_addr != NULL);
68 assert(heap_size != NULL);
69
70 *heap_addr = heap;
71 *heap_size = sizeof(heap);
72 return 0;
73}
74#endif /* TRUSTED_BOARD_BOOT */