xref: /rk3399_ARM-atf/bl32/sp_min/aarch32/entrypoint.S (revision 7303319b3823e9e33748d963e9173f3678aba4da)
1c11ba852SSoby Mathew/*
24779becdSBoyan Karatotev * Copyright (c) 2016-2025, Arm Limited and Contributors. All rights reserved.
3c11ba852SSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5c11ba852SSoby Mathew */
6c11ba852SSoby Mathew
7c11ba852SSoby Mathew#include <arch.h>
8c11ba852SSoby Mathew#include <asm_macros.S>
909d40e0eSAntonio Nino Diaz#include <common/bl_common.h>
1009d40e0eSAntonio Nino Diaz#include <common/runtime_svc.h>
11c11ba852SSoby Mathew#include <context.h>
123bdf0e5dSYatharth Kochar#include <el3_common_macros.S>
130531ada5SBence Szépkúti#include <lib/el3_runtime/cpu_data.h>
140531ada5SBence Szépkúti#include <lib/pmf/aarch32/pmf_asm_macros.S>
150531ada5SBence Szépkúti#include <lib/runtime_instr.h>
1609d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
17085e80ecSAntonio Nino Diaz#include <smccc_helpers.h>
18085e80ecSAntonio Nino Diaz#include <smccc_macros.S>
19c11ba852SSoby Mathew
20c11ba852SSoby Mathew	.globl	sp_min_vector_table
21c11ba852SSoby Mathew	.globl	sp_min_entrypoint
22c11ba852SSoby Mathew	.globl	sp_min_warm_entrypoint
237343505dSDimitris Papastamos	.globl	sp_min_handle_smc
247343505dSDimitris Papastamos	.globl	sp_min_handle_fiq
25c11ba852SSoby Mathew
264324a14bSYann Gautier#define FIXUP_SIZE	((BL32_LIMIT) - (BL32_BASE))
274324a14bSYann Gautier
2871816096SEtienne Carriere	.macro route_fiq_to_sp_min reg
2971816096SEtienne Carriere		/* -----------------------------------------------------
3071816096SEtienne Carriere		 * FIQs are secure interrupts trapped by Monitor and non
3171816096SEtienne Carriere		 * secure is not allowed to mask the FIQs.
3271816096SEtienne Carriere		 * -----------------------------------------------------
3371816096SEtienne Carriere		 */
3471816096SEtienne Carriere		ldcopr	\reg, SCR
3571816096SEtienne Carriere		orr	\reg, \reg, #SCR_FIQ_BIT
3671816096SEtienne Carriere		bic	\reg, \reg, #SCR_FW_BIT
3771816096SEtienne Carriere		stcopr	\reg, SCR
3871816096SEtienne Carriere	.endm
393bdf0e5dSYatharth Kochar
4070896274SEtienne Carriere	.macro clrex_on_monitor_entry
4170896274SEtienne Carriere#if (ARM_ARCH_MAJOR == 7)
4270896274SEtienne Carriere	/*
4370896274SEtienne Carriere	 * ARMv7 architectures need to clear the exclusive access when
4470896274SEtienne Carriere	 * entering Monitor mode.
4570896274SEtienne Carriere	 */
4670896274SEtienne Carriere	clrex
4770896274SEtienne Carriere#endif
4870896274SEtienne Carriere	.endm
4970896274SEtienne Carriere
503bdf0e5dSYatharth Kocharvector_base sp_min_vector_table
51c11ba852SSoby Mathew	b	sp_min_entrypoint
52c11ba852SSoby Mathew	b	plat_panic_handler	/* Undef */
537343505dSDimitris Papastamos	b	sp_min_handle_smc	/* Syscall */
546dc5979aSYann Gautier	b	report_prefetch_abort	/* Prefetch abort */
556dc5979aSYann Gautier	b	report_data_abort	/* Data abort */
56c11ba852SSoby Mathew	b	plat_panic_handler	/* Reserved */
57c11ba852SSoby Mathew	b	plat_panic_handler	/* IRQ */
587343505dSDimitris Papastamos	b	sp_min_handle_fiq	/* FIQ */
59c11ba852SSoby Mathew
60c11ba852SSoby Mathew
61c11ba852SSoby Mathew/*
62c11ba852SSoby Mathew * The Cold boot/Reset entrypoint for SP_MIN
63c11ba852SSoby Mathew */
64c11ba852SSoby Mathewfunc sp_min_entrypoint
653bdf0e5dSYatharth Kochar	/* ---------------------------------------------------------------
6656055e87SStephan Gerhold	 * Stash the previous bootloader arguments r0 - r3 for later use.
673bdf0e5dSYatharth Kochar	 * ---------------------------------------------------------------
68c11ba852SSoby Mathew	 */
69a6f340feSSoby Mathew	mov	r9, r0
70a6f340feSSoby Mathew	mov	r10, r1
71a6f340feSSoby Mathew	mov	r11, r2
72a6f340feSSoby Mathew	mov	r12, r3
73c11ba852SSoby Mathew
7456055e87SStephan Gerhold#if !RESET_TO_SP_MIN
753bdf0e5dSYatharth Kochar	/* ---------------------------------------------------------------------
763bdf0e5dSYatharth Kochar	 * For !RESET_TO_SP_MIN systems, only the primary CPU ever reaches
773bdf0e5dSYatharth Kochar	 * sp_min_entrypoint() during the cold boot flow, so the cold/warm boot
783bdf0e5dSYatharth Kochar	 * and primary/secondary CPU logic should not be executed in this case.
793bdf0e5dSYatharth Kochar	 *
8018f2efd6SDavid Cunado	 * Also, assume that the previous bootloader has already initialised the
8118f2efd6SDavid Cunado	 * SCTLR, including the CPU endianness, and has initialised the memory.
823bdf0e5dSYatharth Kochar	 * ---------------------------------------------------------------------
83c11ba852SSoby Mathew	 */
843bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
8518f2efd6SDavid Cunado		_init_sctlr=0					\
863bdf0e5dSYatharth Kochar		_warm_boot_mailbox=0				\
873bdf0e5dSYatharth Kochar		_secondary_cold_boot=0				\
883bdf0e5dSYatharth Kochar		_init_memory=0					\
893bdf0e5dSYatharth Kochar		_init_c_runtime=1				\
904324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
914324a14bSYann Gautier		_pie_fixup_size=FIXUP_SIZE
923bdf0e5dSYatharth Kochar#else
933bdf0e5dSYatharth Kochar	/* ---------------------------------------------------------------------
943bdf0e5dSYatharth Kochar	 * For RESET_TO_SP_MIN systems which have a programmable reset address,
953bdf0e5dSYatharth Kochar	 * sp_min_entrypoint() is executed only on the cold boot path so we can
963bdf0e5dSYatharth Kochar	 * skip the warm boot mailbox mechanism.
973bdf0e5dSYatharth Kochar	 * ---------------------------------------------------------------------
98c11ba852SSoby Mathew	 */
993bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
10018f2efd6SDavid Cunado		_init_sctlr=1					\
1013bdf0e5dSYatharth Kochar		_warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS	\
1023bdf0e5dSYatharth Kochar		_secondary_cold_boot=!COLD_BOOT_SINGLE_CPU	\
1033bdf0e5dSYatharth Kochar		_init_memory=1					\
1043bdf0e5dSYatharth Kochar		_init_c_runtime=1				\
1054324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
1064324a14bSYann Gautier		_pie_fixup_size=FIXUP_SIZE
1073bdf0e5dSYatharth Kochar#endif /* RESET_TO_SP_MIN */
108c11ba852SSoby Mathew
10971816096SEtienne Carriere#if SP_MIN_WITH_SECURE_FIQ
11071816096SEtienne Carriere	route_fiq_to_sp_min r4
11171816096SEtienne Carriere#endif
11271816096SEtienne Carriere
11356055e87SStephan Gerhold	/* ---------------------------------------------------------------------
11456055e87SStephan Gerhold	 * Relay the previous bootloader's arguments to the platform layer
11556055e87SStephan Gerhold	 * ---------------------------------------------------------------------
11656055e87SStephan Gerhold	 */
117a6f340feSSoby Mathew	mov	r0, r9
118a6f340feSSoby Mathew	mov	r1, r10
119a6f340feSSoby Mathew	mov	r2, r11
120a6f340feSSoby Mathew	mov	r3, r12
121a1255c75SYann Gautier	bl	sp_min_setup
122c11ba852SSoby Mathew
123c11ba852SSoby Mathew	/* Jump to the main function */
124c11ba852SSoby Mathew	bl	sp_min_main
125c11ba852SSoby Mathew
126c11ba852SSoby Mathew	/* -------------------------------------------------------------
127c11ba852SSoby Mathew	 * Clean the .data & .bss sections to main memory. This ensures
128c11ba852SSoby Mathew	 * that any global data which was initialised by the primary CPU
129c11ba852SSoby Mathew	 * is visible to secondary CPUs before they enable their data
130c11ba852SSoby Mathew	 * caches and participate in coherency.
131c11ba852SSoby Mathew	 * -------------------------------------------------------------
132c11ba852SSoby Mathew	 */
133c11ba852SSoby Mathew	ldr	r0, =__DATA_START__
134c11ba852SSoby Mathew	ldr	r1, =__DATA_END__
135c11ba852SSoby Mathew	sub	r1, r1, r0
136c11ba852SSoby Mathew	bl	clean_dcache_range
137c11ba852SSoby Mathew
138c11ba852SSoby Mathew	ldr	r0, =__BSS_START__
139c11ba852SSoby Mathew	ldr	r1, =__BSS_END__
140c11ba852SSoby Mathew	sub	r1, r1, r0
141c11ba852SSoby Mathew	bl	clean_dcache_range
142c11ba852SSoby Mathew
143*98859b99SSammit Joshi	ldr	r0, =__PER_CPU_START__
144*98859b99SSammit Joshi	ldr	r1, =__PER_CPU_END__
145*98859b99SSammit Joshi	sub	r1, r1, r0
146*98859b99SSammit Joshi	bl	clean_dcache_range
147*98859b99SSammit Joshi
148c11ba852SSoby Mathew	bl	smc_get_next_ctx
149b6285d64SSoby Mathew
150b6285d64SSoby Mathew	/* r0 points to `smc_ctx_t` */
151b6285d64SSoby Mathew	/* The PSCI cpu_context registers have been copied to `smc_ctx_t` */
152c11ba852SSoby Mathew	b	sp_min_exit
153c11ba852SSoby Mathewendfunc sp_min_entrypoint
154c11ba852SSoby Mathew
1553bdf0e5dSYatharth Kochar
1563bdf0e5dSYatharth Kochar/*
1573bdf0e5dSYatharth Kochar * SMC handling function for SP_MIN.
1583bdf0e5dSYatharth Kochar */
1597343505dSDimitris Papastamosfunc sp_min_handle_smc
160b6285d64SSoby Mathew	/* On SMC entry, `sp` points to `smc_ctx_t`. Save `lr`. */
161b6285d64SSoby Mathew	str	lr, [sp, #SMC_CTX_LR_MON]
162b6285d64SSoby Mathew
1630531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
1640531ada5SBence Szépkúti	/*
1650531ada5SBence Szépkúti	 * Read the timestamp value and store it on top of the C runtime stack.
1660531ada5SBence Szépkúti	 * The value will be saved to the per-cpu data once the C stack is
1670531ada5SBence Szépkúti	 * available, as a valid stack is needed to call _cpu_data()
1680531ada5SBence Szépkúti	 */
1690531ada5SBence Szépkúti	strd	r0, r1, [sp, #SMC_CTX_GPREG_R0]
1700531ada5SBence Szépkúti	ldcopr16 r0, r1, CNTPCT_64
1710531ada5SBence Szépkúti	ldr	lr, [sp, #SMC_CTX_SP_MON]
1720531ada5SBence Szépkúti	strd	r0, r1, [lr, #-8]!
1730531ada5SBence Szépkúti	str	lr, [sp, #SMC_CTX_SP_MON]
1740531ada5SBence Szépkúti	ldrd	r0, r1, [sp, #SMC_CTX_GPREG_R0]
1750531ada5SBence Szépkúti#endif
1760531ada5SBence Szépkúti
177085e80ecSAntonio Nino Diaz	smccc_save_gp_mode_regs
1783bdf0e5dSYatharth Kochar
17970896274SEtienne Carriere	clrex_on_monitor_entry
18070896274SEtienne Carriere
1819f3ee61cSSoby Mathew	/*
182b6285d64SSoby Mathew	 * `sp` still points to `smc_ctx_t`. Save it to a register
183b6285d64SSoby Mathew	 * and restore the C runtime stack pointer to `sp`.
1849f3ee61cSSoby Mathew	 */
185b6285d64SSoby Mathew	mov	r2, sp				/* handle */
186b6285d64SSoby Mathew	ldr	sp, [r2, #SMC_CTX_SP_MON]
187b6285d64SSoby Mathew
1880531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
1890531ada5SBence Szépkúti	/* Save handle to a callee saved register */
1900531ada5SBence Szépkúti	mov	r6, r2
1910531ada5SBence Szépkúti
1920531ada5SBence Szépkúti	/*
1930531ada5SBence Szépkúti	 * Restore the timestamp value and store it in per-cpu data. The value
1940531ada5SBence Szépkúti	 * will be extracted from per-cpu data by the C level SMC handler and
1950531ada5SBence Szépkúti	 * saved to the PMF timestamp region.
1960531ada5SBence Szépkúti	 */
1970531ada5SBence Szépkúti	ldrd	r4, r5, [sp], #8
1980531ada5SBence Szépkúti	bl	_cpu_data
1994779becdSBoyan Karatotev	strd	r4, r5, [r0, #CPU_DATA_CPU_DATA_PMF_TS]
2000531ada5SBence Szépkúti
2010531ada5SBence Szépkúti	/* Restore handle */
2020531ada5SBence Szépkúti	mov	r2, r6
2030531ada5SBence Szépkúti#endif
2040531ada5SBence Szépkúti
205b6285d64SSoby Mathew	ldr	r0, [r2, #SMC_CTX_SCR]
2063bdf0e5dSYatharth Kochar	and	r3, r0, #SCR_NS_BIT		/* flags */
2073bdf0e5dSYatharth Kochar
2083bdf0e5dSYatharth Kochar	/* Switch to Secure Mode*/
2093bdf0e5dSYatharth Kochar	bic	r0, #SCR_NS_BIT
2103bdf0e5dSYatharth Kochar	stcopr	r0, SCR
2113bdf0e5dSYatharth Kochar	isb
212b6285d64SSoby Mathew
2133bdf0e5dSYatharth Kochar	ldr	r0, [r2, #SMC_CTX_GPREG_R0]	/* smc_fid */
2143bdf0e5dSYatharth Kochar	/* Check whether an SMC64 is issued */
2153bdf0e5dSYatharth Kochar	tst	r0, #(FUNCID_CC_MASK << FUNCID_CC_SHIFT)
216b6285d64SSoby Mathew	beq	1f
217b6285d64SSoby Mathew	/* SMC32 is not detected. Return error back to caller */
2183bdf0e5dSYatharth Kochar	mov	r0, #SMC_UNK
2193bdf0e5dSYatharth Kochar	str	r0, [r2, #SMC_CTX_GPREG_R0]
2203bdf0e5dSYatharth Kochar	mov	r0, r2
221b6285d64SSoby Mathew	b	sp_min_exit
2223bdf0e5dSYatharth Kochar1:
223b6285d64SSoby Mathew	/* SMC32 is detected */
2243bdf0e5dSYatharth Kochar	mov	r1, #0				/* cookie */
2253bdf0e5dSYatharth Kochar	bl	handle_runtime_svc
2263bdf0e5dSYatharth Kochar
227b6285d64SSoby Mathew	/* `r0` points to `smc_ctx_t` */
2283bdf0e5dSYatharth Kochar	b	sp_min_exit
2297343505dSDimitris Papastamosendfunc sp_min_handle_smc
2303bdf0e5dSYatharth Kochar
231c11ba852SSoby Mathew/*
23271816096SEtienne Carriere * Secure Interrupts handling function for SP_MIN.
23371816096SEtienne Carriere */
2347343505dSDimitris Papastamosfunc sp_min_handle_fiq
23571816096SEtienne Carriere#if !SP_MIN_WITH_SECURE_FIQ
23671816096SEtienne Carriere	b plat_panic_handler
23771816096SEtienne Carriere#else
23871816096SEtienne Carriere	/* FIQ has a +4 offset for lr compared to preferred return address */
23971816096SEtienne Carriere	sub	lr, lr, #4
24071816096SEtienne Carriere	/* On SMC entry, `sp` points to `smc_ctx_t`. Save `lr`. */
24171816096SEtienne Carriere	str	lr, [sp, #SMC_CTX_LR_MON]
24271816096SEtienne Carriere
243085e80ecSAntonio Nino Diaz	smccc_save_gp_mode_regs
24471816096SEtienne Carriere
24570896274SEtienne Carriere	clrex_on_monitor_entry
24671816096SEtienne Carriere
24771816096SEtienne Carriere	/* load run-time stack */
24871816096SEtienne Carriere	mov	r2, sp
24971816096SEtienne Carriere	ldr	sp, [r2, #SMC_CTX_SP_MON]
25071816096SEtienne Carriere
25171816096SEtienne Carriere	/* Switch to Secure Mode */
25271816096SEtienne Carriere	ldr	r0, [r2, #SMC_CTX_SCR]
25371816096SEtienne Carriere	bic	r0, #SCR_NS_BIT
25471816096SEtienne Carriere	stcopr	r0, SCR
25571816096SEtienne Carriere	isb
25671816096SEtienne Carriere
25771816096SEtienne Carriere	push	{r2, r3}
25871816096SEtienne Carriere	bl	sp_min_fiq
25971816096SEtienne Carriere	pop	{r0, r3}
26071816096SEtienne Carriere
26171816096SEtienne Carriere	b	sp_min_exit
26271816096SEtienne Carriere#endif
2637343505dSDimitris Papastamosendfunc sp_min_handle_fiq
26471816096SEtienne Carriere
26571816096SEtienne Carriere/*
266c11ba852SSoby Mathew * The Warm boot entrypoint for SP_MIN.
267c11ba852SSoby Mathew */
268c11ba852SSoby Mathewfunc sp_min_warm_entrypoint
2690531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
2700531ada5SBence Szépkúti	/*
2710531ada5SBence Szépkúti	 * This timestamp update happens with cache off.  The next
2720531ada5SBence Szépkúti	 * timestamp collection will need to do cache maintenance prior
2730531ada5SBence Szépkúti	 * to timestamp update.
2740531ada5SBence Szépkúti	 */
2750531ada5SBence Szépkúti	pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_HW_LOW_PWR
2760531ada5SBence Szépkúti	ldcopr16 r2, r3, CNTPCT_64
2770531ada5SBence Szépkúti	strd	r2, r3, [r0]
2780531ada5SBence Szépkúti#endif
2793bdf0e5dSYatharth Kochar	/*
2803bdf0e5dSYatharth Kochar	 * On the warm boot path, most of the EL3 initialisations performed by
2813bdf0e5dSYatharth Kochar	 * 'el3_entrypoint_common' must be skipped:
2823bdf0e5dSYatharth Kochar	 *
2833bdf0e5dSYatharth Kochar	 *  - Only when the platform bypasses the BL1/BL32 (SP_MIN) entrypoint by
28418f2efd6SDavid Cunado	 *    programming the reset address do we need to initialied the SCTLR.
2853bdf0e5dSYatharth Kochar	 *    In other cases, we assume this has been taken care by the
2863bdf0e5dSYatharth Kochar	 *    entrypoint code.
2873bdf0e5dSYatharth Kochar	 *
2883bdf0e5dSYatharth Kochar	 *  - No need to determine the type of boot, we know it is a warm boot.
2893bdf0e5dSYatharth Kochar	 *
2903bdf0e5dSYatharth Kochar	 *  - Do not try to distinguish between primary and secondary CPUs, this
2913bdf0e5dSYatharth Kochar	 *    notion only exists for a cold boot.
2923bdf0e5dSYatharth Kochar	 *
2933bdf0e5dSYatharth Kochar	 *  - No need to initialise the memory or the C runtime environment,
2943bdf0e5dSYatharth Kochar	 *    it has been done once and for all on the cold boot path.
2953bdf0e5dSYatharth Kochar	 */
2963bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
29718f2efd6SDavid Cunado		_init_sctlr=PROGRAMMABLE_RESET_ADDRESS		\
2983bdf0e5dSYatharth Kochar		_warm_boot_mailbox=0				\
2993bdf0e5dSYatharth Kochar		_secondary_cold_boot=0				\
3003bdf0e5dSYatharth Kochar		_init_memory=0					\
3013bdf0e5dSYatharth Kochar		_init_c_runtime=0				\
3024324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
3034324a14bSYann Gautier		_pie_fixup_size=0
304c11ba852SSoby Mathew
30525a93f7cSJeenu Viswambharan	/*
30625a93f7cSJeenu Viswambharan	 * We're about to enable MMU and participate in PSCI state coordination.
30725a93f7cSJeenu Viswambharan	 *
30825a93f7cSJeenu Viswambharan	 * The PSCI implementation invokes platform routines that enable CPUs to
30925a93f7cSJeenu Viswambharan	 * participate in coherency. On a system where CPUs are not
310bcc3c49cSSoby Mathew	 * cache-coherent without appropriate platform specific programming,
311bcc3c49cSSoby Mathew	 * having caches enabled until such time might lead to coherency issues
312bcc3c49cSSoby Mathew	 * (resulting from stale data getting speculatively fetched, among
313bcc3c49cSSoby Mathew	 * others). Therefore we keep data caches disabled even after enabling
314bcc3c49cSSoby Mathew	 * the MMU for such platforms.
31525a93f7cSJeenu Viswambharan	 *
316bcc3c49cSSoby Mathew	 * On systems with hardware-assisted coherency, or on single cluster
317bcc3c49cSSoby Mathew	 * platforms, such platform specific programming is not required to
318bcc3c49cSSoby Mathew	 * enter coherency (as CPUs already are); and there's no reason to have
319bcc3c49cSSoby Mathew	 * caches disabled either.
320c11ba852SSoby Mathew	 */
32164ee263eSJeenu Viswambharan#if HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY
32264ee263eSJeenu Viswambharan	mov	r0, #0
32364ee263eSJeenu Viswambharan#else
324c11ba852SSoby Mathew	mov	r0, #DISABLE_DCACHE
32564ee263eSJeenu Viswambharan#endif
326c11ba852SSoby Mathew	bl	bl32_plat_enable_mmu
327c11ba852SSoby Mathew
32871816096SEtienne Carriere#if SP_MIN_WITH_SECURE_FIQ
32971816096SEtienne Carriere	route_fiq_to_sp_min r0
33071816096SEtienne Carriere#endif
33171816096SEtienne Carriere
332c11ba852SSoby Mathew	bl	sp_min_warm_boot
333c11ba852SSoby Mathew	bl	smc_get_next_ctx
334b6285d64SSoby Mathew	/* r0 points to `smc_ctx_t` */
335b6285d64SSoby Mathew	/* The PSCI cpu_context registers have been copied to `smc_ctx_t` */
3360531ada5SBence Szépkúti
3370531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
3380531ada5SBence Szépkúti	/* Save smc_ctx_t */
3390531ada5SBence Szépkúti	mov	r5, r0
3400531ada5SBence Szépkúti
3410531ada5SBence Szépkúti	pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_PSCI
3420531ada5SBence Szépkúti	mov	r4, r0
3430531ada5SBence Szépkúti
3440531ada5SBence Szépkúti	/*
3450531ada5SBence Szépkúti	 * Invalidate before updating timestamp to ensure previous timestamp
3460531ada5SBence Szépkúti	 * updates on the same cache line with caches disabled are properly
3470531ada5SBence Szépkúti	 * seen by the same core. Without the cache invalidate, the core might
3480531ada5SBence Szépkúti	 * write into a stale cache line.
3490531ada5SBence Szépkúti	 */
3500531ada5SBence Szépkúti	mov	r1, #PMF_TS_SIZE
3510531ada5SBence Szépkúti	bl	inv_dcache_range
3520531ada5SBence Szépkúti
3530531ada5SBence Szépkúti	ldcopr16 r0, r1, CNTPCT_64
3540531ada5SBence Szépkúti	strd	r0, r1, [r4]
3550531ada5SBence Szépkúti
3560531ada5SBence Szépkúti	/* Restore smc_ctx_t */
3570531ada5SBence Szépkúti	mov	r0, r5
3580531ada5SBence Szépkúti#endif
3590531ada5SBence Szépkúti
360c11ba852SSoby Mathew	b	sp_min_exit
361c11ba852SSoby Mathewendfunc sp_min_warm_entrypoint
362c11ba852SSoby Mathew
363c11ba852SSoby Mathew/*
364c11ba852SSoby Mathew * The function to restore the registers from SMC context and return
365c11ba852SSoby Mathew * to the mode restored to SPSR.
366c11ba852SSoby Mathew *
367c11ba852SSoby Mathew * Arguments : r0 must point to the SMC context to restore from.
368c11ba852SSoby Mathew */
369c11ba852SSoby Mathewfunc sp_min_exit
370b6285d64SSoby Mathew	monitor_exit
371c11ba852SSoby Mathewendfunc sp_min_exit
372