2013-10-25 09:08:21 +01:00
|
|
|
/*
|
2018-01-09 14:36:14 +00:00
|
|
|
* Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
|
2013-10-25 09:08:21 +01:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2013-10-25 09:08:21 +01:00
|
|
|
*/
|
|
|
|
|
2013-11-12 16:41:16 +00:00
|
|
|
#include <arch.h>
|
2014-03-18 13:46:55 +00:00
|
|
|
#include <asm_macros.S>
|
2018-12-14 00:18:21 +00:00
|
|
|
#include <common/bl_common.h>
|
2013-10-25 09:08:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
.globl bl2_entrypoint
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-18 13:46:55 +00:00
|
|
|
func bl2_entrypoint
|
2013-10-25 09:08:21 +01:00
|
|
|
/*---------------------------------------------
|
2018-01-09 14:36:14 +00:00
|
|
|
* Save arguments x0 - x3 from BL1 for future
|
|
|
|
* use.
|
2013-10-25 09:08:21 +01:00
|
|
|
* ---------------------------------------------
|
2016-02-01 13:57:25 +00:00
|
|
|
*/
|
2018-01-09 14:36:14 +00:00
|
|
|
mov x20, x0
|
|
|
|
mov x21, x1
|
|
|
|
mov x22, x2
|
|
|
|
mov x23, x3
|
2013-10-25 09:08:21 +01:00
|
|
|
|
2013-11-12 16:41:16 +00:00
|
|
|
/* ---------------------------------------------
|
|
|
|
* Set the exception vector to something sane.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
|
|
|
adr x0, early_exceptions
|
|
|
|
msr vbar_el1, x0
|
2014-08-04 23:13:10 +01:00
|
|
|
isb
|
|
|
|
|
|
|
|
/* ---------------------------------------------
|
|
|
|
* Enable the SError interrupt now that the
|
|
|
|
* exception vectors have been setup.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
|
|
|
msr daifclr, #DAIF_ABT_BIT
|
2013-11-12 16:41:16 +00:00
|
|
|
|
|
|
|
/* ---------------------------------------------
|
2014-07-18 18:38:28 +01:00
|
|
|
* Enable the instruction cache, stack pointer
|
|
|
|
* and data access alignment checks
|
2013-11-12 16:41:16 +00:00
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
2014-07-18 18:38:28 +01:00
|
|
|
mov x1, #(SCTLR_I_BIT | SCTLR_A_BIT | SCTLR_SA_BIT)
|
2013-11-12 16:41:16 +00:00
|
|
|
mrs x0, sctlr_el1
|
2014-07-18 18:38:28 +01:00
|
|
|
orr x0, x0, x1
|
2013-11-12 16:41:16 +00:00
|
|
|
msr sctlr_el1, x0
|
|
|
|
isb
|
|
|
|
|
2015-09-11 16:03:13 +01:00
|
|
|
/* ---------------------------------------------
|
|
|
|
* Invalidate the RW memory used by the BL2
|
|
|
|
* image. This includes the data and NOBITS
|
|
|
|
* sections. This is done to safeguard against
|
|
|
|
* possible corruption of this memory by dirty
|
|
|
|
* cache lines in a system cache as a result of
|
|
|
|
* use by an earlier boot loader stage.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
|
|
|
adr x0, __RW_START__
|
|
|
|
adr x1, __RW_END__
|
|
|
|
sub x1, x1, x0
|
|
|
|
bl inv_dcache_range
|
|
|
|
|
2013-11-28 09:43:06 +00:00
|
|
|
/* ---------------------------------------------
|
|
|
|
* Zero out NOBITS sections. There are 2 of them:
|
|
|
|
* - the .bss section;
|
|
|
|
* - the coherent memory section.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
2018-10-12 16:40:28 +01:00
|
|
|
adrp x0, __BSS_START__
|
|
|
|
add x0, x0, :lo12:__BSS_START__
|
|
|
|
adrp x1, __BSS_END__
|
|
|
|
add x1, x1, :lo12:__BSS_END__
|
|
|
|
sub x1, x1, x0
|
2016-12-02 13:51:54 +00:00
|
|
|
bl zeromem
|
2013-11-28 09:43:06 +00:00
|
|
|
|
2015-01-08 18:02:44 +00:00
|
|
|
#if USE_COHERENT_MEM
|
2018-10-12 16:40:28 +01:00
|
|
|
adrp x0, __COHERENT_RAM_START__
|
|
|
|
add x0, x0, :lo12:__COHERENT_RAM_START__
|
|
|
|
adrp x1, __COHERENT_RAM_END_UNALIGNED__
|
|
|
|
add x1, x1, :lo12:__COHERENT_RAM_END_UNALIGNED__
|
|
|
|
sub x1, x1, x0
|
2016-12-02 13:51:54 +00:00
|
|
|
bl zeromem
|
2015-01-08 18:02:44 +00:00
|
|
|
#endif
|
2013-11-28 09:43:06 +00:00
|
|
|
|
2013-10-25 09:08:21 +01:00
|
|
|
/* --------------------------------------------
|
2014-06-25 19:26:22 +01:00
|
|
|
* Allocate a stack whose memory will be marked
|
|
|
|
* as Normal-IS-WBWA when the MMU is enabled.
|
|
|
|
* There is no risk of reading stale stack
|
|
|
|
* memory after enabling the MMU as only the
|
|
|
|
* primary cpu is running at the moment.
|
2013-10-25 09:08:21 +01:00
|
|
|
* --------------------------------------------
|
|
|
|
*/
|
2015-07-13 11:21:11 +01:00
|
|
|
bl plat_set_my_stack
|
2013-10-25 09:08:21 +01:00
|
|
|
|
2017-02-24 18:14:15 +00:00
|
|
|
/* ---------------------------------------------
|
|
|
|
* Initialize the stack protector canary before
|
|
|
|
* any C code is called.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
|
|
|
#if STACK_PROTECTOR_ENABLED
|
|
|
|
bl update_stack_protector_canary
|
|
|
|
#endif
|
|
|
|
|
2013-10-25 09:08:21 +01:00
|
|
|
/* ---------------------------------------------
|
|
|
|
* Perform early platform setup & platform
|
|
|
|
* specific early arch. setup e.g. mmu setup
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
2015-10-29 12:47:02 +00:00
|
|
|
mov x0, x20
|
2018-01-09 14:36:14 +00:00
|
|
|
mov x1, x21
|
|
|
|
mov x2, x22
|
|
|
|
mov x3, x23
|
|
|
|
bl bl2_early_platform_setup2
|
|
|
|
|
2013-10-25 09:08:21 +01:00
|
|
|
bl bl2_plat_arch_setup
|
|
|
|
|
|
|
|
/* ---------------------------------------------
|
|
|
|
* Jump to main function.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
|
|
|
bl bl2_main
|
2016-02-01 13:57:25 +00:00
|
|
|
|
|
|
|
/* ---------------------------------------------
|
|
|
|
* Should never reach this point.
|
|
|
|
* ---------------------------------------------
|
|
|
|
*/
|
2016-11-30 15:21:11 +00:00
|
|
|
no_ret plat_panic_handler
|
2016-02-01 13:57:25 +00:00
|
|
|
|
2015-03-24 14:03:57 +00:00
|
|
|
endfunc bl2_entrypoint
|