]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S
ArmPkg: Add ArmHvcLib
[mirror_edk2.git] / ArmPkg / Library / ArmHvcLib / Arm / ArmHvc.S
1 //
2 // Copyright (c) 2012-2014, ARM Limited. All rights reserved.
3 // Copyright (c) 2014, 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 .text
16 .align 3
17 .arch_extension virt
18
19 GCC_ASM_EXPORT(ArmCallHvc)
20
21 ASM_PFX(ArmCallHvc):
22 push {r4-r8}
23 // r0 will be popped just after the HVC call
24 push {r0}
25
26 // Load the HVC arguments values into the appropriate registers
27 ldr r7, [r0, #28]
28 ldr r6, [r0, #24]
29 ldr r5, [r0, #20]
30 ldr r4, [r0, #16]
31 ldr r3, [r0, #12]
32 ldr r2, [r0, #8]
33 ldr r1, [r0, #4]
34 ldr r0, [r0, #0]
35
36 hvc #0
37
38 // Pop the ARM_HVC_ARGS structure address from the stack into r8
39 pop {r8}
40
41 // Load the HVC returned values into the appropriate registers
42 // A HVC call can return up to 4 values - we do not need to store back r4-r7.
43 str r3, [r8, #12]
44 str r2, [r8, #8]
45 str r1, [r8, #4]
46 str r0, [r8, #0]
47
48 mov r0, r8
49
50 // Restore the registers r4-r8
51 pop {r4-r8}
52
53 bx lr