]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/OpteeLib/Optee.c
ArmPkg: Add initial OpteeLib implementation
[mirror_edk2.git] / ArmPkg / Library / OpteeLib / Optee.c
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