12#define EFI_VFR_ATTRACT_GUID \
13{ 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } }
15EFI_GUID gVfrArrayAttractGuid = EFI_VFR_ATTRACT_GUID;
18{ 0xFFFFFFFF, 0xFFFF, 0xFFFF, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }
22#define VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('V', 'D', 'R', 'I')
32#define VAR_CHECK_VFR_DRIVER_INFO_FROM_LINK(a) CR (a, VAR_CHECK_VFR_DRIVER_INFO, Link, VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE)
34#define MAX_MATCH_GUID_NUM 100
58 OUT UINT8 *NumOfMatchingGuid
64 if ((Ffs ==
NULL) || (Guid ==
NULL) || (Length == 0)) {
68 if (NumOfMatchingGuid !=
NULL) {
69 *NumOfMatchingGuid = 0;
73 for (LoopControl = 0; LoopControl < Length; LoopControl++) {
80 if ((NumOfMatchingGuid !=
NULL) && (Offset !=
NULL)) {
81 if (*NumOfMatchingGuid == 0) {
83 ASSERT (*Offset !=
NULL);
86 *(*Offset + *NumOfMatchingGuid) = LoopControl +
sizeof (
EFI_GUID);
87 (*NumOfMatchingGuid)++;
118 OUT UINT8 *NumOfMatchingOffset
125 if ((Ffs ==
NULL) || (Offset ==
NULL)) {
126 return EFI_NOT_FOUND;
131 &gVfrArrayAttractGuid,
140 for (Index = 0; Index < *NumOfMatchingOffset; Index++) {
144 VirOffValue = *(
UINTN *)((
UINTN)Ffs + *(*Offset + Index));
148 *(*Offset + Index) = (
UINTN)EfiAddr + VirOffValue;
170 EFI_FV_FILETYPE FoundType;
172 UINT32 AuthenticationStatus;
178 UINT8 NumberofMatchingVfrBin;
179 UINTN *VfrBinBaseAddress;
181 Status = Fv2->ReadFile (
188 &AuthenticationStatus
190 if (EFI_ERROR (Status)) {
195 Status = Fv2->ReadSection (
202 &AuthenticationStatus
204 if (!EFI_ERROR (Status)) {
205 Status =
SearchVfrBinInFfs (Buffer, 0, Size, &VfrBinBaseAddress, &NumberofMatchingVfrBin);
206 if (!EFI_ERROR (Status)) {
207 SectionBuffer =
NULL;
208 Status = Fv2->ReadSection (
215 &AuthenticationStatus
217 if (!EFI_ERROR (Status)) {
218 DEBUG ((DEBUG_INFO,
"FfsNameGuid - %g\n", DriverGuid));
219 DEBUG ((DEBUG_INFO,
"NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin));
221 for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) {
224 DumpHiiPackage ((UINT8 *)(
UINTN)SectionBuffer + VfrBinBaseAddress[VfrBinIndex] +
sizeof (UINT32));
259 EFI_FV_FILETYPE FileType;
268 Status =
gBS->LocateHandleBuffer (
270 &gEfiFirmwareVolume2ProtocolGuid,
275 if (EFI_ERROR (Status)) {
282 for (Index = 0; Index < HandleCount; Index++) {
283 DEBUG ((DEBUG_INFO,
"FvIndex - %x\n", Index));
284 Status =
gBS->HandleProtocol (
286 &gEfiFirmwareVolume2ProtocolGuid,
296 Status =
gBS->HandleProtocol (
298 &gEfiFirmwareVolumeBlock2ProtocolGuid,
302 Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress);
303 if (!EFI_ERROR (Status)) {
304 DEBUG ((DEBUG_INFO,
"FvAddress - 0x%08x\n", FvAddress));
306 DEBUG ((DEBUG_INFO,
"FvSize - 0x%08x\n", FvSize));
316 ASSERT (Key !=
NULL);
318 for (FfsIndex = 0; ; FfsIndex++) {
320 Status = Fv2->GetNextFile (
328 if (EFI_ERROR (Status)) {
340 VfrDriverLink = mVfrDriverList.ForwardLink;
341 while (VfrDriverLink != &mVfrDriverList) {
342 VfrDriverInfo = VAR_CHECK_VFR_DRIVER_INFO_FROM_LINK (VfrDriverLink);
343 VfrDriverLink = VfrDriverLink->ForwardLink;
344 if (
ParseFfs (Fv2, VfrDriverInfo->DriverGuid)) {
372 for (Index = 0; !
IsZeroGuid (&DriverGuidArray[Index]); Index++) {
373 DEBUG ((DEBUG_INFO,
"CreateVfrDriverList: %g\n", &DriverGuidArray[Index]));
375 ASSERT (VfrDriverInfo !=
NULL);
376 VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE;
377 VfrDriverInfo->DriverGuid = &DriverGuidArray[Index];
394 while (mVfrDriverList.ForwardLink != &mVfrDriverList) {
395 VfrDriverLink = mVfrDriverList.ForwardLink;
396 VfrDriverInfo = VAR_CHECK_VFR_DRIVER_INFO_FROM_LINK (VfrDriverLink);
414 DEBUG ((DEBUG_INFO,
"VarCheckHiiGenDxeFromFv\n"));
428 if (
CompareGuid (&DriverGuidArray[0], &mAllFfGuid)) {
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define PcdGetPtr(TokenName)
#define EFI_FV_FILETYPE_ALL
UINT32 EFI_FV_FILE_ATTRIBUTES
UINT64 EFI_PHYSICAL_ADDRESS
VOID EFIAPI InternalVarCheckFreePool(IN VOID *Buffer)
VOID VarCheckParseHiiPackage(IN VOID *HiiPackage, IN BOOLEAN FromFv)
VOID * InternalVarCheckAllocateZeroPool(IN UINTN AllocationSize)
VOID DumpHiiPackage(IN VOID *HiiPackage)
VOID CreateVfrDriverList(IN EFI_GUID *DriverGuidArray)
EFI_STATUS GetAddressByGuid(IN VOID *Ffs, IN EFI_GUID *Guid, IN UINTN Length, OUT UINTN **Offset, OUT UINT8 *NumOfMatchingGuid)
VOID VarCheckHiiGenFromFv(VOID)
EFI_STATUS SearchVfrBinInFfs(IN VOID *Ffs, IN VOID *EfiAddr, IN UINTN Length, OUT UINTN **Offset, OUT UINT8 *NumOfMatchingOffset)
VOID ParseFv(IN BOOLEAN ScanAll)
BOOLEAN ParseFfs(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv2, IN EFI_GUID *DriverGuid)
VOID DestroyVfrDriverList(VOID)