diff options
Diffstat (limited to 'MdeModulePkg/Bus/Scsi/ScsiDiskDxe')
-rw-r--r-- | MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c | 34 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 2359 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 541 |
3 files changed, 1480 insertions, 1454 deletions
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c index b193de9..212d26b 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c @@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "ScsiDisk.h"
//
@@ -21,16 +20,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentNam //
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ScsiDiskComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ScsiDiskComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)ScsiDiskComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)ScsiDiskComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {
- { "eng;en", (CHAR16 *) L"Scsi Disk Driver" },
- { NULL , NULL }
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {
+ { "eng;en", (CHAR16 *)L"Scsi Disk Driver" },
+ { NULL, NULL }
};
/**
@@ -160,16 +158,16 @@ ScsiDiskComponentNameGetDriverName ( EFI_STATUS
EFIAPI
ScsiDiskComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- SCSI_DISK_DEV *ScsiDiskDevice;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_STATUS Status;
+ SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
//
// This is a device driver, so ChildHandle must be NULL.
@@ -189,13 +187,14 @@ ScsiDiskComponentNameGetControllerName ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Get the device context
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
gScsiDiskDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -214,5 +213,4 @@ ScsiDiskComponentNameGetControllerName ( ControllerName,
(BOOLEAN)(This == &gScsiDiskComponentName)
);
-
}
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c index b35d92f..98e84b4 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c @@ -6,10 +6,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "ScsiDisk.h"
-EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = {
ScsiDiskDriverBindingSupported,
ScsiDiskDriverBindingStart,
ScsiDiskDriverBindingStop,
@@ -18,7 +17,7 @@ EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = { NULL
};
-EFI_DISK_INFO_PROTOCOL gScsiDiskInfoProtocolTemplate = {
+EFI_DISK_INFO_PROTOCOL gScsiDiskInfoProtocolTemplate = {
EFI_DISK_INFO_SCSI_INTERFACE_GUID,
ScsiDiskInfoInquiry,
ScsiDiskInfoIdentify,
@@ -40,8 +39,8 @@ EFI_DISK_INFO_PROTOCOL gScsiDiskInfoProtocolTemplate = { **/
VOID *
AllocateAlignedBuffer (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN UINTN BufferSize
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN UINTN BufferSize
)
{
return AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), ScsiDiskDevice->ScsiIo->IoAlign);
@@ -59,8 +58,8 @@ AllocateAlignedBuffer ( **/
VOID
FreeAlignedBuffer (
- IN VOID *Buffer,
- IN UINTN BufferSize
+ IN VOID *Buffer,
+ IN UINTN BufferSize
)
{
if (Buffer != NULL) {
@@ -82,12 +81,12 @@ FreeAlignedBuffer ( **/
EFI_STATUS
EFIAPI
-InitializeScsiDisk(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeScsiDisk (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
@@ -102,7 +101,6 @@ InitializeScsiDisk( );
ASSERT_EFI_ERROR (Status);
-
return Status;
}
@@ -140,7 +138,7 @@ ScsiDiskDriverBindingSupported ( Status = gBS->OpenProtocol (
Controller,
&gEfiScsiIoProtocolGuid,
- (VOID **) &ScsiIo,
+ (VOID **)&ScsiIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -153,7 +151,8 @@ ScsiDiskDriverBindingSupported ( if (!EFI_ERROR (Status)) {
if ((DeviceType == EFI_SCSI_TYPE_DISK) ||
(DeviceType == EFI_SCSI_TYPE_CDROM) ||
- (DeviceType == EFI_SCSI_TYPE_WLUN)) {
+ (DeviceType == EFI_SCSI_TYPE_WLUN))
+ {
Status = EFI_SUCCESS;
} else {
Status = EFI_UNSUPPORTED;
@@ -169,7 +168,6 @@ ScsiDiskDriverBindingSupported ( return Status;
}
-
/**
Start this driver on ControllerHandle.
@@ -208,7 +206,7 @@ ScsiDiskDriverBindingStart ( MustReadCapacity = TRUE;
- ScsiDiskDevice = (SCSI_DISK_DEV *) AllocateZeroPool (sizeof (SCSI_DISK_DEV));
+ ScsiDiskDevice = (SCSI_DISK_DEV *)AllocateZeroPool (sizeof (SCSI_DISK_DEV));
if (ScsiDiskDevice == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -216,7 +214,7 @@ ScsiDiskDriverBindingStart ( Status = gBS->OpenProtocol (
Controller,
&gEfiScsiIoProtocolGuid,
- (VOID **) &ScsiIo,
+ (VOID **)&ScsiIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -252,35 +250,36 @@ ScsiDiskDriverBindingStart ( ScsiIo->GetDeviceType (ScsiIo, &(ScsiDiskDevice->DeviceType));
switch (ScsiDiskDevice->DeviceType) {
- case EFI_SCSI_TYPE_DISK:
- ScsiDiskDevice->BlkIo.Media->BlockSize = 0x200;
- MustReadCapacity = TRUE;
- break;
+ case EFI_SCSI_TYPE_DISK:
+ ScsiDiskDevice->BlkIo.Media->BlockSize = 0x200;
+ MustReadCapacity = TRUE;
+ break;
- case EFI_SCSI_TYPE_CDROM:
- ScsiDiskDevice->BlkIo.Media->BlockSize = 0x800;
- ScsiDiskDevice->BlkIo.Media->ReadOnly = TRUE;
- MustReadCapacity = FALSE;
- break;
+ case EFI_SCSI_TYPE_CDROM:
+ ScsiDiskDevice->BlkIo.Media->BlockSize = 0x800;
+ ScsiDiskDevice->BlkIo.Media->ReadOnly = TRUE;
+ MustReadCapacity = FALSE;
+ break;
- case EFI_SCSI_TYPE_WLUN:
- MustReadCapacity = FALSE;
- break;
+ case EFI_SCSI_TYPE_WLUN:
+ MustReadCapacity = FALSE;
+ break;
}
+
//
// The Sense Data Array's initial size is 6
//
ScsiDiskDevice->SenseDataNumber = 6;
- ScsiDiskDevice->SenseData = (EFI_SCSI_SENSE_DATA *) AllocateZeroPool (
- sizeof (EFI_SCSI_SENSE_DATA) * ScsiDiskDevice->SenseDataNumber
- );
+ ScsiDiskDevice->SenseData = (EFI_SCSI_SENSE_DATA *)AllocateZeroPool (
+ sizeof (EFI_SCSI_SENSE_DATA) * ScsiDiskDevice->SenseDataNumber
+ );
if (ScsiDiskDevice->SenseData == NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiScsiIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiScsiIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
FreePool (ScsiDiskDevice);
return EFI_OUT_OF_RESOURCES;
}
@@ -307,6 +306,7 @@ ScsiDiskDriverBindingStart ( return EFI_DEVICE_ERROR;
}
}
+
//
// The second parameter "TRUE" means must
// retrieve media capacity
@@ -341,6 +341,7 @@ ScsiDiskDriverBindingStart ( DEBUG ((DEBUG_ERROR, "ScsiDisk: Failed to install the Erase Block Protocol! Status = %r\n", Status));
}
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, Controller)) {
Status = gBS->InstallProtocolInterface (
&Controller,
@@ -352,6 +353,7 @@ ScsiDiskDriverBindingStart ( DEBUG ((DEBUG_ERROR, "ScsiDisk: Failed to install the Storage Security Command Protocol! Status = %r\n", Status));
}
}
+
ScsiDiskDevice->ControllerNameTable = NULL;
AddUnicodeString2 (
"eng",
@@ -381,10 +383,8 @@ ScsiDiskDriverBindingStart ( Controller
);
return Status;
-
}
-
/**
Stop this driver on ControllerHandle.
@@ -407,21 +407,21 @@ ScsiDiskDriverBindingStart ( EFI_STATUS
EFIAPI
ScsiDiskDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- EFI_ERASE_BLOCK_PROTOCOL *EraseBlock;
- SCSI_DISK_DEV *ScsiDiskDevice;
- EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlkIo;
+ EFI_ERASE_BLOCK_PROTOCOL *EraseBlock;
+ SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_STATUS Status;
Status = gBS->OpenProtocol (
Controller,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo,
+ (VOID **)&BlkIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -435,7 +435,8 @@ ScsiDiskDriverBindingStop ( //
// Wait for the BlockIo2 requests queue to become empty
//
- while (!IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue));
+ while (!IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue)) {
+ }
//
// If Erase Block Protocol is installed, then uninstall this protocol.
@@ -443,7 +444,7 @@ ScsiDiskDriverBindingStop ( Status = gBS->OpenProtocol (
Controller,
&gEfiEraseBlockProtocolGuid,
- (VOID **) &EraseBlock,
+ (VOID **)&EraseBlock,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -482,6 +483,7 @@ ScsiDiskDriverBindingStop ( return EFI_SUCCESS;
}
+
//
// errors met
//
@@ -504,19 +506,19 @@ ScsiDiskDriverBindingStop ( EFI_STATUS
EFIAPI
ScsiDiskReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EFI_TPL OldTpl;
- SCSI_DISK_DEV *ScsiDiskDevice;
- EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_STATUS Status;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
- Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
+ Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
if (EFI_ERROR (Status)) {
if (Status == EFI_UNSUPPORTED) {
@@ -563,11 +565,11 @@ Done: EFI_STATUS
EFIAPI
ScsiDiskReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -583,8 +585,7 @@ ScsiDiskReadBlocks ( ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
Media = ScsiDiskDevice->BlkIo.Media;
- if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
-
+ if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -593,11 +594,11 @@ ScsiDiskReadBlocks ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -612,33 +613,37 @@ ScsiDiskReadBlocks ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
+
//
// Get the intrinsic block size
//
- BlockSize = Media->BlockSize;
+ BlockSize = Media->BlockSize;
if (BlockSize == 0) {
Status = EFI_DEVICE_ERROR;
goto Done;
}
- NumberOfBlocks = BufferSize / BlockSize;
+ NumberOfBlocks = BufferSize / BlockSize;
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
@@ -675,7 +680,7 @@ ScsiDiskReadBlocks ( goto Done;
}
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
+ if ((Media->IoAlign > 1) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -712,11 +717,11 @@ Done: EFI_STATUS
EFIAPI
ScsiDiskWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -732,8 +737,7 @@ ScsiDiskWriteBlocks ( ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
Media = ScsiDiskDevice->BlkIo.Media;
- if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
-
+ if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -742,11 +746,11 @@ ScsiDiskWriteBlocks ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -761,33 +765,37 @@ ScsiDiskWriteBlocks ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
+
//
// Get the intrinsic block size
//
- BlockSize = Media->BlockSize;
+ BlockSize = Media->BlockSize;
if (BlockSize == 0) {
Status = EFI_DEVICE_ERROR;
goto Done;
}
- NumberOfBlocks = BufferSize / BlockSize;
+ NumberOfBlocks = BufferSize / BlockSize;
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
@@ -829,10 +837,11 @@ ScsiDiskWriteBlocks ( goto Done;
}
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
+ if ((Media->IoAlign > 1) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
+
//
// if all the parameters are valid, then perform read sectors command
// to transfer data from device to host.
@@ -857,7 +866,7 @@ Done: EFI_STATUS
EFIAPI
ScsiDiskFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
+ IN EFI_BLOCK_IO_PROTOCOL *This
)
{
//
@@ -866,7 +875,6 @@ ScsiDiskFlushBlocks ( return EFI_SUCCESS;
}
-
/**
Reset SCSI Disk.
@@ -886,15 +894,15 @@ ScsiDiskResetEx ( IN BOOLEAN ExtendedVerification
)
{
- EFI_TPL OldTpl;
- SCSI_DISK_DEV *ScsiDiskDevice;
- EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_STATUS Status;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
- Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
+ Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
if (EFI_ERROR (Status)) {
if (Status == EFI_UNSUPPORTED) {
@@ -950,12 +958,12 @@ Done: 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
+ 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
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -971,8 +979,7 @@ ScsiDiskReadBlocksEx ( ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
Media = ScsiDiskDevice->BlkIo.Media;
- if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
-
+ if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -981,11 +988,11 @@ ScsiDiskReadBlocksEx ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -1000,33 +1007,37 @@ ScsiDiskReadBlocksEx ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
+
//
// Get the intrinsic block size
//
- BlockSize = Media->BlockSize;
+ BlockSize = Media->BlockSize;
if (BlockSize == 0) {
Status = EFI_DEVICE_ERROR;
goto Done;
}
- NumberOfBlocks = BufferSize / BlockSize;
+ NumberOfBlocks = BufferSize / BlockSize;
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
@@ -1068,7 +1079,7 @@ ScsiDiskReadBlocksEx ( goto Done;
}
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
+ if ((Media->IoAlign > 1) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1079,13 +1090,13 @@ ScsiDiskReadBlocksEx ( //
if ((Token != NULL) && (Token->Event != NULL)) {
Token->TransactionStatus = EFI_SUCCESS;
- Status = ScsiDiskAsyncReadSectors (
- ScsiDiskDevice,
- Buffer,
- Lba,
- NumberOfBlocks,
- Token
- );
+ Status = ScsiDiskAsyncReadSectors (
+ ScsiDiskDevice,
+ Buffer,
+ Lba,
+ NumberOfBlocks,
+ Token
+ );
} else {
Status = ScsiDiskReadSectors (
ScsiDiskDevice,
@@ -1126,12 +1137,12 @@ Done: 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
+ 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
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -1147,8 +1158,7 @@ ScsiDiskWriteBlocksEx ( ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
Media = ScsiDiskDevice->BlkIo.Media;
- if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
-
+ if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -1157,11 +1167,11 @@ ScsiDiskWriteBlocksEx ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -1176,33 +1186,37 @@ ScsiDiskWriteBlocksEx ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
+
//
// Get the intrinsic block size
//
- BlockSize = Media->BlockSize;
+ BlockSize = Media->BlockSize;
if (BlockSize == 0) {
Status = EFI_DEVICE_ERROR;
goto Done;
}
- NumberOfBlocks = BufferSize / BlockSize;
+ NumberOfBlocks = BufferSize / BlockSize;
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
@@ -1249,7 +1263,7 @@ ScsiDiskWriteBlocksEx ( goto Done;
}
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
+ if ((Media->IoAlign > 1) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1260,13 +1274,13 @@ ScsiDiskWriteBlocksEx ( //
if ((Token != NULL) && (Token->Event != NULL)) {
Token->TransactionStatus = EFI_SUCCESS;
- Status = ScsiDiskAsyncWriteSectors (
- ScsiDiskDevice,
- Buffer,
- Lba,
- NumberOfBlocks,
- Token
- );
+ Status = ScsiDiskAsyncWriteSectors (
+ ScsiDiskDevice,
+ Buffer,
+ Lba,
+ NumberOfBlocks,
+ Token
+ );
} else {
Status = ScsiDiskWriteSectors (
ScsiDiskDevice,
@@ -1313,8 +1327,7 @@ ScsiDiskFlushBlocksEx ( ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
Media = ScsiDiskDevice->BlkIo.Media;
- if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
-
+ if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -1323,11 +1336,11 @@ ScsiDiskFlushBlocksEx ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -1342,19 +1355,22 @@ ScsiDiskFlushBlocksEx ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
@@ -1372,7 +1388,8 @@ ScsiDiskFlushBlocksEx ( //
// Wait for the BlockIo2 requests queue to become empty
//
- while (!IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue));
+ while (!IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue)) {
+ }
Status = EFI_SUCCESS;
@@ -1389,7 +1406,6 @@ Done: return Status;
}
-
/**
Internal helper notify function which process the result of an asynchronous
SCSI UNMAP Command and signal the event passed from EraseBlocks.
@@ -1412,13 +1428,13 @@ ScsiDiskAsyncUnmapNotify ( gBS->CloseEvent (Event);
- EraseBlkReq = (SCSI_ERASEBLK_REQUEST *) Context;
+ EraseBlkReq = (SCSI_ERASEBLK_REQUEST *)Context;
CommandPacket = &EraseBlkReq->CommandPacket;
Token = EraseBlkReq->Token;
Token->TransactionStatus = EFI_SUCCESS;
Status = CheckHostAdapterStatus (CommandPacket->HostAdapterStatus);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ScsiDiskAsyncUnmapNotify: Host adapter indicating error status 0x%x.\n",
@@ -1430,7 +1446,7 @@ ScsiDiskAsyncUnmapNotify ( }
Status = CheckTargetStatus (CommandPacket->TargetStatus);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ScsiDiskAsyncUnmapNotify: Target indicating error status 0x%x.\n",
@@ -1465,10 +1481,10 @@ Done: **/
EFI_STATUS
ScsiDiskUnmap (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN UINT64 Lba,
- IN UINTN Blocks,
- IN EFI_ERASE_BLOCK_TOKEN *Token OPTIONAL
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN UINT64 Lba,
+ IN UINTN Blocks,
+ IN EFI_ERASE_BLOCK_TOKEN *Token OPTIONAL
)
{
EFI_SCSI_IO_PROTOCOL *ScsiIo;
@@ -1494,7 +1510,7 @@ ScsiDiskUnmap ( AsyncUnmapEvent = NULL;
ReturnStatus = EFI_SUCCESS;
- if (Blocks / (UINTN) MaxLbaCnt > MaxBlkDespCnt) {
+ if (Blocks / (UINTN)MaxLbaCnt > MaxBlkDespCnt) {
ReturnStatus = EFI_DEVICE_ERROR;
goto Done;
}
@@ -1511,10 +1527,10 @@ ScsiDiskUnmap ( goto Done;
}
- BlkDespCnt = (UINT32) ((Blocks - 1) / MaxLbaCnt + 1);
- UnmapParamListLen = (UINT16) (sizeof (EFI_SCSI_DISK_UNMAP_PARAM_LIST_HEADER)
- + BlkDespCnt * sizeof (EFI_SCSI_DISK_UNMAP_BLOCK_DESP));
- UnmapParamList = AllocateZeroPool (UnmapParamListLen);
+ BlkDespCnt = (UINT32)((Blocks - 1) / MaxLbaCnt + 1);
+ UnmapParamListLen = (UINT16)(sizeof (EFI_SCSI_DISK_UNMAP_PARAM_LIST_HEADER)
+ + BlkDespCnt * sizeof (EFI_SCSI_DISK_UNMAP_BLOCK_DESP));
+ UnmapParamList = AllocateZeroPool (UnmapParamListLen);
if (UnmapParamList == NULL) {
ReturnStatus = EFI_DEVICE_ERROR;
goto Done;
@@ -1528,12 +1544,12 @@ ScsiDiskUnmap ( if (Blocks > MaxLbaCnt) {
*(UINT64 *)(&BlkDespPtr->Lba) = SwapBytes64 (Lba);
*(UINT32 *)(&BlkDespPtr->BlockNum) = SwapBytes32 (MaxLbaCnt);
- Blocks -= MaxLbaCnt;
- Lba += MaxLbaCnt;
+ Blocks -= MaxLbaCnt;
+ Lba += MaxLbaCnt;
} else {
*(UINT64 *)(&BlkDespPtr->Lba) = SwapBytes64 (Lba);
- *(UINT32 *)(&BlkDespPtr->BlockNum) = SwapBytes32 ((UINT32) Blocks);
- Blocks = 0;
+ *(UINT32 *)(&BlkDespPtr->BlockNum) = SwapBytes32 ((UINT32)Blocks);
+ Blocks = 0;
}
BlkDespPtr++;
@@ -1563,7 +1579,7 @@ ScsiDiskUnmap ( EraseBlkReq,
&AsyncUnmapEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ReturnStatus = EFI_DEVICE_ERROR;
goto Done;
}
@@ -1579,7 +1595,7 @@ ScsiDiskUnmap ( CommandPacket,
AsyncUnmapEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ReturnStatus = EFI_DEVICE_ERROR;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
@@ -1602,7 +1618,7 @@ ScsiDiskUnmap ( CommandPacket,
NULL
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ReturnStatus = EFI_DEVICE_ERROR;
goto Done;
}
@@ -1612,7 +1628,7 @@ ScsiDiskUnmap ( // Only blocking UNMAP request will reach here.
//
Status = CheckHostAdapterStatus (CommandPacket->HostAdapterStatus);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ScsiDiskUnmap: Host adapter indicating error status 0x%x.\n",
@@ -1624,7 +1640,7 @@ ScsiDiskUnmap ( }
Status = CheckTargetStatus (CommandPacket->TargetStatus);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ScsiDiskUnmap: Target indicating error status 0x%x.\n",
@@ -1640,6 +1656,7 @@ Done: if (EraseBlkReq->CommandPacket.Cdb != NULL) {
FreePool (EraseBlkReq->CommandPacket.Cdb);
}
+
FreePool (EraseBlkReq);
}
@@ -1684,11 +1701,11 @@ Done: 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
+ IN EFI_ERASE_BLOCK_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN OUT EFI_ERASE_BLOCK_TOKEN *Token,
+ IN UINTN Size
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -1703,7 +1720,7 @@ ScsiDiskEraseBlocks ( OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_ERASEBLK (This);
- if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
+ if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -1712,11 +1729,11 @@ ScsiDiskEraseBlocks ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -1731,18 +1748,21 @@ ScsiDiskEraseBlocks ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
Status = EFI_MEDIA_CHANGED;
goto Done;
}
}
+
//
// Get the intrinsic block size
//
@@ -1768,6 +1788,7 @@ ScsiDiskEraseBlocks ( Token->TransactionStatus = EFI_SUCCESS;
gBS->SignalEvent (Token->Event);
}
+
Status = EFI_SUCCESS;
goto Done;
}
@@ -1862,14 +1883,14 @@ Done: 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
+ 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
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -1883,14 +1904,14 @@ ScsiDiskReceiveData ( VOID *AlignedBuffer;
BOOLEAN AlignedBufferAllocated;
- AlignedBuffer = NULL;
- MediaChange = FALSE;
- AlignedBufferAllocated = FALSE;
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
- Media = ScsiDiskDevice->BlkIo.Media;
+ AlignedBuffer = NULL;
+ MediaChange = FALSE;
+ AlignedBufferAllocated = FALSE;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
@@ -1901,11 +1922,11 @@ ScsiDiskReceiveData ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -1920,19 +1941,22 @@ ScsiDiskReceiveData ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
@@ -1962,6 +1986,7 @@ ScsiDiskReceiveData ( Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
ZeroMem (AlignedBuffer, PayloadBufferSize);
AlignedBufferAllocated = TRUE;
} else {
@@ -1970,19 +1995,19 @@ ScsiDiskReceiveData ( }
Status = ScsiSecurityProtocolInCommand (
- ScsiDiskDevice->ScsiIo,
- Timeout,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- SecurityProtocolId,
- SecurityProtocolSpecificData,
- FALSE,
- PayloadBufferSize,
- AlignedBuffer,
- PayloadTransferSize
- );
+ ScsiDiskDevice->ScsiIo,
+ Timeout,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ SecurityProtocolId,
+ SecurityProtocolSpecificData,
+ FALSE,
+ PayloadBufferSize,
+ AlignedBuffer,
+ PayloadTransferSize
+ );
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2011,6 +2036,7 @@ Done: ZeroMem (AlignedBuffer, PayloadBufferSize);
FreeAlignedBuffer (AlignedBuffer, PayloadBufferSize);
}
+
gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -2073,13 +2099,13 @@ Done: 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
+ 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
)
{
SCSI_DISK_DEV *ScsiDiskDevice;
@@ -2093,14 +2119,14 @@ ScsiDiskSendData ( VOID *AlignedBuffer;
BOOLEAN AlignedBufferAllocated;
- AlignedBuffer = NULL;
- MediaChange = FALSE;
- AlignedBufferAllocated = FALSE;
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
- Media = ScsiDiskDevice->BlkIo.Media;
+ AlignedBuffer = NULL;
+ MediaChange = FALSE;
+ AlignedBufferAllocated = FALSE;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange);
@@ -2111,11 +2137,11 @@ ScsiDiskSendData ( if (MediaChange) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiBlockIoProtocolGuid,
- &ScsiDiskDevice->BlkIo,
- &ScsiDiskDevice->BlkIo
- );
+ ScsiDiskDevice->Handle,
+ &gEfiBlockIoProtocolGuid,
+ &ScsiDiskDevice->BlkIo,
+ &ScsiDiskDevice->BlkIo
+ );
gBS->ReinstallProtocolInterface (
ScsiDiskDevice->Handle,
&gEfiBlockIo2ProtocolGuid,
@@ -2130,19 +2156,22 @@ ScsiDiskSendData ( &ScsiDiskDevice->EraseBlock
);
}
+
if (DetermineInstallStorageSecurity (ScsiDiskDevice, ScsiDiskDevice->Handle)) {
gBS->ReinstallProtocolInterface (
- ScsiDiskDevice->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- &ScsiDiskDevice->StorageSecurity,
- &ScsiDiskDevice->StorageSecurity
- );
+ ScsiDiskDevice->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ &ScsiDiskDevice->StorageSecurity,
+ &ScsiDiskDevice->StorageSecurity
+ );
}
+
if (Media->MediaPresent) {
Status = EFI_MEDIA_CHANGED;
} else {
Status = EFI_NO_MEDIA;
}
+
goto Done;
}
}
@@ -2177,6 +2206,7 @@ ScsiDiskSendData ( Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
CopyMem (AlignedBuffer, PayloadBuffer, PayloadBufferSize);
AlignedBufferAllocated = TRUE;
} else {
@@ -2185,18 +2215,18 @@ ScsiDiskSendData ( }
Status = ScsiSecurityProtocolOutCommand (
- ScsiDiskDevice->ScsiIo,
- Timeout,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- SecurityProtocolId,
- SecurityProtocolSpecificData,
- FALSE,
- PayloadBufferSize,
- AlignedBuffer
- );
+ ScsiDiskDevice->ScsiIo,
+ Timeout,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ SecurityProtocolId,
+ SecurityProtocolSpecificData,
+ FALSE,
+ PayloadBufferSize,
+ AlignedBuffer
+ );
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2216,11 +2246,11 @@ Done: ZeroMem (AlignedBuffer, PayloadBufferSize);
FreeAlignedBuffer (AlignedBuffer, PayloadBufferSize);
}
+
gBS->RestoreTPL (OldTpl);
return Status;
}
-
/**
Detect Device and read out capacity ,if error occurs, parse the sense key.
@@ -2234,31 +2264,31 @@ Done: **/
EFI_STATUS
ScsiDiskDetectMedia (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN BOOLEAN MustReadCapacity,
- OUT BOOLEAN *MediaChange
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN BOOLEAN MustReadCapacity,
+ OUT BOOLEAN *MediaChange
)
{
- EFI_STATUS Status;
- EFI_SCSI_SENSE_DATA *SenseData;
- UINTN NumberOfSenseKeys;
- BOOLEAN NeedRetry;
- BOOLEAN NeedReadCapacity;
- UINT8 Retry;
- UINT8 MaxRetry;
- EFI_BLOCK_IO_MEDIA OldMedia;
- UINTN Action;
- EFI_EVENT TimeoutEvt;
-
- Status = EFI_SUCCESS;
- SenseData = NULL;
- NumberOfSenseKeys = 0;
- Retry = 0;
- MaxRetry = 3;
- Action = ACTION_NO_ACTION;
- NeedReadCapacity = FALSE;
- *MediaChange = FALSE;
- TimeoutEvt = NULL;
+ EFI_STATUS Status;
+ EFI_SCSI_SENSE_DATA *SenseData;
+ UINTN NumberOfSenseKeys;
+ BOOLEAN NeedRetry;
+ BOOLEAN NeedReadCapacity;
+ UINT8 Retry;
+ UINT8 MaxRetry;
+ EFI_BLOCK_IO_MEDIA OldMedia;
+ UINTN Action;
+ EFI_EVENT TimeoutEvt;
+
+ Status = EFI_SUCCESS;
+ SenseData = NULL;
+ NumberOfSenseKeys = 0;
+ Retry = 0;
+ MaxRetry = 3;
+ Action = ACTION_NO_ACTION;
+ NeedReadCapacity = FALSE;
+ *MediaChange = FALSE;
+ TimeoutEvt = NULL;
CopyMem (&OldMedia, ScsiDiskDevice->BlkIo.Media, sizeof (OldMedia));
@@ -2273,7 +2303,7 @@ ScsiDiskDetectMedia ( return Status;
}
- Status = gBS->SetTimer (TimeoutEvt, TimerRelative, EFI_TIMER_PERIOD_SECONDS(120));
+ Status = gBS->SetTimer (TimeoutEvt, TimerRelative, EFI_TIMER_PERIOD_SECONDS (120));
if (EFI_ERROR (Status)) {
goto EXIT;
}
@@ -2285,11 +2315,11 @@ ScsiDiskDetectMedia ( //
while (EFI_ERROR (gBS->CheckEvent (TimeoutEvt))) {
Status = ScsiDiskTestUnitReady (
- ScsiDiskDevice,
- &NeedRetry,
- &SenseData,
- &NumberOfSenseKeys
- );
+ ScsiDiskDevice,
+ &NeedRetry,
+ &SenseData,
+ &NumberOfSenseKeys
+ );
if (!EFI_ERROR (Status)) {
Status = DetectMediaParsingSenseKeys (
ScsiDiskDevice,
@@ -2328,8 +2358,8 @@ ScsiDiskDetectMedia ( // READ_CAPACITY command is not supported by any of the UFS WLUNs.
//
if (ScsiDiskDevice->DeviceType == EFI_SCSI_TYPE_WLUN) {
- NeedReadCapacity = FALSE;
- MustReadCapacity = FALSE;
+ NeedReadCapacity = FALSE;
+ MustReadCapacity = FALSE;
ScsiDiskDevice->BlkIo.Media->MediaPresent = TRUE;
}
@@ -2391,17 +2421,17 @@ ScsiDiskDetectMedia ( }
if (ScsiDiskDevice->BlkIo.Media->ReadOnly != OldMedia.ReadOnly) {
- *MediaChange = TRUE;
+ *MediaChange = TRUE;
ScsiDiskDevice->BlkIo.Media->MediaId += 1;
}
if (ScsiDiskDevice->BlkIo.Media->BlockSize != OldMedia.BlockSize) {
- *MediaChange = TRUE;
+ *MediaChange = TRUE;
ScsiDiskDevice->BlkIo.Media->MediaId += 1;
}
if (ScsiDiskDevice->BlkIo.Media->LastBlock != OldMedia.LastBlock) {
- *MediaChange = TRUE;
+ *MediaChange = TRUE;
ScsiDiskDevice->BlkIo.Media->MediaId += 1;
}
@@ -2425,10 +2455,10 @@ EXIT: if (TimeoutEvt != NULL) {
gBS->CloseEvent (TimeoutEvt);
}
+
return Status;
}
-
/**
Send out Inquiry command to Device.
@@ -2441,40 +2471,40 @@ EXIT: **/
EFI_STATUS
ScsiDiskInquiryDevice (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry
)
{
- UINT32 InquiryDataLength;
- UINT8 SenseDataLength;
- UINT8 HostAdapterStatus;
- UINT8 TargetStatus;
- EFI_SCSI_SENSE_DATA *SenseDataArray;
- UINTN NumberOfSenseKeys;
- EFI_STATUS Status;
- UINT8 MaxRetry;
- UINT8 Index;
- EFI_SCSI_SUPPORTED_VPD_PAGES_VPD_PAGE *SupportedVpdPages;
- EFI_SCSI_BLOCK_LIMITS_VPD_PAGE *BlockLimits;
- UINTN PageLength;
+ UINT32 InquiryDataLength;
+ UINT8 SenseDataLength;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ EFI_SCSI_SENSE_DATA *SenseDataArray;
+ UINTN NumberOfSenseKeys;
+ EFI_STATUS Status;
+ UINT8 MaxRetry;
+ UINT8 Index;
+ EFI_SCSI_SUPPORTED_VPD_PAGES_VPD_PAGE *SupportedVpdPages;
+ EFI_SCSI_BLOCK_LIMITS_VPD_PAGE *BlockLimits;
+ UINTN PageLength;
InquiryDataLength = sizeof (EFI_SCSI_INQUIRY_DATA);
SenseDataLength = 0;
Status = ScsiInquiryCommand (
- ScsiDiskDevice->ScsiIo,
- SCSI_DISK_TIMEOUT,
- NULL,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- (VOID *) &(ScsiDiskDevice->InquiryData),
- &InquiryDataLength,
- FALSE
- );
- //
- // no need to check HostAdapterStatus and TargetStatus
- //
+ ScsiDiskDevice->ScsiIo,
+ SCSI_DISK_TIMEOUT,
+ NULL,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ (VOID *)&(ScsiDiskDevice->InquiryData),
+ &InquiryDataLength,
+ FALSE
+ );
+ //
+ // no need to check HostAdapterStatus and TargetStatus
+ //
if ((Status == EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) {
ParseInquiryData (ScsiDiskDevice);
@@ -2487,41 +2517,49 @@ ScsiDiskInquiryDevice ( *NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
ZeroMem (SupportedVpdPages, sizeof (EFI_SCSI_SUPPORTED_VPD_PAGES_VPD_PAGE));
InquiryDataLength = sizeof (EFI_SCSI_SUPPORTED_VPD_PAGES_VPD_PAGE);
SenseDataLength = 0;
- Status = ScsiInquiryCommandEx (
- ScsiDiskDevice->ScsiIo,
- SCSI_DISK_TIMEOUT,
- NULL,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- (VOID *) SupportedVpdPages,
- &InquiryDataLength,
- TRUE,
- EFI_SCSI_PAGE_CODE_SUPPORTED_VPD
- );
+ Status = ScsiInquiryCommandEx (
+ ScsiDiskDevice->ScsiIo,
+ SCSI_DISK_TIMEOUT,
+ NULL,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ (VOID *)SupportedVpdPages,
+ &InquiryDataLength,
+ TRUE,
+ EFI_SCSI_PAGE_CODE_SUPPORTED_VPD
+ );
if (!EFI_ERROR (Status)) {
PageLength = (SupportedVpdPages->PageLength2 << 8)
- | SupportedVpdPages->PageLength1;
+ | SupportedVpdPages->PageLength1;
//
// Sanity checks for coping with broken devices
//
if (PageLength > sizeof SupportedVpdPages->SupportedVpdPageList) {
- DEBUG ((DEBUG_WARN,
+ DEBUG ((
+ DEBUG_WARN,
"%a: invalid PageLength (%u) in Supported VPD Pages page\n",
- __FUNCTION__, (UINT32)PageLength));
+ __FUNCTION__,
+ (UINT32)PageLength
+ ));
PageLength = 0;
}
if ((PageLength > 0) &&
(SupportedVpdPages->SupportedVpdPageList[0] !=
- EFI_SCSI_PAGE_CODE_SUPPORTED_VPD)) {
- DEBUG ((DEBUG_WARN,
+ EFI_SCSI_PAGE_CODE_SUPPORTED_VPD))
+ {
+ DEBUG ((
+ DEBUG_WARN,
"%a: Supported VPD Pages page doesn't start with code 0x%02x\n",
- __FUNCTION__, EFI_SCSI_PAGE_CODE_SUPPORTED_VPD));
+ __FUNCTION__,
+ EFI_SCSI_PAGE_CODE_SUPPORTED_VPD
+ ));
PageLength = 0;
}
@@ -2534,11 +2572,15 @@ ScsiDiskInquiryDevice ( //
if ((Index > 0) &&
(SupportedVpdPages->SupportedVpdPageList[Index] <=
- SupportedVpdPages->SupportedVpdPageList[Index - 1])) {
- DEBUG ((DEBUG_WARN,
+ SupportedVpdPages->SupportedVpdPageList[Index - 1]))
+ {
+ DEBUG ((
+ DEBUG_WARN,
"%a: non-ascending code in Supported VPD Pages page @ %u\n",
- __FUNCTION__, Index));
- Index = 0;
+ __FUNCTION__,
+ Index
+ ));
+ Index = 0;
PageLength = 0;
break;
}
@@ -2558,25 +2600,26 @@ ScsiDiskInquiryDevice ( *NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
ZeroMem (BlockLimits, sizeof (EFI_SCSI_BLOCK_LIMITS_VPD_PAGE));
InquiryDataLength = sizeof (EFI_SCSI_BLOCK_LIMITS_VPD_PAGE);
SenseDataLength = 0;
- Status = ScsiInquiryCommandEx (
- ScsiDiskDevice->ScsiIo,
- SCSI_DISK_TIMEOUT,
- NULL,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- (VOID *) BlockLimits,
- &InquiryDataLength,
- TRUE,
- EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD
- );
+ Status = ScsiInquiryCommandEx (
+ ScsiDiskDevice->ScsiIo,
+ SCSI_DISK_TIMEOUT,
+ NULL,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ (VOID *)BlockLimits,
+ &InquiryDataLength,
+ TRUE,
+ EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD
+ );
if (!EFI_ERROR (Status)) {
ScsiDiskDevice->BlkIo.Media->OptimalTransferLengthGranularity =
(BlockLimits->OptimalTransferLengthGranularity2 << 8) |
- BlockLimits->OptimalTransferLengthGranularity1;
+ BlockLimits->OptimalTransferLengthGranularity1;
ScsiDiskDevice->UnmapInfo.MaxLbaCnt =
(BlockLimits->MaximumUnmapLbaCount4 << 24) |
@@ -2622,15 +2665,14 @@ ScsiDiskInquiryDevice ( if (!EFI_ERROR (Status)) {
return EFI_SUCCESS;
-
} else if (Status == EFI_NOT_READY) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
-
} else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
//
// go ahead to check HostAdapterStatus and TargetStatus
// (EFI_TIMEOUT, EFI_DEVICE_ERROR)
@@ -2641,9 +2683,9 @@ ScsiDiskInquiryDevice ( *NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
} else if (Status == EFI_DEVICE_ERROR) {
- //
- // reset the scsi channel
- //
+ //
+ // reset the scsi channel
+ //
ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
@@ -2657,7 +2699,6 @@ ScsiDiskInquiryDevice ( ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
-
} else if (Status == EFI_DEVICE_ERROR) {
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
@@ -2671,12 +2712,12 @@ ScsiDiskInquiryDevice ( MaxRetry = 3;
for (Index = 0; Index < MaxRetry; Index++) {
Status = ScsiDiskRequestSenseKeys (
- ScsiDiskDevice,
- NeedRetry,
- &SenseDataArray,
- &NumberOfSenseKeys,
- TRUE
- );
+ ScsiDiskDevice,
+ NeedRetry,
+ &SenseDataArray,
+ &NumberOfSenseKeys,
+ TRUE
+ );
if (!EFI_ERROR (Status)) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
@@ -2686,6 +2727,7 @@ ScsiDiskInquiryDevice ( return EFI_DEVICE_ERROR;
}
}
+
//
// ScsiDiskRequestSenseKeys() failed after several rounds of retry.
// set *NeedRetry = FALSE to avoid the outside caller try again.
@@ -2712,10 +2754,10 @@ ScsiDiskInquiryDevice ( **/
EFI_STATUS
ScsiDiskTestUnitReady (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry,
- OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
- OUT UINTN *NumberOfSenseKeys
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
+ OUT UINTN *NumberOfSenseKeys
)
{
EFI_STATUS Status;
@@ -2725,31 +2767,31 @@ ScsiDiskTestUnitReady ( UINT8 Index;
UINT8 MaxRetry;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
- *NumberOfSenseKeys = 0;
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ *NumberOfSenseKeys = 0;
//
// Parameter 3 and 4: do not require sense data, retrieve it when needed.
//
Status = ScsiTestUnitReadyCommand (
- ScsiDiskDevice->ScsiIo,
- SCSI_DISK_TIMEOUT,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus
- );
+ ScsiDiskDevice->ScsiIo,
+ SCSI_DISK_TIMEOUT,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus
+ );
//
// no need to check HostAdapterStatus and TargetStatus
//
if (Status == EFI_NOT_READY) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
-
} else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
//
// go ahead to check HostAdapterStatus and TargetStatus(in case of EFI_DEVICE_ERROR)
//
@@ -2758,7 +2800,6 @@ ScsiDiskTestUnitReady ( if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
-
} else if (Status == EFI_DEVICE_ERROR) {
//
// reset the scsi channel
@@ -2776,7 +2817,6 @@ ScsiDiskTestUnitReady ( ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
-
} else if (Status == EFI_DEVICE_ERROR) {
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
@@ -2791,12 +2831,12 @@ ScsiDiskTestUnitReady ( MaxRetry = 3;
for (Index = 0; Index < MaxRetry; Index++) {
Status = ScsiDiskRequestSenseKeys (
- ScsiDiskDevice,
- NeedRetry,
- SenseDataArray,
- NumberOfSenseKeys,
- FALSE
- );
+ ScsiDiskDevice,
+ NeedRetry,
+ SenseDataArray,
+ NumberOfSenseKeys,
+ FALSE
+ );
if (!EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
@@ -2805,6 +2845,7 @@ ScsiDiskTestUnitReady ( return EFI_DEVICE_ERROR;
}
}
+
//
// ScsiDiskRequestSenseKeys() failed after several rounds of retry.
// set *NeedRetry = FALSE to avoid the outside caller try again.
@@ -2827,13 +2868,13 @@ ScsiDiskTestUnitReady ( **/
EFI_STATUS
DetectMediaParsingSenseKeys (
- OUT SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN NumberOfSenseKeys,
- OUT UINTN *Action
+ OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN NumberOfSenseKeys,
+ OUT UINTN *Action
)
{
- BOOLEAN RetryLater;
+ BOOLEAN RetryLater;
//
// Default is to read capacity, unless..
@@ -2844,6 +2885,7 @@ DetectMediaParsingSenseKeys ( if (ScsiDiskDevice->BlkIo.Media->MediaPresent == TRUE) {
*Action = ACTION_NO_ACTION;
}
+
return EFI_SUCCESS;
}
@@ -2854,13 +2896,14 @@ DetectMediaParsingSenseKeys ( if (ScsiDiskDevice->BlkIo.Media->MediaPresent == TRUE) {
*Action = ACTION_NO_ACTION;
}
+
return EFI_SUCCESS;
}
if (ScsiDiskIsNoMedia (SenseData, NumberOfSenseKeys)) {
ScsiDiskDevice->BlkIo.Media->MediaPresent = FALSE;
ScsiDiskDevice->BlkIo.Media->LastBlock = 0;
- *Action = ACTION_NO_ACTION;
+ *Action = ACTION_NO_ACTION;
DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskIsNoMedia\n"));
return EFI_SUCCESS;
}
@@ -2895,6 +2938,7 @@ DetectMediaParsingSenseKeys ( DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskDriveNotReady!\n"));
return EFI_SUCCESS;
}
+
*Action = ACTION_NO_ACTION;
return EFI_DEVICE_ERROR;
}
@@ -2904,7 +2948,6 @@ DetectMediaParsingSenseKeys ( return EFI_SUCCESS;
}
-
/**
Send read capacity command to device and get the device parameter.
@@ -2919,29 +2962,30 @@ DetectMediaParsingSenseKeys ( **/
EFI_STATUS
ScsiDiskReadCapacity (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry,
- OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
- OUT UINTN *NumberOfSenseKeys
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
+ OUT UINTN *NumberOfSenseKeys
)
{
- UINT8 HostAdapterStatus;
- UINT8 TargetStatus;
- EFI_STATUS CommandStatus;
- EFI_STATUS Status;
- UINT8 Index;
- UINT8 MaxRetry;
- UINT8 SenseDataLength;
- UINT32 DataLength10;
- UINT32 DataLength16;
- EFI_SCSI_DISK_CAPACITY_DATA *CapacityData10;
- EFI_SCSI_DISK_CAPACITY_DATA16 *CapacityData16;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ EFI_STATUS CommandStatus;
+ EFI_STATUS Status;
+ UINT8 Index;
+ UINT8 MaxRetry;
+ UINT8 SenseDataLength;
+ UINT32 DataLength10;
+ UINT32 DataLength16;
+ EFI_SCSI_DISK_CAPACITY_DATA *CapacityData10;
+ EFI_SCSI_DISK_CAPACITY_DATA16 *CapacityData16;
CapacityData10 = AllocateAlignedBuffer (ScsiDiskDevice, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
if (CapacityData10 == NULL) {
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
CapacityData16 = AllocateAlignedBuffer (ScsiDiskDevice, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
if (CapacityData16 == NULL) {
FreeAlignedBuffer (CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
@@ -2949,14 +2993,14 @@ ScsiDiskReadCapacity ( return EFI_DEVICE_ERROR;
}
- SenseDataLength = 0;
- DataLength10 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA);
- DataLength16 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA16);
+ SenseDataLength = 0;
+ DataLength10 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA);
+ DataLength16 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA16);
ZeroMem (CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
ZeroMem (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
- *NumberOfSenseKeys = 0;
- *NeedRetry = FALSE;
+ *NumberOfSenseKeys = 0;
+ *NeedRetry = FALSE;
//
// submit Read Capacity(10) Command. If it returns capacity of FFFFFFFFh,
@@ -2969,14 +3013,15 @@ ScsiDiskReadCapacity ( &SenseDataLength,
&HostAdapterStatus,
&TargetStatus,
- (VOID *) CapacityData10,
+ (VOID *)CapacityData10,
&DataLength10,
FALSE
);
ScsiDiskDevice->Cdb16Byte = FALSE;
if ((!EFI_ERROR (CommandStatus)) && (CapacityData10->LastLba3 == 0xff) && (CapacityData10->LastLba2 == 0xff) &&
- (CapacityData10->LastLba1 == 0xff) && (CapacityData10->LastLba0 == 0xff)) {
+ (CapacityData10->LastLba1 == 0xff) && (CapacityData10->LastLba0 == 0xff))
+ {
//
// use Read Capacity (16), Read (16) and Write (16) next when hard disk size > 2TB
//
@@ -2992,44 +3037,43 @@ ScsiDiskReadCapacity ( &SenseDataLength,
&HostAdapterStatus,
&TargetStatus,
- (VOID *) CapacityData16,
+ (VOID *)CapacityData16,
&DataLength16,
FALSE
);
}
- //
- // no need to check HostAdapterStatus and TargetStatus
- //
- if (CommandStatus == EFI_SUCCESS) {
- GetMediaInfo (ScsiDiskDevice, CapacityData10, CapacityData16);
- FreeAlignedBuffer (CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
- FreeAlignedBuffer (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
- return EFI_SUCCESS;
- }
-
- FreeAlignedBuffer (CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
- FreeAlignedBuffer (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
-
- if (CommandStatus == EFI_NOT_READY) {
- *NeedRetry = TRUE;
- return EFI_DEVICE_ERROR;
- } else if ((CommandStatus == EFI_INVALID_PARAMETER) || (CommandStatus == EFI_UNSUPPORTED)) {
- *NeedRetry = FALSE;
- return EFI_DEVICE_ERROR;
- }
-
- //
- // go ahead to check HostAdapterStatus and TargetStatus
- // (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL)
- //
-
- Status = CheckHostAdapterStatus (HostAdapterStatus);
- if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
- *NeedRetry = TRUE;
- return EFI_DEVICE_ERROR;
-
- } else if (Status == EFI_DEVICE_ERROR) {
+ //
+ // no need to check HostAdapterStatus and TargetStatus
+ //
+ if (CommandStatus == EFI_SUCCESS) {
+ GetMediaInfo (ScsiDiskDevice, CapacityData10, CapacityData16);
+ FreeAlignedBuffer (CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
+ FreeAlignedBuffer (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
+ return EFI_SUCCESS;
+ }
+
+ FreeAlignedBuffer (CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
+ FreeAlignedBuffer (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
+
+ if (CommandStatus == EFI_NOT_READY) {
+ *NeedRetry = TRUE;
+ return EFI_DEVICE_ERROR;
+ } else if ((CommandStatus == EFI_INVALID_PARAMETER) || (CommandStatus == EFI_UNSUPPORTED)) {
+ *NeedRetry = FALSE;
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // go ahead to check HostAdapterStatus and TargetStatus
+ // (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL)
+ //
+
+ Status = CheckHostAdapterStatus (HostAdapterStatus);
+ if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
+ *NeedRetry = TRUE;
+ return EFI_DEVICE_ERROR;
+ } else if (Status == EFI_DEVICE_ERROR) {
//
// reset the scsi channel
//
@@ -3046,7 +3090,6 @@ ScsiDiskReadCapacity ( ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
-
} else if (Status == EFI_DEVICE_ERROR) {
*NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
@@ -3059,14 +3102,13 @@ ScsiDiskReadCapacity ( //
MaxRetry = 3;
for (Index = 0; Index < MaxRetry; Index++) {
-
Status = ScsiDiskRequestSenseKeys (
- ScsiDiskDevice,
- NeedRetry,
- SenseDataArray,
- NumberOfSenseKeys,
- TRUE
- );
+ ScsiDiskDevice,
+ NeedRetry,
+ SenseDataArray,
+ NumberOfSenseKeys,
+ TRUE
+ );
if (!EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
@@ -3075,6 +3117,7 @@ ScsiDiskReadCapacity ( return EFI_DEVICE_ERROR;
}
}
+
//
// ScsiDiskRequestSenseKeys() failed after several rounds of retry.
// set *NeedRetry = FALSE to avoid the outside caller try again.
@@ -3096,35 +3139,34 @@ ScsiDiskReadCapacity ( **/
EFI_STATUS
CheckHostAdapterStatus (
- IN UINT8 HostAdapterStatus
+ IN UINT8 HostAdapterStatus
)
{
switch (HostAdapterStatus) {
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK:
- return EFI_SUCCESS;
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK:
+ return EFI_SUCCESS;
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND:
- return EFI_TIMEOUT;
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND:
+ return EFI_TIMEOUT;
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET:
- return EFI_NOT_READY;
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET:
+ return EFI_NOT_READY;
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE:
- case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR:
- return EFI_DEVICE_ERROR;
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE:
+ case EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR:
+ return EFI_DEVICE_ERROR;
- default:
- return EFI_SUCCESS;
+ default:
+ return EFI_SUCCESS;
}
}
-
/**
Check the target status and re-interpret it in EFI_STATUS.
@@ -3137,30 +3179,29 @@ CheckHostAdapterStatus ( **/
EFI_STATUS
CheckTargetStatus (
- IN UINT8 TargetStatus
+ IN UINT8 TargetStatus
)
{
switch (TargetStatus) {
- case EFI_EXT_SCSI_STATUS_TARGET_GOOD:
- case EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION:
- case EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET:
- return EFI_SUCCESS;
+ case EFI_EXT_SCSI_STATUS_TARGET_GOOD:
+ case EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION:
+ case EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET:
+ return EFI_SUCCESS;
- case EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE:
- case EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET:
- case EFI_EXT_SCSI_STATUS_TARGET_BUSY:
- case EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL:
- return EFI_NOT_READY;
+ case EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE:
+ case EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET:
+ case EFI_EXT_SCSI_STATUS_TARGET_BUSY:
+ case EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL:
+ return EFI_NOT_READY;
- case EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT:
- return EFI_DEVICE_ERROR;
+ case EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT:
+ return EFI_DEVICE_ERROR;
- default:
- return EFI_SUCCESS;
+ default:
+ return EFI_SUCCESS;
}
}
-
/**
Retrieve all sense keys from the device.
@@ -3180,33 +3221,33 @@ CheckTargetStatus ( **/
EFI_STATUS
ScsiDiskRequestSenseKeys (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry,
- OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
- OUT UINTN *NumberOfSenseKeys,
- IN BOOLEAN AskResetIfError
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
+ OUT UINTN *NumberOfSenseKeys,
+ IN BOOLEAN AskResetIfError
)
{
- EFI_SCSI_SENSE_DATA *PtrSenseData;
- UINT8 SenseDataLength;
- BOOLEAN SenseReq;
- EFI_STATUS Status;
- EFI_STATUS FallStatus;
- UINT8 HostAdapterStatus;
- UINT8 TargetStatus;
+ EFI_SCSI_SENSE_DATA *PtrSenseData;
+ UINT8 SenseDataLength;
+ BOOLEAN SenseReq;
+ EFI_STATUS Status;
+ EFI_STATUS FallStatus;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
FallStatus = EFI_SUCCESS;
- SenseDataLength = (UINT8) sizeof (EFI_SCSI_SENSE_DATA);
+ SenseDataLength = (UINT8)sizeof (EFI_SCSI_SENSE_DATA);
ZeroMem (
ScsiDiskDevice->SenseData,
sizeof (EFI_SCSI_SENSE_DATA) * (ScsiDiskDevice->SenseDataNumber)
);
- *NumberOfSenseKeys = 0;
- *SenseDataArray = ScsiDiskDevice->SenseData;
- Status = EFI_SUCCESS;
- PtrSenseData = AllocateAlignedBuffer (ScsiDiskDevice, sizeof (EFI_SCSI_SENSE_DATA));
+ *NumberOfSenseKeys = 0;
+ *SenseDataArray = ScsiDiskDevice->SenseData;
+ Status = EFI_SUCCESS;
+ PtrSenseData = AllocateAlignedBuffer (ScsiDiskDevice, sizeof (EFI_SCSI_SENSE_DATA));
if (PtrSenseData == NULL) {
return EFI_DEVICE_ERROR;
}
@@ -3214,36 +3255,33 @@ ScsiDiskRequestSenseKeys ( for (SenseReq = TRUE; SenseReq;) {
ZeroMem (PtrSenseData, sizeof (EFI_SCSI_SENSE_DATA));
Status = ScsiRequestSenseCommand (
- ScsiDiskDevice->ScsiIo,
- SCSI_DISK_TIMEOUT,
- PtrSenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus
- );
- if ((Status == EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) {
- FallStatus = EFI_SUCCESS;
-
- } else if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
- *NeedRetry = TRUE;
- FallStatus = EFI_DEVICE_ERROR;
-
- } else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
- *NeedRetry = FALSE;
- FallStatus = EFI_DEVICE_ERROR;
-
- } else if (Status == EFI_DEVICE_ERROR) {
- if (AskResetIfError) {
- ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
- }
+ ScsiDiskDevice->ScsiIo,
+ SCSI_DISK_TIMEOUT,
+ PtrSenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus
+ );
+ if ((Status == EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) {
+ FallStatus = EFI_SUCCESS;
+ } else if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
+ *NeedRetry = TRUE;
+ FallStatus = EFI_DEVICE_ERROR;
+ } else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {
+ *NeedRetry = FALSE;
+ FallStatus = EFI_DEVICE_ERROR;
+ } else if (Status == EFI_DEVICE_ERROR) {
+ if (AskResetIfError) {
+ ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
+ }
- FallStatus = EFI_DEVICE_ERROR;
+ FallStatus = EFI_DEVICE_ERROR;
}
if (EFI_ERROR (FallStatus)) {
if (*NumberOfSenseKeys != 0) {
*NeedRetry = FALSE;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto EXIT;
} else {
Status = EFI_DEVICE_ERROR;
@@ -3259,7 +3297,8 @@ ScsiDiskRequestSenseKeys ( // skip the loop.
//
if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) ||
- (*NumberOfSenseKeys == ScsiDiskDevice->SenseDataNumber)) {
+ (*NumberOfSenseKeys == ScsiDiskDevice->SenseDataNumber))
+ {
SenseReq = FALSE;
}
}
@@ -3269,7 +3308,6 @@ EXIT: return Status;
}
-
/**
Get information from media read capacity command.
@@ -3285,25 +3323,25 @@ GetMediaInfo ( IN EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16
)
{
- UINT8 *Ptr;
+ UINT8 *Ptr;
if (!ScsiDiskDevice->Cdb16Byte) {
- ScsiDiskDevice->BlkIo.Media->LastBlock = ((UINT32) Capacity10->LastLba3 << 24) |
- (Capacity10->LastLba2 << 16) |
- (Capacity10->LastLba1 << 8) |
- Capacity10->LastLba0;
+ ScsiDiskDevice->BlkIo.Media->LastBlock = ((UINT32)Capacity10->LastLba3 << 24) |
+ (Capacity10->LastLba2 << 16) |
+ (Capacity10->LastLba1 << 8) |
+ Capacity10->LastLba0;
ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity10->BlockSize3 << 24) |
(Capacity10->BlockSize2 << 16) |
(Capacity10->BlockSize1 << 8) |
- Capacity10->BlockSize0;
- ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = 0;
- ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 0;
+ Capacity10->BlockSize0;
+ ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = 0;
+ ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 0;
if (!ScsiDiskDevice->BlockLimitsVpdSupported) {
- ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32) ScsiDiskDevice->BlkIo.Media->LastBlock;
+ ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32)ScsiDiskDevice->BlkIo.Media->LastBlock;
}
} else {
- Ptr = (UINT8*)&ScsiDiskDevice->BlkIo.Media->LastBlock;
+ Ptr = (UINT8 *)&ScsiDiskDevice->BlkIo.Media->LastBlock;
*Ptr++ = Capacity16->LastLba0;
*Ptr++ = Capacity16->LastLba1;
*Ptr++ = Capacity16->LastLba2;
@@ -3316,16 +3354,16 @@ GetMediaInfo ( ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity16->BlockSize3 << 24) |
(Capacity16->BlockSize2 << 16) |
(Capacity16->BlockSize1 << 8) |
- Capacity16->BlockSize0;
+ Capacity16->BlockSize0;
ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = (Capacity16->LowestAlignLogic2 << 8) |
- Capacity16->LowestAlignLogic1;
- ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = (1 << Capacity16->LogicPerPhysical);
+ Capacity16->LowestAlignLogic1;
+ ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = (1 << Capacity16->LogicPerPhysical);
if (!ScsiDiskDevice->BlockLimitsVpdSupported) {
- if (ScsiDiskDevice->BlkIo.Media->LastBlock > (UINT32) -1) {
- ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32) -1;
+ if (ScsiDiskDevice->BlkIo.Media->LastBlock > (UINT32)-1) {
+ ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32)-1;
} else {
- ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32) ScsiDiskDevice->BlkIo.Media->LastBlock;
+ ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32)ScsiDiskDevice->BlkIo.Media->LastBlock;
}
}
}
@@ -3341,11 +3379,11 @@ GetMediaInfo ( **/
VOID
ParseInquiryData (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice
)
{
- ScsiDiskDevice->FixedDevice = (BOOLEAN) ((ScsiDiskDevice->InquiryData.Rmb == 1) ? 0 : 1);
- ScsiDiskDevice->BlkIoMedia.RemovableMedia = (BOOLEAN) (!ScsiDiskDevice->FixedDevice);
+ ScsiDiskDevice->FixedDevice = (BOOLEAN)((ScsiDiskDevice->InquiryData.Rmb == 1) ? 0 : 1);
+ ScsiDiskDevice->BlkIoMedia.RemovableMedia = (BOOLEAN)(!ScsiDiskDevice->FixedDevice);
}
/**
@@ -3362,48 +3400,47 @@ ParseInquiryData ( **/
EFI_STATUS
ScsiDiskReadSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- OUT VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks
)
{
- UINTN BlocksRemaining;
- UINT8 *PtrBuffer;
- UINT32 BlockSize;
- UINT32 ByteCount;
- UINT32 MaxBlock;
- UINT32 SectorCount;
- UINT32 NextSectorCount;
- UINT64 Timeout;
- EFI_STATUS Status;
- UINT8 Index;
- UINT8 MaxRetry;
- BOOLEAN NeedRetry;
+ UINTN BlocksRemaining;
+ UINT8 *PtrBuffer;
+ UINT32 BlockSize;
+ UINT32 ByteCount;
+ UINT32 MaxBlock;
+ UINT32 SectorCount;
+ UINT32 NextSectorCount;
+ UINT64 Timeout;
+ EFI_STATUS Status;
+ UINT8 Index;
+ UINT8 MaxRetry;
+ BOOLEAN NeedRetry;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- BlocksRemaining = NumberOfBlocks;
- BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
+ BlocksRemaining = NumberOfBlocks;
+ BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
//
// limit the data bytes that can be transferred by one Read(10) or Read(16) Command
//
if (!ScsiDiskDevice->Cdb16Byte) {
- MaxBlock = 0xFFFF;
+ MaxBlock = 0xFFFF;
} else {
- MaxBlock = 0xFFFFFFFF;
+ MaxBlock = 0xFFFFFFFF;
}
PtrBuffer = Buffer;
while (BlocksRemaining > 0) {
-
if (BlocksRemaining <= MaxBlock) {
if (!ScsiDiskDevice->Cdb16Byte) {
- SectorCount = (UINT16) BlocksRemaining;
+ SectorCount = (UINT16)BlocksRemaining;
} else {
- SectorCount = (UINT32) BlocksRemaining;
+ SectorCount = (UINT32)BlocksRemaining;
}
} else {
SectorCount = MaxBlock;
@@ -3442,31 +3479,32 @@ ScsiDiskReadSectors ( // to follow ATA spec in which it mentioned that the device may take up to 30s to respond
// commands in the Standby/Idle mode.
//
- Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
+ Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
- MaxRetry = 2;
+ MaxRetry = 2;
for (Index = 0; Index < MaxRetry; Index++) {
if (!ScsiDiskDevice->Cdb16Byte) {
Status = ScsiDiskRead10 (
- ScsiDiskDevice,
- &NeedRetry,
- Timeout,
- PtrBuffer,
- &ByteCount,
- (UINT32) Lba,
- SectorCount
- );
+ ScsiDiskDevice,
+ &NeedRetry,
+ Timeout,
+ PtrBuffer,
+ &ByteCount,
+ (UINT32)Lba,
+ SectorCount
+ );
} else {
Status = ScsiDiskRead16 (
- ScsiDiskDevice,
- &NeedRetry,
- Timeout,
- PtrBuffer,
- &ByteCount,
- Lba,
- SectorCount
- );
+ ScsiDiskDevice,
+ &NeedRetry,
+ Timeout,
+ PtrBuffer,
+ &ByteCount,
+ Lba,
+ SectorCount
+ );
}
+
if (!EFI_ERROR (Status)) {
break;
}
@@ -3505,8 +3543,8 @@ ScsiDiskReadSectors ( //
SectorCount = ByteCount / BlockSize;
- Lba += SectorCount;
- PtrBuffer = PtrBuffer + SectorCount * BlockSize;
+ Lba += SectorCount;
+ PtrBuffer = PtrBuffer + SectorCount * BlockSize;
BlocksRemaining -= SectorCount;
}
@@ -3527,48 +3565,47 @@ ScsiDiskReadSectors ( **/
EFI_STATUS
ScsiDiskWriteSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks
)
{
- UINTN BlocksRemaining;
- UINT8 *PtrBuffer;
- UINT32 BlockSize;
- UINT32 ByteCount;
- UINT32 MaxBlock;
- UINT32 SectorCount;
- UINT32 NextSectorCount;
- UINT64 Timeout;
- EFI_STATUS Status;
- UINT8 Index;
- UINT8 MaxRetry;
- BOOLEAN NeedRetry;
+ UINTN BlocksRemaining;
+ UINT8 *PtrBuffer;
+ UINT32 BlockSize;
+ UINT32 ByteCount;
+ UINT32 MaxBlock;
+ UINT32 SectorCount;
+ UINT32 NextSectorCount;
+ UINT64 Timeout;
+ EFI_STATUS Status;
+ UINT8 Index;
+ UINT8 MaxRetry;
+ BOOLEAN NeedRetry;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- BlocksRemaining = NumberOfBlocks;
- BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
+ BlocksRemaining = NumberOfBlocks;
+ BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
//
// limit the data bytes that can be transferred by one Read(10) or Read(16) Command
//
if (!ScsiDiskDevice->Cdb16Byte) {
- MaxBlock = 0xFFFF;
+ MaxBlock = 0xFFFF;
} else {
- MaxBlock = 0xFFFFFFFF;
+ MaxBlock = 0xFFFFFFFF;
}
PtrBuffer = Buffer;
while (BlocksRemaining > 0) {
-
if (BlocksRemaining <= MaxBlock) {
if (!ScsiDiskDevice->Cdb16Byte) {
- SectorCount = (UINT16) BlocksRemaining;
+ SectorCount = (UINT16)BlocksRemaining;
} else {
- SectorCount = (UINT32) BlocksRemaining;
+ SectorCount = (UINT32)BlocksRemaining;
}
} else {
SectorCount = MaxBlock;
@@ -3607,30 +3644,31 @@ ScsiDiskWriteSectors ( // to follow ATA spec in which it mentioned that the device may take up to 30s to respond
// commands in the Standby/Idle mode.
//
- Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
- MaxRetry = 2;
+ Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
+ MaxRetry = 2;
for (Index = 0; Index < MaxRetry; Index++) {
if (!ScsiDiskDevice->Cdb16Byte) {
Status = ScsiDiskWrite10 (
- ScsiDiskDevice,
- &NeedRetry,
- Timeout,
- PtrBuffer,
- &ByteCount,
- (UINT32) Lba,
- SectorCount
- );
+ ScsiDiskDevice,
+ &NeedRetry,
+ Timeout,
+ PtrBuffer,
+ &ByteCount,
+ (UINT32)Lba,
+ SectorCount
+ );
} else {
Status = ScsiDiskWrite16 (
- ScsiDiskDevice,
- &NeedRetry,
- Timeout,
- PtrBuffer,
- &ByteCount,
- Lba,
- SectorCount
- );
- }
+ ScsiDiskDevice,
+ &NeedRetry,
+ Timeout,
+ PtrBuffer,
+ &ByteCount,
+ Lba,
+ SectorCount
+ );
+ }
+
if (!EFI_ERROR (Status)) {
break;
}
@@ -3663,13 +3701,14 @@ ScsiDiskWriteSectors ( if ((Index == MaxRetry) && (Status != EFI_SUCCESS)) {
return EFI_DEVICE_ERROR;
}
+
//
// actual transferred sectors
//
SectorCount = ByteCount / BlockSize;
- Lba += SectorCount;
- PtrBuffer = PtrBuffer + SectorCount * BlockSize;
+ Lba += SectorCount;
+ PtrBuffer = PtrBuffer + SectorCount * BlockSize;
BlocksRemaining -= SectorCount;
}
@@ -3693,23 +3732,23 @@ ScsiDiskWriteSectors ( **/
EFI_STATUS
ScsiDiskAsyncReadSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- OUT VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks,
- IN EFI_BLOCK_IO2_TOKEN *Token
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks,
+ IN EFI_BLOCK_IO2_TOKEN *Token
)
{
- UINTN BlocksRemaining;
- UINT8 *PtrBuffer;
- UINT32 BlockSize;
- UINT32 ByteCount;
- UINT32 MaxBlock;
- UINT32 SectorCount;
- UINT64 Timeout;
- SCSI_BLKIO2_REQUEST *BlkIo2Req;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ UINTN BlocksRemaining;
+ UINT8 *PtrBuffer;
+ UINT32 BlockSize;
+ UINT32 ByteCount;
+ UINT32 MaxBlock;
+ UINT32 SectorCount;
+ UINT64 Timeout;
+ SCSI_BLKIO2_REQUEST *BlkIo2Req;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if ((Token == NULL) || (Token->Event == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -3720,7 +3759,7 @@ ScsiDiskAsyncReadSectors ( return EFI_OUT_OF_RESOURCES;
}
- BlkIo2Req->Token = Token;
+ BlkIo2Req->Token = Token;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &BlkIo2Req->Link);
@@ -3728,30 +3767,29 @@ ScsiDiskAsyncReadSectors ( InitializeListHead (&BlkIo2Req->ScsiRWQueue);
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- BlocksRemaining = NumberOfBlocks;
- BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
+ BlocksRemaining = NumberOfBlocks;
+ BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
//
// Limit the data bytes that can be transferred by one Read(10) or Read(16)
// Command
//
if (!ScsiDiskDevice->Cdb16Byte) {
- MaxBlock = 0xFFFF;
+ MaxBlock = 0xFFFF;
} else {
- MaxBlock = 0xFFFFFFFF;
+ MaxBlock = 0xFFFFFFFF;
}
PtrBuffer = Buffer;
while (BlocksRemaining > 0) {
-
if (BlocksRemaining <= MaxBlock) {
if (!ScsiDiskDevice->Cdb16Byte) {
- SectorCount = (UINT16) BlocksRemaining;
+ SectorCount = (UINT16)BlocksRemaining;
} else {
- SectorCount = (UINT32) BlocksRemaining;
+ SectorCount = (UINT32)BlocksRemaining;
}
} else {
SectorCount = MaxBlock;
@@ -3791,7 +3829,7 @@ ScsiDiskAsyncReadSectors ( // 30s is added to follow ATA spec in which it mentioned that the device
// may take up to 30s to respond commands in the Standby/Idle mode.
//
- Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
+ Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
if (!ScsiDiskDevice->Cdb16Byte) {
Status = ScsiDiskAsyncRead10 (
@@ -3800,7 +3838,7 @@ ScsiDiskAsyncReadSectors ( 0,
PtrBuffer,
ByteCount,
- (UINT32) Lba,
+ (UINT32)Lba,
SectorCount,
BlkIo2Req,
Token
@@ -3818,6 +3856,7 @@ ScsiDiskAsyncReadSectors ( Token
);
}
+
if (EFI_ERROR (Status)) {
//
// Some devices will return EFI_DEVICE_ERROR or EFI_TIMEOUT when the data
@@ -3868,8 +3907,8 @@ ScsiDiskAsyncReadSectors ( //
SectorCount = ByteCount / BlockSize;
- Lba += SectorCount;
- PtrBuffer = PtrBuffer + SectorCount * BlockSize;
+ Lba += SectorCount;
+ PtrBuffer = PtrBuffer + SectorCount * BlockSize;
BlocksRemaining -= SectorCount;
}
@@ -3887,6 +3926,7 @@ Done: gBS->SignalEvent (Token->Event);
}
+
gBS->RestoreTPL (OldTpl);
}
@@ -3910,23 +3950,23 @@ Done: **/
EFI_STATUS
ScsiDiskAsyncWriteSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks,
- IN EFI_BLOCK_IO2_TOKEN *Token
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks,
+ IN EFI_BLOCK_IO2_TOKEN *Token
)
{
- UINTN BlocksRemaining;
- UINT8 *PtrBuffer;
- UINT32 BlockSize;
- UINT32 ByteCount;
- UINT32 MaxBlock;
- UINT32 SectorCount;
- UINT64 Timeout;
- SCSI_BLKIO2_REQUEST *BlkIo2Req;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ UINTN BlocksRemaining;
+ UINT8 *PtrBuffer;
+ UINT32 BlockSize;
+ UINT32 ByteCount;
+ UINT32 MaxBlock;
+ UINT32 SectorCount;
+ UINT64 Timeout;
+ SCSI_BLKIO2_REQUEST *BlkIo2Req;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if ((Token == NULL) || (Token->Event == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -3937,7 +3977,7 @@ ScsiDiskAsyncWriteSectors ( return EFI_OUT_OF_RESOURCES;
}
- BlkIo2Req->Token = Token;
+ BlkIo2Req->Token = Token;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &BlkIo2Req->Link);
@@ -3945,30 +3985,29 @@ ScsiDiskAsyncWriteSectors ( InitializeListHead (&BlkIo2Req->ScsiRWQueue);
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- BlocksRemaining = NumberOfBlocks;
- BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
+ BlocksRemaining = NumberOfBlocks;
+ BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize;
//
// Limit the data bytes that can be transferred by one Read(10) or Read(16)
// Command
//
if (!ScsiDiskDevice->Cdb16Byte) {
- MaxBlock = 0xFFFF;
+ MaxBlock = 0xFFFF;
} else {
- MaxBlock = 0xFFFFFFFF;
+ MaxBlock = 0xFFFFFFFF;
}
PtrBuffer = Buffer;
while (BlocksRemaining > 0) {
-
if (BlocksRemaining <= MaxBlock) {
if (!ScsiDiskDevice->Cdb16Byte) {
- SectorCount = (UINT16) BlocksRemaining;
+ SectorCount = (UINT16)BlocksRemaining;
} else {
- SectorCount = (UINT32) BlocksRemaining;
+ SectorCount = (UINT32)BlocksRemaining;
}
} else {
SectorCount = MaxBlock;
@@ -4008,7 +4047,7 @@ ScsiDiskAsyncWriteSectors ( // 30s is added to follow ATA spec in which it mentioned that the device
// may take up to 30s to respond commands in the Standby/Idle mode.
//
- Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
+ Timeout = EFI_TIMER_PERIOD_SECONDS (ByteCount / 2100000 + 31);
if (!ScsiDiskDevice->Cdb16Byte) {
Status = ScsiDiskAsyncWrite10 (
@@ -4017,7 +4056,7 @@ ScsiDiskAsyncWriteSectors ( 0,
PtrBuffer,
ByteCount,
- (UINT32) Lba,
+ (UINT32)Lba,
SectorCount,
BlkIo2Req,
Token
@@ -4035,6 +4074,7 @@ ScsiDiskAsyncWriteSectors ( Token
);
}
+
if (EFI_ERROR (Status)) {
//
// Some devices will return EFI_DEVICE_ERROR or EFI_TIMEOUT when the data
@@ -4085,8 +4125,8 @@ ScsiDiskAsyncWriteSectors ( //
SectorCount = ByteCount / BlockSize;
- Lba += SectorCount;
- PtrBuffer = PtrBuffer + SectorCount * BlockSize;
+ Lba += SectorCount;
+ PtrBuffer = PtrBuffer + SectorCount * BlockSize;
BlocksRemaining -= SectorCount;
}
@@ -4104,13 +4144,13 @@ Done: gBS->SignalEvent (Token->Event);
}
+
gBS->RestoreTPL (OldTpl);
}
return Status;
}
-
/**
Submit Read(10) command.
@@ -4126,13 +4166,13 @@ Done: **/
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
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ IN UINT64 Timeout,
+ OUT UINT8 *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT32 StartLba,
+ IN UINT32 SectorCount
)
{
UINT8 SenseDataLength;
@@ -4151,23 +4191,23 @@ ScsiDiskRead10 ( // try again till the operation succeeds or fails with one sector transfer length.
//
BackOff:
- *NeedRetry = FALSE;
- Action = ACTION_NO_ACTION;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
- ReturnStatus = ScsiRead10Command (
- ScsiDiskDevice->ScsiIo,
- Timeout,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- DataBuffer,
- DataLength,
- StartLba,
- SectorCount
- );
+ *NeedRetry = FALSE;
+ Action = ACTION_NO_ACTION;
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ ReturnStatus = ScsiRead10Command (
+ ScsiDiskDevice->ScsiIo,
+ Timeout,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ DataBuffer,
+ DataLength,
+ StartLba,
+ SectorCount
+ );
- if (ReturnStatus == EFI_NOT_READY || ReturnStatus == EFI_BAD_BUFFER_SIZE) {
+ if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
@@ -4219,11 +4259,12 @@ BackOff: *NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
//
// Try again with half length if the sense data shows we need to retry.
//
SectorCount >>= 1;
- *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
+ *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
goto BackOff;
} else {
*NeedRetry = FALSE;
@@ -4234,7 +4275,6 @@ BackOff: return ReturnStatus;
}
-
/**
Submit Write(10) Command.
@@ -4251,13 +4291,13 @@ BackOff: **/
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
+ 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 Status;
@@ -4276,22 +4316,22 @@ ScsiDiskWrite10 ( // try again till the operation succeeds or fails with one sector transfer length.
//
BackOff:
- *NeedRetry = FALSE;
- Action = ACTION_NO_ACTION;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
- ReturnStatus = ScsiWrite10Command (
- ScsiDiskDevice->ScsiIo,
- Timeout,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- DataBuffer,
- DataLength,
- StartLba,
- SectorCount
- );
- if (ReturnStatus == EFI_NOT_READY || ReturnStatus == EFI_BAD_BUFFER_SIZE) {
+ *NeedRetry = FALSE;
+ Action = ACTION_NO_ACTION;
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ ReturnStatus = ScsiWrite10Command (
+ ScsiDiskDevice->ScsiIo,
+ Timeout,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ DataBuffer,
+ DataLength,
+ StartLba,
+ SectorCount
+ );
+ if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
@@ -4343,11 +4383,12 @@ BackOff: *NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
//
// Try again with half length if the sense data shows we need to retry.
//
SectorCount >>= 1;
- *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
+ *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
goto BackOff;
} else {
*NeedRetry = FALSE;
@@ -4358,7 +4399,6 @@ BackOff: return ReturnStatus;
}
-
/**
Submit Read(16) command.
@@ -4374,13 +4414,13 @@ BackOff: **/
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
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ IN UINT64 Timeout,
+ OUT UINT8 *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT64 StartLba,
+ IN UINT32 SectorCount
)
{
UINT8 SenseDataLength;
@@ -4399,22 +4439,22 @@ ScsiDiskRead16 ( // try again till the operation succeeds or fails with one sector transfer length.
//
BackOff:
- *NeedRetry = FALSE;
- Action = ACTION_NO_ACTION;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
- ReturnStatus = ScsiRead16Command (
- ScsiDiskDevice->ScsiIo,
- Timeout,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- DataBuffer,
- DataLength,
- StartLba,
- SectorCount
- );
- if (ReturnStatus == EFI_NOT_READY || ReturnStatus == EFI_BAD_BUFFER_SIZE) {
+ *NeedRetry = FALSE;
+ Action = ACTION_NO_ACTION;
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ ReturnStatus = ScsiRead16Command (
+ ScsiDiskDevice->ScsiIo,
+ Timeout,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ DataBuffer,
+ DataLength,
+ StartLba,
+ SectorCount
+ );
+ if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
@@ -4466,11 +4506,12 @@ BackOff: *NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
//
// Try again with half length if the sense data shows we need to retry.
//
SectorCount >>= 1;
- *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
+ *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
goto BackOff;
} else {
*NeedRetry = FALSE;
@@ -4481,7 +4522,6 @@ BackOff: return ReturnStatus;
}
-
/**
Submit Write(16) Command.
@@ -4498,13 +4538,13 @@ BackOff: **/
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
+ 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 Status;
@@ -4523,22 +4563,22 @@ ScsiDiskWrite16 ( // try again till the operation succeeds or fails with one sector transfer length.
//
BackOff:
- *NeedRetry = FALSE;
- Action = ACTION_NO_ACTION;
- SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
- ReturnStatus = ScsiWrite16Command (
- ScsiDiskDevice->ScsiIo,
- Timeout,
- ScsiDiskDevice->SenseData,
- &SenseDataLength,
- &HostAdapterStatus,
- &TargetStatus,
- DataBuffer,
- DataLength,
- StartLba,
- SectorCount
- );
- if (ReturnStatus == EFI_NOT_READY || ReturnStatus == EFI_BAD_BUFFER_SIZE) {
+ *NeedRetry = FALSE;
+ Action = ACTION_NO_ACTION;
+ SenseDataLength = (UINT8)(ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
+ ReturnStatus = ScsiWrite16Command (
+ ScsiDiskDevice->ScsiIo,
+ Timeout,
+ ScsiDiskDevice->SenseData,
+ &SenseDataLength,
+ &HostAdapterStatus,
+ &TargetStatus,
+ DataBuffer,
+ DataLength,
+ StartLba,
+ SectorCount
+ );
+ if ((ReturnStatus == EFI_NOT_READY) || (ReturnStatus == EFI_BAD_BUFFER_SIZE)) {
*NeedRetry = TRUE;
return EFI_DEVICE_ERROR;
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
@@ -4590,11 +4630,12 @@ BackOff: *NeedRetry = FALSE;
return EFI_DEVICE_ERROR;
}
+
//
// Try again with half length if the sense data shows we need to retry.
//
SectorCount >>= 1;
- *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
+ *DataLength = SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
goto BackOff;
} else {
*NeedRetry = FALSE;
@@ -4605,7 +4646,6 @@ BackOff: return ReturnStatus;
}
-
/**
Internal helper notify function in which determine whether retry of a SCSI
Read/Write command is needed and signal the event passed from Block I/O(2) if
@@ -4622,23 +4662,23 @@ ScsiDiskNotify ( IN VOID *Context
)
{
- EFI_STATUS Status;
- SCSI_ASYNC_RW_REQUEST *Request;
- SCSI_DISK_DEV *ScsiDiskDevice;
- EFI_BLOCK_IO2_TOKEN *Token;
- UINTN Action;
- UINT32 OldDataLength;
- UINT32 OldSectorCount;
- UINT8 MaxRetry;
+ EFI_STATUS Status;
+ SCSI_ASYNC_RW_REQUEST *Request;
+ SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_BLOCK_IO2_TOKEN *Token;
+ UINTN Action;
+ UINT32 OldDataLength;
+ UINT32 OldSectorCount;
+ UINT8 MaxRetry;
gBS->CloseEvent (Event);
- Request = (SCSI_ASYNC_RW_REQUEST *) Context;
- ScsiDiskDevice = Request->ScsiDiskDevice;
- Token = Request->BlkIo2Req->Token;
- OldDataLength = Request->DataLength;
- OldSectorCount = Request->SectorCount;
- MaxRetry = 2;
+ Request = (SCSI_ASYNC_RW_REQUEST *)Context;
+ ScsiDiskDevice = Request->ScsiDiskDevice;
+ Token = Request->BlkIo2Req->Token;
+ OldDataLength = Request->DataLength;
+ OldSectorCount = Request->SectorCount;
+ MaxRetry = 2;
//
// If previous sub-tasks already fails, no need to process this sub-task.
@@ -4710,13 +4750,14 @@ ScsiDiskNotify ( Token->TransactionStatus = EFI_DEVICE_ERROR;
goto Exit;
}
+
//
// Try again with two half length request if the sense data shows we need
// to retry.
//
Request->SectorCount >>= 1;
- Request->DataLength = Request->SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
- Request->TimesRetry = 0;
+ Request->DataLength = Request->SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize;
+ Request->TimesRetry = 0;
goto Retry;
} else {
@@ -4742,7 +4783,7 @@ Retry: Request->TimesRetry,
Request->InBuffer,
Request->DataLength,
- (UINT32) Request->StartLba,
+ (UINT32)Request->StartLba,
Request->SectorCount,
Request->BlkIo2Req,
Token
@@ -4776,7 +4817,7 @@ Retry: 0,
Request->InBuffer + Request->SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize,
OldDataLength - Request->DataLength,
- (UINT32) Request->StartLba + Request->SectorCount,
+ (UINT32)Request->StartLba + Request->SectorCount,
OldSectorCount - Request->SectorCount,
Request->BlkIo2Req,
Token
@@ -4794,6 +4835,7 @@ Retry: Token
);
}
+
if (EFI_ERROR (Status)) {
Token->TransactionStatus = EFI_DEVICE_ERROR;
goto Exit;
@@ -4810,7 +4852,7 @@ Retry: Request->TimesRetry,
Request->OutBuffer,
Request->DataLength,
- (UINT32) Request->StartLba,
+ (UINT32)Request->StartLba,
Request->SectorCount,
Request->BlkIo2Req,
Token
@@ -4844,7 +4886,7 @@ Retry: 0,
Request->OutBuffer + Request->SectorCount * ScsiDiskDevice->BlkIo.Media->BlockSize,
OldDataLength - Request->DataLength,
- (UINT32) Request->StartLba + Request->SectorCount,
+ (UINT32)Request->StartLba + Request->SectorCount,
OldSectorCount - Request->SectorCount,
Request->BlkIo2Req,
Token
@@ -4862,6 +4904,7 @@ Retry: Token
);
}
+
if (EFI_ERROR (Status)) {
Token->TransactionStatus = EFI_DEVICE_ERROR;
goto Exit;
@@ -4872,7 +4915,8 @@ Retry: Exit:
RemoveEntryList (&Request->Link);
if ((IsListEmpty (&Request->BlkIo2Req->ScsiRWQueue)) &&
- (Request->BlkIo2Req->LastScsiRW)) {
+ (Request->BlkIo2Req->LastScsiRW))
+ {
//
// The last SCSI R/W command of a BlockIo2 request completes
//
@@ -4885,7 +4929,6 @@ Exit: FreePool (Request);
}
-
/**
Submit Async Read(10) command.
@@ -4908,21 +4951,21 @@ Exit: **/
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
+ 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 Status;
- SCSI_ASYNC_RW_REQUEST *Request;
- EFI_EVENT AsyncIoEvent;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ SCSI_ASYNC_RW_REQUEST *Request;
+ EFI_EVENT AsyncIoEvent;
+ EFI_TPL OldTpl;
AsyncIoEvent = NULL;
@@ -4935,21 +4978,21 @@ ScsiDiskAsyncRead10 ( InsertTailList (&BlkIo2Req->ScsiRWQueue, &Request->Link);
gBS->RestoreTPL (OldTpl);
- Request->SenseDataLength = (UINT8) (6 * sizeof (EFI_SCSI_SENSE_DATA));
+ Request->SenseDataLength = (UINT8)(6 * sizeof (EFI_SCSI_SENSE_DATA));
Request->SenseData = AllocateZeroPool (Request->SenseDataLength);
if (Request->SenseData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- Request->ScsiDiskDevice = ScsiDiskDevice;
- Request->Timeout = Timeout;
- Request->TimesRetry = TimesRetry;
- Request->InBuffer = DataBuffer;
- Request->DataLength = DataLength;
- Request->StartLba = StartLba;
- Request->SectorCount = SectorCount;
- Request->BlkIo2Req = BlkIo2Req;
+ Request->ScsiDiskDevice = ScsiDiskDevice;
+ Request->Timeout = Timeout;
+ Request->TimesRetry = TimesRetry;
+ Request->InBuffer = DataBuffer;
+ Request->DataLength = DataLength;
+ Request->StartLba = StartLba;
+ Request->SectorCount = SectorCount;
+ Request->BlkIo2Req = BlkIo2Req;
//
// Create Event
@@ -4961,7 +5004,7 @@ ScsiDiskAsyncRead10 ( Request,
&AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -4974,11 +5017,11 @@ ScsiDiskAsyncRead10 ( &Request->TargetStatus,
Request->InBuffer,
&Request->DataLength,
- (UINT32) Request->StartLba,
+ (UINT32)Request->StartLba,
Request->SectorCount,
AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5004,7 +5047,6 @@ ErrorExit: return Status;
}
-
/**
Submit Async Write(10) command.
@@ -5027,21 +5069,21 @@ ErrorExit: **/
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
+ 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 Status;
- SCSI_ASYNC_RW_REQUEST *Request;
- EFI_EVENT AsyncIoEvent;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ SCSI_ASYNC_RW_REQUEST *Request;
+ EFI_EVENT AsyncIoEvent;
+ EFI_TPL OldTpl;
AsyncIoEvent = NULL;
@@ -5054,21 +5096,21 @@ ScsiDiskAsyncWrite10 ( InsertTailList (&BlkIo2Req->ScsiRWQueue, &Request->Link);
gBS->RestoreTPL (OldTpl);
- Request->SenseDataLength = (UINT8) (6 * sizeof (EFI_SCSI_SENSE_DATA));
+ Request->SenseDataLength = (UINT8)(6 * sizeof (EFI_SCSI_SENSE_DATA));
Request->SenseData = AllocateZeroPool (Request->SenseDataLength);
if (Request->SenseData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- Request->ScsiDiskDevice = ScsiDiskDevice;
- Request->Timeout = Timeout;
- Request->TimesRetry = TimesRetry;
- Request->OutBuffer = DataBuffer;
- Request->DataLength = DataLength;
- Request->StartLba = StartLba;
- Request->SectorCount = SectorCount;
- Request->BlkIo2Req = BlkIo2Req;
+ Request->ScsiDiskDevice = ScsiDiskDevice;
+ Request->Timeout = Timeout;
+ Request->TimesRetry = TimesRetry;
+ Request->OutBuffer = DataBuffer;
+ Request->DataLength = DataLength;
+ Request->StartLba = StartLba;
+ Request->SectorCount = SectorCount;
+ Request->BlkIo2Req = BlkIo2Req;
//
// Create Event
@@ -5080,7 +5122,7 @@ ScsiDiskAsyncWrite10 ( Request,
&AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5093,11 +5135,11 @@ ScsiDiskAsyncWrite10 ( &Request->TargetStatus,
Request->OutBuffer,
&Request->DataLength,
- (UINT32) Request->StartLba,
+ (UINT32)Request->StartLba,
Request->SectorCount,
AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5123,7 +5165,6 @@ ErrorExit: return Status;
}
-
/**
Submit Async Read(16) command.
@@ -5146,21 +5187,21 @@ ErrorExit: **/
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
+ 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 Status;
- SCSI_ASYNC_RW_REQUEST *Request;
- EFI_EVENT AsyncIoEvent;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ SCSI_ASYNC_RW_REQUEST *Request;
+ EFI_EVENT AsyncIoEvent;
+ EFI_TPL OldTpl;
AsyncIoEvent = NULL;
@@ -5173,21 +5214,21 @@ ScsiDiskAsyncRead16 ( InsertTailList (&BlkIo2Req->ScsiRWQueue, &Request->Link);
gBS->RestoreTPL (OldTpl);
- Request->SenseDataLength = (UINT8) (6 * sizeof (EFI_SCSI_SENSE_DATA));
+ Request->SenseDataLength = (UINT8)(6 * sizeof (EFI_SCSI_SENSE_DATA));
Request->SenseData = AllocateZeroPool (Request->SenseDataLength);
if (Request->SenseData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- Request->ScsiDiskDevice = ScsiDiskDevice;
- Request->Timeout = Timeout;
- Request->TimesRetry = TimesRetry;
- Request->InBuffer = DataBuffer;
- Request->DataLength = DataLength;
- Request->StartLba = StartLba;
- Request->SectorCount = SectorCount;
- Request->BlkIo2Req = BlkIo2Req;
+ Request->ScsiDiskDevice = ScsiDiskDevice;
+ Request->Timeout = Timeout;
+ Request->TimesRetry = TimesRetry;
+ Request->InBuffer = DataBuffer;
+ Request->DataLength = DataLength;
+ Request->StartLba = StartLba;
+ Request->SectorCount = SectorCount;
+ Request->BlkIo2Req = BlkIo2Req;
//
// Create Event
@@ -5199,7 +5240,7 @@ ScsiDiskAsyncRead16 ( Request,
&AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5216,7 +5257,7 @@ ScsiDiskAsyncRead16 ( Request->SectorCount,
AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5242,7 +5283,6 @@ ErrorExit: return Status;
}
-
/**
Submit Async Write(16) command.
@@ -5265,21 +5305,21 @@ ErrorExit: **/
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
+ 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 Status;
- SCSI_ASYNC_RW_REQUEST *Request;
- EFI_EVENT AsyncIoEvent;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ SCSI_ASYNC_RW_REQUEST *Request;
+ EFI_EVENT AsyncIoEvent;
+ EFI_TPL OldTpl;
AsyncIoEvent = NULL;
@@ -5292,21 +5332,21 @@ ScsiDiskAsyncWrite16 ( InsertTailList (&BlkIo2Req->ScsiRWQueue, &Request->Link);
gBS->RestoreTPL (OldTpl);
- Request->SenseDataLength = (UINT8) (6 * sizeof (EFI_SCSI_SENSE_DATA));
+ Request->SenseDataLength = (UINT8)(6 * sizeof (EFI_SCSI_SENSE_DATA));
Request->SenseData = AllocateZeroPool (Request->SenseDataLength);
if (Request->SenseData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- Request->ScsiDiskDevice = ScsiDiskDevice;
- Request->Timeout = Timeout;
- Request->TimesRetry = TimesRetry;
- Request->OutBuffer = DataBuffer;
- Request->DataLength = DataLength;
- Request->StartLba = StartLba;
- Request->SectorCount = SectorCount;
- Request->BlkIo2Req = BlkIo2Req;
+ Request->ScsiDiskDevice = ScsiDiskDevice;
+ Request->Timeout = Timeout;
+ Request->TimesRetry = TimesRetry;
+ Request->OutBuffer = DataBuffer;
+ Request->DataLength = DataLength;
+ Request->StartLba = StartLba;
+ Request->SectorCount = SectorCount;
+ Request->BlkIo2Req = BlkIo2Req;
//
// Create Event
@@ -5318,7 +5358,7 @@ ScsiDiskAsyncWrite16 ( Request,
&AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5335,7 +5375,7 @@ ScsiDiskAsyncWrite16 ( Request->SectorCount,
AsyncIoEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -5361,7 +5401,6 @@ ErrorExit: return Status;
}
-
/**
Check sense key to find if media presents.
@@ -5373,13 +5412,13 @@ ErrorExit: **/
BOOLEAN
ScsiDiskIsNoMedia (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN IsNoMedia;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN IsNoMedia;
IsNoMedia = FALSE;
SensePtr = SenseData;
@@ -5390,16 +5429,17 @@ ScsiDiskIsNoMedia ( // Additional Sense Code is ASC_NO_MEDIA (0x3A)
//
if ((SensePtr->Sense_Key == EFI_SCSI_SK_NOT_READY) &&
- (SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_NO_MEDIA)) {
+ (SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_NO_MEDIA))
+ {
IsNoMedia = TRUE;
}
+
SensePtr++;
}
return IsNoMedia;
}
-
/**
Parse sense key.
@@ -5412,70 +5452,68 @@ ScsiDiskIsNoMedia ( **/
BOOLEAN
ScsiDiskIsMediaError (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN IsError;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN IsError;
- IsError = FALSE;
- SensePtr = SenseData;
+ IsError = FALSE;
+ SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
-
switch (SensePtr->Sense_Key) {
+ case EFI_SCSI_SK_MEDIUM_ERROR:
+ //
+ // Sense Key is EFI_SCSI_SK_MEDIUM_ERROR (0x3)
+ //
+ switch (SensePtr->Addnl_Sense_Code) {
+ //
+ // fall through
+ //
+ case EFI_SCSI_ASC_MEDIA_ERR1:
- case EFI_SCSI_SK_MEDIUM_ERROR:
- //
- // Sense Key is EFI_SCSI_SK_MEDIUM_ERROR (0x3)
- //
- switch (SensePtr->Addnl_Sense_Code) {
+ //
+ // fall through
+ //
+ case EFI_SCSI_ASC_MEDIA_ERR2:
- //
- // fall through
- //
- case EFI_SCSI_ASC_MEDIA_ERR1:
+ //
+ // fall through
+ //
+ case EFI_SCSI_ASC_MEDIA_ERR3:
+ case EFI_SCSI_ASC_MEDIA_ERR4:
+ IsError = TRUE;
+ break;
- //
- // fall through
- //
- case EFI_SCSI_ASC_MEDIA_ERR2:
+ default:
+ break;
+ }
- //
- // fall through
- //
- case EFI_SCSI_ASC_MEDIA_ERR3:
- case EFI_SCSI_ASC_MEDIA_ERR4:
- IsError = TRUE;
break;
- default:
- break;
- }
+ case EFI_SCSI_SK_NOT_READY:
+ //
+ // Sense Key is EFI_SCSI_SK_NOT_READY (0x2)
+ //
+ switch (SensePtr->Addnl_Sense_Code) {
+ //
+ // Additional Sense Code is ASC_MEDIA_UPSIDE_DOWN (0x6)
+ //
+ case EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN:
+ IsError = TRUE;
+ break;
- break;
+ default:
+ break;
+ }
- case EFI_SCSI_SK_NOT_READY:
- //
- // Sense Key is EFI_SCSI_SK_NOT_READY (0x2)
- //
- switch (SensePtr->Addnl_Sense_Code) {
- //
- // Additional Sense Code is ASC_MEDIA_UPSIDE_DOWN (0x6)
- //
- case EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN:
- IsError = TRUE;
break;
default:
break;
- }
- break;
-
- default:
- break;
}
SensePtr++;
@@ -5484,7 +5522,6 @@ ScsiDiskIsMediaError ( return IsError;
}
-
/**
Check sense key to find if hardware error happens.
@@ -5497,19 +5534,18 @@ ScsiDiskIsMediaError ( **/
BOOLEAN
ScsiDiskIsHardwareError (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN IsError;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN IsError;
- IsError = FALSE;
- SensePtr = SenseData;
+ IsError = FALSE;
+ SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
-
//
// Sense Key is EFI_SCSI_SK_HARDWARE_ERROR (0x4)
//
@@ -5523,7 +5559,6 @@ ScsiDiskIsHardwareError ( return IsError;
}
-
/**
Check sense key to find if media has changed.
@@ -5535,16 +5570,16 @@ ScsiDiskIsHardwareError ( **/
BOOLEAN
ScsiDiskIsMediaChange (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN IsMediaChanged;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN IsMediaChanged;
- IsMediaChanged = FALSE;
- SensePtr = SenseData;
+ IsMediaChanged = FALSE;
+ SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
//
@@ -5552,7 +5587,8 @@ ScsiDiskIsMediaChange ( // Additional sense code is EFI_SCSI_ASC_MEDIA_CHANGE (0x28)
//
if ((SensePtr->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
- (SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_CHANGE)) {
+ (SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_CHANGE))
+ {
IsMediaChanged = TRUE;
}
@@ -5574,25 +5610,25 @@ ScsiDiskIsMediaChange ( **/
BOOLEAN
ScsiDiskIsResetBefore (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN IsResetBefore;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN IsResetBefore;
IsResetBefore = FALSE;
SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
-
//
// Sense Key is EFI_SCSI_SK_UNIT_ATTENTION (0x6)
// Additional Sense Code is EFI_SCSI_ASC_RESET (0x29)
//
if ((SensePtr->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
- (SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_RESET)) {
+ (SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_RESET))
+ {
IsResetBefore = TRUE;
}
@@ -5615,56 +5651,56 @@ ScsiDiskIsResetBefore ( **/
BOOLEAN
ScsiDiskIsDriveReady (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts,
- OUT BOOLEAN *RetryLater
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts,
+ OUT BOOLEAN *RetryLater
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN IsReady;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN IsReady;
IsReady = TRUE;
*RetryLater = FALSE;
SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
-
switch (SensePtr->Sense_Key) {
-
- case EFI_SCSI_SK_NOT_READY:
- //
- // Sense Key is EFI_SCSI_SK_NOT_READY (0x2)
- //
- switch (SensePtr->Addnl_Sense_Code) {
- case EFI_SCSI_ASC_NOT_READY:
+ case EFI_SCSI_SK_NOT_READY:
//
- // Additional Sense Code is EFI_SCSI_ASC_NOT_READY (0x4)
+ // Sense Key is EFI_SCSI_SK_NOT_READY (0x2)
//
- switch (SensePtr->Addnl_Sense_Code_Qualifier) {
- case EFI_SCSI_ASCQ_IN_PROGRESS:
- //
- // Additional Sense Code Qualifier is
- // EFI_SCSI_ASCQ_IN_PROGRESS (0x1)
- //
- IsReady = FALSE;
- *RetryLater = TRUE;
- break;
+ switch (SensePtr->Addnl_Sense_Code) {
+ case EFI_SCSI_ASC_NOT_READY:
+ //
+ // Additional Sense Code is EFI_SCSI_ASC_NOT_READY (0x4)
+ //
+ switch (SensePtr->Addnl_Sense_Code_Qualifier) {
+ case EFI_SCSI_ASCQ_IN_PROGRESS:
+ //
+ // Additional Sense Code Qualifier is
+ // EFI_SCSI_ASCQ_IN_PROGRESS (0x1)
+ //
+ IsReady = FALSE;
+ *RetryLater = TRUE;
+ break;
+
+ default:
+ IsReady = FALSE;
+ *RetryLater = FALSE;
+ break;
+ }
- default:
- IsReady = FALSE;
- *RetryLater = FALSE;
- break;
+ break;
+
+ default:
+ break;
}
+
break;
default:
break;
- }
- break;
-
- default:
- break;
}
SensePtr++;
@@ -5685,13 +5721,13 @@ ScsiDiskIsDriveReady ( **/
BOOLEAN
ScsiDiskHaveSenseKey (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
- EFI_SCSI_SENSE_DATA *SensePtr;
- UINTN Index;
- BOOLEAN HaveSenseKey;
+ EFI_SCSI_SENSE_DATA *SensePtr;
+ UINTN Index;
+ BOOLEAN HaveSenseKey;
if (SenseCounts == 0) {
HaveSenseKey = FALSE;
@@ -5702,12 +5738,12 @@ ScsiDiskHaveSenseKey ( SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
-
//
// Sense Key is SK_NO_SENSE (0x0)
//
if ((SensePtr->Sense_Key == EFI_SCSI_SK_NO_SENSE) &&
- (Index == 0)) {
+ (Index == 0))
+ {
HaveSenseKey = FALSE;
}
@@ -5725,11 +5761,11 @@ ScsiDiskHaveSenseKey ( **/
VOID
ReleaseScsiDiskDeviceResources (
- IN SCSI_DISK_DEV *ScsiDiskDevice
+ IN SCSI_DISK_DEV *ScsiDiskDevice
)
{
if (ScsiDiskDevice == NULL) {
- return ;
+ return;
}
if (ScsiDiskDevice->SenseData != NULL) {
@@ -5759,11 +5795,11 @@ ReleaseScsiDiskDeviceResources ( **/
BOOLEAN
DetermineInstallBlockIo (
- IN EFI_HANDLE ChildHandle
+ IN EFI_HANDLE ChildHandle
)
{
- EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
+ EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
//
// Firstly, check if ExtScsiPassThru Protocol parent handle exists. If existence,
@@ -5805,15 +5841,15 @@ DetermineInstallBlockIo ( VOID *
EFIAPI
GetParentProtocol (
- IN EFI_GUID *ProtocolGuid,
- IN EFI_HANDLE ChildHandle
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_HANDLE ChildHandle
)
{
- UINTN Index;
- UINTN HandleCount;
- VOID *Interface;
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ UINTN HandleCount;
+ VOID *Interface;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
//
// Retrieve the list of all handles from the handle database
@@ -5860,20 +5896,20 @@ GetParentProtocol ( **/
BOOLEAN
DetermineInstallEraseBlock (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_HANDLE ChildHandle
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_HANDLE ChildHandle
)
{
- UINT8 HostAdapterStatus;
- UINT8 TargetStatus;
- EFI_STATUS CommandStatus;
- EFI_STATUS Status;
- BOOLEAN UfsDevice;
- BOOLEAN RetVal;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- UINT8 SenseDataLength;
- UINT32 DataLength16;
- EFI_SCSI_DISK_CAPACITY_DATA16 *CapacityData16;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ EFI_STATUS CommandStatus;
+ EFI_STATUS Status;
+ BOOLEAN UfsDevice;
+ BOOLEAN RetVal;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ UINT8 SenseDataLength;
+ UINT32 DataLength16;
+ EFI_SCSI_DISK_CAPACITY_DATA16 *CapacityData16;
UfsDevice = FALSE;
RetVal = TRUE;
@@ -5890,7 +5926,7 @@ DetermineInstallEraseBlock ( Status = gBS->HandleProtocol (
ChildHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePathNode
+ (VOID **)&DevicePathNode
);
//
// Device Path protocol must be installed on the device handle.
@@ -5902,13 +5938,15 @@ DetermineInstallEraseBlock ( // For now, only support Erase Block Protocol on UFS devices.
//
if ((DevicePathNode->Type == MESSAGING_DEVICE_PATH) &&
- (DevicePathNode->SubType == MSG_UFS_DP)) {
+ (DevicePathNode->SubType == MSG_UFS_DP))
+ {
UfsDevice = TRUE;
break;
}
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
+
if (!UfsDevice) {
RetVal = FALSE;
goto Done;
@@ -5934,7 +5972,7 @@ DetermineInstallEraseBlock ( &SenseDataLength,
&HostAdapterStatus,
&TargetStatus,
- (VOID *) CapacityData16,
+ (VOID *)CapacityData16,
&DataLength16,
FALSE
);
@@ -5946,7 +5984,8 @@ DetermineInstallEraseBlock ( // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
//
if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
- ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
+ ((CapacityData16->LowestAlignLogic2 & BIT6) == 0))
+ {
DEBUG ((
DEBUG_VERBOSE,
"ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
@@ -5971,7 +6010,8 @@ DetermineInstallEraseBlock ( // Check whether the UFS device server implements the UNMAP command.
//
if ((ScsiDiskDevice->UnmapInfo.MaxLbaCnt == 0) ||
- (ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt == 0)) {
+ (ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt == 0))
+ {
DEBUG ((
DEBUG_VERBOSE,
"ScsiDisk EraseBlock: The device server does not implement the UNMAP command.\n"
@@ -6001,22 +6041,22 @@ Done: **/
BOOLEAN
DetermineInstallStorageSecurity (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_HANDLE ChildHandle
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_HANDLE ChildHandle
)
{
- EFI_STATUS Status;
- UFS_DEVICE_PATH *UfsDevice;
- BOOLEAN RetVal;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ EFI_STATUS Status;
+ UFS_DEVICE_PATH *UfsDevice;
+ BOOLEAN RetVal;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- UfsDevice = NULL;
- RetVal = TRUE;
+ UfsDevice = NULL;
+ RetVal = TRUE;
Status = gBS->HandleProtocol (
ChildHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePathNode
+ (VOID **)&DevicePathNode
);
//
// Device Path protocol must be installed on the device handle.
@@ -6028,13 +6068,15 @@ DetermineInstallStorageSecurity ( // For now, only support Storage Security Command Protocol on UFS devices.
//
if ((DevicePathNode->Type == MESSAGING_DEVICE_PATH) &&
- (DevicePathNode->SubType == MSG_UFS_DP)) {
- UfsDevice = (UFS_DEVICE_PATH *) DevicePathNode;
+ (DevicePathNode->SubType == MSG_UFS_DP))
+ {
+ UfsDevice = (UFS_DEVICE_PATH *)DevicePathNode;
break;
}
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
+
if (UfsDevice == NULL) {
RetVal = FALSE;
goto Done;
@@ -6067,26 +6109,26 @@ Done: EFI_STATUS
EFIAPI
ScsiDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *InquiryDataSize
)
{
- EFI_STATUS Status;
- SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_STATUS Status;
+ SCSI_DISK_DEV *ScsiDiskDevice;
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
Status = EFI_BUFFER_TOO_SMALL;
if (*InquiryDataSize >= sizeof (ScsiDiskDevice->InquiryData)) {
Status = EFI_SUCCESS;
CopyMem (InquiryData, &ScsiDiskDevice->InquiryData, sizeof (ScsiDiskDevice->InquiryData));
}
+
*InquiryDataSize = sizeof (ScsiDiskDevice->InquiryData);
return Status;
}
-
/**
Provides identify information for the controller type.
@@ -6108,13 +6150,13 @@ ScsiDiskInfoInquiry ( EFI_STATUS
EFIAPI
ScsiDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
)
{
- EFI_STATUS Status;
- SCSI_DISK_DEV *ScsiDiskDevice;
+ EFI_STATUS Status;
+ SCSI_DISK_DEV *ScsiDiskDevice;
if (CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid) || CompareGuid (&This->Interface, &gEfiDiskInfoUfsInterfaceGuid)) {
//
@@ -6123,13 +6165,14 @@ ScsiDiskInfoIdentify ( return EFI_NOT_FOUND;
}
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
Status = EFI_BUFFER_TOO_SMALL;
if (*IdentifyDataSize >= sizeof (ScsiDiskDevice->IdentifyData)) {
Status = EFI_SUCCESS;
CopyMem (IdentifyData, &ScsiDiskDevice->IdentifyData, sizeof (ScsiDiskDevice->IdentifyData));
}
+
*IdentifyDataSize = sizeof (ScsiDiskDevice->IdentifyData);
return Status;
}
@@ -6154,16 +6197,15 @@ ScsiDiskInfoIdentify ( EFI_STATUS
EFIAPI
ScsiDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
)
{
return EFI_NOT_FOUND;
}
-
/**
This function is used by the IDE bus driver to get controller information.
@@ -6178,12 +6220,12 @@ ScsiDiskInfoSenseData ( EFI_STATUS
EFIAPI
ScsiDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
)
{
- SCSI_DISK_DEV *ScsiDiskDevice;
+ SCSI_DISK_DEV *ScsiDiskDevice;
if (CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid) || CompareGuid (&This->Interface, &gEfiDiskInfoUfsInterfaceGuid)) {
//
@@ -6192,14 +6234,13 @@ ScsiDiskInfoWhichIde ( return EFI_UNSUPPORTED;
}
- ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
- *IdeChannel = ScsiDiskDevice->Channel;
- *IdeDevice = ScsiDiskDevice->Device;
+ ScsiDiskDevice = SCSI_DISK_DEV_FROM_DISKINFO (This);
+ *IdeChannel = ScsiDiskDevice->Channel;
+ *IdeDevice = ScsiDiskDevice->Device;
return EFI_SUCCESS;
}
-
/**
Issues ATA IDENTIFY DEVICE command to identify ATAPI device.
@@ -6215,11 +6256,11 @@ ScsiDiskInfoWhichIde ( **/
EFI_STATUS
AtapiIdentifyDevice (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice
)
{
- EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
- UINT8 Cdb[6];
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT8 Cdb[6];
//
// Initialize SCSI REQUEST_PACKET and 6-byte Cdb
@@ -6227,17 +6268,16 @@ AtapiIdentifyDevice ( ZeroMem (&CommandPacket, sizeof (CommandPacket));
ZeroMem (Cdb, sizeof (Cdb));
- Cdb[0] = ATA_CMD_IDENTIFY_DEVICE;
- CommandPacket.Timeout = SCSI_DISK_TIMEOUT;
- CommandPacket.Cdb = Cdb;
- CommandPacket.CdbLength = (UINT8) sizeof (Cdb);
- CommandPacket.InDataBuffer = &ScsiDiskDevice->IdentifyData;
+ Cdb[0] = ATA_CMD_IDENTIFY_DEVICE;
+ CommandPacket.Timeout = SCSI_DISK_TIMEOUT;
+ CommandPacket.Cdb = Cdb;
+ CommandPacket.CdbLength = (UINT8)sizeof (Cdb);
+ CommandPacket.InDataBuffer = &ScsiDiskDevice->IdentifyData;
CommandPacket.InTransferLength = sizeof (ScsiDiskDevice->IdentifyData);
return ScsiDiskDevice->ScsiIo->ExecuteScsiCommand (ScsiDiskDevice->ScsiIo, &CommandPacket, NULL);
}
-
/**
Initialize the installation of DiskInfo protocol.
@@ -6252,8 +6292,8 @@ AtapiIdentifyDevice ( **/
VOID
InitializeInstallDiskInfo (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_HANDLE ChildHandle
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_HANDLE ChildHandle
)
{
EFI_STATUS Status;
@@ -6263,7 +6303,7 @@ InitializeInstallDiskInfo ( SATA_DEVICE_PATH *SataDevicePath;
UINTN IdentifyRetry;
- Status = gBS->HandleProtocol (ChildHandle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePathNode);
+ Status = gBS->HandleProtocol (ChildHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathNode);
//
// Device Path protocol must be installed on the device handle.
//
@@ -6278,9 +6318,9 @@ InitializeInstallDiskInfo ( if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&
(DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&
(DevicePathType (ChildDevicePathNode) == MESSAGING_DEVICE_PATH) &&
- ((DevicePathSubType (ChildDevicePathNode) == MSG_ATAPI_DP) ||
- (DevicePathSubType (ChildDevicePathNode) == MSG_SATA_DP))) {
-
+ ((DevicePathSubType (ChildDevicePathNode) == MSG_ATAPI_DP) ||
+ (DevicePathSubType (ChildDevicePathNode) == MSG_SATA_DP)))
+ {
IdentifyRetry = 3;
do {
//
@@ -6289,13 +6329,13 @@ InitializeInstallDiskInfo ( //
Status = AtapiIdentifyDevice (ScsiDiskDevice);
if (!EFI_ERROR (Status)) {
- if (DevicePathSubType(ChildDevicePathNode) == MSG_ATAPI_DP) {
+ if (DevicePathSubType (ChildDevicePathNode) == MSG_ATAPI_DP) {
//
// We find the valid ATAPI device path
//
- AtapiDevicePath = (ATAPI_DEVICE_PATH *) ChildDevicePathNode;
+ AtapiDevicePath = (ATAPI_DEVICE_PATH *)ChildDevicePathNode;
ScsiDiskDevice->Channel = AtapiDevicePath->PrimarySecondary;
- ScsiDiskDevice->Device = AtapiDevicePath->SlaveMaster;
+ ScsiDiskDevice->Device = AtapiDevicePath->SlaveMaster;
//
// Update the DiskInfo.Interface to IDE interface GUID for the physical ATAPI device.
//
@@ -6304,22 +6344,25 @@ InitializeInstallDiskInfo ( //
// We find the valid SATA device path
//
- SataDevicePath = (SATA_DEVICE_PATH *) ChildDevicePathNode;
+ SataDevicePath = (SATA_DEVICE_PATH *)ChildDevicePathNode;
ScsiDiskDevice->Channel = SataDevicePath->HBAPortNumber;
- ScsiDiskDevice->Device = SataDevicePath->PortMultiplierPortNumber;
+ ScsiDiskDevice->Device = SataDevicePath->PortMultiplierPortNumber;
//
// Update the DiskInfo.Interface to AHCI interface GUID for the physical AHCI device.
//
CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoAhciInterfaceGuid);
}
+
return;
}
} while (--IdentifyRetry > 0);
} else if ((DevicePathType (ChildDevicePathNode) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (ChildDevicePathNode) == MSG_UFS_DP)) {
+ (DevicePathSubType (ChildDevicePathNode) == MSG_UFS_DP))
+ {
CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoUfsInterfaceGuid);
break;
}
+
DevicePathNode = ChildDevicePathNode;
}
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h index ed9bbd6..d54282d 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h @@ -9,10 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _SCSI_DISK_H_
#define _SCSI_DISK_H_
-
#include <Uefi.h>
-
#include <Protocol/ScsiIo.h>
#include <Protocol/ComponentName.h>
#include <Protocol/BlockIo.h>
@@ -24,7 +22,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/DiskInfo.h>
#include <Protocol/StorageSecurityCommand.h>
-
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
@@ -37,74 +34,74 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <IndustryStandard/Scsi.h>
#include <IndustryStandard/Atapi.h>
-#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0
+#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0
-#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
+#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
-#define UFS_WLUN_RPMB 0xC4
+#define UFS_WLUN_RPMB 0xC4
typedef struct {
- UINT32 MaxLbaCnt;
- UINT32 MaxBlkDespCnt;
- UINT32 GranularityAlignment;
+ UINT32 MaxLbaCnt;
+ UINT32 MaxBlkDespCnt;
+ UINT32 GranularityAlignment;
} SCSI_UNMAP_PARAM_INFO;
-#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')
+#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')
typedef struct {
- UINT32 Signature;
+ UINT32 Signature;
- EFI_HANDLE Handle;
+ EFI_HANDLE Handle;
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;
- EFI_BLOCK_IO_PROTOCOL BlkIo;
- EFI_BLOCK_IO2_PROTOCOL BlkIo2;
- EFI_BLOCK_IO_MEDIA BlkIoMedia;
- EFI_ERASE_BLOCK_PROTOCOL EraseBlock;
- EFI_SCSI_IO_PROTOCOL *ScsiIo;
- UINT8 DeviceType;
- BOOLEAN FixedDevice;
- UINT16 Reserved;
+ EFI_BLOCK_IO_PROTOCOL BlkIo;
+ EFI_BLOCK_IO2_PROTOCOL BlkIo2;
+ EFI_BLOCK_IO_MEDIA BlkIoMedia;
+ EFI_ERASE_BLOCK_PROTOCOL EraseBlock;
+ EFI_SCSI_IO_PROTOCOL *ScsiIo;
+ UINT8 DeviceType;
+ BOOLEAN FixedDevice;
+ UINT16 Reserved;
- EFI_SCSI_SENSE_DATA *SenseData;
- UINTN SenseDataNumber;
- EFI_SCSI_INQUIRY_DATA InquiryData;
+ EFI_SCSI_SENSE_DATA *SenseData;
+ UINTN SenseDataNumber;
+ EFI_SCSI_INQUIRY_DATA InquiryData;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- EFI_DISK_INFO_PROTOCOL DiskInfo;
+ EFI_DISK_INFO_PROTOCOL DiskInfo;
//
// The following fields are only valid for ATAPI/SATA device
//
- UINT32 Channel;
- UINT32 Device;
- ATAPI_IDENTIFY_DATA IdentifyData;
+ UINT32 Channel;
+ UINT32 Device;
+ ATAPI_IDENTIFY_DATA IdentifyData;
//
// Scsi UNMAP command parameters information
//
- SCSI_UNMAP_PARAM_INFO UnmapInfo;
- BOOLEAN BlockLimitsVpdSupported;
+ SCSI_UNMAP_PARAM_INFO UnmapInfo;
+ BOOLEAN BlockLimitsVpdSupported;
//
// The flag indicates if 16-byte command can be used
//
- BOOLEAN Cdb16Byte;
+ BOOLEAN Cdb16Byte;
//
// The queue for asynchronous task requests
//
- LIST_ENTRY AsyncTaskQueue;
+ LIST_ENTRY AsyncTaskQueue;
} SCSI_DISK_DEV;
-#define SCSI_DISK_DEV_FROM_BLKIO(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)
-#define SCSI_DISK_DEV_FROM_BLKIO2(a) CR (a, SCSI_DISK_DEV, BlkIo2, SCSI_DISK_DEV_SIGNATURE)
+#define SCSI_DISK_DEV_FROM_BLKIO(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)
+#define SCSI_DISK_DEV_FROM_BLKIO2(a) CR (a, SCSI_DISK_DEV, BlkIo2, SCSI_DISK_DEV_SIGNATURE)
#define SCSI_DISK_DEV_FROM_ERASEBLK(a) CR (a, SCSI_DISK_DEV, EraseBlock, SCSI_DISK_DEV_SIGNATURE)
-#define SCSI_DISK_DEV_FROM_STORSEC(a) CR (a, SCSI_DISK_DEV, StorageSecurity, SCSI_DISK_DEV_SIGNATURE)
+#define SCSI_DISK_DEV_FROM_STORSEC(a) CR (a, SCSI_DISK_DEV, StorageSecurity, SCSI_DISK_DEV_SIGNATURE)
-#define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)
+#define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)
//
// Asynchronous I/O request
@@ -113,55 +110,55 @@ typedef struct { // Private data structure for a BlockIo2 request
//
typedef struct {
- EFI_BLOCK_IO2_TOKEN *Token;
+ EFI_BLOCK_IO2_TOKEN *Token;
//
// The flag indicates if the last Scsi Read/Write sub-task for a BlockIo2
// request is sent to device
//
- BOOLEAN LastScsiRW;
+ BOOLEAN LastScsiRW;
//
// The queue for Scsi Read/Write sub-tasks of a BlockIo2 request
//
- LIST_ENTRY ScsiRWQueue;
+ LIST_ENTRY ScsiRWQueue;
- LIST_ENTRY Link;
+ LIST_ENTRY Link;
} SCSI_BLKIO2_REQUEST;
//
// Private data structure for a SCSI Read/Write request
//
typedef struct {
- SCSI_DISK_DEV *ScsiDiskDevice;
- UINT64 Timeout;
- EFI_SCSI_SENSE_DATA *SenseData;
- UINT8 SenseDataLength;
- UINT8 HostAdapterStatus;
- UINT8 TargetStatus;
- UINT8 *InBuffer;
- UINT8 *OutBuffer;
- UINT32 DataLength;
- UINT64 StartLba;
- UINT32 SectorCount;
- UINT8 TimesRetry;
+ SCSI_DISK_DEV *ScsiDiskDevice;
+ UINT64 Timeout;
+ EFI_SCSI_SENSE_DATA *SenseData;
+ UINT8 SenseDataLength;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ UINT8 *InBuffer;
+ UINT8 *OutBuffer;
+ UINT32 DataLength;
+ UINT64 StartLba;
+ UINT32 SectorCount;
+ UINT8 TimesRetry;
//
// The BlockIo2 request this SCSI command belongs to
//
- SCSI_BLKIO2_REQUEST *BlkIo2Req;
+ SCSI_BLKIO2_REQUEST *BlkIo2Req;
- LIST_ENTRY Link;
+ LIST_ENTRY Link;
} SCSI_ASYNC_RW_REQUEST;
//
// Private data structure for an EraseBlock request
//
typedef struct {
- EFI_ERASE_BLOCK_TOKEN *Token;
+ EFI_ERASE_BLOCK_TOKEN *Token;
- EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
- LIST_ENTRY Link;
+ LIST_ENTRY Link;
} SCSI_ERASEBLK_REQUEST;
//
@@ -173,14 +170,14 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2; //
// action code used in detect media process
//
-#define ACTION_NO_ACTION 0x00
-#define ACTION_READ_CAPACITY 0x01
-#define ACTION_RETRY_COMMAND_LATER 0x02
-#define ACTION_RETRY_WITH_BACKOFF_ALGO 0x03
+#define ACTION_NO_ACTION 0x00
+#define ACTION_READ_CAPACITY 0x01
+#define ACTION_RETRY_COMMAND_LATER 0x02
+#define ACTION_RETRY_WITH_BACKOFF_ALGO 0x03
-#define SCSI_COMMAND_VERSION_1 0x01
-#define SCSI_COMMAND_VERSION_2 0x02
-#define SCSI_COMMAND_VERSION_3 0x03
+#define SCSI_COMMAND_VERSION_1 0x01
+#define SCSI_COMMAND_VERSION_2 0x02
+#define SCSI_COMMAND_VERSION_3 0x03
//
// SCSI Disk Timeout Experience Value
@@ -189,7 +186,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2; // value is updated to 30s to follow ATA/ATAPI spec in which the device may take up to 30s
// to respond command.
//
-#define SCSI_DISK_TIMEOUT EFI_TIMER_PERIOD_SECONDS (30)
+#define SCSI_DISK_TIMEOUT EFI_TIMER_PERIOD_SECONDS (30)
/**
Test to see if this driver supports ControllerHandle.
@@ -267,15 +264,16 @@ ScsiDiskDriverBindingStart ( EFI_STATUS
EFIAPI
ScsiDiskDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
);
//
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -323,7 +321,6 @@ ScsiDiskComponentNameGetDriverName ( OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -395,11 +392,11 @@ ScsiDiskComponentNameGetDriverName ( EFI_STATUS
EFIAPI
ScsiDiskComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
/**
@@ -418,11 +415,10 @@ ScsiDiskComponentNameGetControllerName ( EFI_STATUS
EFIAPI
ScsiDiskReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
-
/**
The function is to Read Block from SCSI Disk.
@@ -443,14 +439,13 @@ ScsiDiskReset ( EFI_STATUS
EFIAPI
ScsiDiskReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
-
/**
The function is to Write Block to SCSI Disk.
@@ -472,14 +467,13 @@ ScsiDiskReadBlocks ( EFI_STATUS
EFIAPI
ScsiDiskWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
-
/**
Flush Block to Disk.
@@ -493,10 +487,9 @@ ScsiDiskWriteBlocks ( EFI_STATUS
EFIAPI
ScsiDiskFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
+ IN EFI_BLOCK_IO_PROTOCOL *This
);
-
/**
Reset SCSI Disk.
@@ -545,12 +538,12 @@ ScsiDiskResetEx ( 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
+ 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
);
/**
@@ -579,12 +572,12 @@ ScsiDiskReadBlocksEx ( 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
+ 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
);
/**
@@ -638,14 +631,13 @@ ScsiDiskFlushBlocksEx ( 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
+ IN EFI_ERASE_BLOCK_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN OUT EFI_ERASE_BLOCK_TOKEN *Token,
+ IN UINTN Size
);
-
/**
Send a security protocol command to a device that receives data and/or the result
of one or more commands sent by SendData.
@@ -713,14 +705,14 @@ ScsiDiskEraseBlocks ( 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
+ 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
);
/**
@@ -781,16 +773,15 @@ ScsiDiskReceiveData ( 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
+ 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
);
-
/**
Provides inquiry information for the controller type.
@@ -810,12 +801,11 @@ ScsiDiskSendData ( EFI_STATUS
EFIAPI
ScsiDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *InquiryDataSize
);
-
/**
Provides identify information for the controller type.
@@ -837,12 +827,11 @@ ScsiDiskInfoInquiry ( EFI_STATUS
EFIAPI
ScsiDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
);
-
/**
Provides sense data information for the controller type.
@@ -863,10 +852,10 @@ ScsiDiskInfoIdentify ( EFI_STATUS
EFIAPI
ScsiDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
);
/**
@@ -883,12 +872,11 @@ ScsiDiskInfoSenseData ( EFI_STATUS
EFIAPI
ScsiDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
);
-
/**
Detect Device and read out capacity ,if error occurs, parse the sense key.
@@ -902,9 +890,9 @@ ScsiDiskInfoWhichIde ( **/
EFI_STATUS
ScsiDiskDetectMedia (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN BOOLEAN MustReadCapacity,
- OUT BOOLEAN *MediaChange
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN BOOLEAN MustReadCapacity,
+ OUT BOOLEAN *MediaChange
);
/**
@@ -925,13 +913,12 @@ ScsiDiskDetectMedia ( **/
EFI_STATUS
ScsiDiskTestUnitReady (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry,
- OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
- OUT UINTN *NumberOfSenseKeys
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
+ OUT UINTN *NumberOfSenseKeys
);
-
/**
Parsing Sense Keys which got from request sense command.
@@ -946,13 +933,12 @@ ScsiDiskTestUnitReady ( **/
EFI_STATUS
DetectMediaParsingSenseKeys (
- OUT SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN NumberOfSenseKeys,
- OUT UINTN *Action
+ OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN NumberOfSenseKeys,
+ OUT UINTN *Action
);
-
/**
Send read capacity command to device and get the device parameter.
@@ -967,10 +953,10 @@ DetectMediaParsingSenseKeys ( **/
EFI_STATUS
ScsiDiskReadCapacity (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry,
- OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
- OUT UINTN *NumberOfSenseKeys
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
+ OUT UINTN *NumberOfSenseKeys
);
/**
@@ -986,10 +972,9 @@ ScsiDiskReadCapacity ( **/
EFI_STATUS
CheckHostAdapterStatus (
- IN UINT8 HostAdapterStatus
+ IN UINT8 HostAdapterStatus
);
-
/**
Check the target status and re-interpret it in EFI_STATUS.
@@ -1002,7 +987,7 @@ CheckHostAdapterStatus ( **/
EFI_STATUS
CheckTargetStatus (
- IN UINT8 TargetStatus
+ IN UINT8 TargetStatus
);
/**
@@ -1024,11 +1009,11 @@ CheckTargetStatus ( **/
EFI_STATUS
ScsiDiskRequestSenseKeys (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry,
- OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
- OUT UINTN *NumberOfSenseKeys,
- IN BOOLEAN AskResetIfError
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ OUT EFI_SCSI_SENSE_DATA **SenseDataArray,
+ OUT UINTN *NumberOfSenseKeys,
+ IN BOOLEAN AskResetIfError
);
/**
@@ -1043,8 +1028,8 @@ ScsiDiskRequestSenseKeys ( **/
EFI_STATUS
ScsiDiskInquiryDevice (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
- OUT BOOLEAN *NeedRetry
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry
);
/**
@@ -1055,7 +1040,7 @@ ScsiDiskInquiryDevice ( **/
VOID
ParseInquiryData (
- IN OUT SCSI_DISK_DEV *ScsiDiskDevice
+ IN OUT SCSI_DISK_DEV *ScsiDiskDevice
);
/**
@@ -1072,10 +1057,10 @@ ParseInquiryData ( **/
EFI_STATUS
ScsiDiskReadSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- OUT VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks
);
/**
@@ -1092,10 +1077,10 @@ ScsiDiskReadSectors ( **/
EFI_STATUS
ScsiDiskWriteSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks
);
/**
@@ -1115,11 +1100,11 @@ ScsiDiskWriteSectors ( **/
EFI_STATUS
ScsiDiskAsyncReadSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- OUT VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks,
- IN EFI_BLOCK_IO2_TOKEN *Token
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks,
+ IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
@@ -1139,11 +1124,11 @@ ScsiDiskAsyncReadSectors ( **/
EFI_STATUS
ScsiDiskAsyncWriteSectors (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks,
- IN EFI_BLOCK_IO2_TOKEN *Token
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks,
+ IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
@@ -1161,13 +1146,13 @@ ScsiDiskAsyncWriteSectors ( **/
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
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ IN UINT64 Timeout,
+ OUT UINT8 *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT32 StartLba,
+ IN UINT32 SectorCount
);
/**
@@ -1186,13 +1171,13 @@ ScsiDiskRead10 ( **/
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
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ IN UINT64 Timeout,
+ IN UINT8 *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT32 StartLba,
+ IN UINT32 SectorCount
);
/**
@@ -1210,13 +1195,13 @@ ScsiDiskWrite10 ( **/
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
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ IN UINT64 Timeout,
+ OUT UINT8 *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT64 StartLba,
+ IN UINT32 SectorCount
);
/**
@@ -1235,13 +1220,13 @@ ScsiDiskRead16 ( **/
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
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ OUT BOOLEAN *NeedRetry,
+ IN UINT64 Timeout,
+ IN UINT8 *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT64 StartLba,
+ IN UINT32 SectorCount
);
/**
@@ -1266,15 +1251,15 @@ ScsiDiskWrite16 ( **/
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
+ 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
);
/**
@@ -1299,15 +1284,15 @@ ScsiDiskAsyncRead10 ( **/
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
+ 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
);
/**
@@ -1332,15 +1317,15 @@ ScsiDiskAsyncWrite10 ( **/
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
+ 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
);
/**
@@ -1365,15 +1350,15 @@ ScsiDiskAsyncRead16 ( **/
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
+ 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
);
/**
@@ -1401,8 +1386,8 @@ GetMediaInfo ( **/
BOOLEAN
ScsiDiskIsNoMedia (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -1417,8 +1402,8 @@ ScsiDiskIsNoMedia ( **/
BOOLEAN
ScsiDiskIsMediaError (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -1433,8 +1418,8 @@ ScsiDiskIsMediaError ( **/
BOOLEAN
ScsiDiskIsHardwareError (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -1448,8 +1433,8 @@ ScsiDiskIsHardwareError ( **/
BOOLEAN
ScsiDiskIsMediaChange (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -1464,8 +1449,8 @@ ScsiDiskIsMediaChange ( **/
BOOLEAN
ScsiDiskIsResetBefore (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -1481,9 +1466,9 @@ ScsiDiskIsResetBefore ( **/
BOOLEAN
ScsiDiskIsDriveReady (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts,
- OUT BOOLEAN *RetryLater
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts,
+ OUT BOOLEAN *RetryLater
);
/**
@@ -1498,8 +1483,8 @@ ScsiDiskIsDriveReady ( **/
BOOLEAN
ScsiDiskHaveSenseKey (
- IN EFI_SCSI_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN EFI_SCSI_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -1510,7 +1495,7 @@ ScsiDiskHaveSenseKey ( **/
VOID
ReleaseScsiDiskDeviceResources (
- IN SCSI_DISK_DEV *ScsiDiskDevice
+ IN SCSI_DISK_DEV *ScsiDiskDevice
);
/**
@@ -1525,7 +1510,7 @@ ReleaseScsiDiskDeviceResources ( **/
BOOLEAN
DetermineInstallBlockIo (
- IN EFI_HANDLE ChildHandle
+ IN EFI_HANDLE ChildHandle
);
/**
@@ -1542,8 +1527,8 @@ DetermineInstallBlockIo ( **/
VOID
InitializeInstallDiskInfo (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_HANDLE ChildHandle
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_HANDLE ChildHandle
);
/**
@@ -1561,8 +1546,8 @@ InitializeInstallDiskInfo ( VOID *
EFIAPI
GetParentProtocol (
- IN EFI_GUID *ProtocolGuid,
- IN EFI_HANDLE ChildHandle
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_HANDLE ChildHandle
);
/**
@@ -1577,8 +1562,8 @@ GetParentProtocol ( **/
BOOLEAN
DetermineInstallEraseBlock (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_HANDLE ChildHandle
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_HANDLE ChildHandle
);
/**
@@ -1593,8 +1578,8 @@ DetermineInstallEraseBlock ( **/
BOOLEAN
DetermineInstallStorageSecurity (
- IN SCSI_DISK_DEV *ScsiDiskDevice,
- IN EFI_HANDLE ChildHandle
+ IN SCSI_DISK_DEV *ScsiDiskDevice,
+ IN EFI_HANDLE ChildHandle
);
#endif
|