]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/Include/Library/FmpDependencyLib.h
FmpDevicePkg: Add FmpDependency library class and BASE instance
[mirror_edk2.git] / FmpDevicePkg / Include / Library / FmpDependencyLib.h
diff --git a/FmpDevicePkg/Include/Library/FmpDependencyLib.h b/FmpDevicePkg/Include/Library/FmpDependencyLib.h
new file mode 100644 (file)
index 0000000..1110eef
--- /dev/null
@@ -0,0 +1,89 @@
+/** @file\r
+  Fmp Capsule Dependency support functions for Firmware Management Protocol based\r
+  firmware updates.\r
+\r
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __FMP_DEPENDENCY_LIB__\r
+#define __FMP_DEPENDENCY_LIB__\r
+\r
+#include <PiDxe.h>\r
+#include <Protocol/FirmwareManagement.h>\r
+\r
+//\r
+// Data struct to store FMP ImageType and version for dependency check.\r
+//\r
+typedef struct {\r
+  EFI_GUID ImageTypeId;\r
+  UINT32   Version;\r
+} FMP_DEPEX_CHECK_VERSION_DATA;\r
+\r
+/**\r
+  Validate the dependency expression and output its size.\r
+\r
+  @param[in]   Dependencies   Pointer to the EFI_FIRMWARE_IMAGE_DEP.\r
+  @param[in]   MaxDepexSize   Max size of the dependency.\r
+  @param[out]  DepexSize      Size of dependency.\r
+\r
+  @retval TRUE    The capsule is valid.\r
+  @retval FALSE   The capsule is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ValidateDependency (\r
+  IN  EFI_FIRMWARE_IMAGE_DEP  *Dependencies,\r
+  IN  UINTN                   MaxDepexSize,\r
+  OUT UINT32                  *DepexSize\r
+  );\r
+\r
+/**\r
+  Get dependency from firmware image.\r
+\r
+  @param[in]  Image       Points to the firmware image.\r
+  @param[in]  ImageSize   Size, in bytes, of the firmware image.\r
+  @param[out] DepexSize   Size, in bytes, of the dependency.\r
+\r
+  @retval  The pointer to dependency.\r
+  @retval  Null\r
+\r
+**/\r
+EFI_FIRMWARE_IMAGE_DEP*\r
+EFIAPI\r
+GetImageDependency (\r
+  IN  EFI_FIRMWARE_IMAGE_AUTHENTICATION  *Image,\r
+  IN  UINTN                              ImageSize,\r
+  OUT UINT32                             *DepexSize\r
+  );\r
+\r
+/**\r
+  Evaluate the dependencies. The caller must search all the Fmp instances and\r
+  gather their versions into FmpVersions parameter. If there is PUSH_GUID opcode\r
+  in dependency expression with no FmpVersions provided, the dependency will\r
+  evaluate to FALSE.\r
+\r
+  @param[in]   Dependencies       Dependency expressions.\r
+  @param[in]   DependenciesSize   Size of Dependency expressions.\r
+  @param[in]   FmpVersions        Array of Fmp ImageTypeId and version. This\r
+                                  parameter is optional and can be set to NULL.\r
+  @param[in]   FmpVersionsCount   Element count of the array. When FmpVersions\r
+                                  is NULL, FmpVersionsCount must be 0.\r
+\r
+  @retval TRUE    Dependency expressions evaluate to TRUE.\r
+  @retval FALSE   Dependency expressions evaluate to FALSE.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EvaluateDependency (\r
+  IN EFI_FIRMWARE_IMAGE_DEP        *Dependencies,\r
+  IN UINTN                         DependenciesSize,\r
+  IN FMP_DEPEX_CHECK_VERSION_DATA  *FmpVersions      OPTIONAL,\r
+  IN UINTN                         FmpVersionsCount\r
+  );\r
+\r
+#endif\r