90 while ((Length > 0) && (String[Length-1] ==
' ')) {
94 String[Length] =
'\0';
125 &gScsiDiskDriverBinding,
127 &gScsiDiskComponentName,
128 &gScsiDiskComponentName2
166 Status =
gBS->OpenProtocol (
168 &gEfiScsiIoProtocolGuid,
170 This->DriverBindingHandle,
172 EFI_OPEN_PROTOCOL_BY_DRIVER
174 if (EFI_ERROR (Status)) {
178 Status = ScsiIo->GetDeviceType (ScsiIo, &DeviceType);
179 if (!EFI_ERROR (Status)) {
186 Status = EFI_UNSUPPORTED;
192 &gEfiScsiIoProtocolGuid,
193 This->DriverBindingHandle,
233 BOOLEAN MustReadCapacity;
234 CHAR8 VendorStr[VENDOR_IDENTIFICATION_LENGTH + 1];
235 CHAR8 ProductStr[PRODUCT_IDENTIFICATION_LENGTH + 1];
236 CHAR16 DeviceStr[VENDOR_IDENTIFICATION_LENGTH + PRODUCT_IDENTIFICATION_LENGTH + 2];
238 MustReadCapacity =
TRUE;
241 if (ScsiDiskDevice ==
NULL) {
242 return EFI_OUT_OF_RESOURCES;
245 Status =
gBS->OpenProtocol (
247 &gEfiScsiIoProtocolGuid,
249 This->DriverBindingHandle,
251 EFI_OPEN_PROTOCOL_BY_DRIVER
253 if (EFI_ERROR (Status)) {
258 ScsiDiskDevice->Signature = SCSI_DISK_DEV_SIGNATURE;
259 ScsiDiskDevice->ScsiIo = ScsiIo;
260 ScsiDiskDevice->BlkIo.
Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3;
261 ScsiDiskDevice->BlkIo.
Media = &ScsiDiskDevice->BlkIoMedia;
267 ScsiDiskDevice->BlkIo2.
Media = &ScsiDiskDevice->BlkIoMedia;
274 ScsiDiskDevice->EraseBlock.Revision = EFI_ERASE_BLOCK_PROTOCOL_REVISION;
275 ScsiDiskDevice->EraseBlock.EraseLengthGranularity = 1;
277 ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt = 1;
278 ScsiDiskDevice->BlockLimitsVpdSupported =
FALSE;
279 ScsiDiskDevice->Handle = Controller;
282 ScsiIo->GetDeviceType (ScsiIo, &(ScsiDiskDevice->DeviceType));
283 switch (ScsiDiskDevice->DeviceType) {
286 MustReadCapacity =
TRUE;
292 MustReadCapacity =
FALSE;
296 MustReadCapacity =
FALSE;
303 ScsiDiskDevice->SenseDataNumber = 6;
307 if (ScsiDiskDevice->SenseData ==
NULL) {
310 &gEfiScsiIoProtocolGuid,
311 This->DriverBindingHandle,
315 return EFI_OUT_OF_RESOURCES;
322 for (Index = 0; Index < MaxRetry; Index++) {
324 if (!EFI_ERROR (Status)) {
329 FreePool (ScsiDiskDevice->SenseData);
332 &gEfiScsiIoProtocolGuid,
333 This->DriverBindingHandle,
337 return EFI_DEVICE_ERROR;
346 if (!EFI_ERROR (Status)) {
353 Status =
gBS->InstallMultipleProtocolInterfaces (
355 &gEfiBlockIoProtocolGuid,
356 &ScsiDiskDevice->BlkIo,
357 &gEfiBlockIo2ProtocolGuid,
358 &ScsiDiskDevice->BlkIo2,
359 &gEfiDiskInfoProtocolGuid,
360 &ScsiDiskDevice->DiskInfo,
363 if (!EFI_ERROR (Status)) {
365 Status =
gBS->InstallProtocolInterface (
367 &gEfiEraseBlockProtocolGuid,
369 &ScsiDiskDevice->EraseBlock
371 if (EFI_ERROR (Status)) {
372 DEBUG ((DEBUG_ERROR,
"ScsiDisk: Failed to install the Erase Block Protocol! Status = %r\n", Status));
377 Status =
gBS->InstallProtocolInterface (
379 &gEfiStorageSecurityCommandProtocolGuid,
381 &ScsiDiskDevice->StorageSecurity
383 if (EFI_ERROR (Status)) {
384 DEBUG ((DEBUG_ERROR,
"ScsiDisk: Failed to install the Storage Security Command Protocol! Status = %r\n", Status));
390 &ScsiDiskDevice->InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET],
391 VENDOR_IDENTIFICATION_LENGTH
393 VendorStr[VENDOR_IDENTIFICATION_LENGTH] = 0;
398 &ScsiDiskDevice->InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET],
399 PRODUCT_IDENTIFICATION_LENGTH
401 ProductStr[PRODUCT_IDENTIFICATION_LENGTH] = 0;
404 UnicodeSPrint (DeviceStr,
sizeof (DeviceStr), L
"%a %a", VendorStr, ProductStr);
406 ScsiDiskDevice->ControllerNameTable =
NULL;
410 &ScsiDiskDevice->ControllerNameTable,
417 &ScsiDiskDevice->ControllerNameTable,
426 gBS->FreePool (ScsiDiskDevice->SenseData);
427 gBS->FreePool (ScsiDiskDevice);
430 &gEfiScsiIoProtocolGuid,
431 This->DriverBindingHandle,
470 Status =
gBS->OpenProtocol (
472 &gEfiBlockIoProtocolGuid,
474 This->DriverBindingHandle,
476 EFI_OPEN_PROTOCOL_GET_PROTOCOL
478 if (EFI_ERROR (Status)) {
482 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (BlkIo);
487 while (!
IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue)) {
493 Status =
gBS->OpenProtocol (
495 &gEfiEraseBlockProtocolGuid,
496 (VOID **)&EraseBlock,
497 This->DriverBindingHandle,
499 EFI_OPEN_PROTOCOL_GET_PROTOCOL
502 if (!EFI_ERROR (Status)) {
503 Status =
gBS->UninstallProtocolInterface (
505 &gEfiEraseBlockProtocolGuid,
506 &ScsiDiskDevice->EraseBlock
508 if (EFI_ERROR (Status)) {
513 Status =
gBS->UninstallMultipleProtocolInterfaces (
515 &gEfiBlockIoProtocolGuid,
516 &ScsiDiskDevice->BlkIo,
517 &gEfiBlockIo2ProtocolGuid,
518 &ScsiDiskDevice->BlkIo2,
519 &gEfiDiskInfoProtocolGuid,
520 &ScsiDiskDevice->DiskInfo,
523 if (!EFI_ERROR (Status)) {
526 &gEfiScsiIoProtocolGuid,
527 This->DriverBindingHandle,
559 IN BOOLEAN ExtendedVerification
566 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
568 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
570 Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
572 if (EFI_ERROR (Status)) {
573 if (Status == EFI_UNSUPPORTED) {
576 Status = EFI_DEVICE_ERROR;
581 if (!ExtendedVerification) {
585 Status = ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
587 if (EFI_ERROR (Status)) {
588 Status = EFI_DEVICE_ERROR;
593 gBS->RestoreTPL (OldTpl);
628 UINTN NumberOfBlocks;
633 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
634 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
635 Media = ScsiDiskDevice->BlkIo.
Media;
637 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
639 if (EFI_ERROR (Status)) {
640 Status = EFI_DEVICE_ERROR;
645 gBS->ReinstallProtocolInterface (
646 ScsiDiskDevice->Handle,
647 &gEfiBlockIoProtocolGuid,
648 &ScsiDiskDevice->BlkIo,
649 &ScsiDiskDevice->BlkIo
651 gBS->ReinstallProtocolInterface (
652 ScsiDiskDevice->Handle,
653 &gEfiBlockIo2ProtocolGuid,
654 &ScsiDiskDevice->BlkIo2,
655 &ScsiDiskDevice->BlkIo2
658 gBS->ReinstallProtocolInterface (
659 ScsiDiskDevice->Handle,
660 &gEfiEraseBlockProtocolGuid,
661 &ScsiDiskDevice->EraseBlock,
662 &ScsiDiskDevice->EraseBlock
667 gBS->ReinstallProtocolInterface (
668 ScsiDiskDevice->Handle,
669 &gEfiStorageSecurityCommandProtocolGuid,
670 &ScsiDiskDevice->StorageSecurity,
671 &ScsiDiskDevice->StorageSecurity
676 Status = EFI_MEDIA_CHANGED;
678 Status = EFI_NO_MEDIA;
690 if (BlockSize == 0) {
691 Status = EFI_DEVICE_ERROR;
695 NumberOfBlocks = BufferSize / BlockSize;
698 Status = EFI_NO_MEDIA;
702 if (MediaId != Media->
MediaId) {
703 Status = EFI_MEDIA_CHANGED;
707 if (Buffer ==
NULL) {
708 Status = EFI_INVALID_PARAMETER;
712 if (BufferSize == 0) {
717 if (BufferSize % BlockSize != 0) {
718 Status = EFI_BAD_BUFFER_SIZE;
723 Status = EFI_INVALID_PARAMETER;
727 if ((Lba + NumberOfBlocks - 1) > Media->
LastBlock) {
728 Status = EFI_INVALID_PARAMETER;
733 Status = EFI_INVALID_PARAMETER;
744 gBS->RestoreTPL (OldTpl);
780 UINTN NumberOfBlocks;
785 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
786 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
787 Media = ScsiDiskDevice->BlkIo.
Media;
789 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
791 if (EFI_ERROR (Status)) {
792 Status = EFI_DEVICE_ERROR;
797 gBS->ReinstallProtocolInterface (
798 ScsiDiskDevice->Handle,
799 &gEfiBlockIoProtocolGuid,
800 &ScsiDiskDevice->BlkIo,
801 &ScsiDiskDevice->BlkIo
803 gBS->ReinstallProtocolInterface (
804 ScsiDiskDevice->Handle,
805 &gEfiBlockIo2ProtocolGuid,
806 &ScsiDiskDevice->BlkIo2,
807 &ScsiDiskDevice->BlkIo2
810 gBS->ReinstallProtocolInterface (
811 ScsiDiskDevice->Handle,
812 &gEfiEraseBlockProtocolGuid,
813 &ScsiDiskDevice->EraseBlock,
814 &ScsiDiskDevice->EraseBlock
819 gBS->ReinstallProtocolInterface (
820 ScsiDiskDevice->Handle,
821 &gEfiStorageSecurityCommandProtocolGuid,
822 &ScsiDiskDevice->StorageSecurity,
823 &ScsiDiskDevice->StorageSecurity
828 Status = EFI_MEDIA_CHANGED;
830 Status = EFI_NO_MEDIA;
842 if (BlockSize == 0) {
843 Status = EFI_DEVICE_ERROR;
847 NumberOfBlocks = BufferSize / BlockSize;
850 Status = EFI_NO_MEDIA;
854 if (MediaId != Media->
MediaId) {
855 Status = EFI_MEDIA_CHANGED;
860 Status = EFI_WRITE_PROTECTED;
864 if (BufferSize == 0) {
869 if (Buffer ==
NULL) {
870 Status = EFI_INVALID_PARAMETER;
874 if (BufferSize % BlockSize != 0) {
875 Status = EFI_BAD_BUFFER_SIZE;
880 Status = EFI_INVALID_PARAMETER;
884 if ((Lba + NumberOfBlocks - 1) > Media->
LastBlock) {
885 Status = EFI_INVALID_PARAMETER;
890 Status = EFI_INVALID_PARAMETER;
901 gBS->RestoreTPL (OldTpl);
943 IN BOOLEAN ExtendedVerification
950 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
952 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
954 Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
956 if (EFI_ERROR (Status)) {
957 if (Status == EFI_UNSUPPORTED) {
960 Status = EFI_DEVICE_ERROR;
965 if (!ExtendedVerification) {
969 Status = ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
971 if (EFI_ERROR (Status)) {
972 Status = EFI_DEVICE_ERROR;
977 gBS->RestoreTPL (OldTpl);
1022 UINTN NumberOfBlocks;
1023 BOOLEAN MediaChange;
1026 MediaChange =
FALSE;
1027 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1028 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
1029 Media = ScsiDiskDevice->BlkIo.
Media;
1031 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
1033 if (EFI_ERROR (Status)) {
1034 Status = EFI_DEVICE_ERROR;
1039 gBS->ReinstallProtocolInterface (
1040 ScsiDiskDevice->Handle,
1041 &gEfiBlockIoProtocolGuid,
1042 &ScsiDiskDevice->BlkIo,
1043 &ScsiDiskDevice->BlkIo
1045 gBS->ReinstallProtocolInterface (
1046 ScsiDiskDevice->Handle,
1047 &gEfiBlockIo2ProtocolGuid,
1048 &ScsiDiskDevice->BlkIo2,
1049 &ScsiDiskDevice->BlkIo2
1052 gBS->ReinstallProtocolInterface (
1053 ScsiDiskDevice->Handle,
1054 &gEfiEraseBlockProtocolGuid,
1055 &ScsiDiskDevice->EraseBlock,
1056 &ScsiDiskDevice->EraseBlock
1061 gBS->ReinstallProtocolInterface (
1062 ScsiDiskDevice->Handle,
1063 &gEfiStorageSecurityCommandProtocolGuid,
1064 &ScsiDiskDevice->StorageSecurity,
1065 &ScsiDiskDevice->StorageSecurity
1070 Status = EFI_MEDIA_CHANGED;
1072 Status = EFI_NO_MEDIA;
1084 if (BlockSize == 0) {
1085 Status = EFI_DEVICE_ERROR;
1089 NumberOfBlocks = BufferSize / BlockSize;
1092 Status = EFI_NO_MEDIA;
1096 if (MediaId != Media->
MediaId) {
1097 Status = EFI_MEDIA_CHANGED;
1101 if (Buffer ==
NULL) {
1102 Status = EFI_INVALID_PARAMETER;
1106 if (BufferSize == 0) {
1107 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1109 gBS->SignalEvent (Token->Event);
1116 if (BufferSize % BlockSize != 0) {
1117 Status = EFI_BAD_BUFFER_SIZE;
1122 Status = EFI_INVALID_PARAMETER;
1126 if ((Lba + NumberOfBlocks - 1) > Media->
LastBlock) {
1127 Status = EFI_INVALID_PARAMETER;
1132 Status = EFI_INVALID_PARAMETER;
1140 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1159 gBS->RestoreTPL (OldTpl);
1201 UINTN NumberOfBlocks;
1202 BOOLEAN MediaChange;
1205 MediaChange =
FALSE;
1206 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1207 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
1208 Media = ScsiDiskDevice->BlkIo.
Media;
1210 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
1212 if (EFI_ERROR (Status)) {
1213 Status = EFI_DEVICE_ERROR;
1218 gBS->ReinstallProtocolInterface (
1219 ScsiDiskDevice->Handle,
1220 &gEfiBlockIoProtocolGuid,
1221 &ScsiDiskDevice->BlkIo,
1222 &ScsiDiskDevice->BlkIo
1224 gBS->ReinstallProtocolInterface (
1225 ScsiDiskDevice->Handle,
1226 &gEfiBlockIo2ProtocolGuid,
1227 &ScsiDiskDevice->BlkIo2,
1228 &ScsiDiskDevice->BlkIo2
1231 gBS->ReinstallProtocolInterface (
1232 ScsiDiskDevice->Handle,
1233 &gEfiEraseBlockProtocolGuid,
1234 &ScsiDiskDevice->EraseBlock,
1235 &ScsiDiskDevice->EraseBlock
1240 gBS->ReinstallProtocolInterface (
1241 ScsiDiskDevice->Handle,
1242 &gEfiStorageSecurityCommandProtocolGuid,
1243 &ScsiDiskDevice->StorageSecurity,
1244 &ScsiDiskDevice->StorageSecurity
1249 Status = EFI_MEDIA_CHANGED;
1251 Status = EFI_NO_MEDIA;
1263 if (BlockSize == 0) {
1264 Status = EFI_DEVICE_ERROR;
1268 NumberOfBlocks = BufferSize / BlockSize;
1271 Status = EFI_NO_MEDIA;
1275 if (MediaId != Media->
MediaId) {
1276 Status = EFI_MEDIA_CHANGED;
1281 Status = EFI_WRITE_PROTECTED;
1285 if (BufferSize == 0) {
1286 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1288 gBS->SignalEvent (Token->Event);
1295 if (Buffer ==
NULL) {
1296 Status = EFI_INVALID_PARAMETER;
1300 if (BufferSize % BlockSize != 0) {
1301 Status = EFI_BAD_BUFFER_SIZE;
1306 Status = EFI_INVALID_PARAMETER;
1310 if ((Lba + NumberOfBlocks - 1) > Media->
LastBlock) {
1311 Status = EFI_INVALID_PARAMETER;
1316 Status = EFI_INVALID_PARAMETER;
1324 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1343 gBS->RestoreTPL (OldTpl);
1371 BOOLEAN MediaChange;
1374 MediaChange =
FALSE;
1375 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1376 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
1377 Media = ScsiDiskDevice->BlkIo.
Media;
1379 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
1381 if (EFI_ERROR (Status)) {
1382 Status = EFI_DEVICE_ERROR;
1387 gBS->ReinstallProtocolInterface (
1388 ScsiDiskDevice->Handle,
1389 &gEfiBlockIoProtocolGuid,
1390 &ScsiDiskDevice->BlkIo,
1391 &ScsiDiskDevice->BlkIo
1393 gBS->ReinstallProtocolInterface (
1394 ScsiDiskDevice->Handle,
1395 &gEfiBlockIo2ProtocolGuid,
1396 &ScsiDiskDevice->BlkIo2,
1397 &ScsiDiskDevice->BlkIo2
1400 gBS->ReinstallProtocolInterface (
1401 ScsiDiskDevice->Handle,
1402 &gEfiEraseBlockProtocolGuid,
1403 &ScsiDiskDevice->EraseBlock,
1404 &ScsiDiskDevice->EraseBlock
1409 gBS->ReinstallProtocolInterface (
1410 ScsiDiskDevice->Handle,
1411 &gEfiStorageSecurityCommandProtocolGuid,
1412 &ScsiDiskDevice->StorageSecurity,
1413 &ScsiDiskDevice->StorageSecurity
1418 Status = EFI_MEDIA_CHANGED;
1420 Status = EFI_NO_MEDIA;
1428 Status = EFI_NO_MEDIA;
1433 Status = EFI_WRITE_PROTECTED;
1440 while (!
IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue)) {
1448 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1450 gBS->SignalEvent (Token->Event);
1454 gBS->RestoreTPL (OldTpl);
1478 gBS->CloseEvent (Event);
1481 CommandPacket = &EraseBlkReq->CommandPacket;
1482 Token = EraseBlkReq->Token;
1486 if (EFI_ERROR (Status)) {
1489 "ScsiDiskAsyncUnmapNotify: Host adapter indicating error status 0x%x.\n",
1493 Token->TransactionStatus = Status;
1498 if (EFI_ERROR (Status)) {
1501 "ScsiDiskAsyncUnmapNotify: Target indicating error status 0x%x.\n",
1505 Token->TransactionStatus = Status;
1515 gBS->SignalEvent (Token->Event);
1547 UINT32 MaxBlkDespCnt;
1549 UINT16 UnmapParamListLen;
1550 VOID *UnmapParamList;
1554 ScsiIo = ScsiDiskDevice->ScsiIo;
1555 MaxLbaCnt = ScsiDiskDevice->UnmapInfo.MaxLbaCnt;
1556 MaxBlkDespCnt = ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt;
1558 UnmapParamList =
NULL;
1559 AsyncUnmapEvent =
NULL;
1562 if (Blocks / (
UINTN)MaxLbaCnt > MaxBlkDespCnt) {
1563 ReturnStatus = EFI_DEVICE_ERROR;
1568 if (EraseBlkReq ==
NULL) {
1569 ReturnStatus = EFI_DEVICE_ERROR;
1574 if (EraseBlkReq->CommandPacket.
Cdb ==
NULL) {
1575 ReturnStatus = EFI_DEVICE_ERROR;
1579 BlkDespCnt = (UINT32)((Blocks - 1) / MaxLbaCnt + 1);
1583 if (UnmapParamList ==
NULL) {
1584 ReturnStatus = EFI_DEVICE_ERROR;
1588 *((UINT16 *)UnmapParamList) =
SwapBytes16 (UnmapParamListLen - 2);
1592 while (Blocks > 0) {
1593 if (Blocks > MaxLbaCnt) {
1594 *(UINT64 *)(&BlkDespPtr->Lba) =
SwapBytes64 (Lba);
1595 *(UINT32 *)(&BlkDespPtr->BlockNum) =
SwapBytes32 (MaxLbaCnt);
1596 Blocks -= MaxLbaCnt;
1599 *(UINT64 *)(&BlkDespPtr->Lba) =
SwapBytes64 (Lba);
1600 *(UINT32 *)(&BlkDespPtr->BlockNum) =
SwapBytes32 ((UINT32)Blocks);
1607 CommandPacket = &EraseBlkReq->CommandPacket;
1608 CommandPacket->
Timeout = SCSI_DISK_TIMEOUT;
1616 Cdb = CommandPacket->
Cdb;
1617 Cdb[0] = EFI_SCSI_OP_UNMAP;
1620 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1624 Status =
gBS->CreateEvent (
1631 if (EFI_ERROR (Status)) {
1632 ReturnStatus = EFI_DEVICE_ERROR;
1636 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1637 InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &EraseBlkReq->Link);
1638 gBS->RestoreTPL (OldTpl);
1640 EraseBlkReq->Token = Token;
1642 Status = ScsiIo->ExecuteScsiCommand (
1647 if (EFI_ERROR (Status)) {
1648 ReturnStatus = EFI_DEVICE_ERROR;
1650 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1652 gBS->RestoreTPL (OldTpl);
1665 Status = ScsiIo->ExecuteScsiCommand (
1670 if (EFI_ERROR (Status)) {
1671 ReturnStatus = EFI_DEVICE_ERROR;
1680 if (EFI_ERROR (Status)) {
1683 "ScsiDiskUnmap: Host adapter indicating error status 0x%x.\n",
1687 ReturnStatus = EFI_DEVICE_ERROR;
1692 if (EFI_ERROR (Status)) {
1695 "ScsiDiskUnmap: Target indicating error status 0x%x.\n",
1699 ReturnStatus = EFI_DEVICE_ERROR;
1704 if (EraseBlkReq !=
NULL) {
1705 if (EraseBlkReq->CommandPacket.
Cdb !=
NULL) {
1712 if (UnmapParamList !=
NULL) {
1716 if (AsyncUnmapEvent !=
NULL) {
1717 gBS->CloseEvent (AsyncUnmapEvent);
1720 return ReturnStatus;
1764 UINTN NumberOfBlocks;
1765 BOOLEAN MediaChange;
1768 MediaChange =
FALSE;
1769 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1770 ScsiDiskDevice = SCSI_DISK_DEV_FROM_ERASEBLK (This);
1772 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
1774 if (EFI_ERROR (Status)) {
1775 Status = EFI_DEVICE_ERROR;
1780 gBS->ReinstallProtocolInterface (
1781 ScsiDiskDevice->Handle,
1782 &gEfiBlockIoProtocolGuid,
1783 &ScsiDiskDevice->BlkIo,
1784 &ScsiDiskDevice->BlkIo
1786 gBS->ReinstallProtocolInterface (
1787 ScsiDiskDevice->Handle,
1788 &gEfiBlockIo2ProtocolGuid,
1789 &ScsiDiskDevice->BlkIo2,
1790 &ScsiDiskDevice->BlkIo2
1793 gBS->ReinstallProtocolInterface (
1794 ScsiDiskDevice->Handle,
1795 &gEfiEraseBlockProtocolGuid,
1796 &ScsiDiskDevice->EraseBlock,
1797 &ScsiDiskDevice->EraseBlock
1802 gBS->ReinstallProtocolInterface (
1803 ScsiDiskDevice->Handle,
1804 &gEfiStorageSecurityCommandProtocolGuid,
1805 &ScsiDiskDevice->StorageSecurity,
1806 &ScsiDiskDevice->StorageSecurity
1810 Status = EFI_MEDIA_CHANGED;
1818 Media = ScsiDiskDevice->BlkIo.
Media;
1821 Status = EFI_NO_MEDIA;
1825 if (MediaId != Media->
MediaId) {
1826 Status = EFI_MEDIA_CHANGED;
1831 Status = EFI_WRITE_PROTECTED;
1836 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1838 gBS->SignalEvent (Token->Event);
1846 if ((Size % BlockSize) != 0) {
1847 Status = EFI_INVALID_PARAMETER;
1851 NumberOfBlocks = Size / BlockSize;
1852 if ((Lba + NumberOfBlocks - 1) > Media->
LastBlock) {
1853 Status = EFI_INVALID_PARAMETER;
1857 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1858 Status =
ScsiDiskUnmap (ScsiDiskDevice, Lba, NumberOfBlocks, Token);
1864 gBS->RestoreTPL (OldTpl);
1938 IN UINT32 MediaId OPTIONAL,
1940 IN UINT8 SecurityProtocolId,
1941 IN UINT16 SecurityProtocolSpecificData,
1943 OUT VOID *PayloadBuffer,
1950 BOOLEAN MediaChange;
1952 UINT8 SenseDataLength;
1953 UINT8 HostAdapterStatus;
1955 VOID *AlignedBuffer;
1956 BOOLEAN AlignedBufferAllocated;
1958 AlignedBuffer =
NULL;
1959 MediaChange =
FALSE;
1960 AlignedBufferAllocated =
FALSE;
1961 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1962 ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
1963 Media = ScsiDiskDevice->BlkIo.
Media;
1965 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
1967 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
1969 if (EFI_ERROR (Status)) {
1970 Status = EFI_DEVICE_ERROR;
1975 gBS->ReinstallProtocolInterface (
1976 ScsiDiskDevice->Handle,
1977 &gEfiBlockIoProtocolGuid,
1978 &ScsiDiskDevice->BlkIo,
1979 &ScsiDiskDevice->BlkIo
1981 gBS->ReinstallProtocolInterface (
1982 ScsiDiskDevice->Handle,
1983 &gEfiBlockIo2ProtocolGuid,
1984 &ScsiDiskDevice->BlkIo2,
1985 &ScsiDiskDevice->BlkIo2
1988 gBS->ReinstallProtocolInterface (
1989 ScsiDiskDevice->Handle,
1990 &gEfiEraseBlockProtocolGuid,
1991 &ScsiDiskDevice->EraseBlock,
1992 &ScsiDiskDevice->EraseBlock
1997 gBS->ReinstallProtocolInterface (
1998 ScsiDiskDevice->Handle,
1999 &gEfiStorageSecurityCommandProtocolGuid,
2000 &ScsiDiskDevice->StorageSecurity,
2001 &ScsiDiskDevice->StorageSecurity
2006 Status = EFI_MEDIA_CHANGED;
2008 Status = EFI_NO_MEDIA;
2019 Status = EFI_NO_MEDIA;
2023 if ((MediaId != 0) && (MediaId != Media->
MediaId)) {
2024 Status = EFI_MEDIA_CHANGED;
2028 if (PayloadBufferSize != 0) {
2029 if ((PayloadBuffer ==
NULL) || (PayloadTransferSize ==
NULL)) {
2030 Status = EFI_INVALID_PARAMETER;
2036 if (AlignedBuffer ==
NULL) {
2037 Status = EFI_OUT_OF_RESOURCES;
2041 ZeroMem (AlignedBuffer, PayloadBufferSize);
2042 AlignedBufferAllocated =
TRUE;
2044 AlignedBuffer = PayloadBuffer;
2049 ScsiDiskDevice->ScsiIo,
2051 ScsiDiskDevice->SenseData,
2056 SecurityProtocolSpecificData,
2062 if (EFI_ERROR (Status)) {
2066 if (AlignedBufferAllocated) {
2067 CopyMem (PayloadBuffer, AlignedBuffer, PayloadBufferSize);
2070 if (PayloadBufferSize < *PayloadTransferSize) {
2071 Status = EFI_WARN_BUFFER_TOO_SMALL;
2076 if (EFI_ERROR (Status)) {
2081 if (EFI_ERROR (Status)) {
2086 if (AlignedBufferAllocated) {
2087 ZeroMem (AlignedBuffer, PayloadBufferSize);
2091 gBS->RestoreTPL (OldTpl);
2156 IN UINT32 MediaId OPTIONAL,
2158 IN UINT8 SecurityProtocolId,
2159 IN UINT16 SecurityProtocolSpecificData,
2161 OUT VOID *PayloadBuffer
2167 BOOLEAN MediaChange;
2169 UINT8 SenseDataLength;
2170 UINT8 HostAdapterStatus;
2172 VOID *AlignedBuffer;
2173 BOOLEAN AlignedBufferAllocated;
2175 AlignedBuffer =
NULL;
2176 MediaChange =
FALSE;
2177 AlignedBufferAllocated =
FALSE;
2178 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
2179 ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
2180 Media = ScsiDiskDevice->BlkIo.
Media;
2182 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
2184 if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
2186 if (EFI_ERROR (Status)) {
2187 Status = EFI_DEVICE_ERROR;
2192 gBS->ReinstallProtocolInterface (
2193 ScsiDiskDevice->Handle,
2194 &gEfiBlockIoProtocolGuid,
2195 &ScsiDiskDevice->BlkIo,
2196 &ScsiDiskDevice->BlkIo
2198 gBS->ReinstallProtocolInterface (
2199 ScsiDiskDevice->Handle,
2200 &gEfiBlockIo2ProtocolGuid,
2201 &ScsiDiskDevice->BlkIo2,
2202 &ScsiDiskDevice->BlkIo2
2205 gBS->ReinstallProtocolInterface (
2206 ScsiDiskDevice->Handle,
2207 &gEfiEraseBlockProtocolGuid,
2208 &ScsiDiskDevice->EraseBlock,
2209 &ScsiDiskDevice->EraseBlock
2214 gBS->ReinstallProtocolInterface (
2215 ScsiDiskDevice->Handle,
2216 &gEfiStorageSecurityCommandProtocolGuid,
2217 &ScsiDiskDevice->StorageSecurity,
2218 &ScsiDiskDevice->StorageSecurity
2223 Status = EFI_MEDIA_CHANGED;
2225 Status = EFI_NO_MEDIA;
2236 Status = EFI_NO_MEDIA;
2240 if ((MediaId != 0) && (MediaId != Media->
MediaId)) {
2241 Status = EFI_MEDIA_CHANGED;
2246 Status = EFI_WRITE_PROTECTED;
2250 if (PayloadBufferSize != 0) {
2251 if (PayloadBuffer ==
NULL) {
2252 Status = EFI_INVALID_PARAMETER;
2258 if (AlignedBuffer ==
NULL) {
2259 Status = EFI_OUT_OF_RESOURCES;
2263 CopyMem (AlignedBuffer, PayloadBuffer, PayloadBufferSize);
2264 AlignedBufferAllocated =
TRUE;
2266 AlignedBuffer = PayloadBuffer;
2271 ScsiDiskDevice->ScsiIo,
2273 ScsiDiskDevice->SenseData,
2278 SecurityProtocolSpecificData,
2283 if (EFI_ERROR (Status)) {
2288 if (EFI_ERROR (Status)) {
2293 if (EFI_ERROR (Status)) {
2298 if (AlignedBufferAllocated) {
2299 ZeroMem (AlignedBuffer, PayloadBufferSize);
2303 gBS->RestoreTPL (OldTpl);
2321 IN BOOLEAN MustReadCapacity,
2322 OUT BOOLEAN *MediaChange
2327 UINTN NumberOfSenseKeys;
2329 BOOLEAN NeedReadCapacity;
2338 NumberOfSenseKeys = 0;
2341 Action = ACTION_NO_ACTION;
2342 NeedReadCapacity =
FALSE;
2343 *MediaChange =
FALSE;
2346 CopyMem (&OldMedia, ScsiDiskDevice->BlkIo.Media, sizeof (OldMedia));
2348 Status =
gBS->CreateEvent (
2355 if (EFI_ERROR (Status)) {
2360 if (EFI_ERROR (Status)) {
2369 while (EFI_ERROR (
gBS->CheckEvent (TimeoutEvt))) {
2376 if (!EFI_ERROR (Status)) {
2383 if (EFI_ERROR (Status)) {
2385 }
else if (Action == ACTION_RETRY_COMMAND_LATER) {
2392 if (!NeedRetry || (Retry >= MaxRetry)) {
2398 if (EFI_ERROR (Status)) {
2406 if (Action == ACTION_READ_CAPACITY) {
2407 NeedReadCapacity =
TRUE;
2414 NeedReadCapacity =
FALSE;
2415 MustReadCapacity =
FALSE;
2416 ScsiDiskDevice->BlkIo.Media->MediaPresent =
TRUE;
2423 if (NeedReadCapacity || MustReadCapacity) {
2427 for (Retry = 0; Retry < MaxRetry; Retry++) {
2434 if (!EFI_ERROR (Status)) {
2444 if (EFI_ERROR (Status)) {
2450 }
else if (Action == ACTION_RETRY_COMMAND_LATER) {
2458 if (!NeedRetry || (Retry >= MaxRetry)) {
2464 if (EFI_ERROR (Status)) {
2469 if (ScsiDiskDevice->BlkIo.Media->MediaId != OldMedia.
MediaId) {
2473 *MediaChange =
TRUE;
2476 if (ScsiDiskDevice->BlkIo.Media->ReadOnly != OldMedia.
ReadOnly) {
2477 *MediaChange =
TRUE;
2478 ScsiDiskDevice->BlkIo.Media->MediaId += 1;
2481 if (ScsiDiskDevice->BlkIo.Media->BlockSize != OldMedia.
BlockSize) {
2482 *MediaChange =
TRUE;
2483 ScsiDiskDevice->BlkIo.Media->MediaId += 1;
2486 if (ScsiDiskDevice->BlkIo.Media->LastBlock != OldMedia.
LastBlock) {
2487 *MediaChange =
TRUE;
2488 ScsiDiskDevice->BlkIo.Media->MediaId += 1;
2491 if (ScsiDiskDevice->BlkIo.Media->MediaPresent != OldMedia.
MediaPresent) {
2492 if (ScsiDiskDevice->BlkIo.Media->MediaPresent) {
2496 ScsiDiskDevice->BlkIo.Media->MediaId = 1;
2501 ScsiDiskDevice->BlkIo.Media->MediaId = 0;
2504 *MediaChange =
TRUE;
2508 if (TimeoutEvt !=
NULL) {
2509 gBS->CloseEvent (TimeoutEvt);
2528 OUT BOOLEAN *NeedRetry
2531 UINT32 InquiryDataLength;
2532 UINT8 SenseDataLength;
2533 UINT8 HostAdapterStatus;
2536 UINTN NumberOfSenseKeys;
2545 SenseDataLength = 0;
2548 ScsiDiskDevice->ScsiIo,
2554 (VOID *)&(ScsiDiskDevice->InquiryData),
2561 if ((Status ==
EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) {
2569 if (SupportedVpdPages ==
NULL) {
2571 return EFI_DEVICE_ERROR;
2576 SenseDataLength = 0;
2578 ScsiDiskDevice->ScsiIo,
2584 (VOID *)SupportedVpdPages,
2587 EFI_SCSI_PAGE_CODE_SUPPORTED_VPD
2589 if (!EFI_ERROR (Status)) {
2590 PageLength = (SupportedVpdPages->PageLength2 << 8)
2591 | SupportedVpdPages->PageLength1;
2596 if (PageLength >
sizeof SupportedVpdPages->SupportedVpdPageList) {
2599 "%a: invalid PageLength (%u) in Supported VPD Pages page\n",
2606 if ((PageLength > 0) &&
2607 (SupportedVpdPages->SupportedVpdPageList[0] !=
2608 EFI_SCSI_PAGE_CODE_SUPPORTED_VPD))
2612 "%a: Supported VPD Pages page doesn't start with code 0x%02x\n",
2614 EFI_SCSI_PAGE_CODE_SUPPORTED_VPD
2622 for (Index = 0; Index < PageLength; Index++) {
2627 (SupportedVpdPages->SupportedVpdPageList[Index] <=
2628 SupportedVpdPages->SupportedVpdPageList[Index - 1]))
2632 "%a: non-ascending code in Supported VPD Pages page @ %u\n",
2641 if (SupportedVpdPages->SupportedVpdPageList[Index] == EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD) {
2649 if (Index < PageLength) {
2651 if (BlockLimits ==
NULL) {
2654 return EFI_DEVICE_ERROR;
2659 SenseDataLength = 0;
2661 ScsiDiskDevice->ScsiIo,
2667 (VOID *)BlockLimits,
2670 EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD
2672 if (!EFI_ERROR (Status)) {
2673 ScsiDiskDevice->BlkIo.Media->OptimalTransferLengthGranularity =
2674 (BlockLimits->OptimalTransferLengthGranularity2 << 8) |
2675 BlockLimits->OptimalTransferLengthGranularity1;
2677 ScsiDiskDevice->UnmapInfo.MaxLbaCnt =
2678 (BlockLimits->MaximumUnmapLbaCount4 << 24) |
2679 (BlockLimits->MaximumUnmapLbaCount3 << 16) |
2680 (BlockLimits->MaximumUnmapLbaCount2 << 8) |
2681 BlockLimits->MaximumUnmapLbaCount1;
2682 ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt =
2683 (BlockLimits->MaximumUnmapBlockDescriptorCount4 << 24) |
2684 (BlockLimits->MaximumUnmapBlockDescriptorCount3 << 16) |
2685 (BlockLimits->MaximumUnmapBlockDescriptorCount2 << 8) |
2686 BlockLimits->MaximumUnmapBlockDescriptorCount1;
2687 ScsiDiskDevice->EraseBlock.EraseLengthGranularity =
2688 (BlockLimits->OptimalUnmapGranularity4 << 24) |
2689 (BlockLimits->OptimalUnmapGranularity3 << 16) |
2690 (BlockLimits->OptimalUnmapGranularity2 << 8) |
2691 BlockLimits->OptimalUnmapGranularity1;
2692 if (BlockLimits->UnmapGranularityAlignmentValid != 0) {
2693 ScsiDiskDevice->UnmapInfo.GranularityAlignment =
2694 (BlockLimits->UnmapGranularityAlignment4 << 24) |
2695 (BlockLimits->UnmapGranularityAlignment3 << 16) |
2696 (BlockLimits->UnmapGranularityAlignment2 << 8) |
2697 BlockLimits->UnmapGranularityAlignment1;
2700 if (ScsiDiskDevice->EraseBlock.EraseLengthGranularity == 0) {
2705 ScsiDiskDevice->EraseBlock.EraseLengthGranularity = 1;
2708 ScsiDiskDevice->BlockLimitsVpdSupported =
TRUE;
2719 if (!EFI_ERROR (Status)) {
2721 }
else if (Status == EFI_NOT_READY) {
2723 return EFI_DEVICE_ERROR;
2724 }
else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
2726 return EFI_DEVICE_ERROR;
2735 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
2737 return EFI_DEVICE_ERROR;
2738 }
else if (Status == EFI_DEVICE_ERROR) {
2742 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
2744 return EFI_DEVICE_ERROR;
2748 if (Status == EFI_NOT_READY) {
2752 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
2754 return EFI_DEVICE_ERROR;
2755 }
else if (Status == EFI_DEVICE_ERROR) {
2757 return EFI_DEVICE_ERROR;
2766 for (Index = 0; Index < MaxRetry; Index++) {
2774 if (!EFI_ERROR (Status)) {
2776 return EFI_DEVICE_ERROR;
2780 return EFI_DEVICE_ERROR;
2789 return EFI_DEVICE_ERROR;
2811 OUT BOOLEAN *NeedRetry,
2817 UINT8 SenseDataLength;
2818 UINT8 HostAdapterStatus;
2823 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
2824 *NumberOfSenseKeys = 0;
2830 ScsiDiskDevice->ScsiIo,
2832 ScsiDiskDevice->SenseData,
2840 if (Status == EFI_NOT_READY) {
2842 return EFI_DEVICE_ERROR;
2843 }
else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
2845 return EFI_DEVICE_ERROR;
2853 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
2855 return EFI_DEVICE_ERROR;
2856 }
else if (Status == EFI_DEVICE_ERROR) {
2860 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
2862 return EFI_DEVICE_ERROR;
2866 if (Status == EFI_NOT_READY) {
2870 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
2872 return EFI_DEVICE_ERROR;
2873 }
else if (Status == EFI_DEVICE_ERROR) {
2875 return EFI_DEVICE_ERROR;
2878 if (SenseDataLength != 0) {
2880 *SenseDataArray = ScsiDiskDevice->SenseData;
2885 for (Index = 0; Index < MaxRetry; Index++) {
2893 if (!EFI_ERROR (Status)) {
2898 return EFI_DEVICE_ERROR;
2907 return EFI_DEVICE_ERROR;
2935 *Action = ACTION_READ_CAPACITY;
2937 if (NumberOfSenseKeys == 0) {
2938 if (ScsiDiskDevice->BlkIo.Media->MediaPresent ==
TRUE) {
2939 *Action = ACTION_NO_ACTION;
2949 if (ScsiDiskDevice->BlkIo.Media->MediaPresent ==
TRUE) {
2950 *Action = ACTION_NO_ACTION;
2957 ScsiDiskDevice->BlkIo.Media->MediaPresent =
FALSE;
2958 ScsiDiskDevice->BlkIo.Media->LastBlock = 0;
2959 *Action = ACTION_NO_ACTION;
2960 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: ScsiDiskIsNoMedia\n"));
2965 ScsiDiskDevice->BlkIo.Media->MediaId++;
2966 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: ScsiDiskIsMediaChange!\n"));
2971 *Action = ACTION_RETRY_COMMAND_LATER;
2972 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: ScsiDiskIsResetBefore!\n"));
2977 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: ScsiDiskIsMediaError\n"));
2978 *Action = ACTION_RETRY_WITH_BACKOFF_ALGO;
2979 return EFI_DEVICE_ERROR;
2983 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: ScsiDiskIsHardwareError\n"));
2984 *Action = ACTION_RETRY_WITH_BACKOFF_ALGO;
2985 return EFI_DEVICE_ERROR;
2990 *Action = ACTION_RETRY_COMMAND_LATER;
2991 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: ScsiDiskDriveNotReady!\n"));
2995 *Action = ACTION_NO_ACTION;
2996 return EFI_DEVICE_ERROR;
2999 *Action = ACTION_RETRY_WITH_BACKOFF_ALGO;
3000 DEBUG ((DEBUG_VERBOSE,
"ScsiDisk: Sense Key = 0x%x ASC = 0x%x!\n", SenseData->Sense_Key, SenseData->Addnl_Sense_Code));
3019 OUT BOOLEAN *NeedRetry,
3024 UINT8 HostAdapterStatus;
3030 UINT8 SenseDataLength;
3031 UINT32 DataLength10;
3032 UINT32 DataLength16;
3037 if (CapacityData10 ==
NULL) {
3039 return EFI_DEVICE_ERROR;
3043 if (CapacityData16 ==
NULL) {
3046 return EFI_DEVICE_ERROR;
3049 SenseDataLength = 0;
3055 *NumberOfSenseKeys = 0;
3063 ScsiDiskDevice->ScsiIo,
3069 (VOID *)CapacityData10,
3074 ScsiDiskDevice->Cdb16Byte =
FALSE;
3075 if ((!EFI_ERROR (CommandStatus)) && (CapacityData10->LastLba3 == 0xff) && (CapacityData10->LastLba2 == 0xff) &&
3076 (CapacityData10->LastLba1 == 0xff) && (CapacityData10->LastLba0 == 0xff))
3081 ScsiDiskDevice->Cdb16Byte =
TRUE;
3087 ScsiDiskDevice->ScsiIo,
3093 (VOID *)CapacityData16,
3103 GetMediaInfo (ScsiDiskDevice, CapacityData10, CapacityData16);
3112 if (CommandStatus == EFI_NOT_READY) {
3114 return EFI_DEVICE_ERROR;
3115 }
else if ((CommandStatus == EFI_INVALID_PARAMETER) || (CommandStatus == EFI_UNSUPPORTED)) {
3117 return EFI_DEVICE_ERROR;
3126 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
3128 return EFI_DEVICE_ERROR;
3129 }
else if (Status == EFI_DEVICE_ERROR) {
3133 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
3135 return EFI_DEVICE_ERROR;
3139 if (Status == EFI_NOT_READY) {
3143 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
3145 return EFI_DEVICE_ERROR;
3146 }
else if (Status == EFI_DEVICE_ERROR) {
3148 return EFI_DEVICE_ERROR;
3157 for (Index = 0; Index < MaxRetry; Index++) {
3165 if (!EFI_ERROR (Status)) {
3170 return EFI_DEVICE_ERROR;
3179 return EFI_DEVICE_ERROR;
3195 IN UINT8 HostAdapterStatus
3198 switch (HostAdapterStatus) {
3199 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK:
3202 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT:
3203 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT:
3204 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND:
3207 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT:
3208 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR:
3209 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED:
3210 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN:
3211 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET:
3212 return EFI_NOT_READY;
3214 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE:
3215 case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR:
3216 return EFI_DEVICE_ERROR;
3235 IN UINT8 TargetStatus
3238 switch (TargetStatus) {
3239 case EFI_EXT_SCSI_STATUS_TARGET_GOOD:
3240 case EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION:
3241 case EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET:
3244 case EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE:
3245 case EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET:
3246 case EFI_EXT_SCSI_STATUS_TARGET_BUSY:
3247 case EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL:
3248 return EFI_NOT_READY;
3250 case EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT:
3251 return EFI_DEVICE_ERROR;
3278 OUT BOOLEAN *NeedRetry,
3281 IN BOOLEAN AskResetIfError
3285 UINT8 SenseDataLength;
3289 UINT8 HostAdapterStatus;
3296 ScsiDiskDevice->SenseData,
3300 *NumberOfSenseKeys = 0;
3301 *SenseDataArray = ScsiDiskDevice->SenseData;
3304 if (PtrSenseData ==
NULL) {
3305 return EFI_DEVICE_ERROR;
3308 for (SenseReq =
TRUE; SenseReq;) {
3311 ScsiDiskDevice->ScsiIo,
3318 if ((Status ==
EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) {
3320 }
else if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
3322 FallStatus = EFI_DEVICE_ERROR;
3323 }
else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
3325 FallStatus = EFI_DEVICE_ERROR;
3326 }
else if (Status == EFI_DEVICE_ERROR) {
3327 if (AskResetIfError) {
3328 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
3331 FallStatus = EFI_DEVICE_ERROR;
3334 if (EFI_ERROR (FallStatus)) {
3335 if (*NumberOfSenseKeys != 0) {
3340 Status = EFI_DEVICE_ERROR;
3345 CopyMem (ScsiDiskDevice->SenseData + *NumberOfSenseKeys, PtrSenseData, SenseDataLength);
3346 (*NumberOfSenseKeys) += 1;
3352 if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) ||
3353 (*NumberOfSenseKeys == ScsiDiskDevice->SenseDataNumber))
3381 if (!ScsiDiskDevice->Cdb16Byte) {
3382 ScsiDiskDevice->BlkIo.Media->LastBlock = ((UINT32)Capacity10->LastLba3 << 24) |
3383 (Capacity10->LastLba2 << 16) |
3384 (Capacity10->LastLba1 << 8) |
3385 Capacity10->LastLba0;
3387 ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity10->BlockSize3 << 24) |
3388 (Capacity10->BlockSize2 << 16) |
3389 (Capacity10->BlockSize1 << 8) |
3390 Capacity10->BlockSize0;
3391 ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = 0;
3392 ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 0;
3393 if (!ScsiDiskDevice->BlockLimitsVpdSupported) {
3394 ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32)ScsiDiskDevice->BlkIo.Media->LastBlock;
3397 Ptr = (UINT8 *)&ScsiDiskDevice->BlkIo.Media->LastBlock;
3398 *Ptr++ = Capacity16->LastLba0;
3399 *Ptr++ = Capacity16->LastLba1;
3400 *Ptr++ = Capacity16->LastLba2;
3401 *Ptr++ = Capacity16->LastLba3;
3402 *Ptr++ = Capacity16->LastLba4;
3403 *Ptr++ = Capacity16->LastLba5;
3404 *Ptr++ = Capacity16->LastLba6;
3405 *Ptr = Capacity16->LastLba7;
3407 ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity16->BlockSize3 << 24) |
3408 (Capacity16->BlockSize2 << 16) |
3409 (Capacity16->BlockSize1 << 8) |
3410 Capacity16->BlockSize0;
3412 ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = (Capacity16->LowestAlignLogic2 << 8) |
3413 Capacity16->LowestAlignLogic1;
3414 ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = (1 << Capacity16->LogicPerPhysical);
3415 if (!ScsiDiskDevice->BlockLimitsVpdSupported) {
3416 if (ScsiDiskDevice->BlkIo.Media->LastBlock > (UINT32)-1) {
3417 ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32)-1;
3419 ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32)ScsiDiskDevice->BlkIo.Media->LastBlock;
3424 ScsiDiskDevice->BlkIo.Media->MediaPresent =
TRUE;
3438 ScsiDiskDevice->FixedDevice = (BOOLEAN)((ScsiDiskDevice->InquiryData.Rmb == 1) ? 0 : 1);
3439 ScsiDiskDevice->BlkIoMedia.RemovableMedia = (BOOLEAN)(!ScsiDiskDevice->FixedDevice);
3462 UINTN BlocksRemaining;
3468 UINT32 NextSectorCount;
3477 BlocksRemaining = NumberOfBlocks;
3478 BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
3483 if (!ScsiDiskDevice->Cdb16Byte) {
3486 MaxBlock = 0xFFFFFFFF;
3491 while (BlocksRemaining > 0) {
3492 if (BlocksRemaining <= MaxBlock) {
3493 if (!ScsiDiskDevice->Cdb16Byte) {
3494 SectorCount = (UINT16)BlocksRemaining;
3496 SectorCount = (UINT32)BlocksRemaining;
3499 SectorCount = MaxBlock;
3502 ByteCount = SectorCount * BlockSize;
3538 for (Index = 0; Index < MaxRetry; Index++) {
3539 if (!ScsiDiskDevice->Cdb16Byte) {
3561 if (!EFI_ERROR (Status)) {
3566 return EFI_DEVICE_ERROR;
3580 NextSectorCount = ByteCount / BlockSize;
3581 if (NextSectorCount < SectorCount) {
3582 SectorCount = NextSectorCount;
3586 ByteCount = SectorCount * BlockSize;
3590 if ((Index == MaxRetry) && (Status !=
EFI_SUCCESS)) {
3591 return EFI_DEVICE_ERROR;
3597 SectorCount = ByteCount / BlockSize;
3600 PtrBuffer = PtrBuffer + SectorCount * BlockSize;
3601 BlocksRemaining -= SectorCount;
3627 UINTN BlocksRemaining;
3633 UINT32 NextSectorCount;
3642 BlocksRemaining = NumberOfBlocks;
3643 BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
3648 if (!ScsiDiskDevice->Cdb16Byte) {
3651 MaxBlock = 0xFFFFFFFF;
3656 while (BlocksRemaining > 0) {
3657 if (BlocksRemaining <= MaxBlock) {
3658 if (!ScsiDiskDevice->Cdb16Byte) {
3659 SectorCount = (UINT16)BlocksRemaining;
3661 SectorCount = (UINT32)BlocksRemaining;
3664 SectorCount = MaxBlock;
3667 ByteCount = SectorCount * BlockSize;
3702 for (Index = 0; Index < MaxRetry; Index++) {
3703 if (!ScsiDiskDevice->Cdb16Byte) {
3725 if (!EFI_ERROR (Status)) {
3730 return EFI_DEVICE_ERROR;
3744 NextSectorCount = ByteCount / BlockSize;
3745 if (NextSectorCount < SectorCount) {
3746 SectorCount = NextSectorCount;
3750 ByteCount = SectorCount * BlockSize;
3754 if ((Index == MaxRetry) && (Status !=
EFI_SUCCESS)) {
3755 return EFI_DEVICE_ERROR;
3761 SectorCount = ByteCount / BlockSize;
3764 PtrBuffer = PtrBuffer + SectorCount * BlockSize;
3765 BlocksRemaining -= SectorCount;
3795 UINTN BlocksRemaining;
3806 if ((Token ==
NULL) || (Token->Event ==
NULL)) {
3807 return EFI_INVALID_PARAMETER;
3811 if (BlkIo2Req ==
NULL) {
3812 return EFI_OUT_OF_RESOURCES;
3815 BlkIo2Req->Token = Token;
3817 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
3818 InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &BlkIo2Req->Link);
3819 gBS->RestoreTPL (OldTpl);
3825 BlocksRemaining = NumberOfBlocks;
3826 BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
3832 if (!ScsiDiskDevice->Cdb16Byte) {
3835 MaxBlock = 0xFFFFFFFF;
3840 while (BlocksRemaining > 0) {
3841 if (BlocksRemaining <= MaxBlock) {
3842 if (!ScsiDiskDevice->Cdb16Byte) {
3843 SectorCount = (UINT16)BlocksRemaining;
3845 SectorCount = (UINT32)BlocksRemaining;
3848 SectorCount = MaxBlock;
3851 ByteCount = SectorCount * BlockSize;
3887 if (!ScsiDiskDevice->Cdb16Byte) {
3913 if (EFI_ERROR (Status)) {
3920 if ((Status == EFI_DEVICE_ERROR) || (Status == EFI_TIMEOUT)) {
3921 if ((MaxBlock > 1) && (SectorCount > 1)) {
3922 MaxBlock =
MIN (MaxBlock, SectorCount) >> 1;
3927 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
3937 gBS->RestoreTPL (OldTpl);
3943 Status = EFI_DEVICE_ERROR;
3946 gBS->RestoreTPL (OldTpl);
3961 SectorCount = ByteCount / BlockSize;
3964 PtrBuffer = PtrBuffer + SectorCount * BlockSize;
3965 BlocksRemaining -= SectorCount;
3971 if (BlkIo2Req !=
NULL) {
3972 BlkIo2Req->LastScsiRW =
TRUE;
3974 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
3980 gBS->SignalEvent (Token->Event);
3983 gBS->RestoreTPL (OldTpl);
4013 UINTN BlocksRemaining;
4024 if ((Token ==
NULL) || (Token->Event ==
NULL)) {
4025 return EFI_INVALID_PARAMETER;
4029 if (BlkIo2Req ==
NULL) {
4030 return EFI_OUT_OF_RESOURCES;
4033 BlkIo2Req->Token = Token;
4035 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
4036 InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &BlkIo2Req->Link);
4037 gBS->RestoreTPL (OldTpl);
4043 BlocksRemaining = NumberOfBlocks;
4044 BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
4050 if (!ScsiDiskDevice->Cdb16Byte) {
4053 MaxBlock = 0xFFFFFFFF;
4058 while (BlocksRemaining > 0) {
4059 if (BlocksRemaining <= MaxBlock) {
4060 if (!ScsiDiskDevice->Cdb16Byte) {
4061 SectorCount = (UINT16)BlocksRemaining;
4063 SectorCount = (UINT32)BlocksRemaining;
4066 SectorCount = MaxBlock;
4069 ByteCount = SectorCount * BlockSize;
4105 if (!ScsiDiskDevice->Cdb16Byte) {
4131 if (EFI_ERROR (Status)) {
4138 if ((Status == EFI_DEVICE_ERROR) || (Status == EFI_TIMEOUT)) {
4139 if ((MaxBlock > 1) && (SectorCount > 1)) {
4140 MaxBlock =
MIN (MaxBlock, SectorCount) >> 1;
4145 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
4155 gBS->RestoreTPL (OldTpl);
4161 Status = EFI_DEVICE_ERROR;
4164 gBS->RestoreTPL (OldTpl);
4179 SectorCount = ByteCount / BlockSize;
4182 PtrBuffer = PtrBuffer + SectorCount * BlockSize;
4183 BlocksRemaining -= SectorCount;
4189 if (BlkIo2Req !=
NULL) {
4190 BlkIo2Req->LastScsiRW =
TRUE;
4192 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
4198 gBS->SignalEvent (Token->Event);
4201 gBS->RestoreTPL (OldTpl);
4223 OUT BOOLEAN *NeedRetry,
4225 OUT UINT8 *DataBuffer,
4226 IN OUT UINT32 *DataLength,
4228 IN UINT32 SectorCount
4231 UINT8 SenseDataLength;
4234 UINT8 HostAdapterStatus;
4248 Action = ACTION_NO_ACTION;
4249 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
4251 ScsiDiskDevice->ScsiIo,
4253 ScsiDiskDevice->SenseData,
4263 if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
4265 return EFI_DEVICE_ERROR;
4266 }
else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
4268 return ReturnStatus;
4276 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
4278 return EFI_DEVICE_ERROR;
4279 }
else if (Status == EFI_DEVICE_ERROR) {
4283 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
4285 return EFI_DEVICE_ERROR;
4289 if (Status == EFI_NOT_READY) {
4293 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
4295 return EFI_DEVICE_ERROR;
4296 }
else if (Status == EFI_DEVICE_ERROR) {
4298 return EFI_DEVICE_ERROR;
4301 if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) {
4302 DEBUG ((DEBUG_ERROR,
"ScsiDiskRead10: Check Condition happened!\n"));
4304 if (Action == ACTION_RETRY_COMMAND_LATER) {
4306 return EFI_DEVICE_ERROR;
4307 }
else if (Action == ACTION_RETRY_WITH_BACKOFF_ALGO) {
4308 if (SectorCount <= 1) {
4313 return EFI_DEVICE_ERROR;
4320 *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
4324 return EFI_DEVICE_ERROR;
4328 return ReturnStatus;
4348 OUT BOOLEAN *NeedRetry,
4350 IN UINT8 *DataBuffer,
4351 IN OUT UINT32 *DataLength,
4353 IN UINT32 SectorCount
4358 UINT8 SenseDataLength;
4359 UINT8 HostAdapterStatus;
4373 Action = ACTION_NO_ACTION;
4374 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
4376 ScsiDiskDevice->ScsiIo,
4378 ScsiDiskDevice->SenseData,
4387 if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
4389 return EFI_DEVICE_ERROR;
4390 }
else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
4392 return ReturnStatus;
4400 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
4402 return EFI_DEVICE_ERROR;
4403 }
else if (Status == EFI_DEVICE_ERROR) {
4407 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
4409 return EFI_DEVICE_ERROR;
4413 if (Status == EFI_NOT_READY) {
4417 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
4419 return EFI_DEVICE_ERROR;
4420 }
else if (Status == EFI_DEVICE_ERROR) {
4422 return EFI_DEVICE_ERROR;
4425 if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) {
4426 DEBUG ((DEBUG_ERROR,
"ScsiDiskWrite10: Check Condition happened!\n"));
4428 if (Action == ACTION_RETRY_COMMAND_LATER) {
4430 return EFI_DEVICE_ERROR;
4431 }
else if (Action == ACTION_RETRY_WITH_BACKOFF_ALGO) {
4432 if (SectorCount <= 1) {
4437 return EFI_DEVICE_ERROR;
4444 *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
4448 return EFI_DEVICE_ERROR;
4452 return ReturnStatus;
4471 OUT BOOLEAN *NeedRetry,
4473 OUT UINT8 *DataBuffer,
4474 IN OUT UINT32 *DataLength,
4476 IN UINT32 SectorCount
4479 UINT8 SenseDataLength;
4482 UINT8 HostAdapterStatus;
4496 Action = ACTION_NO_ACTION;
4497 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
4499 ScsiDiskDevice->ScsiIo,
4501 ScsiDiskDevice->SenseData,
4510 if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
4512 return EFI_DEVICE_ERROR;
4513 }
else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
4515 return ReturnStatus;
4523 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
4525 return EFI_DEVICE_ERROR;
4526 }
else if (Status == EFI_DEVICE_ERROR) {
4530 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
4532 return EFI_DEVICE_ERROR;
4536 if (Status == EFI_NOT_READY) {
4540 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
4542 return EFI_DEVICE_ERROR;
4543 }
else if (Status == EFI_DEVICE_ERROR) {
4545 return EFI_DEVICE_ERROR;
4548 if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) {
4549 DEBUG ((DEBUG_ERROR,
"ScsiDiskRead16: Check Condition happened!\n"));
4551 if (Action == ACTION_RETRY_COMMAND_LATER) {
4553 return EFI_DEVICE_ERROR;
4554 }
else if (Action == ACTION_RETRY_WITH_BACKOFF_ALGO) {
4555 if (SectorCount <= 1) {
4560 return EFI_DEVICE_ERROR;
4567 *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
4571 return EFI_DEVICE_ERROR;
4575 return ReturnStatus;
4595 OUT BOOLEAN *NeedRetry,
4597 IN UINT8 *DataBuffer,
4598 IN OUT UINT32 *DataLength,
4600 IN UINT32 SectorCount
4605 UINT8 SenseDataLength;
4606 UINT8 HostAdapterStatus;
4620 Action = ACTION_NO_ACTION;
4621 SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (
EFI_SCSI_SENSE_DATA));
4623 ScsiDiskDevice->ScsiIo,
4625 ScsiDiskDevice->SenseData,
4634 if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
4636 return EFI_DEVICE_ERROR;
4637 }
else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
4639 return ReturnStatus;
4647 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
4649 return EFI_DEVICE_ERROR;
4650 }
else if (Status == EFI_DEVICE_ERROR) {
4654 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
4656 return EFI_DEVICE_ERROR;
4660 if (Status == EFI_NOT_READY) {
4664 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
4666 return EFI_DEVICE_ERROR;
4667 }
else if (Status == EFI_DEVICE_ERROR) {
4669 return EFI_DEVICE_ERROR;
4672 if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) {
4673 DEBUG ((DEBUG_ERROR,
"ScsiDiskWrite16: Check Condition happened!\n"));
4675 if (Action == ACTION_RETRY_COMMAND_LATER) {
4677 return EFI_DEVICE_ERROR;
4678 }
else if (Action == ACTION_RETRY_WITH_BACKOFF_ALGO) {
4679 if (SectorCount <= 1) {
4684 return EFI_DEVICE_ERROR;
4691 *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
4695 return EFI_DEVICE_ERROR;
4699 return ReturnStatus;
4723 UINT32 OldDataLength;
4724 UINT32 OldSectorCount;
4727 gBS->CloseEvent (Event);
4730 ScsiDiskDevice = Request->ScsiDiskDevice;
4731 Token = Request->BlkIo2Req->Token;
4732 OldDataLength = Request->DataLength;
4733 OldSectorCount = Request->SectorCount;
4748 if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
4749 if (++Request->TimesRetry > MaxRetry) {
4755 }
else if (Status == EFI_DEVICE_ERROR) {
4759 ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
4765 if (Status == EFI_NOT_READY) {
4769 ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
4770 if (++Request->TimesRetry > MaxRetry) {
4776 }
else if (Status == EFI_DEVICE_ERROR) {
4781 if (Request->TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) {
4782 DEBUG ((DEBUG_ERROR,
"ScsiDiskNotify: Check Condition happened!\n"));
4790 if (Action == ACTION_RETRY_COMMAND_LATER) {
4791 if (++Request->TimesRetry > MaxRetry) {
4797 }
else if (Action == ACTION_RETRY_WITH_BACKOFF_ALGO) {
4798 if (Request->SectorCount <= 1) {
4811 Request->SectorCount >>= 1;
4812 Request->DataLength = Request->SectorCount * ScsiDiskDevice->BlkIo.
Media->
BlockSize;
4813 Request->TimesRetry = 0;
4828 if (Request->InBuffer !=
NULL) {
4832 if (!ScsiDiskDevice->Cdb16Byte) {
4836 Request->TimesRetry,
4838 Request->DataLength,
4839 (UINT32)Request->StartLba,
4840 Request->SectorCount,
4848 Request->TimesRetry,
4850 Request->DataLength,
4852 Request->SectorCount,
4858 if (EFI_ERROR (Status)) {
4861 }
else if (OldSectorCount != Request->SectorCount) {
4866 if (!ScsiDiskDevice->Cdb16Byte) {
4871 Request->InBuffer + Request->SectorCount * ScsiDiskDevice->BlkIo.
Media->
BlockSize,
4872 OldDataLength - Request->DataLength,
4873 (UINT32)Request->StartLba + Request->SectorCount,
4874 OldSectorCount - Request->SectorCount,
4883 Request->InBuffer + Request->SectorCount * ScsiDiskDevice->BlkIo.
Media->
BlockSize,
4884 OldDataLength - Request->DataLength,
4885 Request->StartLba + Request->SectorCount,
4886 OldSectorCount - Request->SectorCount,
4892 if (EFI_ERROR (Status)) {
4901 if (!ScsiDiskDevice->Cdb16Byte) {
4905 Request->TimesRetry,
4907 Request->DataLength,
4908 (UINT32)Request->StartLba,
4909 Request->SectorCount,
4917 Request->TimesRetry,
4919 Request->DataLength,
4921 Request->SectorCount,
4927 if (EFI_ERROR (Status)) {
4930 }
else if (OldSectorCount != Request->SectorCount) {
4935 if (!ScsiDiskDevice->Cdb16Byte) {
4940 Request->OutBuffer + Request->SectorCount * ScsiDiskDevice->BlkIo.
Media->
BlockSize,
4941 OldDataLength - Request->DataLength,
4942 (UINT32)Request->StartLba + Request->SectorCount,
4943 OldSectorCount - Request->SectorCount,
4952 Request->OutBuffer + Request->SectorCount * ScsiDiskDevice->BlkIo.
Media->
BlockSize,
4953 OldDataLength - Request->DataLength,
4954 Request->StartLba + Request->SectorCount,
4955 OldSectorCount - Request->SectorCount,
4961 if (EFI_ERROR (Status)) {
4970 if ((
IsListEmpty (&Request->BlkIo2Req->ScsiRWQueue)) &&
4971 (Request->BlkIo2Req->LastScsiRW))
5009 IN UINT8 TimesRetry,
5010 OUT UINT8 *DataBuffer,
5011 IN UINT32 DataLength,
5013 IN UINT32 SectorCount,
5023 AsyncIoEvent =
NULL;
5026 if (Request ==
NULL) {
5027 return EFI_OUT_OF_RESOURCES;
5030 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5032 gBS->RestoreTPL (OldTpl);
5036 if (Request->SenseData ==
NULL) {
5037 Status = EFI_OUT_OF_RESOURCES;
5041 Request->ScsiDiskDevice = ScsiDiskDevice;
5042 Request->Timeout = Timeout;
5043 Request->TimesRetry = TimesRetry;
5044 Request->InBuffer = DataBuffer;
5045 Request->DataLength = DataLength;
5046 Request->StartLba = StartLba;
5047 Request->SectorCount = SectorCount;
5048 Request->BlkIo2Req = BlkIo2Req;
5053 Status =
gBS->CreateEvent (
5060 if (EFI_ERROR (Status)) {
5065 ScsiDiskDevice->ScsiIo,
5068 &Request->SenseDataLength,
5069 &Request->HostAdapterStatus,
5070 &Request->TargetStatus,
5072 &Request->DataLength,
5073 (UINT32)Request->StartLba,
5074 Request->SectorCount,
5077 if (EFI_ERROR (Status)) {
5084 if (AsyncIoEvent !=
NULL) {
5085 gBS->CloseEvent (AsyncIoEvent);
5088 if (Request !=
NULL) {
5089 if (Request->SenseData !=
NULL) {
5093 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5095 gBS->RestoreTPL (OldTpl);
5127 IN UINT8 TimesRetry,
5128 IN UINT8 *DataBuffer,
5129 IN UINT32 DataLength,
5131 IN UINT32 SectorCount,
5141 AsyncIoEvent =
NULL;
5144 if (Request ==
NULL) {
5145 return EFI_OUT_OF_RESOURCES;
5148 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5150 gBS->RestoreTPL (OldTpl);
5154 if (Request->SenseData ==
NULL) {
5155 Status = EFI_OUT_OF_RESOURCES;
5159 Request->ScsiDiskDevice = ScsiDiskDevice;
5160 Request->Timeout = Timeout;
5161 Request->TimesRetry = TimesRetry;
5162 Request->OutBuffer = DataBuffer;
5163 Request->DataLength = DataLength;
5164 Request->StartLba = StartLba;
5165 Request->SectorCount = SectorCount;
5166 Request->BlkIo2Req = BlkIo2Req;
5171 Status =
gBS->CreateEvent (
5178 if (EFI_ERROR (Status)) {
5183 ScsiDiskDevice->ScsiIo,
5186 &Request->SenseDataLength,
5187 &Request->HostAdapterStatus,
5188 &Request->TargetStatus,
5190 &Request->DataLength,
5191 (UINT32)Request->StartLba,
5192 Request->SectorCount,
5195 if (EFI_ERROR (Status)) {
5202 if (AsyncIoEvent !=
NULL) {
5203 gBS->CloseEvent (AsyncIoEvent);
5206 if (Request !=
NULL) {
5207 if (Request->SenseData !=
NULL) {
5211 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5213 gBS->RestoreTPL (OldTpl);
5245 IN UINT8 TimesRetry,
5246 OUT UINT8 *DataBuffer,
5247 IN UINT32 DataLength,
5249 IN UINT32 SectorCount,
5259 AsyncIoEvent =
NULL;
5262 if (Request ==
NULL) {
5263 return EFI_OUT_OF_RESOURCES;
5266 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5268 gBS->RestoreTPL (OldTpl);
5272 if (Request->SenseData ==
NULL) {
5273 Status = EFI_OUT_OF_RESOURCES;
5277 Request->ScsiDiskDevice = ScsiDiskDevice;
5278 Request->Timeout = Timeout;
5279 Request->TimesRetry = TimesRetry;
5280 Request->InBuffer = DataBuffer;
5281 Request->DataLength = DataLength;
5282 Request->StartLba = StartLba;
5283 Request->SectorCount = SectorCount;
5284 Request->BlkIo2Req = BlkIo2Req;
5289 Status =
gBS->CreateEvent (
5296 if (EFI_ERROR (Status)) {
5301 ScsiDiskDevice->ScsiIo,
5304 &Request->SenseDataLength,
5305 &Request->HostAdapterStatus,
5306 &Request->TargetStatus,
5308 &Request->DataLength,
5310 Request->SectorCount,
5313 if (EFI_ERROR (Status)) {
5320 if (AsyncIoEvent !=
NULL) {
5321 gBS->CloseEvent (AsyncIoEvent);
5324 if (Request !=
NULL) {
5325 if (Request->SenseData !=
NULL) {
5329 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5331 gBS->RestoreTPL (OldTpl);
5363 IN UINT8 TimesRetry,
5364 IN UINT8 *DataBuffer,
5365 IN UINT32 DataLength,
5367 IN UINT32 SectorCount,
5377 AsyncIoEvent =
NULL;
5380 if (Request ==
NULL) {
5381 return EFI_OUT_OF_RESOURCES;
5384 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5386 gBS->RestoreTPL (OldTpl);
5390 if (Request->SenseData ==
NULL) {
5391 Status = EFI_OUT_OF_RESOURCES;
5395 Request->ScsiDiskDevice = ScsiDiskDevice;
5396 Request->Timeout = Timeout;
5397 Request->TimesRetry = TimesRetry;
5398 Request->OutBuffer = DataBuffer;
5399 Request->DataLength = DataLength;
5400 Request->StartLba = StartLba;
5401 Request->SectorCount = SectorCount;
5402 Request->BlkIo2Req = BlkIo2Req;
5407 Status =
gBS->CreateEvent (
5414 if (EFI_ERROR (Status)) {
5419 ScsiDiskDevice->ScsiIo,
5422 &Request->SenseDataLength,
5423 &Request->HostAdapterStatus,
5424 &Request->TargetStatus,
5426 &Request->DataLength,
5428 Request->SectorCount,
5431 if (EFI_ERROR (Status)) {
5438 if (AsyncIoEvent !=
NULL) {
5439 gBS->CloseEvent (AsyncIoEvent);
5442 if (Request !=
NULL) {
5443 if (Request->SenseData !=
NULL) {
5447 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
5449 gBS->RestoreTPL (OldTpl);
5477 SensePtr = SenseData;
5479 for (Index = 0; Index < SenseCounts; Index++) {
5484 if ((SensePtr->Sense_Key == EFI_SCSI_SK_NOT_READY) &&
5517 SensePtr = SenseData;
5519 for (Index = 0; Index < SenseCounts; Index++) {
5520 switch (SensePtr->Sense_Key) {
5521 case EFI_SCSI_SK_MEDIUM_ERROR:
5529 case EFI_SCSI_ASC_MEDIA_ERR1:
5534 case EFI_SCSI_ASC_MEDIA_ERR2:
5539 case EFI_SCSI_ASC_MEDIA_ERR3:
5540 case EFI_SCSI_ASC_MEDIA_ERR4:
5550 case EFI_SCSI_SK_NOT_READY:
5558 case EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN:
5599 SensePtr = SenseData;
5601 for (Index = 0; Index < SenseCounts; Index++) {
5605 if (SensePtr->Sense_Key == EFI_SCSI_SK_HARDWARE_ERROR) {
5632 BOOLEAN IsMediaChanged;
5634 IsMediaChanged =
FALSE;
5635 SensePtr = SenseData;
5637 for (Index = 0; Index < SenseCounts; Index++) {
5642 if ((SensePtr->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
5645 IsMediaChanged =
TRUE;
5651 return IsMediaChanged;
5672 BOOLEAN IsResetBefore;
5674 IsResetBefore =
FALSE;
5675 SensePtr = SenseData;
5677 for (Index = 0; Index < SenseCounts; Index++) {
5682 if ((SensePtr->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
5685 IsResetBefore =
TRUE;
5691 return IsResetBefore;
5709 OUT BOOLEAN *RetryLater
5717 *RetryLater =
FALSE;
5718 SensePtr = SenseData;
5720 for (Index = 0; Index < SenseCounts; Index++) {
5721 switch (SensePtr->Sense_Key) {
5722 case EFI_SCSI_SK_NOT_READY:
5727 case EFI_SCSI_ASC_NOT_READY:
5732 case EFI_SCSI_ASCQ_IN_PROGRESS:
5743 *RetryLater =
FALSE;
5783 BOOLEAN HaveSenseKey;
5785 if (SenseCounts == 0) {
5786 HaveSenseKey =
FALSE;
5788 HaveSenseKey =
TRUE;
5791 SensePtr = SenseData;
5793 for (Index = 0; Index < SenseCounts; Index++) {
5797 if ((SensePtr->Sense_Key == EFI_SCSI_SK_NO_SENSE) &&
5800 HaveSenseKey =
FALSE;
5806 return HaveSenseKey;
5820 if (ScsiDiskDevice ==
NULL) {
5824 if (ScsiDiskDevice->SenseData !=
NULL) {
5825 FreePool (ScsiDiskDevice->SenseData);
5826 ScsiDiskDevice->SenseData =
NULL;
5829 if (ScsiDiskDevice->ControllerNameTable !=
NULL) {
5831 ScsiDiskDevice->ControllerNameTable =
NULL;
5836 ScsiDiskDevice =
NULL;
5862 if (ExtScsiPassThru !=
NULL) {
5863 if ((ExtScsiPassThru->
Mode->
Attributes & EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL) != 0) {
5873 if (ScsiPassThru !=
NULL) {
5874 if ((ScsiPassThru->
Mode->
Attributes & EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL) != 0) {
5910 Status =
gBS->LocateHandleBuffer (
5918 if (EFI_ERROR (Status)) {
5925 for (Index = 0; Index < HandleCount; Index++) {
5927 if (!EFI_ERROR (Status)) {
5928 Status =
gBS->HandleProtocol (HandleBuffer[Index], ProtocolGuid, (VOID **)&Interface);
5929 if (!EFI_ERROR (Status)) {
5930 gBS->FreePool (HandleBuffer);
5936 gBS->FreePool (HandleBuffer);
5956 UINT8 HostAdapterStatus;
5963 UINT8 SenseDataLength;
5964 UINT32 DataLength16;
5969 CapacityData16 =
NULL;
5979 Status =
gBS->HandleProtocol (
5981 &gEfiDevicePathProtocolGuid,
5982 (VOID **)&DevicePathNode
6012 if (CapacityData16 ==
NULL) {
6017 SenseDataLength = 0;
6022 ScsiDiskDevice->ScsiIo,
6028 (VOID *)CapacityData16,
6039 if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
6040 ((CapacityData16->LowestAlignLogic2 & BIT6) == 0))
6044 "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
6045 CapacityData16->LowestAlignLogic2
6054 "ScsiDisk EraseBlock: ReadCapacity16 failed with status %r.\n",
6065 if ((ScsiDiskDevice->UnmapInfo.MaxLbaCnt == 0) ||
6066 (ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt == 0))
6070 "ScsiDisk EraseBlock: The device server does not implement the UNMAP command.\n"
6078 if (CapacityData16 !=
NULL) {
6109 Status =
gBS->HandleProtocol (
6111 &gEfiDevicePathProtocolGuid,
6112 (VOID **)&DevicePathNode
6166 IN OUT VOID *InquiryData,
6167 IN OUT UINT32 *InquiryDataSize
6173 ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
6175 Status = EFI_BUFFER_TOO_SMALL;
6176 if (*InquiryDataSize >=
sizeof (ScsiDiskDevice->InquiryData)) {
6178 CopyMem (InquiryData, &ScsiDiskDevice->InquiryData, sizeof (ScsiDiskDevice->InquiryData));
6181 *InquiryDataSize =
sizeof (ScsiDiskDevice->InquiryData);
6207 IN OUT VOID *IdentifyData,
6208 IN OUT UINT32 *IdentifyDataSize
6214 if (
CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid) ||
CompareGuid (&This->Interface, &gEfiDiskInfoUfsInterfaceGuid)) {
6218 return EFI_NOT_FOUND;
6221 ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
6223 Status = EFI_BUFFER_TOO_SMALL;
6224 if (*IdentifyDataSize >=
sizeof (ScsiDiskDevice->IdentifyData)) {
6226 CopyMem (IdentifyData, &ScsiDiskDevice->IdentifyData, sizeof (ScsiDiskDevice->IdentifyData));
6229 *IdentifyDataSize =
sizeof (ScsiDiskDevice->IdentifyData);
6254 IN OUT VOID *SenseData,
6255 IN OUT UINT32 *SenseDataSize,
6256 OUT UINT8 *SenseDataNumber
6259 return EFI_NOT_FOUND;
6277 OUT UINT32 *IdeChannel,
6278 OUT UINT32 *IdeDevice
6283 if (
CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid) ||
CompareGuid (&This->Interface, &gEfiDiskInfoUfsInterfaceGuid)) {
6287 return EFI_UNSUPPORTED;
6290 ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
6291 *IdeChannel = ScsiDiskDevice->Channel;
6292 *IdeDevice = ScsiDiskDevice->Device;
6321 ZeroMem (&CommandPacket,
sizeof (CommandPacket));
6325 CommandPacket.
Timeout = SCSI_DISK_TIMEOUT;
6326 CommandPacket.
Cdb = Cdb;
6327 CommandPacket.
CdbLength = (UINT8)
sizeof (Cdb);
6328 CommandPacket.
InDataBuffer = &ScsiDiskDevice->IdentifyData;
6331 return ScsiDiskDevice->ScsiIo->ExecuteScsiCommand (ScsiDiskDevice->ScsiIo, &CommandPacket,
NULL);
6357 UINTN IdentifyRetry;
6359 Status =
gBS->HandleProtocol (ChildHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathNode);
6367 CopyMem (&ScsiDiskDevice->DiskInfo, &gScsiDiskInfoProtocolTemplate, sizeof (gScsiDiskInfoProtocolTemplate));
6384 if (!EFI_ERROR (Status)) {
6391 ScsiDiskDevice->Device = AtapiDevicePath->
SlaveMaster;
6395 CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoIdeInterfaceGuid);
6406 CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoAhciInterfaceGuid);
6411 }
while (--IdentifyRetry > 0);
6415 CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoUfsInterfaceGuid);
6419 DevicePathNode = ChildDevicePathNode;
#define ATA_CMD_IDENTIFY_DEVICE
defined from ATA-3
BOOLEAN IsNoMedia(IN ATAPI_REQUEST_SENSE_DATA *SenseData, IN UINTN SenseCounts)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
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 HARDWARE_DEVICE_PATH
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
#define EFI_DISK_INFO_SCSI_INTERFACE_GUID
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI FreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
#define ADDRESS_IS_ALIGNED(Address, Alignment)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
@ UfsDevice
The recovery device is a Universal Flash Storage device.
VOID *EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
#define EFI_SCSI_ASC_RESET
Power On Reset or Bus Reset occurred.
#define EFI_SCSI_TYPE_DISK
Direct-access device (e.g. magnetic disk)
#define EFI_SCSI_TYPE_CDROM
CD/DVD device.
#define EFI_SCSI_TYPE_WLUN
Well known logical unit.
EFI_STATUS EFIAPI ScsiDiskDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
EFI_STATUS EFIAPI InitializeScsiDisk(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID ParseInquiryData(IN OUT SCSI_DISK_DEV *ScsiDiskDevice)
EFI_STATUS EFIAPI ScsiDiskWriteBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI ScsiDiskSendData(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId OPTIONAL, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer)
EFI_STATUS EFIAPI ScsiDiskFlushBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
VOID * AllocateAlignedBuffer(IN SCSI_DISK_DEV *ScsiDiskDevice, IN UINTN BufferSize)
EFI_STATUS ScsiDiskAsyncWrite10(IN SCSI_DISK_DEV *ScsiDiskDevice, IN UINT64 Timeout, IN UINT8 TimesRetry, IN UINT8 *DataBuffer, IN UINT32 DataLength, IN UINT32 StartLba, IN UINT32 SectorCount, IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req, IN EFI_BLOCK_IO2_TOKEN *Token)
EFI_STATUS ScsiDiskAsyncRead16(IN SCSI_DISK_DEV *ScsiDiskDevice, IN UINT64 Timeout, IN UINT8 TimesRetry, OUT UINT8 *DataBuffer, IN UINT32 DataLength, IN UINT64 StartLba, IN UINT32 SectorCount, IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req, IN EFI_BLOCK_IO2_TOKEN *Token)
EFI_STATUS EFIAPI ScsiDiskDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
BOOLEAN ScsiDiskIsHardwareError(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts)
EFI_STATUS ScsiDiskReadSectors(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT VOID *Buffer, IN EFI_LBA Lba, IN UINTN NumberOfBlocks)
EFI_STATUS EFIAPI ScsiDiskInfoWhichIde(IN EFI_DISK_INFO_PROTOCOL *This, OUT UINT32 *IdeChannel, OUT UINT32 *IdeDevice)
EFI_STATUS ScsiDiskRequestSenseKeys(IN OUT SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OUT UINTN *NumberOfSenseKeys, IN BOOLEAN AskResetIfError)
EFI_STATUS EFIAPI ScsiDiskFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
BOOLEAN ScsiDiskIsResetBefore(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts)
EFI_STATUS EFIAPI ScsiDiskInfoInquiry(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize)
VOID FreeAlignedBuffer(IN VOID *Buffer, IN UINTN BufferSize)
EFI_STATUS EFIAPI ScsiDiskReceiveData(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId OPTIONAL, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize)
EFI_STATUS ScsiDiskAsyncRead10(IN SCSI_DISK_DEV *ScsiDiskDevice, IN UINT64 Timeout, IN UINT8 TimesRetry, OUT UINT8 *DataBuffer, IN UINT32 DataLength, IN UINT32 StartLba, IN UINT32 SectorCount, IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req, IN EFI_BLOCK_IO2_TOKEN *Token)
EFI_STATUS ScsiDiskWrite10(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, IN UINT64 Timeout, IN UINT8 *DataBuffer, IN OUT UINT32 *DataLength, IN UINT32 StartLba, IN UINT32 SectorCount)
EFI_STATUS ScsiDiskUnmap(IN SCSI_DISK_DEV *ScsiDiskDevice, IN UINT64 Lba, IN UINTN Blocks, IN EFI_ERASE_BLOCK_TOKEN *Token OPTIONAL)
EFI_STATUS AtapiIdentifyDevice(IN OUT SCSI_DISK_DEV *ScsiDiskDevice)
EFI_STATUS ScsiDiskInquiryDevice(IN OUT SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry)
BOOLEAN ScsiDiskHaveSenseKey(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts)
BOOLEAN ScsiDiskIsMediaChange(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts)
EFI_STATUS ScsiDiskRead10(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, IN UINT64 Timeout, OUT UINT8 *DataBuffer, IN OUT UINT32 *DataLength, IN UINT32 StartLba, IN UINT32 SectorCount)
EFI_STATUS EFIAPI ScsiDiskReadBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS ScsiDiskAsyncWrite16(IN SCSI_DISK_DEV *ScsiDiskDevice, IN UINT64 Timeout, IN UINT8 TimesRetry, IN UINT8 *DataBuffer, IN UINT32 DataLength, IN UINT64 StartLba, IN UINT32 SectorCount, IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req, IN EFI_BLOCK_IO2_TOKEN *Token)
EFI_STATUS ScsiDiskAsyncWriteSectors(IN SCSI_DISK_DEV *ScsiDiskDevice, IN VOID *Buffer, IN EFI_LBA Lba, IN UINTN NumberOfBlocks, IN EFI_BLOCK_IO2_TOKEN *Token)
BOOLEAN DetermineInstallEraseBlock(IN SCSI_DISK_DEV *ScsiDiskDevice, IN EFI_HANDLE ChildHandle)
VOID EFIAPI ScsiDiskNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI ScsiDiskReset(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI ScsiDiskWriteBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
VOID GetMediaInfo(IN OUT SCSI_DISK_DEV *ScsiDiskDevice, IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity10, IN EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16)
EFI_STATUS DetectMediaParsingSenseKeys(OUT SCSI_DISK_DEV *ScsiDiskDevice, IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN NumberOfSenseKeys, OUT UINTN *Action)
EFI_STATUS EFIAPI ScsiDiskInfoSenseData(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *SenseData, IN OUT UINT32 *SenseDataSize, OUT UINT8 *SenseDataNumber)
VOID ReleaseScsiDiskDeviceResources(IN SCSI_DISK_DEV *ScsiDiskDevice)
EFI_STATUS CheckTargetStatus(IN UINT8 TargetStatus)
EFI_STATUS ScsiDiskTestUnitReady(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OUT UINTN *NumberOfSenseKeys)
EFI_STATUS ScsiDiskWriteSectors(IN SCSI_DISK_DEV *ScsiDiskDevice, IN VOID *Buffer, IN EFI_LBA Lba, IN UINTN NumberOfBlocks)
EFI_STATUS EFIAPI ScsiDiskResetEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
UINTN RemoveTrailingSpaces(IN OUT CHAR8 *String)
BOOLEAN DetermineInstallStorageSecurity(IN SCSI_DISK_DEV *ScsiDiskDevice, IN EFI_HANDLE ChildHandle)
EFI_STATUS ScsiDiskAsyncReadSectors(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT VOID *Buffer, IN EFI_LBA Lba, IN UINTN NumberOfBlocks, IN EFI_BLOCK_IO2_TOKEN *Token)
BOOLEAN ScsiDiskIsMediaError(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts)
EFI_STATUS ScsiDiskReadCapacity(IN OUT SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OUT UINTN *NumberOfSenseKeys)
BOOLEAN ScsiDiskIsDriveReady(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts, OUT BOOLEAN *RetryLater)
VOID EFIAPI ScsiDiskAsyncUnmapNotify(IN EFI_EVENT Event, IN VOID *Context)
BOOLEAN DetermineInstallBlockIo(IN EFI_HANDLE ChildHandle)
EFI_STATUS CheckHostAdapterStatus(IN UINT8 HostAdapterStatus)
EFI_STATUS ScsiDiskDetectMedia(IN SCSI_DISK_DEV *ScsiDiskDevice, IN BOOLEAN MustReadCapacity, OUT BOOLEAN *MediaChange)
EFI_STATUS EFIAPI ScsiDiskReadBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI ScsiDiskEraseBlocks(IN EFI_ERASE_BLOCK_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_ERASE_BLOCK_TOKEN *Token, IN UINTN Size)
VOID *EFIAPI GetParentProtocol(IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE ChildHandle)
EFI_STATUS ScsiDiskRead16(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, IN UINT64 Timeout, OUT UINT8 *DataBuffer, IN OUT UINT32 *DataLength, IN UINT64 StartLba, IN UINT32 SectorCount)
EFI_STATUS ScsiDiskWrite16(IN SCSI_DISK_DEV *ScsiDiskDevice, OUT BOOLEAN *NeedRetry, IN UINT64 Timeout, IN UINT8 *DataBuffer, IN OUT UINT32 *DataLength, IN UINT64 StartLba, IN UINT32 SectorCount)
EFI_STATUS EFIAPI ScsiDiskDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
VOID InitializeInstallDiskInfo(IN SCSI_DISK_DEV *ScsiDiskDevice, IN EFI_HANDLE ChildHandle)
EFI_STATUS EFIAPI ScsiDiskInfoIdentify(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize)
BOOLEAN ScsiDiskIsNoMedia(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts)
VOID EFIAPI Exit(IN EFI_STATUS Status)
#define EFI_SIZE_TO_PAGES(Size)
EFI_STATUS EFIAPI AddUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
#define EFI_TIMER_PERIOD_SECONDS(Seconds)
EFI_STATUS EFIAPI EfiTestChildHandle(IN CONST EFI_HANDLE ControllerHandle, IN CONST EFI_HANDLE ChildHandle, IN CONST EFI_GUID *ProtocolGuid)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
EFI_STATUS EFIAPI ScsiWrite10CommandEx(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT32 StartLba, IN UINT32 SectorSize, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI ScsiSecurityProtocolInCommand(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN UINT8 SecurityProtocol, IN UINT16 SecurityProtocolSpecific, IN BOOLEAN Inc512, IN UINTN DataLength, IN OUT VOID *DataBuffer OPTIONAL, OUT UINTN *TransferLength)
EFI_STATUS EFIAPI ScsiRead10CommandEx(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT32 StartLba, IN UINT32 SectorSize, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI ScsiRead10Command(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT32 StartLba, IN UINT32 SectorSize)
EFI_STATUS EFIAPI ScsiTestUnitReadyCommand(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus)
EFI_STATUS EFIAPI ScsiWrite16Command(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT64 StartLba, IN UINT32 SectorSize)
EFI_STATUS EFIAPI ScsiRequestSenseCommand(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus)
EFI_STATUS EFIAPI ScsiInquiryCommandEx(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *InquiryDataBuffer OPTIONAL, IN OUT UINT32 *InquiryDataLength, IN BOOLEAN EnableVitalProductData, IN UINT8 PageCode)
EFI_STATUS EFIAPI ScsiWrite16CommandEx(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT64 StartLba, IN UINT32 SectorSize, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI ScsiSecurityProtocolOutCommand(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN UINT8 SecurityProtocol, IN UINT16 SecurityProtocolSpecific, IN BOOLEAN Inc512, IN UINTN DataLength, IN OUT VOID *DataBuffer OPTIONAL)
EFI_STATUS EFIAPI ScsiRead16CommandEx(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT64 StartLba, IN UINT32 SectorSize, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI ScsiInquiryCommand(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *InquiryDataBuffer OPTIONAL, IN OUT UINT32 *InquiryDataLength, IN BOOLEAN EnableVitalProductData)
EFI_STATUS EFIAPI ScsiReadCapacity16Command(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN BOOLEAN Pmi)
EFI_STATUS EFIAPI ScsiRead16Command(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT64 StartLba, IN UINT32 SectorSize)
EFI_STATUS EFIAPI ScsiWrite10Command(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN UINT32 StartLba, IN UINT32 SectorSize)
EFI_STATUS EFIAPI ScsiReadCapacityCommand(IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, IN OUT VOID *SenseData OPTIONAL, IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, IN OUT VOID *DataBuffer OPTIONAL, IN OUT UINT32 *DataLength, IN BOOLEAN Pmi)
EFI_BLOCK_IO_MEDIA * Media
EFI_BLOCK_IO_MEDIA * Media
CHAR8 * SupportedLanguages
CHAR8 * SupportedLanguages
EFI_EXT_SCSI_PASS_THRU_MODE * Mode
EFI_SCSI_PASS_THRU_MODE * Mode
EFI_STATUS TransactionStatus
UINT8 Addnl_Sense_Code
Additional sense code.
UINT8 Addnl_Sense_Code_Qualifier
Additional sense code qualifier.
UINT16 PortMultiplierPortNumber