• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020, Google Inc. All rights reserved
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#include <asm.h>
25
26.macro smc8_hvc8, instr
27    /* Save stack location where r3-r7 smc/hvc arguments are stored */
28    mov     r12, sp
29
30    /* Save original r4-r7 values as caller expects these to be preserved */
31    push    {r4-r7}
32
33    /* Save return value pointer and return address */
34    push    {r0, lr}
35
36    /* arm abi shifts arguments when returning a struct, shift them back */
37    mov     r0, r1
38    mov     r1, r2
39    mov     r2, r3
40
41    /* Load stack based arguments */
42    ldmia   r12, {r3-r7}
43
44    \instr  #0
45
46    /* Restore return address and get return value pointer */
47    pop     {r12, lr}
48
49    /* Copy 8-register smc return value to struct smc_ret8 return value */
50    stmia   r12, {r0-r7}
51
52    /* Restore original r4-r7 values */
53    pop     {r4-r7}
54
55    /* Return */
56    bx      lr
57.endm
58
59FUNCTION(smc8)
60    smc8_hvc8 smc
61
62FUNCTION(hvc8)
63    smc8_hvc8 hvc
64