blob: 1fd822e9aba80a8f6770b739bb69d0ff83b5e914 [file] [log] [blame]
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00001/*
2 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
8#include <assert.h>
9#include <bl_common.h>
10#include <console.h>
11#include <debug.h>
12#include <desc_image_load.h>
13#include <platform_def.h>
14#include <xlat_mmu_helpers.h>
15#include <xlat_tables_defs.h>
16
17#include "rpi3_private.h"
18
19/* Data structure which holds the extents of the trusted SRAM for BL2 */
20static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE);
21
22/*******************************************************************************
23 * BL1 has passed the extents of the trusted SRAM that should be visible to BL2
24 * in x0. This memory layout is sitting at the base of the free trusted SRAM.
25 * Copy it to a safe location before its reclaimed by later BL2 functionality.
26 ******************************************************************************/
27void bl2_early_platform_setup(meminfo_t *mem_layout)
28{
29 /* Initialize the console to provide early debug support */
30 console_init(PLAT_RPI3_UART_BASE, PLAT_RPI3_UART_CLK_IN_HZ,
31 PLAT_RPI3_UART_BAUDRATE);
32
33 /* Setup the BL2 memory layout */
34 bl2_tzram_layout = *mem_layout;
35
36 plat_rpi3_io_setup();
37}
38
39void bl2_platform_setup(void)
40{
41 /*
42 * This is where a TrustZone address space controller and other
43 * security related peripherals, would be configured.
44 */
45}
46
47/*******************************************************************************
48 * Perform the very early platform specific architectural setup here.
49 ******************************************************************************/
50void bl2_plat_arch_setup(void)
51{
52 rpi3_setup_page_tables(bl2_tzram_layout.total_base,
53 bl2_tzram_layout.total_size,
54 BL_CODE_BASE, BL_CODE_END,
55 BL_RO_DATA_BASE, BL_RO_DATA_END
56#if USE_COHERENT_MEM
57 , BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_END
58#endif
59 );
60
61 enable_mmu_el1(0);
62}
63
64/*******************************************************************************
65 * This function can be used by the platforms to update/use image
66 * information for given `image_id`.
67 ******************************************************************************/
68int bl2_plat_handle_post_image_load(unsigned int image_id)
69{
70 int err = 0;
71 bl_mem_params_node_t *bl_mem_params = get_bl_mem_params_node(image_id);
72
73 assert(bl_mem_params != NULL);
74
75 switch (image_id) {
76 case BL32_IMAGE_ID:
77 bl_mem_params->ep_info.spsr = rpi3_get_spsr_for_bl32_entry();
78 break;
79
80 case BL33_IMAGE_ID:
81 /* BL33 expects to receive the primary CPU MPID (through r0) */
82 bl_mem_params->ep_info.args.arg0 = 0xffff & read_mpidr();
83 bl_mem_params->ep_info.spsr = rpi3_get_spsr_for_bl33_entry();
84 break;
85
86 }
87
88 return err;
89}