54 UINTN BlockIoPpiInstance;
57 UINTN NumberBlockDevices;
70 for (Index = 0; Index < PEI_FAT_CACHE_SIZE; Index++) {
71 PrivateData->CacheBuffer[Index].Valid =
FALSE;
74 PrivateData->BlockDeviceCount = 0;
80 for (BlockIoPpiInstance = 0; BlockIoPpiInstance < PEI_FAT_MAX_BLOCK_IO_PPI; BlockIoPpiInstance++) {
83 &gEfiPeiVirtualBlockIo2PpiGuid,
90 &gEfiPeiVirtualBlockIoPpiGuid,
97 if (EFI_ERROR (Status)) {
118 if (EFI_ERROR (Status)) {
122 for (Index = 1; Index <= NumberBlockDevices && PrivateData->BlockDeviceCount < PEI_FAT_MAX_BLOCK_DEVICE; Index++) {
134 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockIo2 = BlockIo2Ppi;
135 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].InterfaceType = Media2.
InterfaceType;
136 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].LastBlock = Media2.
LastBlock;
137 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockSize = Media2.
BlockSize;
149 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockIo = BlockIoPpi;
150 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].DevType = Media.
DeviceType;
151 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].LastBlock = Media.
LastBlock;
152 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockSize = (UINT32)Media.
BlockSize;
155 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].IoAlign = 0;
159 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].Logical =
FALSE;
160 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].PartitionChecked =
FALSE;
162 PrivateData->BlockDevice[PrivateData->BlockDeviceCount].PhysicalDevNo = (UINT8)Index;
163 PrivateData->BlockDeviceCount++;
175 PrivateData->VolumeCount = 0;
176 for (Index = 0; Index < PrivateData->BlockDeviceCount; Index++) {
177 Volume.BlockDeviceNo = Index;
184 (UINT8 *)&(PrivateData->Volume[PrivateData->VolumeCount]),
188 PrivateData->VolumeCount += 1;
189 if (PrivateData->VolumeCount >= PEI_FAT_MAX_VOLUME) {
220 if (
CompareGuid (NotifyDescriptor->Guid, &gEfiPeiVirtualBlockIo2PpiGuid)) {
255 if (!EFI_ERROR (Status)) {
264 if (EFI_ERROR (Status)) {
265 return EFI_OUT_OF_RESOURCES;
275 PrivateData->Signature = PEI_FAT_PRIVATE_DATA_SIGNATURE;
284 PrivateData->PpiDescriptor.
Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
285 PrivateData->PpiDescriptor.
Guid = &gEfiPeiDeviceRecoveryModulePpiGuid;
286 PrivateData->PpiDescriptor.
Ppi = &PrivateData->DeviceRecoveryPpi;
289 if (EFI_ERROR (Status)) {
290 return EFI_OUT_OF_RESOURCES;
296 PrivateData->BlockDeviceCount = 0;
304 mPrivateData = PrivateData;
309 PrivateData->NotifyDescriptor[0].
Flags =
311 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
313 PrivateData->NotifyDescriptor[0].
Guid = &gEfiPeiVirtualBlockIoPpiGuid;
315 PrivateData->NotifyDescriptor[1].
Flags =
317 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
318 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
320 PrivateData->NotifyDescriptor[1].
Guid = &gEfiPeiVirtualBlockIo2PpiGuid;
359 UINTN RecoveryCapsuleCount;
360 PEI_FILE_HANDLE Handle;
362 PrivateData = PEI_FAT_PRIVATE_DATA_FROM_THIS (This);
367 RecoveryCapsuleCount = 0;
368 for (Index = 0; Index < PrivateData->VolumeCount; Index++) {
370 if (EFI_ERROR (Status)) {
374 RecoveryCapsuleCount++;
377 *NumberRecoveryCapsules = RecoveryCapsuleCount;
379 if (*NumberRecoveryCapsules == 0) {
380 return EFI_NOT_FOUND;
425 UINTN RecoveryCapsuleCount;
426 PEI_FILE_HANDLE Handle;
427 UINTN NumberRecoveryCapsules;
433 if (EFI_ERROR (Status)) {
437 if ((CapsuleInstance == 0) || (CapsuleInstance > NumberRecoveryCapsules)) {
438 return EFI_NOT_FOUND;
441 PrivateData = PEI_FAT_PRIVATE_DATA_FROM_THIS (This);
446 RecoveryCapsuleCount = 0;
447 for (Index = 0; Index < PrivateData->VolumeCount; Index++) {
450 if (EFI_ERROR (Status)) {
454 if (CapsuleInstance - 1 == RecoveryCapsuleCount) {
463 BlockDeviceNo = PrivateData->Volume[Index].BlockDeviceNo;
464 while (BlockDeviceNo < PrivateData->BlockDeviceCount && PrivateData->BlockDevice[BlockDeviceNo].Logical) {
465 BlockDeviceNo = PrivateData->BlockDevice[BlockDeviceNo].ParentDevNo;
471 if (BlockDeviceNo < PrivateData->BlockDeviceCount) {
472 if (PrivateData->BlockDevice[BlockDeviceNo].BlockIo2 !=
NULL) {
473 switch (PrivateData->BlockDevice[BlockDeviceNo].InterfaceType) {
475 CopyGuid (CapsuleType, &gRecoveryOnFatIdeDiskGuid);
479 CopyGuid (CapsuleType, &gRecoveryOnFatUsbDiskGuid);
483 CopyGuid (CapsuleType, &gRecoveryOnFatNvmeDiskGuid);
491 if (PrivateData->BlockDevice[BlockDeviceNo].BlockIo !=
NULL) {
492 switch (PrivateData->BlockDevice[BlockDeviceNo].DevType) {
494 CopyGuid (CapsuleType, &gRecoveryOnFatFloppyDiskGuid);
499 CopyGuid (CapsuleType, &gRecoveryOnFatIdeDiskGuid);
503 CopyGuid (CapsuleType, &gRecoveryOnFatUsbDiskGuid);
515 RecoveryCapsuleCount++;
518 return EFI_NOT_FOUND;
552 UINTN RecoveryCapsuleCount;
553 PEI_FILE_HANDLE Handle;
554 UINTN NumberRecoveryCapsules;
560 if (EFI_ERROR (Status)) {
564 if ((CapsuleInstance == 0) || (CapsuleInstance > NumberRecoveryCapsules)) {
565 return EFI_NOT_FOUND;
568 PrivateData = PEI_FAT_PRIVATE_DATA_FROM_THIS (This);
573 RecoveryCapsuleCount = 0;
574 for (Index = 0; Index < PrivateData->VolumeCount; Index++) {
576 if (EFI_ERROR (Status)) {
580 if (CapsuleInstance - 1 == RecoveryCapsuleCount) {
590 RecoveryCapsuleCount++;
593 return EFI_NOT_FOUND;
619 OUT PEI_FILE_HANDLE *Handle
626 File = &PrivateData->File;
632 ASSERT (VolumeIndex < PEI_FAT_MAX_VOLUME);
638 Parent.IsFixedRootDir = (BOOLEAN)((PrivateData->Volume[VolumeIndex].FatType == Fat32) ?
FALSE :
TRUE);
639 Parent.Attributes = FAT_ATTR_DIRECTORY;
640 Parent.CurrentPos = 0;
641 Parent.CurrentCluster = Parent.IsFixedRootDir ? 0 : PrivateData->Volume[VolumeIndex].RootDirCluster;
642 Parent.StartingCluster = Parent.CurrentCluster;
643 Parent.Volume = &PrivateData->Volume[VolumeIndex];
646 if (EFI_ERROR (Status)) {
647 return EFI_DEVICE_ERROR;
658 if (
EngStriColl (PrivateData, FileName, File->FileName)) {
665 if (EFI_ERROR (Status)) {
666 return EFI_NOT_FOUND;
672 if (File->StartingCluster != 0) {
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define MSG_NVME_NAMESPACE_DP
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS EFIAPI PeiServicesAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
EFI_STATUS FatReadNextDirectoryEntry(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *ParentDir, OUT PEI_FAT_FILE *SubFile)
EFI_STATUS FatGetBpbInfo(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN OUT PEI_FAT_VOLUME *Volume)
EFI_STATUS FatSetFilePos(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *File, IN UINT32 Pos)
EFI_STATUS FatReadFile(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *File, IN UINTN Size, OUT VOID *Buffer)
EFI_STATUS EFIAPI GetRecoveryCapsuleInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, IN UINTN CapsuleInstance, OUT UINTN *Size, OUT EFI_GUID *CapsuleType)
EFI_STATUS FindRecoveryFile(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN VolumeIndex, IN CHAR16 *FileName, OUT PEI_FILE_HANDLE *Handle)
EFI_STATUS EFIAPI GetNumberRecoveryCapsules(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
EFI_STATUS EFIAPI BlockIoNotifyEntry(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS UpdateBlocksAndVolumes(IN OUT PEI_FAT_PRIVATE_DATA *PrivateData, IN BOOLEAN BlockIo2)
EFI_STATUS EFIAPI LoadRecoveryCapsule(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, IN UINTN CapsuleInstance, OUT VOID *Buffer)
EFI_STATUS EFIAPI FatPeimEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
BOOLEAN EngStriColl(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN CHAR16 *Str1, IN CHAR16 *Str2)
VOID FatFindPartitions(IN PEI_FAT_PRIVATE_DATA *PrivateData)
@ IdeLS120
The recovery device is an IDE LS-120.
@ IdeCDROM
The recovery device is an IDE CD-ROM.
@ UsbMassStorage
The recovery device is a USB Mass Storage device.
@ LegacyFloppy
The recovery device is a floppy.
#define PcdGetPtr(TokenName)
VOID * EFI_PEI_FILE_HANDLE
UINT64 EFI_PHYSICAL_ADDRESS
EFI_PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE GetNumberRecoveryCapsules
Returns the number of DXE capsules residing on the device.
EFI_PEI_DEVICE_LOAD_RECOVERY_CAPSULE LoadRecoveryCapsule
Loads a DXE capsule from some media into memory.
EFI_PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO GetRecoveryCapsuleInfo
Returns the size and type of the requested recovery capsule.
EFI_PEIM_NOTIFY_ENTRY_POINT Notify
EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2 GetBlockDeviceMediaInfo
EFI_PEI_GET_NUMBER_BLOCK_DEVICES2 GetNumberOfBlockDevices
EFI_PEI_GET_NUMBER_BLOCK_DEVICES GetNumberOfBlockDevices
EFI_PEI_GET_DEVICE_MEDIA_INFORMATION GetBlockDeviceMediaInfo
EFI_PEI_BLOCK_DEVICE_TYPE DeviceType