]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmSvcLib/AArch64/ArmSvc.S
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Library / ArmSvcLib / AArch64 / ArmSvc.S
1 //
2 // Copyright (c) 2012 - 2020, ARM Limited. All rights reserved.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause-Patent
5 //
6 //
7
8 .text
9 .align 3
10
11 GCC_ASM_EXPORT(ArmCallSvc)
12
13 ASM_PFX(ArmCallSvc):
14 // Push frame pointer and return address on the stack
15 stp x29, x30, [sp, #-32]!
16 mov x29, sp
17
18 // Push x0 on the stack - The stack must always be quad-word aligned
19 str x0, [sp, #16]
20
21 // Load the SVC arguments values into the appropriate registers
22 ldp x6, x7, [x0, #48]
23 ldp x4, x5, [x0, #32]
24 ldp x2, x3, [x0, #16]
25 ldp x0, x1, [x0, #0]
26
27 svc #0
28 // Prevent speculative execution beyond svc instruction
29 dsb nsh
30 isb
31
32 // Pop the ARM_SVC_ARGS structure address from the stack into x9
33 ldr x9, [sp, #16]
34
35 // Store the SVC returned values into the ARM_SVC_ARGS structure.
36 // A SVC call can return up to 8 values
37 stp x0, x1, [x9, #0]
38 stp x2, x3, [x9, #16]
39 stp x4, x5, [x9, #32]
40 stp x6, x7, [x9, #48]
41
42 mov x0, x9
43
44 ldp x29, x30, [sp], #32
45 ret