]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: Add initial OpteeLib implementation
authorSumit Garg <sumit.garg@linaro.org>
Wed, 1 Aug 2018 06:07:41 +0000 (11:37 +0530)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 1 Aug 2018 09:03:45 +0000 (11:03 +0200)
This is initial version of OP-TEE library that provides api's to
communicate with OP-TEE OS (Trusted OS based on ARM TrustZone) via
secure monitor calls. Currently it provides basic api to detect OP-TEE
presence via UID matching.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
ArmPkg/ArmPkg.dec
ArmPkg/ArmPkg.dsc
ArmPkg/Include/IndustryStandard/ArmStdSmc.h
ArmPkg/Include/Library/OpteeLib.h [new file with mode: 0644]
ArmPkg/Library/OpteeLib/Optee.c [new file with mode: 0644]
ArmPkg/Library/OpteeLib/OpteeLib.inf [new file with mode: 0644]

index 3aa229fe2ec9a020a6084d58657f67baf1b86d27..84e57a0bf01c358fda0c164f3416f6b27b8ca9e5 100644 (file)
@@ -41,6 +41,7 @@
   ArmGicArchLib|Include/Library/ArmGicArchLib.h\r
   ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h\r
   ArmSvcLib|Include/Library/ArmSvcLib.h\r
+  OpteeLib|Include/Library/OpteeLib.h\r
 \r
 [Guids.common]\r
   gArmTokenSpaceGuid       = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }\r
index 76d768126b17fe05ee26c423171873b80ca08540..810caaff629f445afd926e1b549045aa26e0b704 100644 (file)
@@ -71,6 +71,7 @@
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf\r
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf\r
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf\r
+  OpteeLib|ArmPkg/Library/OpteeLib/OpteeLib.inf\r
 \r
   UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
   PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
   ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf\r
   ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf\r
   ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf\r
+  ArmPkg/Library/OpteeLib/OpteeLib.inf\r
 \r
   ArmPkg/Filesystem/SemihostFs/SemihostFs.inf\r
 \r
index 37d079664986aea16370959a4f193cabc31ffc20..a3df8e5e51dee1c876ab4a5cb88b6ac2446a65d6 100644 (file)
 #define ARM_SMC_ID_PSCI_AFFINITY_INFO_OFF         1\r
 #define ARM_SMC_ID_PSCI_AFFINITY_INFO_ON_PENDING  2\r
 \r
+/*\r
+ * SMC function IDs for Trusted OS Service queries\r
+ */\r
+#define ARM_SMC_ID_TOS_CALL_COUNT     0xbf00ff00\r
+#define ARM_SMC_ID_TOS_UID            0xbf00ff01\r
+/*                                    0xbf00ff02 is reserved */\r
+#define ARM_SMC_ID_TOS_REVISION       0xbf00ff03\r
+\r
 #endif\r
diff --git a/ArmPkg/Include/Library/OpteeLib.h b/ArmPkg/Include/Library/OpteeLib.h
new file mode 100644 (file)
index 0000000..f65d867
--- /dev/null
@@ -0,0 +1,34 @@
+/** @file\r
+  OP-TEE specific header file.\r
+\r
+  Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>\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 _OPTEE_H_\r
+#define _OPTEE_H_\r
+\r
+/*\r
+ * The 'Trusted OS Call UID' is supposed to return the following UUID for\r
+ * OP-TEE OS. This is a 128-bit value.\r
+ */\r
+#define OPTEE_OS_UID0          0x384fb3e0\r
+#define OPTEE_OS_UID1          0xe7f811e3\r
+#define OPTEE_OS_UID2          0xaf630002\r
+#define OPTEE_OS_UID3          0xa5d5c51b\r
+\r
+BOOLEAN\r
+EFIAPI\r
+IsOpteePresent (\r
+  VOID\r
+  );\r
+\r
+#endif\r
diff --git a/ArmPkg/Library/OpteeLib/Optee.c b/ArmPkg/Library/OpteeLib/Optee.c
new file mode 100644 (file)
index 0000000..574527f
--- /dev/null
@@ -0,0 +1,46 @@
+/** @file\r
+  Api's to communicate with OP-TEE OS (Trusted OS based on ARM TrustZone) via\r
+  secure monitor calls.\r
+\r
+  Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>\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
+#include <Library/ArmSmcLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/OpteeLib.h>\r
+\r
+#include <IndustryStandard/ArmStdSmc.h>\r
+\r
+/**\r
+  Check for OP-TEE presence.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsOpteePresent (\r
+  VOID\r
+  )\r
+{\r
+  ARM_SMC_ARGS ArmSmcArgs;\r
+\r
+  // Send a Trusted OS Calls UID command\r
+  ArmSmcArgs.Arg0 = ARM_SMC_ID_TOS_UID;\r
+  ArmCallSmc (&ArmSmcArgs);\r
+\r
+  if ((ArmSmcArgs.Arg0 == OPTEE_OS_UID0) &&\r
+      (ArmSmcArgs.Arg1 == OPTEE_OS_UID1) &&\r
+      (ArmSmcArgs.Arg2 == OPTEE_OS_UID2) &&\r
+      (ArmSmcArgs.Arg3 == OPTEE_OS_UID3)) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
diff --git a/ArmPkg/Library/OpteeLib/OpteeLib.inf b/ArmPkg/Library/OpteeLib/OpteeLib.inf
new file mode 100644 (file)
index 0000000..5abd427
--- /dev/null
@@ -0,0 +1,33 @@
+#/** @file\r
+#  OP-TEE lib using secure monitor calls\r
+#\r
+#  Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>\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
+#  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
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001001A\r
+  BASE_NAME                      = OpteeLib\r
+  FILE_GUID                      = BCD50D08-9568-45B2-84DF-30AE0279AD46\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = OpteeLib\r
+\r
+[Sources]\r
+  Optee.c\r
+\r
+[Packages]\r
+  ArmPkg/ArmPkg.dec\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  ArmSmcLib\r
+  BaseLib\r