TianoCore EDK2 master
Loading...
Searching...
No Matches
FmpPayloadHeaderLib.c
Go to the documentation of this file.
1
15#include <PiDxe.h>
17
21
22#pragma pack(1)
23
24typedef struct {
25 UINT32 Signature;
26 UINT32 HeaderSize;
27 UINT32 FwVersion;
28 UINT32 LowestSupportedVersion;
30
31#pragma pack()
32
37#define FMP_PAYLOAD_HEADER_SIGNATURE SIGNATURE_32 ('M', 'S', 'S', '1')
38
53EFIAPI
55 IN CONST VOID *Header,
56 IN CONST UINTN FmpPayloadSize,
57 OUT UINT32 *Size
58 )
59{
60 FMP_PAYLOAD_HEADER *FmpPayloadHeader;
61
62 FmpPayloadHeader = NULL;
63
64 if ((Header == NULL) || (Size == NULL)) {
65 return EFI_INVALID_PARAMETER;
66 }
67
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 {
73 return EFI_INVALID_PARAMETER;
74 }
75
76 if (FmpPayloadHeader->Signature != FMP_PAYLOAD_HEADER_SIGNATURE) {
77 return EFI_INVALID_PARAMETER;
78 }
79
80 *Size = FmpPayloadHeader->HeaderSize;
81 return EFI_SUCCESS;
82}
83
99EFIAPI
101 IN CONST VOID *Header,
102 IN CONST UINTN FmpPayloadSize,
103 OUT UINT32 *Version
104 )
105{
106 FMP_PAYLOAD_HEADER *FmpPayloadHeader;
107
108 FmpPayloadHeader = NULL;
109
110 if ((Header == NULL) || (Version == NULL)) {
111 return EFI_INVALID_PARAMETER;
112 }
113
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)))
118 {
119 return EFI_INVALID_PARAMETER;
120 }
121
122 if (FmpPayloadHeader->Signature != FMP_PAYLOAD_HEADER_SIGNATURE) {
123 return EFI_INVALID_PARAMETER;
124 }
125
126 *Version = FmpPayloadHeader->FwVersion;
127 return EFI_SUCCESS;
128}
129
145EFIAPI
147 IN CONST VOID *Header,
148 IN CONST UINTN FmpPayloadSize,
149 OUT UINT32 *LowestSupportedVersion
150 )
151{
152 FMP_PAYLOAD_HEADER *FmpPayloadHeader;
153
154 FmpPayloadHeader = NULL;
155
156 if ((Header == NULL) || (LowestSupportedVersion == NULL)) {
157 return EFI_INVALID_PARAMETER;
158 }
159
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)))
164 {
165 return EFI_INVALID_PARAMETER;
166 }
167
168 if (FmpPayloadHeader->Signature != FMP_PAYLOAD_HEADER_SIGNATURE) {
169 return EFI_INVALID_PARAMETER;
170 }
171
172 *LowestSupportedVersion = FmpPayloadHeader->LowestSupportedVersion;
173 return EFI_SUCCESS;
174}
UINT64 UINTN
#define FMP_PAYLOAD_HEADER_SIGNATURE
EFI_STATUS EFIAPI GetFmpPayloadHeaderLowestSupportedVersion(IN CONST VOID *Header, IN CONST UINTN FmpPayloadSize, OUT UINT32 *LowestSupportedVersion)
EFI_STATUS EFIAPI GetFmpPayloadHeaderVersion(IN CONST VOID *Header, IN CONST UINTN FmpPayloadSize, OUT UINT32 *Version)
EFI_STATUS EFIAPI GetFmpPayloadHeaderSize(IN CONST VOID *Header, IN CONST UINTN FmpPayloadSize, OUT UINT32 *Size)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112