]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
ArmPkg/ArmSmcLib: Fixed SMC helper functions
[mirror_edk2.git] / ArmPkg / Library / ArmSmcLib / AArch64 / ArmSmc.S
index 579a73e96c9bae44b56d7f6f59fb2c046919b28d..f73c98cfc38bde9c88f590ccd04e82f275c240b5 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//  Copyright (c) 2012-2013, ARM Limited. All rights reserved.\r
+//  Copyright (c) 2012-2014, ARM 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
 .align 3\r
 \r
 GCC_ASM_EXPORT(ArmCallSmc)\r
-GCC_ASM_EXPORT(ArmCallSmcArg1)\r
-GCC_ASM_EXPORT(ArmCallSmcArg2)\r
-GCC_ASM_EXPORT(ArmCallSmcArg3)\r
 \r
 ASM_PFX(ArmCallSmc):\r
-  str   x1, [sp, #-0x10]!\r
-  mov   x1, x0\r
-  ldr   x0,[x1]\r
-  smc   #0\r
-  str   x0,[x1]\r
-  ldr   x1, [sp], #0x10\r
-  ret\r
+  // Push x0 on the stack\r
+  str   x0, [sp, #-8]!\r
 \r
-ASM_PFX(ArmCallSmcArg1):\r
-  stp   x2, x3, [sp, #-0x10]!\r
-  mov   x2, x0\r
-  mov   x3, x1\r
-  ldr   x0,[x2]\r
-  ldr   x1,[x3]\r
-  smc   #0\r
-  str   x0,[x2]\r
-  str   x1,[x3]\r
-  ldp   x2, x3, [sp], #0x10\r
-  ret\r
+  // Load the SMC 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
-ASM_PFX(ArmCallSmcArg2):\r
-  stp   x3, x4, [sp, #-0x10]!\r
-  str   x5, [sp, #-8]!\r
-  mov   x3, x0\r
-  mov   x4, x1\r
-  mov   x5, x2\r
-  ldr   x0,[x3]\r
-  ldr   x1,[x4]\r
-  ldr   x2,[x5]\r
   smc   #0\r
-  str   x0,[x3]\r
-  str   x1,[x4]\r
-  str   x2,[x5]\r
-  ldr   x5, [sp], #8\r
-  ldp   x3, x4, [sp], #0x10\r
-  ret\r
 \r
-ASM_PFX(ArmCallSmcArg3):\r
-  stp   x4, x5, [sp, #-0x10]!\r
-  stp   x6, x7, [sp, #-0x10]!\r
-  mov   x4, x0\r
-  mov   x5, x1\r
-  mov   x6, x2\r
-  mov   x7, x3\r
-  ldr   x0,[x4]\r
-  ldr   x1,[x5]\r
-  ldr   x2,[x6]\r
-  ldr   x3,[x7]\r
-  smc   #0\r
-  str   x0,[x4]\r
-  str   x1,[x5]\r
-  str   x2,[x6]\r
-  str   x3,[x7]\r
-  ldp   x4, x5, [sp], #0x10\r
-  ldp   x6, x7, [sp], #0x10\r
+  // Pop the ARM_SMC_ARGS structure address from the stack into x9\r
+  ldr   x9, [sp], #8\r
+\r
+  // Store the SMC returned values into the appropriate registers\r
+  // A SMC call can return up to 4 values - we do not need to store back x4-x7.\r
+  stp   x2, x3, [x9, #16]\r
+  stp   x0, x1, [x9, #0]\r
+\r
+  mov   x0, x9\r
+\r
   ret\r