FmpDependencyLib.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /** @file
  2. Fmp Capsule Dependency support functions for Firmware Management Protocol based
  3. firmware updates.
  4. Copyright (c) Microsoft Corporation.<BR>
  5. Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #ifndef __FMP_DEPENDENCY_LIB__
  9. #define __FMP_DEPENDENCY_LIB__
  10. #include <PiDxe.h>
  11. #include <Protocol/FirmwareManagement.h>
  12. //
  13. // Data struct to store FMP ImageType and version for dependency check.
  14. //
  15. typedef struct {
  16. EFI_GUID ImageTypeId;
  17. UINT32 Version;
  18. } FMP_DEPEX_CHECK_VERSION_DATA;
  19. /**
  20. Validate the dependency expression and output its size.
  21. @param[in] Dependencies Pointer to the EFI_FIRMWARE_IMAGE_DEP.
  22. @param[in] MaxDepexSize Max size of the dependency.
  23. @param[out] DepexSize Size of dependency.
  24. @param[out] LastAttemptStatus An optional pointer to a UINT32 that holds the
  25. last attempt status to report back to the caller.
  26. If a last attempt status error code is not returned,
  27. this function will not modify the LastAttemptStatus value.
  28. @retval TRUE The dependency expression is valid.
  29. @retval FALSE The dependency expression is invalid.
  30. **/
  31. BOOLEAN
  32. EFIAPI
  33. ValidateDependency (
  34. IN EFI_FIRMWARE_IMAGE_DEP *Dependencies,
  35. IN UINTN MaxDepexSize,
  36. OUT UINT32 *DepexSize,
  37. OUT UINT32 *LastAttemptStatus OPTIONAL
  38. );
  39. /**
  40. Get dependency from firmware image.
  41. @param[in] Image Points to the firmware image.
  42. @param[in] ImageSize Size, in bytes, of the firmware image.
  43. @param[out] DepexSize Size, in bytes, of the dependency.
  44. @param[out] LastAttemptStatus An optional pointer to a UINT32 that holds the
  45. last attempt status to report back to the caller.
  46. If a last attempt status error code is not returned,
  47. this function will not modify the LastAttemptStatus value.
  48. @retval The pointer to dependency.
  49. @retval Null
  50. **/
  51. EFI_FIRMWARE_IMAGE_DEP *
  52. EFIAPI
  53. GetImageDependency (
  54. IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image,
  55. IN UINTN ImageSize,
  56. OUT UINT32 *DepexSize,
  57. OUT UINT32 *LastAttemptStatus OPTIONAL
  58. );
  59. /**
  60. Evaluate the dependencies. The caller must search all the Fmp instances and
  61. gather their versions into FmpVersions parameter. If there is PUSH_GUID opcode
  62. in dependency expression with no FmpVersions provided, the dependency will
  63. evaluate to FALSE.
  64. @param[in] Dependencies Dependency expressions.
  65. @param[in] DependenciesSize Size of Dependency expressions.
  66. @param[in] FmpVersions Array of Fmp ImageTypeId and version. This
  67. parameter is optional and can be set to NULL.
  68. @param[in] FmpVersionsCount Element count of the array. When FmpVersions
  69. is NULL, FmpVersionsCount must be 0.
  70. @param[out] LastAttemptStatus An optional pointer to a UINT32 that holds the
  71. last attempt status to report back to the caller.
  72. This function will set the value to LAST_ATTEMPT_STATUS_SUCCESS
  73. if an error code is not set.
  74. @retval TRUE Dependency expressions evaluate to TRUE.
  75. @retval FALSE Dependency expressions evaluate to FALSE.
  76. **/
  77. BOOLEAN
  78. EFIAPI
  79. EvaluateDependency (
  80. IN EFI_FIRMWARE_IMAGE_DEP *Dependencies,
  81. IN UINTN DependenciesSize,
  82. IN FMP_DEPEX_CHECK_VERSION_DATA *FmpVersions OPTIONAL,
  83. IN UINTN FmpVersionsCount,
  84. OUT UINT32 *LastAttemptStatus OPTIONAL
  85. );
  86. #endif