16 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
28 EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION,
36 EFI_PEI_PPI_DESCRIPTOR_PPI,
37 &gEfiPeiVirtualBlockIoPpiGuid,
41 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
42 &gEfiPeiVirtualBlockIo2PpiGuid,
82 UINTN UsbIoPpiInstance;
96 for (UsbIoPpiInstance = 0; UsbIoPpiInstance < PEI_FAT_MAX_USB_IO_PPI; UsbIoPpiInstance++) {
103 if (EFI_ERROR (Status)) {
172 Status = UsbIoPpi->UsbGetInterfaceDescriptor (
177 if (EFI_ERROR (Status)) {
184 if ((InterfaceDesc->InterfaceClass != 0x08) || (InterfaceDesc->InterfaceProtocol != 0x50)) {
185 return EFI_NOT_FOUND;
194 if (EFI_ERROR (Status)) {
200 PeiBotDevice->Signature = PEI_BOT_DEVICE_SIGNATURE;
201 PeiBotDevice->UsbIoPpi = UsbIoPpi;
203 PeiBotDevice->BotInterface = InterfaceDesc;
218 for (Index = 0; Index < 2; Index++) {
219 Status = UsbIoPpi->UsbGetEndpointDescriptor (
226 if (EFI_ERROR (Status)) {
230 if ((EndpointDesc->EndpointAddress & 0x80) != 0) {
231 PeiBotDevice->BulkInEndpoint = EndpointDesc;
233 PeiBotDevice->BulkOutEndpoint = EndpointDesc;
238 &(PeiBotDevice->BlkIoPpi),
243 &(PeiBotDevice->BlkIo2Ppi),
248 &(PeiBotDevice->BlkIoPpiList),
253 &(PeiBotDevice->BlkIo2PpiList),
257 PeiBotDevice->BlkIoPpiList.
Ppi = &PeiBotDevice->BlkIoPpi;
258 PeiBotDevice->BlkIo2PpiList.
Ppi = &PeiBotDevice->BlkIo2Ppi;
261 if (EFI_ERROR (Status)) {
270 if (EFI_ERROR (Status)) {
278 if (EFI_ERROR (Status)) {
315 *NumberBlockDevices = 1;
358 PeiBotDev = PEI_BOT_DEVICE_FROM_THIS (This);
373 if (EFI_ERROR (Status)) {
374 return EFI_DEVICE_ERROR;
434 UINTN NumberOfBlocks;
437 PeiBotDev = PEI_BOT_DEVICE_FROM_THIS (This);
442 if (Buffer ==
NULL) {
443 return EFI_INVALID_PARAMETER;
446 if (BufferSize == 0) {
456 if (BufferSize % BlockSize != 0) {
457 Status = EFI_BAD_BUFFER_SIZE;
460 if (StartLBA > PeiBotDev->Media2.
LastBlock) {
461 Status = EFI_INVALID_PARAMETER;
464 NumberOfBlocks = BufferSize / (PeiBotDev->Media.
BlockSize);
490 if (EFI_ERROR (Status)) {
500 return EFI_DEVICE_ERROR;
503 NumberOfBlocks = BufferSize / PeiBotDev->Media.
BlockSize;
509 if (BufferSize % (PeiBotDev->Media.
BlockSize) != 0) {
510 return EFI_BAD_BUFFER_SIZE;
513 if (StartLBA > PeiBotDev->Media2.
LastBlock) {
514 return EFI_INVALID_PARAMETER;
517 if ((StartLBA + NumberOfBlocks - 1) > PeiBotDev->Media2.
LastBlock) {
518 return EFI_INVALID_PARAMETER;
534 return EFI_DEVICE_ERROR;
539 Buffer = (UINT8 *)Buffer + PeiBotDev->Media.
BlockSize;
541 if (NumberOfBlocks == 0) {
557 return EFI_DEVICE_ERROR;
592 *NumberBlockDevices = 1;
635 PeiBotDev = PEI_BOT_DEVICE2_FROM_THIS (This);
639 &PeiBotDev->BlkIoPpi,
644 if (EFI_ERROR (Status)) {
650 &(PeiBotDev->Media2),
706 return EFI_INVALID_PARAMETER;
710 PeiBotDev = PEI_BOT_DEVICE2_FROM_THIS (This);
714 &PeiBotDev->BlkIoPpi,
744 BOOLEAN NeedReadCapacity;
755 NeedReadCapacity =
TRUE;
762 if (EFI_ERROR (Status)) {
766 SensePtr = PeiBotDev->SensePtr;
767 ZeroMem (SensePtr, EFI_PAGE_SIZE);
781 NeedReadCapacity =
FALSE;
782 PeiBotDev->Media.MediaPresent =
FALSE;
783 PeiBotDev->Media.LastBlock = 0;
784 PeiBotDev->Media2.MediaPresent =
FALSE;
785 PeiBotDev->Media2.LastBlock = 0;
791 PeiBotDev->Media.MediaPresent =
TRUE;
792 PeiBotDev->Media2.MediaPresent =
TRUE;
802 PeiBotDev->Media.MediaPresent =
FALSE;
803 PeiBotDev->Media.LastBlock = 0;
804 PeiBotDev->Media2.MediaPresent =
FALSE;
805 PeiBotDev->Media2.LastBlock = 0;
810 if (NeedReadCapacity) {
814 for (Retry = 0; Retry < 4; Retry++) {
815 switch (PeiBotDev->DeviceType) {
828 if (EFI_ERROR (Status) ||
829 !PeiBotDev->Media.MediaPresent)
834 PeiBotDev->DeviceType = USBFLOPPY;
835 Status = EFI_DEVICE_ERROR;
845 if (EFI_ERROR (Status)) {
849 PeiBotDev->DeviceType = USBFLOPPY2;
855 return EFI_INVALID_PARAMETER;
859 ZeroMem (SensePtr, EFI_PAGE_SIZE);
875 if (EFI_ERROR (FloppyStatus)) {
883 PeiBotDev->Media.MediaPresent =
FALSE;
884 PeiBotDev->Media.LastBlock = 0;
885 PeiBotDev->Media2.MediaPresent =
FALSE;
886 PeiBotDev->Media2.LastBlock = 0;
894 PeiBotDev->Media.MediaPresent =
FALSE;
895 PeiBotDev->Media.LastBlock = 0;
896 PeiBotDev->Media2.MediaPresent =
FALSE;
897 PeiBotDev->Media2.LastBlock = 0;
910 return EFI_DEVICE_ERROR;
BOOLEAN IsNoMedia(IN ATAPI_REQUEST_SENSE_DATA *SenseData, IN UINTN SenseCounts)
BOOLEAN IsMediaError(IN ATAPI_REQUEST_SENSE_DATA *SenseData, IN UINTN SenseCounts)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS PeiUsbReadCapacity(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDevice)
EFI_STATUS PeiUsbRequestSense(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDevice, OUT UINTN *SenseCounts, IN UINT8 *SenseKeyBuffer)
EFI_STATUS PeiUsbRead10(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDevice, IN VOID *Buffer, IN EFI_PEI_LBA Lba, IN UINTN NumberOfBlocks)
EFI_STATUS PeiUsbReadFormattedCapacity(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDevice)
EFI_STATUS PeiUsbTestUnitReady(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDevice)
EFI_STATUS PeiUsbInquiry(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDevice)
BOOLEAN IsMediaChange(IN ATAPI_REQUEST_SENSE_DATA *SenseData, IN UINTN SenseCounts)
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)
@ UsbMassStorage
The recovery device is a USB Mass Storage device.
VOID * EFI_PEI_FILE_HANDLE
UINT64 EFI_PHYSICAL_ADDRESS
EFI_STATUS EFIAPI BotGetMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
EFI_STATUS EFIAPI BotReadBlocks2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS PeiBotDetectMedia(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDev)
EFI_STATUS EFIAPI NotifyOnUsbIoPpi(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc, IN VOID *InvokePpi)
EFI_STATUS EFIAPI PeimInitializeUsbBot(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI BotGetNumberOfBlockDevices(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
EFI_STATUS EFIAPI BotGetMediaInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo)
EFI_STATUS EFIAPI BotGetNumberOfBlockDevices2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
EFI_STATUS InitUsbBot(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *UsbIoPpi)
EFI_STATUS EFIAPI BotReadBlocks(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_PEI_BLOCK_DEVICE_TYPE DeviceType