plat_trampoline.S 2.53 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/*
 * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch.h>
#include <asm_macros.S>
#include <plat/common/common_def.h>
#include <memctrl_v2.h>
#include <tegra_def.h>

13
#define TEGRA194_SMMU_CTX_SIZE		0x490
14
15

	.align 4
16
	.globl	tegra194_cpu_reset_handler
17
18

/* CPU reset handler routine */
19
func tegra194_cpu_reset_handler
20
21
22
23
24
25
26
27
28
29
30
31
	/*
	 * The TZRAM loses state during System Suspend. We use this
	 * information to decide if the reset handler is running after a
	 * System Suspend. Resume from system suspend requires restoring
	 * the entire state from TZDRAM to TZRAM.
	 */
	mov	x0, #BL31_BASE
	ldr	x0, [x0]
	cbnz	x0, boot_cpu

	/* resume from system suspend */
	mov	x0, #BL31_BASE
32
33
	adr	x1, __tegra194_cpu_reset_handler_end
	adr	x2, __tegra194_cpu_reset_handler_data
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	ldr	x2, [x2, #8]

	/* memcpy16 */
m_loop16:
	cmp	x2, #16
	b.lt	m_loop1
	ldp	x3, x4, [x1], #16
	stp	x3, x4, [x0], #16
	sub	x2, x2, #16
	b	m_loop16
	/* copy byte per byte */
m_loop1:
	cbz	x2, boot_cpu
	ldrb	w3, [x1], #1
	strb	w3, [x0], #1
	subs	x2, x2, #1
	b.ne	m_loop1

boot_cpu:
53
	adr	x0, __tegra194_cpu_reset_handler_data
54
55
	ldr	x0, [x0]
	br	x0
56
endfunc tegra194_cpu_reset_handler
57
58

	/*
59
	 * Tegra194 reset data (offset 0x0 - 0x2490)
60
	 *
61
62
63
64
	 * 0x0000: secure world's entrypoint
	 * 0x0008: BL31 size (RO + RW)
	 * 0x0010: SMMU context start
	 * 0x2490: SMMU context end
65
66
67
	 */

	.align 4
68
69
70
	.type	__tegra194_cpu_reset_handler_data, %object
	.globl	__tegra194_cpu_reset_handler_data
__tegra194_cpu_reset_handler_data:
71
72
	.quad	tegra_secure_entrypoint
	.quad	__BL31_END__ - BL31_BASE
73
74
75

	.align 4
__tegra194_smmu_context:
76
	.rept	TEGRA194_SMMU_CTX_SIZE
77
78
	.quad	0
	.endr
79
80
	.size	__tegra194_cpu_reset_handler_data, \
		. - __tegra194_cpu_reset_handler_data
81
82

	.align 4
83
84
	.globl	__tegra194_cpu_reset_handler_end
__tegra194_cpu_reset_handler_end:
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

	.globl tegra194_get_cpu_reset_handler_size
	.globl tegra194_get_cpu_reset_handler_base
	.globl tegra194_get_smmu_ctx_offset

/* return size of the CPU reset handler */
func tegra194_get_cpu_reset_handler_size
	adr	x0, __tegra194_cpu_reset_handler_end
	adr	x1, tegra194_cpu_reset_handler
	sub	x0, x0, x1
	ret
endfunc tegra194_get_cpu_reset_handler_size

/* return the start address of the CPU reset handler */
func tegra194_get_cpu_reset_handler_base
	adr	x0, tegra194_cpu_reset_handler
	ret
endfunc tegra194_get_cpu_reset_handler_base

/* return the size of the SMMU context */
func tegra194_get_smmu_ctx_offset
	adr	x0, __tegra194_smmu_context
	adr	x1, tegra194_cpu_reset_handler
	sub	x0, x0, x1
	ret
endfunc tegra194_get_smmu_ctx_offset