blob: b46656c7ac03c15b95794bfb244acb95fb847061 [file] [log] [blame]
Masahiro Yamada0fc50a82018-02-01 18:42:24 +09001/*
John Tsichritzis17e13352019-02-28 11:14:03 +00002 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada0fc50a82018-02-01 18:42:24 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Soby Mathew566034f2018-02-08 17:45:12 +00007#include <assert.h>
Soby Mathew566034f2018-02-08 17:45:12 +00008#include <errno.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00009
10#include <arch_helpers.h>
11#include <common/bl_common.h>
12#include <common/debug.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000013#include <lib/xlat_tables/xlat_tables_compat.h>
14#include <plat/common/platform.h>
Masahiro Yamada0fc50a82018-02-01 18:42:24 +090015
16/*
Soby Mathew566034f2018-02-08 17:45:12 +000017 * The following platform functions are weakly defined. The Platforms
18 * may redefine with strong definition.
Masahiro Yamada0fc50a82018-02-01 18:42:24 +090019 */
Soby Mathew566034f2018-02-08 17:45:12 +000020#pragma weak bl2_el3_plat_prepare_exit
Masahiro Yamada0fc50a82018-02-01 18:42:24 +090021#pragma weak plat_error_handler
22#pragma weak bl2_plat_preload_setup
Masahiro Yamadaba68ef52018-02-01 16:45:51 +090023#pragma weak bl2_plat_handle_pre_image_load
24#pragma weak bl2_plat_handle_post_image_load
Masahiro Yamada0fc50a82018-02-01 18:42:24 +090025#pragma weak plat_try_next_boot_source
26
Soby Mathew566034f2018-02-08 17:45:12 +000027void bl2_el3_plat_prepare_exit(void)
28{
29}
30
Masahiro Yamada0fc50a82018-02-01 18:42:24 +090031void __dead2 plat_error_handler(int err)
32{
33 while (1)
34 wfi();
35}
36
37void bl2_plat_preload_setup(void)
38{
39}
40
Masahiro Yamadaba68ef52018-02-01 16:45:51 +090041int bl2_plat_handle_pre_image_load(unsigned int image_id)
42{
43 return 0;
44}
45
46int bl2_plat_handle_post_image_load(unsigned int image_id)
47{
48 return 0;
49}
50
Masahiro Yamada0fc50a82018-02-01 18:42:24 +090051int plat_try_next_boot_source(void)
52{
53 return 0;
54}
Soby Mathewa6f340f2018-01-09 14:36:14 +000055
Roberto Vargas0916c382018-10-19 16:44:18 +010056/*
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
66void __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}