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