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
)))
73 return EFI_INVALID_PARAMETER
;
76 if (FmpPayloadHeader
->Signature
!= FMP_PAYLOAD_HEADER_SIGNATURE
) {
77 return EFI_INVALID_PARAMETER
;
80 *Size
= FmpPayloadHeader
->HeaderSize
;
85 Returns the version described in the FMP Payload Header.
87 @param[in] Header FMP Payload Header to evaluate
88 @param[in] FmpPayloadSize Size of FMP payload
89 @param[out] Version The firmware version described in the FMP Payload
92 @retval EFI_SUCCESS The firmware version was returned.
93 @retval EFI_INVALID_PARAMETER Header is NULL.
94 @retval EFI_INVALID_PARAMETER Version is NULL.
95 @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header.
100 GetFmpPayloadHeaderVersion (
101 IN CONST VOID
*Header
,
102 IN CONST UINTN FmpPayloadSize
,
106 FMP_PAYLOAD_HEADER
*FmpPayloadHeader
;
108 FmpPayloadHeader
= NULL
;
110 if ((Header
== NULL
) || (Version
== NULL
)) {
111 return EFI_INVALID_PARAMETER
;
114 FmpPayloadHeader
= (FMP_PAYLOAD_HEADER
*)Header
;
115 if (((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) < (UINTN
)FmpPayloadHeader
) ||
116 ((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) >= (UINTN
)FmpPayloadHeader
+ FmpPayloadSize
) ||
117 (FmpPayloadHeader
->HeaderSize
< sizeof (FMP_PAYLOAD_HEADER
)))
119 return EFI_INVALID_PARAMETER
;
122 if (FmpPayloadHeader
->Signature
!= FMP_PAYLOAD_HEADER_SIGNATURE
) {
123 return EFI_INVALID_PARAMETER
;
126 *Version
= FmpPayloadHeader
->FwVersion
;
131 Returns the lowest supported version described in the FMP Payload Header.
133 @param[in] Header FMP Payload Header to evaluate
134 @param[in] FmpPayloadSize Size of FMP payload
135 @param[out] LowestSupportedVersion The lowest supported version described in
136 the FMP Payload Header.
138 @retval EFI_SUCCESS The lowest support version was returned.
139 @retval EFI_INVALID_PARAMETER Header is NULL.
140 @retval EFI_INVALID_PARAMETER LowestSupportedVersion is NULL.
141 @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header.
146 GetFmpPayloadHeaderLowestSupportedVersion (
147 IN CONST VOID
*Header
,
148 IN CONST UINTN FmpPayloadSize
,
149 OUT UINT32
*LowestSupportedVersion
152 FMP_PAYLOAD_HEADER
*FmpPayloadHeader
;
154 FmpPayloadHeader
= NULL
;
156 if ((Header
== NULL
) || (LowestSupportedVersion
== NULL
)) {
157 return EFI_INVALID_PARAMETER
;
160 FmpPayloadHeader
= (FMP_PAYLOAD_HEADER
*)Header
;
161 if (((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) < (UINTN
)FmpPayloadHeader
) ||
162 ((UINTN
)FmpPayloadHeader
+ sizeof (FMP_PAYLOAD_HEADER
) >= (UINTN
)FmpPayloadHeader
+ FmpPayloadSize
) ||
163 (FmpPayloadHeader
->HeaderSize
< sizeof (FMP_PAYLOAD_HEADER
)))
165 return EFI_INVALID_PARAMETER
;
168 if (FmpPayloadHeader
->Signature
!= FMP_PAYLOAD_HEADER_SIGNATURE
) {
169 return EFI_INVALID_PARAMETER
;
172 *LowestSupportedVersion
= FmpPayloadHeader
->LowestSupportedVersion
;