]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmSmcLib: Added helper library to make SMC call to the Secure World
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 26 Mar 2012 10:59:50 +0000 (10:59 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 26 Mar 2012 10:59:50 +0000 (10:59 +0000)
This library adds C-wrapper around the SMC instruction and allows to pass
parameters to the Secure World.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13133 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Include/Library/ArmSmcLib.h [new file with mode: 0644]
ArmPlatformPkg/Library/ArmSmcLib/ArmSmc.S [new file with mode: 0644]
ArmPlatformPkg/Library/ArmSmcLib/ArmSmc.asm [new file with mode: 0644]
ArmPlatformPkg/Library/ArmSmcLib/ArmSmcLib.inf [new file with mode: 0644]

diff --git a/ArmPlatformPkg/Include/Library/ArmSmcLib.h b/ArmPlatformPkg/Include/Library/ArmSmcLib.h
new file mode 100644 (file)
index 0000000..ff946f2
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+*\r
+*  Copyright (c) 2012, 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
+*  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
+#ifndef __ARM_SMC_LIB__\r
+#define __ARM_SMC_LIB__\r
+\r
+VOID\r
+ArmCallSmc (\r
+  IN OUT UINTN *Rx\r
+  );\r
+\r
+VOID\r
+ArmCallSmcArg1 (\r
+  IN OUT UINTN *Rx,\r
+  IN OUT UINTN *Arg1\r
+  );\r
+\r
+VOID\r
+ArmCallSmcArg2 (\r
+  IN OUT UINTN *Rx,\r
+  IN OUT UINTN *Arg1,\r
+  IN OUT UINTN *Arg2\r
+  );\r
+\r
+VOID\r
+ArmCallSmcArg3 (\r
+  IN OUT UINTN *Rx,\r
+  IN OUT UINTN *Arg1,\r
+  IN OUT UINTN *Arg2,\r
+  IN OUT UINTN *Arg3\r
+  );\r
+\r
+#endif\r
diff --git a/ArmPlatformPkg/Library/ArmSmcLib/ArmSmc.S b/ArmPlatformPkg/Library/ArmSmcLib/ArmSmc.S
new file mode 100644 (file)
index 0000000..13f51a9
--- /dev/null
@@ -0,0 +1,76 @@
+//\r
+//  Copyright (c) 2012, 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
+//  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
+.arch_extension sec\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
+    push    {r1}\r
+    mov     r1, r0\r
+    ldr     r0,[r1]\r
+    smc     #0\r
+    str     r0,[r1]\r
+    pop     {r1}\r
+    blx     lr\r
+\r
+// Arg1 in R1\r
+ASM_PFX(ArmCallSmcArg1):\r
+    push    {r2-r3}\r
+    mov     r2, r0\r
+    mov     r3, r1\r
+    ldr     r0,[r2]\r
+    ldr     r1,[r3]\r
+    smc     #0\r
+    str     r0,[r2]\r
+    str     r1,[r3]\r
+    pop     {r2-r3}\r
+    blx     lr\r
+\r
+ASM_PFX(ArmCallSmcArg2):\r
+    push    {r3-r5}\r
+    mov     r3, r0\r
+    mov     r4, r1\r
+    mov     r5, r2\r
+    ldr     r0,[r3]\r
+    ldr     r1,[r4]\r
+    ldr     r2,[r5]\r
+    smc     #0\r
+    str     r0,[r3]\r
+    str     r1,[r4]\r
+    str     r2,[r5]\r
+    pop     {r3-r5}\r
+    blx     lr\r
+\r
+ASM_PFX(ArmCallSmcArg3):\r
+    push    {r4-r7}\r
+    mov     r4, r0\r
+    mov     r5, r1\r
+    mov     r6, r2\r
+    mov     r7, r3\r
+    ldr     r0,[r4]\r
+    ldr     r1,[r5]\r
+    ldr     r2,[r6]\r
+    ldr     r3,[r7]\r
+    smc     #0\r
+    str     r0,[r4]\r
+    str     r1,[r5]\r
+    str     r2,[r6]\r
+    str     r3,[r7]\r
+    pop     {r4-r7}\r
+    blx     lr\r
diff --git a/ArmPlatformPkg/Library/ArmSmcLib/ArmSmc.asm b/ArmPlatformPkg/Library/ArmSmcLib/ArmSmc.asm
new file mode 100644 (file)
index 0000000..0efb177
--- /dev/null
@@ -0,0 +1,76 @@
+//\r
+//  Copyright (c) 2012, 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
+//  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
+    EXPORT ArmCallSmc\r
+    EXPORT ArmCallSmcArg1\r
+    EXPORT ArmCallSmcArg2\r
+    EXPORT ArmCallSmcArg3\r
+\r
+    AREA   ArmSmc, CODE, READONLY\r
+\r
+ArmCallSmc\r
+    push    {r1}\r
+    mov     r1, r0\r
+    ldr     r0,[r1]\r
+    smc     #0\r
+    str     r0,[r1]\r
+    pop     {r1}\r
+    blx     lr\r
+\r
+// Arg1 in R1\r
+ArmCallSmcArg1\r
+    push    {r2-r3}\r
+    mov     r2, r0\r
+    mov     r3, r1\r
+    ldr     r0,[r2]\r
+    ldr     r1,[r3]\r
+    smc     #0\r
+    str     r0,[r2]\r
+    str     r1,[r3]\r
+    pop     {r2-r3}\r
+    blx     lr\r
+\r
+ArmCallSmcArg2\r
+    push    {r3-r5}\r
+    mov     r3, r0\r
+    mov     r4, r1\r
+    mov     r5, r2\r
+    ldr     r0,[r3]\r
+    ldr     r1,[r4]\r
+    ldr     r2,[r5]\r
+    smc     #0\r
+    str     r0,[r3]\r
+    str     r1,[r4]\r
+    str     r2,[r5]\r
+    pop     {r3-r5}\r
+    blx     lr\r
+\r
+ArmCallSmcArg3\r
+    push    {r4-r7}\r
+    mov     r4, r0\r
+    mov     r5, r1\r
+    mov     r6, r2\r
+    mov     r7, r3\r
+    ldr     r0,[r4]\r
+    ldr     r1,[r5]\r
+    ldr     r2,[r6]\r
+    ldr     r3,[r7]\r
+    smc     #0\r
+    str     r0,[r4]\r
+    str     r1,[r5]\r
+    str     r2,[r6]\r
+    str     r3,[r7]\r
+    pop     {r4-r7}\r
+    blx     lr\r
+\r
+    END\r
diff --git a/ArmPlatformPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPlatformPkg/Library/ArmSmcLib/ArmSmcLib.inf
new file mode 100644 (file)
index 0000000..5df2548
--- /dev/null
@@ -0,0 +1,28 @@
+#/** @file\r
+#  \r
+#  Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>\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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ArmSmcLib\r
+  FILE_GUID                      = eb3f17d5-a3cc-4eac-8912-84162d0f79da \r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ArmSmcLib\r
+  \r
+[Sources.common]\r
+  ArmSmc.asm    | RVCT\r
+  ArmSmc.S      | GCC\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ArmPlatformPkg/ArmPlatformPkg.dec\r