blob: fb697188c847aa4f4fe8f4bb6cf3926d97326b48 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <stdio.h>
32#include <string.h>
33#include <assert.h>
34#include <arch_helpers.h>
35#include <console.h>
36#include <platform.h>
37#include <semihosting.h>
38#include <bl_common.h>
39#include <bl31.h>
40#include <runtime_svc.h>
Achin Gupta7aea9082014-02-01 07:51:28 +000041#include <context_mgmt.h>
42
43/*******************************************************************************
44 * Simple function to initialise all BL31 helper libraries.
45 ******************************************************************************/
46void bl31_lib_init()
47{
48 cm_init();
49}
Achin Gupta4f6ad662013-10-25 09:08:21 +010050
51void bl31_arch_next_el_setup(void);
52
53/*******************************************************************************
54 * BL31 is responsible for setting up the runtime services for the primary cpu
55 * before passing control to the bootloader (UEFI) or Linux.
56 ******************************************************************************/
57void bl31_main(void)
58{
59 el_change_info *image_info;
60 unsigned long mpidr = read_mpidr();
61
62 /* Perform remaining generic architectural setup from EL3 */
63 bl31_arch_setup();
64
65 /* Perform platform setup in BL1 */
66 bl31_platform_setup();
67
68#if defined (__GNUC__)
69 printf("BL31 Built : %s, %s\n\r", __TIME__, __DATE__);
70#endif
Achin Gupta7aea9082014-02-01 07:51:28 +000071 /* Initialise helper libraries */
72 bl31_lib_init();
Achin Gupta4f6ad662013-10-25 09:08:21 +010073
74 /* Initialize the runtime services e.g. psci */
75 runtime_svc_init(mpidr);
76
77 /* Clean caches before re-entering normal world */
78 dcsw_op_all(DCCSW);
79
Sandrine Bailleux93ca2212013-12-02 15:57:09 +000080 image_info = bl31_get_next_image_info();
Achin Gupta4f6ad662013-10-25 09:08:21 +010081 bl31_arch_next_el_setup();
82 change_el(image_info);
83
84 /* There is no valid reason for change_el() to return */
85 assert(0);
86}