xref: /rk3399_ARM-atf/bl32/sp_min/aarch32/entrypoint.S (revision a1255c758593f9f6fb85b70165fad21de7491e1e)
1c11ba852SSoby Mathew/*
2*a1255c75SYann Gautier * Copyright (c) 2016-2024, 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
121*a1255c75SYann 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
143c11ba852SSoby Mathew	bl	smc_get_next_ctx
144b6285d64SSoby Mathew
145b6285d64SSoby Mathew	/* r0 points to `smc_ctx_t` */
146b6285d64SSoby Mathew	/* The PSCI cpu_context registers have been copied to `smc_ctx_t` */
147c11ba852SSoby Mathew	b	sp_min_exit
148c11ba852SSoby Mathewendfunc sp_min_entrypoint
149c11ba852SSoby Mathew
1503bdf0e5dSYatharth Kochar
1513bdf0e5dSYatharth Kochar/*
1523bdf0e5dSYatharth Kochar * SMC handling function for SP_MIN.
1533bdf0e5dSYatharth Kochar */
1547343505dSDimitris Papastamosfunc sp_min_handle_smc
155b6285d64SSoby Mathew	/* On SMC entry, `sp` points to `smc_ctx_t`. Save `lr`. */
156b6285d64SSoby Mathew	str	lr, [sp, #SMC_CTX_LR_MON]
157b6285d64SSoby Mathew
1580531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
1590531ada5SBence Szépkúti	/*
1600531ada5SBence Szépkúti	 * Read the timestamp value and store it on top of the C runtime stack.
1610531ada5SBence Szépkúti	 * The value will be saved to the per-cpu data once the C stack is
1620531ada5SBence Szépkúti	 * available, as a valid stack is needed to call _cpu_data()
1630531ada5SBence Szépkúti	 */
1640531ada5SBence Szépkúti	strd	r0, r1, [sp, #SMC_CTX_GPREG_R0]
1650531ada5SBence Szépkúti	ldcopr16 r0, r1, CNTPCT_64
1660531ada5SBence Szépkúti	ldr	lr, [sp, #SMC_CTX_SP_MON]
1670531ada5SBence Szépkúti	strd	r0, r1, [lr, #-8]!
1680531ada5SBence Szépkúti	str	lr, [sp, #SMC_CTX_SP_MON]
1690531ada5SBence Szépkúti	ldrd	r0, r1, [sp, #SMC_CTX_GPREG_R0]
1700531ada5SBence Szépkúti#endif
1710531ada5SBence Szépkúti
172085e80ecSAntonio Nino Diaz	smccc_save_gp_mode_regs
1733bdf0e5dSYatharth Kochar
17470896274SEtienne Carriere	clrex_on_monitor_entry
17570896274SEtienne Carriere
1769f3ee61cSSoby Mathew	/*
177b6285d64SSoby Mathew	 * `sp` still points to `smc_ctx_t`. Save it to a register
178b6285d64SSoby Mathew	 * and restore the C runtime stack pointer to `sp`.
1799f3ee61cSSoby Mathew	 */
180b6285d64SSoby Mathew	mov	r2, sp				/* handle */
181b6285d64SSoby Mathew	ldr	sp, [r2, #SMC_CTX_SP_MON]
182b6285d64SSoby Mathew
1830531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
1840531ada5SBence Szépkúti	/* Save handle to a callee saved register */
1850531ada5SBence Szépkúti	mov	r6, r2
1860531ada5SBence Szépkúti
1870531ada5SBence Szépkúti	/*
1880531ada5SBence Szépkúti	 * Restore the timestamp value and store it in per-cpu data. The value
1890531ada5SBence Szépkúti	 * will be extracted from per-cpu data by the C level SMC handler and
1900531ada5SBence Szépkúti	 * saved to the PMF timestamp region.
1910531ada5SBence Szépkúti	 */
1920531ada5SBence Szépkúti	ldrd	r4, r5, [sp], #8
1930531ada5SBence Szépkúti	bl	_cpu_data
1940531ada5SBence Szépkúti	strd	r4, r5, [r0, #CPU_DATA_PMF_TS0_OFFSET]
1950531ada5SBence Szépkúti
1960531ada5SBence Szépkúti	/* Restore handle */
1970531ada5SBence Szépkúti	mov	r2, r6
1980531ada5SBence Szépkúti#endif
1990531ada5SBence Szépkúti
200b6285d64SSoby Mathew	ldr	r0, [r2, #SMC_CTX_SCR]
2013bdf0e5dSYatharth Kochar	and	r3, r0, #SCR_NS_BIT		/* flags */
2023bdf0e5dSYatharth Kochar
2033bdf0e5dSYatharth Kochar	/* Switch to Secure Mode*/
2043bdf0e5dSYatharth Kochar	bic	r0, #SCR_NS_BIT
2053bdf0e5dSYatharth Kochar	stcopr	r0, SCR
2063bdf0e5dSYatharth Kochar	isb
207b6285d64SSoby Mathew
2083bdf0e5dSYatharth Kochar	ldr	r0, [r2, #SMC_CTX_GPREG_R0]	/* smc_fid */
2093bdf0e5dSYatharth Kochar	/* Check whether an SMC64 is issued */
2103bdf0e5dSYatharth Kochar	tst	r0, #(FUNCID_CC_MASK << FUNCID_CC_SHIFT)
211b6285d64SSoby Mathew	beq	1f
212b6285d64SSoby Mathew	/* SMC32 is not detected. Return error back to caller */
2133bdf0e5dSYatharth Kochar	mov	r0, #SMC_UNK
2143bdf0e5dSYatharth Kochar	str	r0, [r2, #SMC_CTX_GPREG_R0]
2153bdf0e5dSYatharth Kochar	mov	r0, r2
216b6285d64SSoby Mathew	b	sp_min_exit
2173bdf0e5dSYatharth Kochar1:
218b6285d64SSoby Mathew	/* SMC32 is detected */
2193bdf0e5dSYatharth Kochar	mov	r1, #0				/* cookie */
2203bdf0e5dSYatharth Kochar	bl	handle_runtime_svc
2213bdf0e5dSYatharth Kochar
222b6285d64SSoby Mathew	/* `r0` points to `smc_ctx_t` */
2233bdf0e5dSYatharth Kochar	b	sp_min_exit
2247343505dSDimitris Papastamosendfunc sp_min_handle_smc
2253bdf0e5dSYatharth Kochar
226c11ba852SSoby Mathew/*
22771816096SEtienne Carriere * Secure Interrupts handling function for SP_MIN.
22871816096SEtienne Carriere */
2297343505dSDimitris Papastamosfunc sp_min_handle_fiq
23071816096SEtienne Carriere#if !SP_MIN_WITH_SECURE_FIQ
23171816096SEtienne Carriere	b plat_panic_handler
23271816096SEtienne Carriere#else
23371816096SEtienne Carriere	/* FIQ has a +4 offset for lr compared to preferred return address */
23471816096SEtienne Carriere	sub	lr, lr, #4
23571816096SEtienne Carriere	/* On SMC entry, `sp` points to `smc_ctx_t`. Save `lr`. */
23671816096SEtienne Carriere	str	lr, [sp, #SMC_CTX_LR_MON]
23771816096SEtienne Carriere
238085e80ecSAntonio Nino Diaz	smccc_save_gp_mode_regs
23971816096SEtienne Carriere
24070896274SEtienne Carriere	clrex_on_monitor_entry
24171816096SEtienne Carriere
24271816096SEtienne Carriere	/* load run-time stack */
24371816096SEtienne Carriere	mov	r2, sp
24471816096SEtienne Carriere	ldr	sp, [r2, #SMC_CTX_SP_MON]
24571816096SEtienne Carriere
24671816096SEtienne Carriere	/* Switch to Secure Mode */
24771816096SEtienne Carriere	ldr	r0, [r2, #SMC_CTX_SCR]
24871816096SEtienne Carriere	bic	r0, #SCR_NS_BIT
24971816096SEtienne Carriere	stcopr	r0, SCR
25071816096SEtienne Carriere	isb
25171816096SEtienne Carriere
25271816096SEtienne Carriere	push	{r2, r3}
25371816096SEtienne Carriere	bl	sp_min_fiq
25471816096SEtienne Carriere	pop	{r0, r3}
25571816096SEtienne Carriere
25671816096SEtienne Carriere	b	sp_min_exit
25771816096SEtienne Carriere#endif
2587343505dSDimitris Papastamosendfunc sp_min_handle_fiq
25971816096SEtienne Carriere
26071816096SEtienne Carriere/*
261c11ba852SSoby Mathew * The Warm boot entrypoint for SP_MIN.
262c11ba852SSoby Mathew */
263c11ba852SSoby Mathewfunc sp_min_warm_entrypoint
2640531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
2650531ada5SBence Szépkúti	/*
2660531ada5SBence Szépkúti	 * This timestamp update happens with cache off.  The next
2670531ada5SBence Szépkúti	 * timestamp collection will need to do cache maintenance prior
2680531ada5SBence Szépkúti	 * to timestamp update.
2690531ada5SBence Szépkúti	 */
2700531ada5SBence Szépkúti	pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_HW_LOW_PWR
2710531ada5SBence Szépkúti	ldcopr16 r2, r3, CNTPCT_64
2720531ada5SBence Szépkúti	strd	r2, r3, [r0]
2730531ada5SBence Szépkúti#endif
2743bdf0e5dSYatharth Kochar	/*
2753bdf0e5dSYatharth Kochar	 * On the warm boot path, most of the EL3 initialisations performed by
2763bdf0e5dSYatharth Kochar	 * 'el3_entrypoint_common' must be skipped:
2773bdf0e5dSYatharth Kochar	 *
2783bdf0e5dSYatharth Kochar	 *  - Only when the platform bypasses the BL1/BL32 (SP_MIN) entrypoint by
27918f2efd6SDavid Cunado	 *    programming the reset address do we need to initialied the SCTLR.
2803bdf0e5dSYatharth Kochar	 *    In other cases, we assume this has been taken care by the
2813bdf0e5dSYatharth Kochar	 *    entrypoint code.
2823bdf0e5dSYatharth Kochar	 *
2833bdf0e5dSYatharth Kochar	 *  - No need to determine the type of boot, we know it is a warm boot.
2843bdf0e5dSYatharth Kochar	 *
2853bdf0e5dSYatharth Kochar	 *  - Do not try to distinguish between primary and secondary CPUs, this
2863bdf0e5dSYatharth Kochar	 *    notion only exists for a cold boot.
2873bdf0e5dSYatharth Kochar	 *
2883bdf0e5dSYatharth Kochar	 *  - No need to initialise the memory or the C runtime environment,
2893bdf0e5dSYatharth Kochar	 *    it has been done once and for all on the cold boot path.
2903bdf0e5dSYatharth Kochar	 */
2913bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
29218f2efd6SDavid Cunado		_init_sctlr=PROGRAMMABLE_RESET_ADDRESS		\
2933bdf0e5dSYatharth Kochar		_warm_boot_mailbox=0				\
2943bdf0e5dSYatharth Kochar		_secondary_cold_boot=0				\
2953bdf0e5dSYatharth Kochar		_init_memory=0					\
2963bdf0e5dSYatharth Kochar		_init_c_runtime=0				\
2974324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
2984324a14bSYann Gautier		_pie_fixup_size=0
299c11ba852SSoby Mathew
30025a93f7cSJeenu Viswambharan	/*
30125a93f7cSJeenu Viswambharan	 * We're about to enable MMU and participate in PSCI state coordination.
30225a93f7cSJeenu Viswambharan	 *
30325a93f7cSJeenu Viswambharan	 * The PSCI implementation invokes platform routines that enable CPUs to
30425a93f7cSJeenu Viswambharan	 * participate in coherency. On a system where CPUs are not
305bcc3c49cSSoby Mathew	 * cache-coherent without appropriate platform specific programming,
306bcc3c49cSSoby Mathew	 * having caches enabled until such time might lead to coherency issues
307bcc3c49cSSoby Mathew	 * (resulting from stale data getting speculatively fetched, among
308bcc3c49cSSoby Mathew	 * others). Therefore we keep data caches disabled even after enabling
309bcc3c49cSSoby Mathew	 * the MMU for such platforms.
31025a93f7cSJeenu Viswambharan	 *
311bcc3c49cSSoby Mathew	 * On systems with hardware-assisted coherency, or on single cluster
312bcc3c49cSSoby Mathew	 * platforms, such platform specific programming is not required to
313bcc3c49cSSoby Mathew	 * enter coherency (as CPUs already are); and there's no reason to have
314bcc3c49cSSoby Mathew	 * caches disabled either.
315c11ba852SSoby Mathew	 */
31664ee263eSJeenu Viswambharan#if HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY
31764ee263eSJeenu Viswambharan	mov	r0, #0
31864ee263eSJeenu Viswambharan#else
319c11ba852SSoby Mathew	mov	r0, #DISABLE_DCACHE
32064ee263eSJeenu Viswambharan#endif
321c11ba852SSoby Mathew	bl	bl32_plat_enable_mmu
322c11ba852SSoby Mathew
32371816096SEtienne Carriere#if SP_MIN_WITH_SECURE_FIQ
32471816096SEtienne Carriere	route_fiq_to_sp_min r0
32571816096SEtienne Carriere#endif
32671816096SEtienne Carriere
327c11ba852SSoby Mathew	bl	sp_min_warm_boot
328c11ba852SSoby Mathew	bl	smc_get_next_ctx
329b6285d64SSoby Mathew	/* r0 points to `smc_ctx_t` */
330b6285d64SSoby Mathew	/* The PSCI cpu_context registers have been copied to `smc_ctx_t` */
3310531ada5SBence Szépkúti
3320531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
3330531ada5SBence Szépkúti	/* Save smc_ctx_t */
3340531ada5SBence Szépkúti	mov	r5, r0
3350531ada5SBence Szépkúti
3360531ada5SBence Szépkúti	pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_PSCI
3370531ada5SBence Szépkúti	mov	r4, r0
3380531ada5SBence Szépkúti
3390531ada5SBence Szépkúti	/*
3400531ada5SBence Szépkúti	 * Invalidate before updating timestamp to ensure previous timestamp
3410531ada5SBence Szépkúti	 * updates on the same cache line with caches disabled are properly
3420531ada5SBence Szépkúti	 * seen by the same core. Without the cache invalidate, the core might
3430531ada5SBence Szépkúti	 * write into a stale cache line.
3440531ada5SBence Szépkúti	 */
3450531ada5SBence Szépkúti	mov	r1, #PMF_TS_SIZE
3460531ada5SBence Szépkúti	bl	inv_dcache_range
3470531ada5SBence Szépkúti
3480531ada5SBence Szépkúti	ldcopr16 r0, r1, CNTPCT_64
3490531ada5SBence Szépkúti	strd	r0, r1, [r4]
3500531ada5SBence Szépkúti
3510531ada5SBence Szépkúti	/* Restore smc_ctx_t */
3520531ada5SBence Szépkúti	mov	r0, r5
3530531ada5SBence Szépkúti#endif
3540531ada5SBence Szépkúti
355c11ba852SSoby Mathew	b	sp_min_exit
356c11ba852SSoby Mathewendfunc sp_min_warm_entrypoint
357c11ba852SSoby Mathew
358c11ba852SSoby Mathew/*
359c11ba852SSoby Mathew * The function to restore the registers from SMC context and return
360c11ba852SSoby Mathew * to the mode restored to SPSR.
361c11ba852SSoby Mathew *
362c11ba852SSoby Mathew * Arguments : r0 must point to the SMC context to restore from.
363c11ba852SSoby Mathew */
364c11ba852SSoby Mathewfunc sp_min_exit
365b6285d64SSoby Mathew	monitor_exit
366c11ba852SSoby Mathewendfunc sp_min_exit
367