TianoCore EDK2 master
Loading...
Searching...
No Matches
F86GuidedSectionExtraction.c
Go to the documentation of this file.
1
13#include "Sdk/C/Bra.h"
14
48RETURN_STATUS
49EFIAPI
51 IN CONST VOID *InputSection,
52 OUT UINT32 *OutputBufferSize,
53 OUT UINT32 *ScratchBufferSize,
54 OUT UINT16 *SectionAttribute
55 )
56{
57 ASSERT (InputSection != NULL);
58 ASSERT (OutputBufferSize != NULL);
59 ASSERT (ScratchBufferSize != NULL);
60 ASSERT (SectionAttribute != NULL);
61
62 if (IS_SECTION2 (InputSection)) {
63 if (!CompareGuid (
64 &gLzmaF86CustomDecompressGuid,
65 &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
66 ))
67 {
69 }
70
71 *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes;
72
74 (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
75 SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
76 OutputBufferSize,
77 ScratchBufferSize
78 );
79 } else {
80 if (!CompareGuid (
81 &gLzmaF86CustomDecompressGuid,
82 &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
83 ))
84 {
86 }
87
88 *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes;
89
91 (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
92 SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
93 OutputBufferSize,
94 ScratchBufferSize
95 );
96 }
97}
98
132RETURN_STATUS
133EFIAPI
135 IN CONST VOID *InputSection,
136 OUT VOID **OutputBuffer,
137 OUT VOID *ScratchBuffer OPTIONAL,
138 OUT UINT32 *AuthenticationStatus
139 )
140{
141 EFI_GUID *InputGuid;
142 VOID *Source;
143 UINTN SourceSize;
144 EFI_STATUS Status;
145 UINT32 X86State;
146 UINT32 OutputBufferSize;
147 UINT32 ScratchBufferSize;
148
149 ASSERT (OutputBuffer != NULL);
150 ASSERT (InputSection != NULL);
151
152 if (IS_SECTION2 (InputSection)) {
153 InputGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid);
154 Source = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
155 SourceSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
156 } else {
157 InputGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid);
158 Source = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
159 SourceSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
160 }
161
162 if (!CompareGuid (&gLzmaF86CustomDecompressGuid, InputGuid)) {
164 }
165
166 //
167 // Authentication is set to Zero, which may be ignored.
168 //
169 *AuthenticationStatus = 0;
170
171 Status = LzmaUefiDecompress (
172 Source,
173 SourceSize,
174 *OutputBuffer,
175 ScratchBuffer
176 );
177
178 //
179 // After decompress, the data need to be converted to the raw data.
180 //
181 if (!EFI_ERROR (Status)) {
183 Source,
184 (UINT32)SourceSize,
185 &OutputBufferSize,
186 &ScratchBufferSize
187 );
188
189 if (!EFI_ERROR (Status)) {
190 x86_Convert_Init (X86State);
191 x86_Convert (*OutputBuffer, OutputBufferSize, 0, &X86State, 0);
192 }
193 }
194
195 return Status;
196}
197
205EFIAPI
207 VOID
208 )
209{
211 &gLzmaF86CustomDecompressGuid,
214 );
215}
UINT64 UINTN
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
EFI_STATUS EFIAPI LzmaArchDecompressLibConstructor(VOID)
RETURN_STATUS EFIAPI LzmaArchGuidedSectionExtraction(IN CONST VOID *InputSection, OUT VOID **OutputBuffer, OUT VOID *ScratchBuffer OPTIONAL, OUT UINT32 *AuthenticationStatus)
RETURN_STATUS EFIAPI LzmaArchGuidedSectionGetInfo(IN CONST VOID *InputSection, OUT UINT32 *OutputBufferSize, OUT UINT32 *ScratchBufferSize, OUT UINT16 *SectionAttribute)
RETURN_STATUS EFIAPI LzmaUefiDecompress(IN CONST VOID *Source, IN UINTN SourceSize, IN OUT VOID *Destination, IN OUT VOID *Scratch)
RETURN_STATUS EFIAPI LzmaUefiDecompressGetInfo(IN CONST VOID *Source, IN UINT32 SourceSize, OUT UINT32 *DestinationSize, OUT UINT32 *ScratchSize)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define RETURN_INVALID_PARAMETER
Definition: Base.h:1076
#define SECTION_SIZE(SectionHeaderPtr)
RETURN_STATUS EFIAPI ExtractGuidedSectionRegisterHandlers(IN CONST GUID *SectionGuid, IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler, IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
Definition: Base.h:213