1//
2//  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
3//
4//  This program and the accompanying materials
5//  are licensed and made available under the terms and conditions of the BSD License
6//  which accompanies this distribution.  The full text of the license may be found at
7//  http://opensource.org/licenses/bsd-license.php
8//
9//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11//
12//
13
14.text
15.align 3
16
17GCC_ASM_EXPORT(ArmCallSmc)
18
19ASM_PFX(ArmCallSmc):
20  // Push x0 on the stack - The stack must always be quad-word aligned
21  str   x0, [sp, #-16]!
22
23  // Load the SMC arguments values into the appropriate registers
24  ldp   x6, x7, [x0, #48]
25  ldp   x4, x5, [x0, #32]
26  ldp   x2, x3, [x0, #16]
27  ldp   x0, x1, [x0, #0]
28
29  smc   #0
30
31  // Pop the ARM_SMC_ARGS structure address from the stack into x9
32  ldr   x9, [sp], #16
33
34  // Store the SMC returned values into the ARM_SMC_ARGS structure.
35  // A SMC call can return up to 4 values - we do not need to store back x4-x7.
36  stp   x2, x3, [x9, #16]
37  stp   x0, x1, [x9, #0]
38
39  mov   x0, x9
40
41  ret
42