Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 1 | /* |
Zelalem | 87675d4 | 2020-02-03 14:56:42 -0600 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, 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 | |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <arch_helpers.h> |
| 10 | #include <common/bl_common.h> |
| 11 | #include <common/debug.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | #include <lib/xlat_tables/xlat_tables_compat.h> |
| 13 | #include <plat/common/platform.h> |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 14 | |
| 15 | /* |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 16 | * The following platform functions are weakly defined. The Platforms |
| 17 | * may redefine with strong definition. |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 18 | */ |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 19 | #pragma weak bl2_el3_plat_prepare_exit |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 20 | #pragma weak plat_error_handler |
| 21 | #pragma weak bl2_plat_preload_setup |
Masahiro Yamada | 02a0d3d | 2018-02-01 16:45:51 +0900 | [diff] [blame] | 22 | #pragma weak bl2_plat_handle_pre_image_load |
| 23 | #pragma weak bl2_plat_handle_post_image_load |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 24 | #pragma weak plat_try_next_boot_source |
| 25 | |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 26 | void bl2_el3_plat_prepare_exit(void) |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 27 | { |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 28 | } |
| 29 | |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 30 | void __dead2 plat_error_handler(int err) |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 31 | { |
Soby Mathew | 2f38ce3 | 2018-02-08 17:45:12 +0000 | [diff] [blame] | 32 | while (1) |
| 33 | wfi(); |
Masahiro Yamada | 43d20b3 | 2018-02-01 16:46:18 +0900 | [diff] [blame] | 34 | } |
| 35 | |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 36 | void bl2_plat_preload_setup(void) |
| 37 | { |
| 38 | } |
| 39 | |
Masahiro Yamada | 02a0d3d | 2018-02-01 16:45:51 +0900 | [diff] [blame] | 40 | int bl2_plat_handle_pre_image_load(unsigned int image_id) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | int bl2_plat_handle_post_image_load(unsigned int image_id) |
| 46 | { |
| 47 | return 0; |
| 48 | } |
| 49 | |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 50 | int plat_try_next_boot_source(void) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
Soby Mathew | 73308d0 | 2018-01-09 14:36:14 +0000 | [diff] [blame] | 54 | |
Roberto Vargas | 344ff02 | 2018-10-19 16:44:18 +0100 | [diff] [blame] | 55 | /* |
| 56 | * Set up the page tables for the generic and platform-specific memory regions. |
| 57 | * The size of the Trusted SRAM seen by the BL image must be specified as well |
| 58 | * as an array specifying the generic memory regions which can be; |
| 59 | * - Code section; |
| 60 | * - Read-only data section; |
| 61 | * - Init code section, if applicable |
| 62 | * - Coherent memory region, if applicable. |
| 63 | */ |
| 64 | |
| 65 | void __init setup_page_tables(const mmap_region_t *bl_regions, |
| 66 | const mmap_region_t *plat_regions) |
| 67 | { |
| 68 | #if LOG_LEVEL >= LOG_LEVEL_VERBOSE |
| 69 | const mmap_region_t *regions = bl_regions; |
| 70 | |
| 71 | while (regions->size != 0U) { |
| 72 | VERBOSE("Region: 0x%lx - 0x%lx has attributes 0x%x\n", |
| 73 | regions->base_va, |
| 74 | regions->base_va + regions->size, |
| 75 | regions->attr); |
| 76 | regions++; |
| 77 | } |
| 78 | #endif |
| 79 | /* |
| 80 | * Map the Trusted SRAM with appropriate memory attributes. |
| 81 | * Subsequent mappings will adjust the attributes for specific regions. |
| 82 | */ |
| 83 | mmap_add(bl_regions); |
| 84 | |
| 85 | /* Now (re-)map the platform-specific memory regions */ |
| 86 | mmap_add(plat_regions); |
| 87 | |
| 88 | /* Create the page tables to reflect the above mappings */ |
| 89 | init_xlat_tables(); |
| 90 | } |