blob: 6070db235f91cb0717deee6828ff11d89b3f329e [file] [log] [blame]
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +09001/*
Zelalem87675d42020-02-03 14:56:42 -06002 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Soby Mathew2f38ce32018-02-08 17:45:12 +00007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <arch_helpers.h>
10#include <common/bl_common.h>
11#include <common/debug.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <lib/xlat_tables/xlat_tables_compat.h>
13#include <plat/common/platform.h>
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090014
15/*
Soby Mathew2f38ce32018-02-08 17:45:12 +000016 * The following platform functions are weakly defined. The Platforms
17 * may redefine with strong definition.
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090018 */
Soby Mathew2f38ce32018-02-08 17:45:12 +000019#pragma weak bl2_el3_plat_prepare_exit
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090020#pragma weak plat_error_handler
21#pragma weak bl2_plat_preload_setup
Masahiro Yamada02a0d3d2018-02-01 16:45:51 +090022#pragma weak bl2_plat_handle_pre_image_load
23#pragma weak bl2_plat_handle_post_image_load
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090024#pragma weak plat_try_next_boot_source
25
Soby Mathew2f38ce32018-02-08 17:45:12 +000026void bl2_el3_plat_prepare_exit(void)
Masahiro Yamada43d20b32018-02-01 16:46:18 +090027{
Masahiro Yamada43d20b32018-02-01 16:46:18 +090028}
29
Soby Mathew2f38ce32018-02-08 17:45:12 +000030void __dead2 plat_error_handler(int err)
Masahiro Yamada43d20b32018-02-01 16:46:18 +090031{
Soby Mathew2f38ce32018-02-08 17:45:12 +000032 while (1)
33 wfi();
Masahiro Yamada43d20b32018-02-01 16:46:18 +090034}
35
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090036void bl2_plat_preload_setup(void)
37{
38}
39
Masahiro Yamada02a0d3d2018-02-01 16:45:51 +090040int bl2_plat_handle_pre_image_load(unsigned int image_id)
41{
42 return 0;
43}
44
45int bl2_plat_handle_post_image_load(unsigned int image_id)
46{
47 return 0;
48}
49
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +090050int plat_try_next_boot_source(void)
51{
52 return 0;
53}
Soby Mathew73308d02018-01-09 14:36:14 +000054
Roberto Vargas344ff022018-10-19 16:44:18 +010055/*
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
65void __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}