summaryrefslogtreecommitdiff
path: root/src/mainboard/emulation/qemu-sbsa/bootblock_custom.S
blob: c05afed5ff29713d8202635738b29942142ea081 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

/*
 * Early initialization code for sbsa-ref machine
 */

#include <arch/asm.h>

ENTRY(_start)

	/* TF-A arg which contains a pointer to fdt */
	ldr	x1, =_fdt_pointer
	str	x0, [x1]

	/* Setup CPU. */
	/* bl      arm64_init_cpu */

	/* ==== stack init from arm64_init_cpu ==== */

	msr SPSel, #0 /* use SP_EL0 */

	ldr	x2, =0xdeadbeefdeadbeef
	ldr	x0, =_stack
	ldr	x1, =_estack
1:
	stp	x2, x2, [x0], #16
	cmp	x0, x1
	bne	1b

	sub	sp, x0, #16

	/* ==== END ==== */

	/* Get code positions. */
	ldr	x1, =_flash
	ldr	x0, =_bootblock

	/* Calculate bootblock size. */
	ldr     x2, =_ebootblock
	sub     x2, x2, x0

	/* Call memcpy in arch/arm64/memcpy.S */
	bl	memcpy
	dmb     sy

	/* Calculate relocation offset between bootblock in flash and in DRAM. */
	ldr	x0, =_flash
	ldr	x1, =_bootblock
	sub	x1, x1, x0

	/* Jump to main() in DRAM. */
	adr	x0, main
	add	x0, x0, x1
	blr	x0
ENDPROC(_start)