X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FScsi%2FScsiDiskDxe%2FScsiDisk.c;h=0d63c85e44beb360e359c44b4574ef94c5976a40;hp=1b75d55231a6978806351b66af86faf2f8c02a8a;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hpb=ce1647fc608e8193b416a08da633019de611199c diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c index 1b75d55231..0d63c85e44 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c @@ -1,7 +1,7 @@ /** @file SCSI disk driver that layers on every SCSI IO protocol in the system. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -79,9 +79,9 @@ FreeAlignedBuffer ( The user code starts with this function. - @param ImageHandle The firmware allocated handle for the EFI image. + @param ImageHandle The firmware allocated handle for the EFI image. @param SystemTable A pointer to the EFI System Table. - + @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. @@ -230,22 +230,27 @@ ScsiDiskDriverBindingStart ( return Status; } - ScsiDiskDevice->Signature = SCSI_DISK_DEV_SIGNATURE; - ScsiDiskDevice->ScsiIo = ScsiIo; - ScsiDiskDevice->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3; - ScsiDiskDevice->BlkIo.Media = &ScsiDiskDevice->BlkIoMedia; - ScsiDiskDevice->BlkIo.Media->IoAlign = ScsiIo->IoAlign; - ScsiDiskDevice->BlkIo.Reset = ScsiDiskReset; - ScsiDiskDevice->BlkIo.ReadBlocks = ScsiDiskReadBlocks; - ScsiDiskDevice->BlkIo.WriteBlocks = ScsiDiskWriteBlocks; - ScsiDiskDevice->BlkIo.FlushBlocks = ScsiDiskFlushBlocks; - ScsiDiskDevice->BlkIo2.Media = &ScsiDiskDevice->BlkIoMedia; - ScsiDiskDevice->BlkIo2.Reset = ScsiDiskResetEx; - ScsiDiskDevice->BlkIo2.ReadBlocksEx = ScsiDiskReadBlocksEx; - ScsiDiskDevice->BlkIo2.WriteBlocksEx = ScsiDiskWriteBlocksEx; - ScsiDiskDevice->BlkIo2.FlushBlocksEx = ScsiDiskFlushBlocksEx; - ScsiDiskDevice->Handle = Controller; - InitializeListHead (&ScsiDiskDevice->BlkIo2Queue); + ScsiDiskDevice->Signature = SCSI_DISK_DEV_SIGNATURE; + ScsiDiskDevice->ScsiIo = ScsiIo; + ScsiDiskDevice->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3; + ScsiDiskDevice->BlkIo.Media = &ScsiDiskDevice->BlkIoMedia; + ScsiDiskDevice->BlkIo.Media->IoAlign = ScsiIo->IoAlign; + ScsiDiskDevice->BlkIo.Reset = ScsiDiskReset; + ScsiDiskDevice->BlkIo.ReadBlocks = ScsiDiskReadBlocks; + ScsiDiskDevice->BlkIo.WriteBlocks = ScsiDiskWriteBlocks; + ScsiDiskDevice->BlkIo.FlushBlocks = ScsiDiskFlushBlocks; + ScsiDiskDevice->BlkIo2.Media = &ScsiDiskDevice->BlkIoMedia; + ScsiDiskDevice->BlkIo2.Reset = ScsiDiskResetEx; + ScsiDiskDevice->BlkIo2.ReadBlocksEx = ScsiDiskReadBlocksEx; + ScsiDiskDevice->BlkIo2.WriteBlocksEx = ScsiDiskWriteBlocksEx; + ScsiDiskDevice->BlkIo2.FlushBlocksEx = ScsiDiskFlushBlocksEx; + ScsiDiskDevice->EraseBlock.Revision = EFI_ERASE_BLOCK_PROTOCOL_REVISION; + ScsiDiskDevice->EraseBlock.EraseLengthGranularity = 1; + ScsiDiskDevice->EraseBlock.EraseBlocks = ScsiDiskEraseBlocks; + ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt = 1; + ScsiDiskDevice->BlockLimitsVpdSupported = FALSE; + ScsiDiskDevice->Handle = Controller; + InitializeListHead (&ScsiDiskDevice->AsyncTaskQueue); ScsiIo->GetDeviceType (ScsiIo, &(ScsiDiskDevice->DeviceType)); switch (ScsiDiskDevice->DeviceType) { @@ -323,6 +328,17 @@ ScsiDiskDriverBindingStart ( NULL ); if (!EFI_ERROR(Status)) { + if (DetermineInstallEraseBlock(ScsiDiskDevice, Controller)) { + Status = gBS->InstallProtocolInterface ( + &Controller, + &gEfiEraseBlockProtocolGuid, + EFI_NATIVE_INTERFACE, + &ScsiDiskDevice->EraseBlock + ); + if (EFI_ERROR(Status)) { + DEBUG ((EFI_D_ERROR, "ScsiDisk: Failed to install the Erase Block Protocol! Status = %r\n", Status)); + } + } ScsiDiskDevice->ControllerNameTable = NULL; AddUnicodeString2 ( "eng", @@ -340,7 +356,7 @@ ScsiDiskDriverBindingStart ( ); return EFI_SUCCESS; } - } + } } gBS->FreePool (ScsiDiskDevice->SenseData); @@ -352,7 +368,7 @@ ScsiDiskDriverBindingStart ( Controller ); return Status; - + } @@ -364,7 +380,7 @@ ScsiDiskDriverBindingStart ( restrictions for this service. DisconnectController() must follow these calling restrictions. If any other agent wishes to call Stop() it must also follow these calling restrictions. - + @param This Protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of @@ -384,9 +400,10 @@ ScsiDiskDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_BLOCK_IO_PROTOCOL *BlkIo; - 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, @@ -405,7 +422,30 @@ ScsiDiskDriverBindingStop ( // // Wait for the BlockIo2 requests queue to become empty // - while (!IsListEmpty (&ScsiDiskDevice->BlkIo2Queue)); + while (!IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue)); + + // + // If Erase Block Protocol is installed, then uninstall this protocol. + // + Status = gBS->OpenProtocol ( + Controller, + &gEfiEraseBlockProtocolGuid, + (VOID **) &EraseBlock, + This->DriverBindingHandle, + Controller, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (!EFI_ERROR (Status)) { + Status = gBS->UninstallProtocolInterface ( + Controller, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock + ); + if (EFI_ERROR (Status)) { + return Status; + } + } Status = gBS->UninstallMultipleProtocolInterfaces ( Controller, @@ -528,6 +568,7 @@ ScsiDiskReadBlocks ( MediaChange = FALSE; OldTpl = gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This); + Media = ScsiDiskDevice->BlkIo.Media; if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { @@ -550,14 +591,25 @@ ScsiDiskReadBlocks ( &ScsiDiskDevice->BlkIo2, &ScsiDiskDevice->BlkIo2 ); - Status = EFI_MEDIA_CHANGED; + if (DetermineInstallEraseBlock(ScsiDiskDevice, ScsiDiskDevice->Handle)) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock, + &ScsiDiskDevice->EraseBlock + ); + } + if (Media->MediaPresent) { + Status = EFI_MEDIA_CHANGED; + } else { + Status = EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media = ScsiDiskDevice->BlkIo.Media; BlockSize = Media->BlockSize; NumberOfBlocks = BufferSize / BlockSize; @@ -652,6 +704,7 @@ ScsiDiskWriteBlocks ( MediaChange = FALSE; OldTpl = gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This); + Media = ScsiDiskDevice->BlkIo.Media; if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { @@ -674,14 +727,25 @@ ScsiDiskWriteBlocks ( &ScsiDiskDevice->BlkIo2, &ScsiDiskDevice->BlkIo2 ); - Status = EFI_MEDIA_CHANGED; + if (DetermineInstallEraseBlock(ScsiDiskDevice, ScsiDiskDevice->Handle)) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock, + &ScsiDiskDevice->EraseBlock + ); + } + if (Media->MediaPresent) { + Status = EFI_MEDIA_CHANGED; + } else { + Status = EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media = ScsiDiskDevice->BlkIo.Media; BlockSize = Media->BlockSize; NumberOfBlocks = BufferSize / BlockSize; @@ -866,6 +930,7 @@ ScsiDiskReadBlocksEx ( MediaChange = FALSE; OldTpl = gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media = ScsiDiskDevice->BlkIo.Media; if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { @@ -888,14 +953,25 @@ ScsiDiskReadBlocksEx ( &ScsiDiskDevice->BlkIo2, &ScsiDiskDevice->BlkIo2 ); - Status = EFI_MEDIA_CHANGED; + if (DetermineInstallEraseBlock(ScsiDiskDevice, ScsiDiskDevice->Handle)) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock, + &ScsiDiskDevice->EraseBlock + ); + } + if (Media->MediaPresent) { + Status = EFI_MEDIA_CHANGED; + } else { + Status = EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media = ScsiDiskDevice->BlkIo2.Media; BlockSize = Media->BlockSize; NumberOfBlocks = BufferSize / BlockSize; @@ -1017,6 +1093,7 @@ ScsiDiskWriteBlocksEx ( MediaChange = FALSE; OldTpl = gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media = ScsiDiskDevice->BlkIo.Media; if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { @@ -1039,14 +1116,25 @@ ScsiDiskWriteBlocksEx ( &ScsiDiskDevice->BlkIo2, &ScsiDiskDevice->BlkIo2 ); - Status = EFI_MEDIA_CHANGED; + if (DetermineInstallEraseBlock(ScsiDiskDevice, ScsiDiskDevice->Handle)) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock, + &ScsiDiskDevice->EraseBlock + ); + } + if (Media->MediaPresent) { + Status = EFI_MEDIA_CHANGED; + } else { + Status = EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media = ScsiDiskDevice->BlkIo2.Media; BlockSize = Media->BlockSize; NumberOfBlocks = BufferSize / BlockSize; @@ -1158,6 +1246,7 @@ ScsiDiskFlushBlocksEx ( MediaChange = FALSE; OldTpl = gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media = ScsiDiskDevice->BlkIo.Media; if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { @@ -1180,13 +1269,23 @@ ScsiDiskFlushBlocksEx ( &ScsiDiskDevice->BlkIo2, &ScsiDiskDevice->BlkIo2 ); - Status = EFI_MEDIA_CHANGED; + if (DetermineInstallEraseBlock(ScsiDiskDevice, ScsiDiskDevice->Handle)) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock, + &ScsiDiskDevice->EraseBlock + ); + } + if (Media->MediaPresent) { + Status = EFI_MEDIA_CHANGED; + } else { + Status = EFI_NO_MEDIA; + } goto Done; } } - Media = ScsiDiskDevice->BlkIo2.Media; - if (!(Media->MediaPresent)) { Status = EFI_NO_MEDIA; goto Done; @@ -1200,7 +1299,7 @@ ScsiDiskFlushBlocksEx ( // // Wait for the BlockIo2 requests queue to become empty // - while (!IsListEmpty (&ScsiDiskDevice->BlkIo2Queue)); + while (!IsListEmpty (&ScsiDiskDevice->AsyncTaskQueue)); Status = EFI_SUCCESS; @@ -1218,12 +1317,410 @@ Done: } +/** + Internal helper notify function which process the result of an asynchronous + SCSI UNMAP Command and signal the event passed from EraseBlocks. + + @param Event The instance of EFI_EVENT. + @param Context The parameter passed in. + +**/ +VOID +EFIAPI +ScsiDiskAsyncUnmapNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + SCSI_ERASEBLK_REQUEST *EraseBlkReq; + EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket; + EFI_ERASE_BLOCK_TOKEN *Token; + EFI_STATUS Status; + + gBS->CloseEvent (Event); + + EraseBlkReq = (SCSI_ERASEBLK_REQUEST *) Context; + CommandPacket = &EraseBlkReq->CommandPacket; + Token = EraseBlkReq->Token; + Token->TransactionStatus = EFI_SUCCESS; + + Status = CheckHostAdapterStatus (CommandPacket->HostAdapterStatus); + if (EFI_ERROR(Status)) { + DEBUG (( + EFI_D_ERROR, + "ScsiDiskAsyncUnmapNotify: Host adapter indicating error status 0x%x.\n", + CommandPacket->HostAdapterStatus + )); + + Token->TransactionStatus = Status; + goto Done; + } + + Status = CheckTargetStatus (CommandPacket->TargetStatus); + if (EFI_ERROR(Status)) { + DEBUG (( + EFI_D_ERROR, + "ScsiDiskAsyncUnmapNotify: Target indicating error status 0x%x.\n", + CommandPacket->HostAdapterStatus + )); + + Token->TransactionStatus = Status; + goto Done; + } + +Done: + RemoveEntryList (&EraseBlkReq->Link); + FreePool (CommandPacket->OutDataBuffer); + FreePool (EraseBlkReq->CommandPacket.Cdb); + FreePool (EraseBlkReq); + + gBS->SignalEvent (Token->Event); +} + +/** + Require the device server to cause one or more LBAs to be unmapped. + + @param ScsiDiskDevice The pointer of ScsiDiskDevice. + @param Lba The start block number. + @param Blocks Total block number to be unmapped. + @param Token The pointer to the token associated with the + non-blocking erase block request. + + @retval EFI_SUCCESS Target blocks have been successfully unmapped. + @retval EFI_DEVICE_ERROR Fail to unmap the target blocks. + +**/ +EFI_STATUS +ScsiDiskUnmap ( + IN SCSI_DISK_DEV *ScsiDiskDevice, + IN UINT64 Lba, + IN UINTN Blocks, + IN EFI_ERASE_BLOCK_TOKEN *Token OPTIONAL + ) +{ + EFI_SCSI_IO_PROTOCOL *ScsiIo; + SCSI_ERASEBLK_REQUEST *EraseBlkReq; + EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket; + EFI_SCSI_DISK_UNMAP_BLOCK_DESP *BlkDespPtr; + EFI_STATUS Status; + EFI_STATUS ReturnStatus; + UINT8 *Cdb; + UINT32 MaxLbaCnt; + UINT32 MaxBlkDespCnt; + UINT32 BlkDespCnt; + UINT16 UnmapParamListLen; + VOID *UnmapParamList; + EFI_EVENT AsyncUnmapEvent; + EFI_TPL OldTpl; + + ScsiIo = ScsiDiskDevice->ScsiIo; + MaxLbaCnt = ScsiDiskDevice->UnmapInfo.MaxLbaCnt; + MaxBlkDespCnt = ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt; + EraseBlkReq = NULL; + UnmapParamList = NULL; + AsyncUnmapEvent = NULL; + ReturnStatus = EFI_SUCCESS; + + if (Blocks / (UINTN) MaxLbaCnt > MaxBlkDespCnt) { + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + + EraseBlkReq = AllocateZeroPool (sizeof (SCSI_ERASEBLK_REQUEST)); + if (EraseBlkReq == NULL) { + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + + EraseBlkReq->CommandPacket.Cdb = AllocateZeroPool (0xA); + if (EraseBlkReq->CommandPacket.Cdb == NULL) { + ReturnStatus = EFI_DEVICE_ERROR; + 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); + if (UnmapParamList == NULL) { + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + + *((UINT16 *)UnmapParamList) = SwapBytes16 (UnmapParamListLen - 2); + *((UINT16 *)UnmapParamList + 1) = SwapBytes16 (UnmapParamListLen - sizeof (EFI_SCSI_DISK_UNMAP_PARAM_LIST_HEADER)); + + BlkDespPtr = (EFI_SCSI_DISK_UNMAP_BLOCK_DESP *)((UINT8 *)UnmapParamList + sizeof (EFI_SCSI_DISK_UNMAP_PARAM_LIST_HEADER)); + while (Blocks > 0) { + if (Blocks > MaxLbaCnt) { + *(UINT64 *)(&BlkDespPtr->Lba) = SwapBytes64 (Lba); + *(UINT32 *)(&BlkDespPtr->BlockNum) = SwapBytes32 (MaxLbaCnt); + Blocks -= MaxLbaCnt; + Lba += MaxLbaCnt; + } else { + *(UINT64 *)(&BlkDespPtr->Lba) = SwapBytes64 (Lba); + *(UINT32 *)(&BlkDespPtr->BlockNum) = SwapBytes32 ((UINT32) Blocks); + Blocks = 0; + } + + BlkDespPtr++; + } + + CommandPacket = &EraseBlkReq->CommandPacket; + CommandPacket->Timeout = SCSI_DISK_TIMEOUT; + CommandPacket->OutDataBuffer = UnmapParamList; + CommandPacket->OutTransferLength = UnmapParamListLen; + CommandPacket->CdbLength = 0xA; + CommandPacket->DataDirection = EFI_SCSI_DATA_OUT; + // + // Fill Cdb for UNMAP Command + // + Cdb = CommandPacket->Cdb; + Cdb[0] = EFI_SCSI_OP_UNMAP; + WriteUnaligned16 ((UINT16 *)&Cdb[7], SwapBytes16 (UnmapParamListLen)); + + if ((Token != NULL) && (Token->Event != NULL)) { + // + // Non-blocking UNMAP request + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + ScsiDiskAsyncUnmapNotify, + EraseBlkReq, + &AsyncUnmapEvent + ); + if (EFI_ERROR(Status)) { + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); + InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &EraseBlkReq->Link); + gBS->RestoreTPL (OldTpl); + + EraseBlkReq->Token = Token; + + Status = ScsiIo->ExecuteScsiCommand ( + ScsiIo, + CommandPacket, + AsyncUnmapEvent + ); + if (EFI_ERROR(Status)) { + ReturnStatus = EFI_DEVICE_ERROR; + + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); + RemoveEntryList (&EraseBlkReq->Link); + gBS->RestoreTPL (OldTpl); + + goto Done; + } else { + // + // Directly return if the non-blocking UNMAP request is queued. + // + return EFI_SUCCESS; + } + } else { + // + // Blocking UNMAP request + // + Status = ScsiIo->ExecuteScsiCommand ( + ScsiIo, + CommandPacket, + NULL + ); + if (EFI_ERROR(Status)) { + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + } + + // + // Only blocking UNMAP request will reach here. + // + Status = CheckHostAdapterStatus (CommandPacket->HostAdapterStatus); + if (EFI_ERROR(Status)) { + DEBUG (( + EFI_D_ERROR, + "ScsiDiskUnmap: Host adapter indicating error status 0x%x.\n", + CommandPacket->HostAdapterStatus + )); + + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + + Status = CheckTargetStatus (CommandPacket->TargetStatus); + if (EFI_ERROR(Status)) { + DEBUG (( + EFI_D_ERROR, + "ScsiDiskUnmap: Target indicating error status 0x%x.\n", + CommandPacket->HostAdapterStatus + )); + + ReturnStatus = EFI_DEVICE_ERROR; + goto Done; + } + +Done: + if (EraseBlkReq != NULL) { + if (EraseBlkReq->CommandPacket.Cdb != NULL) { + FreePool (EraseBlkReq->CommandPacket.Cdb); + } + FreePool (EraseBlkReq); + } + + if (UnmapParamList != NULL) { + FreePool (UnmapParamList); + } + + if (AsyncUnmapEvent != NULL) { + gBS->CloseEvent (AsyncUnmapEvent); + } + + return ReturnStatus; +} + +/** + Erase a specified number of device blocks. + + @param[in] This Indicates a pointer to the calling context. + @param[in] MediaId The media ID that the erase request is for. + @param[in] Lba The starting logical block address to be + erased. The caller is responsible for erasing + only legitimate locations. + @param[in, out] Token A pointer to the token associated with the + transaction. + @param[in] Size The size in bytes to be erased. This must be + a multiple of the physical block size of the + device. + + @retval EFI_SUCCESS The erase request was queued if Event is not + NULL. The data was erased correctly to the + device if the Event is NULL.to the device. + @retval EFI_WRITE_PROTECTED The device cannot be erased due to write + protection. + @retval EFI_DEVICE_ERROR The device reported an error while attempting + to perform the erase operation. + @retval EFI_INVALID_PARAMETER The erase request contains LBAs that are not + valid. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. + +**/ +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 + ) +{ + SCSI_DISK_DEV *ScsiDiskDevice; + EFI_BLOCK_IO_MEDIA *Media; + EFI_STATUS Status; + UINTN BlockSize; + UINTN NumberOfBlocks; + BOOLEAN MediaChange; + EFI_TPL OldTpl; + + MediaChange = FALSE; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + ScsiDiskDevice = SCSI_DISK_DEV_FROM_ERASEBLK (This); + + if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { + Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange); + if (EFI_ERROR (Status)) { + Status = EFI_DEVICE_ERROR; + goto Done; + } + + if (MediaChange) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiBlockIoProtocolGuid, + &ScsiDiskDevice->BlkIo, + &ScsiDiskDevice->BlkIo + ); + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiBlockIo2ProtocolGuid, + &ScsiDiskDevice->BlkIo2, + &ScsiDiskDevice->BlkIo2 + ); + if (DetermineInstallEraseBlock(ScsiDiskDevice, ScsiDiskDevice->Handle)) { + gBS->ReinstallProtocolInterface ( + ScsiDiskDevice->Handle, + &gEfiEraseBlockProtocolGuid, + &ScsiDiskDevice->EraseBlock, + &ScsiDiskDevice->EraseBlock + ); + } + Status = EFI_MEDIA_CHANGED; + goto Done; + } + } + // + // Get the intrinsic block size + // + Media = ScsiDiskDevice->BlkIo.Media; + + if (!(Media->MediaPresent)) { + Status = EFI_NO_MEDIA; + goto Done; + } + + if (MediaId != Media->MediaId) { + Status = EFI_MEDIA_CHANGED; + goto Done; + } + + if (Media->ReadOnly) { + Status = EFI_WRITE_PROTECTED; + goto Done; + } + + if (Size == 0) { + if ((Token != NULL) && (Token->Event != NULL)) { + Token->TransactionStatus = EFI_SUCCESS; + gBS->SignalEvent (Token->Event); + } + Status = EFI_SUCCESS; + goto Done; + } + + BlockSize = Media->BlockSize; + if ((Size % BlockSize) != 0) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + + NumberOfBlocks = Size / BlockSize; + if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + + if ((Token != NULL) && (Token->Event != NULL)) { + Status = ScsiDiskUnmap (ScsiDiskDevice, Lba, NumberOfBlocks, Token); + } else { + Status = ScsiDiskUnmap (ScsiDiskDevice, Lba, NumberOfBlocks, NULL); + } + +Done: + gBS->RestoreTPL (OldTpl); + return Status; +} + + /** Detect Device and read out capacity ,if error occurs, parse the sense key. @param ScsiDiskDevice The pointer of SCSI_DISK_DEV @param MustReadCapacity The flag about reading device capacity - @param MediaChange The pointer of flag indicates if media has changed + @param MediaChange The pointer of flag indicates if media has changed @retval EFI_DEVICE_ERROR Indicates that error occurs @retval EFI_SUCCESS Successfully to detect media @@ -1358,7 +1855,7 @@ ScsiDiskDetectMedia ( } else { break; } - } else { + } else { Retry++; if (!NeedRetry || (Retry >= MaxRetry)) { goto EXIT; @@ -1562,9 +2059,42 @@ ScsiDiskInquiryDevice ( EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD ); if (!EFI_ERROR (Status)) { - ScsiDiskDevice->BlkIo.Media->OptimalTransferLengthGranularity = + ScsiDiskDevice->BlkIo.Media->OptimalTransferLengthGranularity = (BlockLimits->OptimalTransferLengthGranularity2 << 8) | BlockLimits->OptimalTransferLengthGranularity1; + + ScsiDiskDevice->UnmapInfo.MaxLbaCnt = + (BlockLimits->MaximumUnmapLbaCount4 << 24) | + (BlockLimits->MaximumUnmapLbaCount3 << 16) | + (BlockLimits->MaximumUnmapLbaCount2 << 8) | + BlockLimits->MaximumUnmapLbaCount1; + ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt = + (BlockLimits->MaximumUnmapBlockDescriptorCount4 << 24) | + (BlockLimits->MaximumUnmapBlockDescriptorCount3 << 16) | + (BlockLimits->MaximumUnmapBlockDescriptorCount2 << 8) | + BlockLimits->MaximumUnmapBlockDescriptorCount1; + ScsiDiskDevice->EraseBlock.EraseLengthGranularity = + (BlockLimits->OptimalUnmapGranularity4 << 24) | + (BlockLimits->OptimalUnmapGranularity3 << 16) | + (BlockLimits->OptimalUnmapGranularity2 << 8) | + BlockLimits->OptimalUnmapGranularity1; + if (BlockLimits->UnmapGranularityAlignmentValid != 0) { + ScsiDiskDevice->UnmapInfo.GranularityAlignment = + (BlockLimits->UnmapGranularityAlignment4 << 24) | + (BlockLimits->UnmapGranularityAlignment3 << 16) | + (BlockLimits->UnmapGranularityAlignment2 << 8) | + BlockLimits->UnmapGranularityAlignment1; + } + + if (ScsiDiskDevice->EraseBlock.EraseLengthGranularity == 0) { + // + // A value of 0 indicates that the optimal unmap granularity is + // not reported. + // + ScsiDiskDevice->EraseBlock.EraseLengthGranularity = 1; + } + + ScsiDiskDevice->BlockLimitsVpdSupported = TRUE; } FreeAlignedBuffer (BlockLimits, sizeof (EFI_SCSI_BLOCK_LIMITS_VPD_PAGE)); @@ -1581,7 +2111,7 @@ ScsiDiskInquiryDevice ( } 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; @@ -1617,7 +2147,7 @@ ScsiDiskInquiryDevice ( *NeedRetry = FALSE; return EFI_DEVICE_ERROR; } - + // // if goes here, meant ScsiInquiryCommand() failed. // if ScsiDiskRequestSenseKeys() succeeds at last, @@ -1773,7 +2303,7 @@ ScsiDiskTestUnitReady ( @param ScsiDiskDevice The pointer of SCSI_DISK_DEV @param SenseData The pointer of EFI_SCSI_SENSE_DATA - @param NumberOfSenseKeys The number of sense key + @param NumberOfSenseKeys The number of sense key @param Action The pointer of action which indicates what is need to do next @retval EFI_DEVICE_ERROR Indicates that error occurs @@ -1914,7 +2444,7 @@ ScsiDiskReadCapacity ( *NeedRetry = FALSE; // - // submit Read Capacity(10) Command. If it returns capacity of FFFFFFFFh, + // submit Read Capacity(10) Command. If it returns capacity of FFFFFFFFh, // 16 byte command should be used to access large hard disk >2TB // CommandStatus = ScsiReadCapacityCommand ( @@ -1978,12 +2508,12 @@ ScsiDiskReadCapacity ( // 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 @@ -2006,7 +2536,7 @@ ScsiDiskReadCapacity ( *NeedRetry = FALSE; return EFI_DEVICE_ERROR; } - + // // if goes here, meant ScsiReadCapacityCommand() failed. // if ScsiDiskRequestSenseKeys() succeeds at last, @@ -2086,7 +2616,7 @@ CheckHostAdapterStatus ( @param TargetStatus Target status @retval EFI_NOT_READY Device is NOT ready. - @retval EFI_DEVICE_ERROR + @retval EFI_DEVICE_ERROR @retval EFI_SUCCESS **/ @@ -2178,20 +2708,20 @@ ScsiDiskRequestSenseKeys ( ); 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; } @@ -2213,7 +2743,7 @@ ScsiDiskRequestSenseKeys ( // no more sense key or number of sense keys exceeds predefined, // skip the loop. // - if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) || + if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) || (*NumberOfSenseKeys == ScsiDiskDevice->SenseDataNumber)) { SenseReq = FALSE; } @@ -2243,17 +2773,20 @@ GetMediaInfo ( UINT8 *Ptr; if (!ScsiDiskDevice->Cdb16Byte) { - ScsiDiskDevice->BlkIo.Media->LastBlock = (Capacity10->LastLba3 << 24) | + 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->BlockSize2 << 16) | (Capacity10->BlockSize1 << 8) | Capacity10->BlockSize0; ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = 0; ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 0; + if (!ScsiDiskDevice->BlockLimitsVpdSupported) { + ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32) ScsiDiskDevice->BlkIo.Media->LastBlock; + } } else { Ptr = (UINT8*)&ScsiDiskDevice->BlkIo.Media->LastBlock; *Ptr++ = Capacity16->LastLba0; @@ -2266,13 +2799,20 @@ GetMediaInfo ( *Ptr = Capacity16->LastLba7; ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity16->BlockSize3 << 24) | - (Capacity16->BlockSize2 << 16) | + (Capacity16->BlockSize2 << 16) | (Capacity16->BlockSize1 << 8) | Capacity16->BlockSize0; ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = (Capacity16->LowestAlignLogic2 << 8) | Capacity16->LowestAlignLogic1; ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = (1 << Capacity16->LogicPerPhysical); + if (!ScsiDiskDevice->BlockLimitsVpdSupported) { + if (ScsiDiskDevice->BlkIo.Media->LastBlock > (UINT32) -1) { + ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32) -1; + } else { + ScsiDiskDevice->UnmapInfo.MaxLbaCnt = (UINT32) ScsiDiskDevice->BlkIo.Media->LastBlock; + } + } } ScsiDiskDevice->BlkIo.Media->MediaPresent = TRUE; @@ -2330,7 +2870,7 @@ ScsiDiskReadSectors ( BlocksRemaining = NumberOfBlocks; BlockSize = ScsiDiskDevice->BlkIo.Media->BlockSize; - + // // limit the data bytes that can be transferred by one Read(10) or Read(16) Command // @@ -2574,7 +3114,7 @@ ScsiDiskWriteSectors ( &ByteCount, Lba, SectorCount - ); + ); } if (!EFI_ERROR (Status)) { break; @@ -2668,7 +3208,7 @@ ScsiDiskAsyncReadSectors ( BlkIo2Req->Token = Token; OldTpl = gBS->RaiseTPL (TPL_NOTIFY); - InsertTailList (&ScsiDiskDevice->BlkIo2Queue, &BlkIo2Req->Link); + InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &BlkIo2Req->Link); gBS->RestoreTPL (OldTpl); InitializeListHead (&BlkIo2Req->ScsiRWQueue); @@ -2885,7 +3425,7 @@ ScsiDiskAsyncWriteSectors ( BlkIo2Req->Token = Token; OldTpl = gBS->RaiseTPL (TPL_NOTIFY); - InsertTailList (&ScsiDiskDevice->BlkIo2Queue, &BlkIo2Req->Link); + InsertTailList (&ScsiDiskDevice->AsyncTaskQueue, &BlkIo2Req->Link); gBS->RestoreTPL (OldTpl); InitializeListHead (&BlkIo2Req->ScsiRWQueue); @@ -4454,7 +4994,7 @@ ScsiDiskIsHardwareError ( SensePtr = SenseData; for (Index = 0; Index < SenseCounts; Index++) { - + // // Sense Key is EFI_SCSI_SK_HARDWARE_ERROR (0x4) // @@ -4531,7 +5071,7 @@ ScsiDiskIsResetBefore ( 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) @@ -4552,7 +5092,7 @@ ScsiDiskIsResetBefore ( @param SenseData The pointer of EFI_SCSI_SENSE_DATA @param SenseCounts The number of sense key - @param RetryLater The flag means if need a retry + @param RetryLater The flag means if need a retry @retval TRUE Drive is ready. @retval FALSE Drive is NOT ready. @@ -4647,7 +5187,7 @@ ScsiDiskHaveSenseKey ( SensePtr = SenseData; for (Index = 0; Index < SenseCounts; Index++) { - + // // Sense Key is SK_NO_SENSE (0x0) // @@ -4694,18 +5234,18 @@ ReleaseScsiDiskDeviceResources ( /** Determine if Block Io & Block Io2 should be produced. - + @param ChildHandle Child Handle to retrieve Parent information. - + @retval TRUE Should produce Block Io & Block Io2. @retval FALSE Should not produce Block Io & Block Io2. -**/ +**/ BOOLEAN DetermineInstallBlockIo ( IN EFI_HANDLE ChildHandle - ) + ) { EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru; EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru; @@ -4731,7 +5271,7 @@ DetermineInstallBlockIo ( return TRUE; } } - + return FALSE; } @@ -4740,23 +5280,23 @@ DetermineInstallBlockIo ( specified by ProtocolGuid is present on a ControllerHandle and opened by ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. If the ControllerHandle is found, then the protocol specified by ProtocolGuid - will be opened on it. - + will be opened on it. + @param ProtocolGuid ProtocolGuid pointer. @param ChildHandle Child Handle to retrieve Parent information. - -**/ + +**/ VOID * EFIAPI GetParentProtocol ( IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE ChildHandle - ) + ) { UINTN Index; UINTN HandleCount; - VOID *Interface; + VOID *Interface; EFI_STATUS Status; EFI_HANDLE *HandleBuffer; @@ -4776,7 +5316,7 @@ GetParentProtocol ( } // - // Iterate to find who is parent handle that is opened with ProtocolGuid by ChildHandle + // Iterate to find who is parent handle that is opened with ProtocolGuid by ChildHandle // for (Index = 0; Index < HandleCount; Index++) { Status = EfiTestChildHandle (HandleBuffer[Index], ChildHandle, ProtocolGuid); @@ -4791,11 +5331,144 @@ GetParentProtocol ( gBS->FreePool (HandleBuffer); return NULL; -} +} + +/** + Determine if EFI Erase Block Protocol should be produced. + + @param ScsiDiskDevice The pointer of SCSI_DISK_DEV. + @param ChildHandle Handle of device. + + @retval TRUE Should produce EFI Erase Block Protocol. + @retval FALSE Should not produce EFI Erase Block Protocol. + +**/ +BOOLEAN +DetermineInstallEraseBlock ( + 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; + + UfsDevice = FALSE; + RetVal = TRUE; + CapacityData16 = NULL; + + Status = gBS->HandleProtocol ( + ChildHandle, + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePathNode + ); + // + // Device Path protocol must be installed on the device handle. + // + ASSERT_EFI_ERROR (Status); + + while (!IsDevicePathEndType (DevicePathNode)) { + // + // For now, only support Erase Block Protocol on UFS devices. + // + if ((DevicePathNode->Type == MESSAGING_DEVICE_PATH) && + (DevicePathNode->SubType == MSG_UFS_DP)) { + UfsDevice = TRUE; + break; + } + + DevicePathNode = NextDevicePathNode (DevicePathNode); + } + if (!UfsDevice) { + RetVal = FALSE; + goto Done; + } + + // + // Check whether the erase functionality is enabled on the UFS device. + // + CapacityData16 = AllocateAlignedBuffer (ScsiDiskDevice, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16)); + if (CapacityData16 == NULL) { + RetVal = FALSE; + goto Done; + } + + SenseDataLength = 0; + DataLength16 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA16); + ZeroMem (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16)); + + CommandStatus = ScsiReadCapacity16Command ( + ScsiDiskDevice->ScsiIo, + SCSI_DISK_TIMEOUT, + NULL, + &SenseDataLength, + &HostAdapterStatus, + &TargetStatus, + (VOID *) CapacityData16, + &DataLength16, + FALSE + ); + + if (CommandStatus == EFI_SUCCESS) { + // + // Universal Flash Storage (UFS) Version 2.0 + // Section 11.3.9.2 + // Bits TPE and TPRZ should both be set to enable the erase feature on UFS. + // + if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) || + ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) { + DEBUG (( + EFI_D_VERBOSE, + "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n", + CapacityData16->LowestAlignLogic2 + )); + + RetVal = FALSE; + goto Done; + } + } else { + DEBUG (( + EFI_D_VERBOSE, + "ScsiDisk EraseBlock: ReadCapacity16 failed with status %r.\n", + CommandStatus + )); + + RetVal = FALSE; + goto Done; + } + + // + // Check whether the UFS device server implements the UNMAP command. + // + if ((ScsiDiskDevice->UnmapInfo.MaxLbaCnt == 0) || + (ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt == 0)) { + DEBUG (( + EFI_D_VERBOSE, + "ScsiDisk EraseBlock: The device server does not implement the UNMAP command.\n" + )); + + RetVal = FALSE; + goto Done; + } + +Done: + if (CapacityData16 != NULL) { + FreeAlignedBuffer (CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16)); + } + + return RetVal; +} /** Provides inquiry information for the controller type. - + This function is used by the IDE bus driver to get inquiry data. Data format of Identify data is defined by the Interface GUID. @@ -4804,9 +5477,9 @@ GetParentProtocol ( @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size. @retval EFI_SUCCESS The command was accepted without any errors. - @retval EFI_NOT_FOUND Device does not support this data class - @retval EFI_DEVICE_ERROR Error reading InquiryData from device - @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough + @retval EFI_NOT_FOUND Device does not support this data class + @retval EFI_DEVICE_ERROR Error reading InquiryData from device + @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough **/ EFI_STATUS @@ -4838,16 +5511,16 @@ ScsiDiskInfoInquiry ( This function is used by the IDE bus driver to get identify data. Data format of Identify data is defined by the Interface GUID. - @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL + @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. @param[in, out] IdentifyData Pointer to a buffer for the identify data. @param[in, out] IdentifyDataSize Pointer to the value for the identify data size. @retval EFI_SUCCESS The command was accepted without any errors. - @retval EFI_NOT_FOUND Device does not support this data class - @retval EFI_DEVICE_ERROR Error reading IdentifyData from device - @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough + @retval EFI_NOT_FOUND Device does not support this data class + @retval EFI_DEVICE_ERROR Error reading IdentifyData from device + @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough **/ EFI_STATUS @@ -4863,7 +5536,7 @@ ScsiDiskInfoIdentify ( if (CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid) || CompareGuid (&This->Interface, &gEfiDiskInfoUfsInterfaceGuid)) { // - // Physical SCSI bus does not support this data class. + // Physical SCSI bus does not support this data class. // return EFI_NOT_FOUND; } @@ -4881,8 +5554,8 @@ ScsiDiskInfoIdentify ( /** Provides sense data information for the controller type. - - This function is used by the IDE bus driver to get sense data. + + This function is used by the IDE bus driver to get sense data. Data format of Sense data is defined by the Interface GUID. @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. @@ -4912,7 +5585,7 @@ ScsiDiskInfoSenseData ( /** This function is used by the IDE bus driver to get controller information. - @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. + @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary. @param[out] IdeDevice Pointer to the Ide Device number. Master or slave. @@ -4953,11 +5626,11 @@ ScsiDiskInfoWhichIde ( via SCSI Request Packet. @param ScsiDiskDevice The pointer of SCSI_DISK_DEV - + @retval EFI_SUCCESS The ATAPI device identify data were retrieved successfully. @retval others Some error occurred during the identification that ATAPI device. -**/ +**/ EFI_STATUS AtapiIdentifyDevice ( IN OUT SCSI_DISK_DEV *ScsiDiskDevice @@ -4993,8 +5666,8 @@ AtapiIdentifyDevice ( @param ScsiDiskDevice The pointer of SCSI_DISK_DEV. @param ChildHandle Child handle to install DiskInfo protocol. - -**/ + +**/ VOID InitializeInstallDiskInfo ( IN SCSI_DISK_DEV *ScsiDiskDevice, @@ -5010,7 +5683,7 @@ InitializeInstallDiskInfo ( Status = gBS->HandleProtocol (ChildHandle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePathNode); // - // Device Path protocol must be installed on the device handle. + // Device Path protocol must be installed on the device handle. // ASSERT_EFI_ERROR (Status); // @@ -5042,7 +5715,7 @@ InitializeInstallDiskInfo ( ScsiDiskDevice->Channel = AtapiDevicePath->PrimarySecondary; ScsiDiskDevice->Device = AtapiDevicePath->SlaveMaster; // - // Update the DiskInfo.Interface to IDE interface GUID for the physical ATAPI device. + // Update the DiskInfo.Interface to IDE interface GUID for the physical ATAPI device. // CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoIdeInterfaceGuid); } else { @@ -5053,7 +5726,7 @@ InitializeInstallDiskInfo ( ScsiDiskDevice->Channel = SataDevicePath->HBAPortNumber; ScsiDiskDevice->Device = SataDevicePath->PortMultiplierPortNumber; // - // Update the DiskInfo.Interface to AHCI interface GUID for the physical AHCI device. + // Update the DiskInfo.Interface to AHCI interface GUID for the physical AHCI device. // CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoAhciInterfaceGuid); }