Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 1 | /* |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch_helpers.h> |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 8 | #include <assert.h> |
| 9 | #include <bl_common.h> |
| 10 | #include <debug.h> |
| 11 | #include <errno.h> |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 12 | #if TRUSTED_BOARD_BOOT |
| 13 | #include <mbedtls_config.h> |
| 14 | #endif |
Soby Mathew | 73308d0 | 2018-01-09 14:36:14 +0000 | [diff] [blame] | 15 | #include <platform.h> |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 16 | |
| 17 | /* |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 18 | * The following platform functions are weakly defined. The Platforms |
| 19 | * may redefine with strong definition. |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 20 | */ |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 21 | #pragma weak bl2_el3_plat_prepare_exit |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 22 | #pragma weak plat_error_handler |
| 23 | #pragma weak bl2_plat_preload_setup |
Masahiro Yamada | 02a0d3d | 2018-02-01 16:45:51 +0900 | [diff] [blame] | 24 | #pragma weak bl2_plat_handle_pre_image_load |
| 25 | #pragma weak bl2_plat_handle_post_image_load |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 26 | #pragma weak plat_try_next_boot_source |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 27 | #pragma weak plat_get_mbedtls_heap |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 28 | |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 29 | void bl2_el3_plat_prepare_exit(void) |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 30 | { |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 31 | } |
| 32 | |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 33 | void __dead2 plat_error_handler(int err) |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 34 | { |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 35 | while (1) |
| 36 | wfi(); |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 37 | } |
| 38 | |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 39 | void bl2_plat_preload_setup(void) |
| 40 | { |
| 41 | } |
| 42 | |
Masahiro Yamada | 02a0d3d | 2018-02-01 16:45:51 +0900 | [diff] [blame] | 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 | |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 53 | int plat_try_next_boot_source(void) |
| 54 | { |
| 55 | return 0; |
| 56 | } |
Soby Mathew | 73308d0 | 2018-01-09 14:36:14 +0000 | [diff] [blame] | 57 | |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 58 | #if TRUSTED_BOARD_BOOT |
| 59 | /* |
| 60 | * The following default implementation of the function simply returns the |
| 61 | * by-default allocated heap. |
| 62 | */ |
| 63 | int 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 */ |