xref: /rk3399_ARM-atf/plat/common/plat_bl_common.c (revision f893160690725fe79c8eb63fd90a945cc0374d90)
1 /*
2  * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 
9 #include <arch_helpers.h>
10 #include <common/bl_common.h>
11 #include <common/debug.h>
12 #include <lib/xlat_tables/xlat_tables_compat.h>
13 #include <plat/common/platform.h>
14 
15 /*
16  * The following platform functions are weakly defined. The Platforms
17  * may redefine with strong definition.
18  */
19 #pragma weak bl2_el3_plat_prepare_exit
20 #pragma weak plat_error_handler
21 #pragma weak bl2_plat_preload_setup
22 #pragma weak bl2_plat_handle_pre_image_load
23 #pragma weak bl2_plat_handle_post_image_load
24 #pragma weak plat_try_next_boot_source
25 
26 void bl2_el3_plat_prepare_exit(void)
27 {
28 }
29 
30 void __dead2 plat_error_handler(int err)
31 {
32 	while (1)
33 		wfi();
34 }
35 
36 void bl2_plat_preload_setup(void)
37 {
38 }
39 
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 
50 int plat_try_next_boot_source(void)
51 {
52 	return 0;
53 }
54 
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 }
91