aboutsummaryrefslogtreecommitdiff
path: root/fwu/ns_bl1u/aarch32/ns_bl1u_entrypoint.S
blob: 61f816f137a0d6ebe8912024ece040ccd1d5e06f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (c) 2018, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch.h>
#include <asm_macros.S>
#include <tftf.h>

	.globl	ns_bl1u_entrypoint

func ns_bl1u_entrypoint
	/* --------------------------------------------------------------------
	 * Set the exception vectors.
	 * --------------------------------------------------------------------
	 */
	ldr	r0, =exception_stubs
	stcopr	r0, HVBAR

	/* --------------------------------------------------------------------
	 * Enable the instruction cache and data access alignment checks.
	 * --------------------------------------------------------------------
	 */
	ldcopr	r0, HSCTLR
	ldr	r1, =(HSCTLR_I_BIT | HSCTLR_A_BIT)
	orr	r0, r0, r1
	stcopr	r0, HSCTLR
	isb

	/* ---------------------------------------------------------------------
	 * Init C runtime environment.
	 *   - Zero-initialise the .bss section;
	 *   - Copy the data section from NS-BL1U image (stored in ROM) to the
	 *     correct location in RAM.
	 * ---------------------------------------------------------------------
	 */
	ldr	r0, =__BSS_START__
	ldr	r1, =__BSS_SIZE__
	bl	zeromem

	ldr	r0, =__DATA_RAM_START__
	ldr	r1, =__DATA_ROM_START__
	ldr	r2, =__DATA_SIZE__
	bl	memcpy4

	/* ---------------------------------------------------------------------
	 * Allocate a stack whose memory will be marked as Normal
	 * Inner-Shareable, Write-Back, Write-Allocate memory 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.
	 * ---------------------------------------------------------------------
	 */
	ldcopr	r0, MPIDR
	bl	platform_set_stack

	/* ---------------------------------------------------------------------
	 * Perform early platform setup & platform specific early architectural
	 * setup, e.g. MMU setup.
	 * ---------------------------------------------------------------------
	 */
	bl	tftf_early_platform_setup
	bl	tftf_plat_arch_setup

	/* ---------------------------------------------------------------------
	 * Jump to main function.
	 * ---------------------------------------------------------------------
	 */
	bl	ns_bl1u_main
dead:
	b	dead
endfunc ns_bl1u_entrypoint