]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/OpteeLib/Optee.c
ArmPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ArmPkg / Library / OpteeLib / Optee.c
index 55dcc7853b596de2fb8dce2c9da02cc818f3191d..2562bc093b61396ae169e79e58425653520c5f80 100644 (file)
@@ -4,13 +4,7 @@
 \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
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -123,6 +117,17 @@ OpteeInit (
   return EFI_SUCCESS;\r
 }\r
 \r
+STATIC\r
+BOOLEAN\r
+IsOpteeSmcReturnRpc (\r
+  UINT32 Return\r
+  )\r
+{\r
+  return (Return != OPTEE_SMC_RETURN_UNKNOWN_FUNCTION) &&\r
+         ((Return & OPTEE_SMC_RETURN_RPC_PREFIX_MASK) ==\r
+          OPTEE_SMC_RETURN_RPC_PREFIX);\r
+}\r
+\r
 /**\r
   Does Standard SMC to OP-TEE in secure world.\r
 \r
@@ -147,13 +152,22 @@ OpteeCallWithArg (
   while (TRUE) {\r
     ArmCallSmc (&ArmSmcArgs);\r
 \r
-    if (ArmSmcArgs.Arg0 == OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT) {\r
-      //\r
-      // A foreign interrupt was raised while secure world was\r
-      // executing, since they are handled in UEFI a dummy RPC is\r
-      // performed to let UEFI take the interrupt through the normal\r
-      // vector.\r
-      //\r
+    if (IsOpteeSmcReturnRpc (ArmSmcArgs.Arg0)) {\r
+      switch (ArmSmcArgs.Arg0) {\r
+      case OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT:\r
+        //\r
+        // A foreign interrupt was raised while secure world was\r
+        // executing, since they are handled in UEFI a dummy RPC is\r
+        // performed to let UEFI take the interrupt through the normal\r
+        // vector.\r
+        //\r
+        break;\r
+\r
+      default:\r
+         // Do nothing in case RPC is not implemented.\r
+        break;\r
+      }\r
+\r
       ArmSmcArgs.Arg0 = OPTEE_SMC_RETURN_FROM_RPC;\r
     } else {\r
       break;\r