xref: /rk3399_ARM-atf/bl31/bl31_main.c (revision ab2d31edbd9dea69bd1ca495e3fce0511c9d42ff)
1 /*
2  * Copyright (c) 2013, ARM Limited and Contributors. All rights reserved.
3  *
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>
41 
42 void bl31_arch_next_el_setup(void);
43 
44 /*******************************************************************************
45  * BL31 is responsible for setting up the runtime services for the primary cpu
46  * before passing control to the bootloader (UEFI) or Linux.
47  ******************************************************************************/
48 void bl31_main(void)
49 {
50 	el_change_info *image_info;
51 	unsigned long mpidr = read_mpidr();
52 
53 	/* Perform remaining generic architectural setup from EL3 */
54 	bl31_arch_setup();
55 
56 	/* Perform platform setup in BL1 */
57 	bl31_platform_setup();
58 
59 #if defined (__GNUC__)
60 	printf("BL31 Built : %s, %s\n\r", __TIME__, __DATE__);
61 #endif
62 
63 
64 	/* Initialize the runtime services e.g. psci */
65 	runtime_svc_init(mpidr);
66 
67 	/* Clean caches before re-entering normal world */
68 	dcsw_op_all(DCCSW);
69 
70 	image_info = bl31_get_next_image_info(mpidr);
71 	bl31_arch_next_el_setup();
72 	change_el(image_info);
73 
74 	/* There is no valid reason for change_el() to return */
75 	assert(0);
76 }
77