• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#include <AsmMacroIoLibV8.h>
15
16.arch_extension sec
17
18ASM_FUNC(ArmCallSmc)
19    push    {r4-r8}
20    // r0 will be popped just after the SMC call
21    push    {r0}
22
23    // Load the SMC arguments values into the appropriate registers
24    ldr     r7, [r0, #28]
25    ldr     r6, [r0, #24]
26    ldr     r5, [r0, #20]
27    ldr     r4, [r0, #16]
28    ldr     r3, [r0, #12]
29    ldr     r2, [r0, #8]
30    ldr     r1, [r0, #4]
31    ldr     r0, [r0, #0]
32
33    smc     #0
34
35    // Pop the ARM_SMC_ARGS structure address from the stack into r8
36    pop     {r8}
37
38    // Load the SMC returned values into the appropriate registers
39    // A SMC call can return up to 4 values - we do not need to store back r4-r7.
40    str     r3, [r8, #12]
41    str     r2, [r8, #8]
42    str     r1, [r8, #4]
43    str     r0, [r8, #0]
44
45    mov     r0, r8
46
47    // Restore the registers r4-r8
48    pop     {r4-r8}
49
50    bx      lr
51