2 Provides services to retrieve values from Version 1 of a capsule's FMP Payload
3 Header. The FMP Payload Header structure is not defined in the library class.
4 Instead, services are provided to retrieve information from the FMP Payload
5 Header. If information is added to the FMP Payload Header, then new services
6 may be added to this library class to retrieve the new information.
8 Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
9 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <Library/FmpPayloadHeaderLib.h>
19 /// Define FMP Payload Header structure here so it is not public
28 UINT32 LowestSupportedVersion
;
34 /// Identifier is used to make sure the data in the header is for this structure
35 /// and version. If the structure changes update the last digit.
37 #define FMP_PAYLOAD_HEADER_SIGNATURE SIGNATURE_32 ('M', 'S', 'S', '1')
40 Returns the FMP Payload Header size in bytes.
42 @param[in] Header FMP Payload Header to evaluate
43 @param[in] FmpPayloadSize Size of FMP payload
44 @param[out] Size The size, in bytes, of the FMP Payload Header.
46 @retval EFI_SUCCESS The firmware version was returned.
47 @retval EFI_INVALID_PARAMETER Header is NULL.
48 @retval EFI_INVALID_PARAMETER Size is NULL.
49 @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header.
54 GetFmpPayloadHeaderSize (
55 IN CONST VOID
*Header
,
56 IN CONST UINTN FmpPayloadSize
,
60 FMP_PAYLOAD_HEADER
*FmpPayloadHeader
;
62 FmpPayloadHeader
= NULL
;
64 if (Header
== NULL
|| Size
== NULL
) {
65 return EFI_INVALID_PARAMETER
;
68 FmpPayloadHeader
= (FMP_PAYLOAD_HEADER
*)Header
;
69 if ((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) < (UINTN
)FmpPayloadHeader
||
70 (UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) >= (UINTN
)FmpPayloadHeader
+ FmpPayloadSize
||
71 FmpPayloadHeader
->HeaderSize
< sizeof (FMP_PAYLOAD_HEADER
)) {
72 return EFI_INVALID_PARAMETER
;
75 if (FmpPayloadHeader
->Signature
!= FMP_PAYLOAD_HEADER_SIGNATURE
) {
76 return EFI_INVALID_PARAMETER
;
79 *Size
= FmpPayloadHeader
->HeaderSize
;
84 Returns the version described in the FMP Payload Header.
86 @param[in] Header FMP Payload Header to evaluate
87 @param[in] FmpPayloadSize Size of FMP payload
88 @param[out] Version The firmware version described in the FMP Payload
91 @retval EFI_SUCCESS The firmware version was returned.
92 @retval EFI_INVALID_PARAMETER Header is NULL.
93 @retval EFI_INVALID_PARAMETER Version is NULL.
94 @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header.
99 GetFmpPayloadHeaderVersion (
100 IN CONST VOID
*Header
,
101 IN CONST UINTN FmpPayloadSize
,
105 FMP_PAYLOAD_HEADER
*FmpPayloadHeader
;
107 FmpPayloadHeader
= NULL
;
109 if (Header
== NULL
|| Version
== NULL
) {
110 return EFI_INVALID_PARAMETER
;
113 FmpPayloadHeader
= (FMP_PAYLOAD_HEADER
*)Header
;
114 if ((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) < (UINTN
)FmpPayloadHeader
||
115 (UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) >= (UINTN
)FmpPayloadHeader
+ FmpPayloadSize
||
116 FmpPayloadHeader
->HeaderSize
< sizeof (FMP_PAYLOAD_HEADER
)) {
117 return EFI_INVALID_PARAMETER
;
120 if (FmpPayloadHeader
->Signature
!= FMP_PAYLOAD_HEADER_SIGNATURE
) {
121 return EFI_INVALID_PARAMETER
;
124 *Version
= FmpPayloadHeader
->FwVersion
;
129 Returns the lowest supported version described in the FMP Payload Header.
131 @param[in] Header FMP Payload Header to evaluate
132 @param[in] FmpPayloadSize Size of FMP payload
133 @param[out] LowestSupportedVersion The lowest supported version described in
134 the FMP Payload Header.
136 @retval EFI_SUCCESS The lowest support version was returned.
137 @retval EFI_INVALID_PARAMETER Header is NULL.
138 @retval EFI_INVALID_PARAMETER LowestSupportedVersion is NULL.
139 @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header.
144 GetFmpPayloadHeaderLowestSupportedVersion (
145 IN CONST VOID
*Header
,
146 IN CONST UINTN FmpPayloadSize
,
147 OUT UINT32
*LowestSupportedVersion
150 FMP_PAYLOAD_HEADER
*FmpPayloadHeader
;
152 FmpPayloadHeader
= NULL
;
154 if (Header
== NULL
|| LowestSupportedVersion
== NULL
) {
155 return EFI_INVALID_PARAMETER
;
158 FmpPayloadHeader
= (FMP_PAYLOAD_HEADER
*)Header
;
159 if ((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) < (UINTN
)FmpPayloadHeader
||
160 (UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) >= (UINTN
)FmpPayloadHeader
+ FmpPayloadSize
||
161 FmpPayloadHeader
->HeaderSize
< sizeof (FMP_PAYLOAD_HEADER
)) {
162 return EFI_INVALID_PARAMETER
;
165 if (FmpPayloadHeader
->Signature
!= FMP_PAYLOAD_HEADER_SIGNATURE
) {
166 return EFI_INVALID_PARAMETER
;
169 *LowestSupportedVersion
= FmpPayloadHeader
->LowestSupportedVersion
;