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
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
#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
--- /dev/null
+/** @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
--- /dev/null
+/** @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
--- /dev/null
+#/** @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