+//\r
+// Copyright (c) 2012-2014, ARM Limited. All rights reserved.\r
+// Copyright (c) 2014, Linaro Limited. All rights reserved.\r
+//\r
+// This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution. The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+//\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+//\r
+\r
+.text\r
+.align 3\r
+\r
+GCC_ASM_EXPORT(ArmCallHvc)\r
+\r
+ASM_PFX(ArmCallHvc):\r
+ // Push x0 on the stack\r
+ str x0, [sp, #-8]!\r
+\r
+ // Load the HVC arguments values into the appropriate registers\r
+ ldp x6, x7, [x0, #48]\r
+ ldp x4, x5, [x0, #32]\r
+ ldp x2, x3, [x0, #16]\r
+ ldp x0, x1, [x0, #0]\r
+\r
+ hvc #0\r
+\r
+ // Pop the ARM_HVC_ARGS structure address from the stack into x9\r
+ ldr x9, [sp], #8\r
+\r
+ // Store the HVC returned values into the appropriate registers\r
+ // A HVC call can return up to 4 values\r
+ stp x2, x3, [x9, #16]\r
+ stp x0, x1, [x9, #0]\r
+\r
+ mov x0, x9\r
+\r
+ ret\r