Home | History | Annotate | Download | only in Arm
      1 //
      2 //  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
      3 //  Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
      4 //
      5 //  This program and the accompanying materials
      6 //  are licensed and made available under the terms and conditions of the BSD License
      7 //  which accompanies this distribution.  The full text of the license may be found at
      8 //  http://opensource.org/licenses/bsd-license.php
      9 //
     10 //  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 //  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 //
     13 //
     14 
     15 #include <AsmMacroIoLibV8.h>
     16 
     17 .arch_extension virt
     18 
     19 ASM_FUNC(ArmCallHvc)
     20     push    {r4-r8}
     21     // r0 will be popped just after the HVC call
     22     push    {r0}
     23 
     24     // Load the HVC arguments values into the appropriate registers
     25     ldr     r7, [r0, #28]
     26     ldr     r6, [r0, #24]
     27     ldr     r5, [r0, #20]
     28     ldr     r4, [r0, #16]
     29     ldr     r3, [r0, #12]
     30     ldr     r2, [r0, #8]
     31     ldr     r1, [r0, #4]
     32     ldr     r0, [r0, #0]
     33 
     34     hvc     #0
     35 
     36     // Pop the ARM_HVC_ARGS structure address from the stack into r8
     37     pop     {r8}
     38 
     39     // Load the HVC returned values into the appropriate registers
     40     // A HVC call can return up to 4 values - we do not need to store back r4-r7.
     41     str     r3, [r8, #12]
     42     str     r2, [r8, #8]
     43     str     r1, [r8, #4]
     44     str     r0, [r8, #0]
     45 
     46     mov     r0, r8
     47 
     48     // Restore the registers r4-r8
     49     pop     {r4-r8}
     50 
     51     bx      lr
     52