X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FBus%2FScsi%2FScsiDisk%2FDxe%2FScsiDisk.c;h=9eac2c474deb944ec5f0727e0c36b98004ad5d79;hp=006cc73bcbcabb1c1918f542928effee484000bd;hb=9c198b406677e91274146dad8d0c723a68228d4e;hpb=f0ec738d392d85d8eb0cc77d66a2713076cb5ee7 diff --git a/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.c b/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.c index 006cc73bcb..9eac2c474d 100644 --- a/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.c +++ b/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2007, 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 @@ -19,36 +19,11 @@ Abstract: #include "ScsiDisk.h" -EFI_STATUS -EFIAPI -ScsiDiskDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -EFI_STATUS -EFIAPI -ScsiDiskDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -EFI_STATUS -EFIAPI -ScsiDiskDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = { ScsiDiskDriverBindingSupported, ScsiDiskDriverBindingStart, ScsiDiskDriverBindingStop, - 0x10, + 0xa, NULL, NULL }; @@ -357,17 +332,22 @@ Returns: { SCSI_DISK_DEV *ScsiDiskDevice; EFI_STATUS Status; + EFI_TPL OldTpl; + + OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK); ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (This); Status = ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo); if (!ExtendedVerification) { - return Status; + goto Done; } Status = ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo); +Done: + gBS->RestoreTPL (OldTpl); return Status; } @@ -414,6 +394,7 @@ Returns: UINTN BlockSize; UINTN NumberOfBlocks; BOOLEAN MediaChange; + EFI_TPL OldTpl; MediaChange = FALSE; if (!Buffer) { @@ -424,13 +405,16 @@ Returns: return EFI_SUCCESS; } + OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK); + ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (This); if (!IsDeviceFixed (ScsiDiskDevice)) { Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + Status = EFI_DEVICE_ERROR; + goto Done; } if (MediaChange) { @@ -451,27 +435,33 @@ Returns: NumberOfBlocks = BufferSize / BlockSize; if (!(Media->MediaPresent)) { - return EFI_NO_MEDIA; + Status = EFI_NO_MEDIA; + goto Done; } if (MediaId != Media->MediaId) { - return EFI_MEDIA_CHANGED; + Status = EFI_MEDIA_CHANGED; + goto Done; } if (BufferSize % BlockSize != 0) { - return EFI_BAD_BUFFER_SIZE; + Status = EFI_BAD_BUFFER_SIZE; + goto Done; } if (LBA > Media->LastBlock) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } if ((LBA + NumberOfBlocks - 1) > Media->LastBlock) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } // @@ -480,6 +470,8 @@ Returns: // Status = ScsiDiskReadSectors (ScsiDiskDevice, Buffer, LBA, NumberOfBlocks); +Done: + gBS->RestoreTPL (OldTpl); return Status; } @@ -526,6 +518,7 @@ Returns: UINTN BlockSize; UINTN NumberOfBlocks; BOOLEAN MediaChange; + EFI_TPL OldTpl; MediaChange = FALSE; if (!Buffer) { @@ -536,13 +529,16 @@ Returns: return EFI_SUCCESS; } + OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK); + ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (This); if (!IsDeviceFixed (ScsiDiskDevice)) { Status = ScsiDiskDetectMedia (ScsiDiskDevice, FALSE, &MediaChange); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + Status = EFI_DEVICE_ERROR; + goto Done; } if (MediaChange) { @@ -563,27 +559,33 @@ Returns: NumberOfBlocks = BufferSize / BlockSize; if (!(Media->MediaPresent)) { - return EFI_NO_MEDIA; + Status = EFI_NO_MEDIA; + goto Done; } if (MediaId != Media->MediaId) { - return EFI_MEDIA_CHANGED; + Status = EFI_MEDIA_CHANGED; + goto Done; } if (BufferSize % BlockSize != 0) { - return EFI_BAD_BUFFER_SIZE; + Status = EFI_BAD_BUFFER_SIZE; + goto Done; } if (LBA > Media->LastBlock) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } if ((LBA + NumberOfBlocks - 1) > Media->LastBlock) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } // // if all the parameters are valid, then perform read sectors command @@ -591,6 +593,9 @@ Returns: // Status = ScsiDiskWriteSectors (ScsiDiskDevice, Buffer, LBA, NumberOfBlocks); +Done: + gBS->RestoreTPL (OldTpl); + return Status; } @@ -874,43 +879,34 @@ Returns: &InquiryDataLength, FALSE ); - switch (Status) { - // - // no need to check HostAdapterStatus and TargetStatus - // - case EFI_SUCCESS: - case EFI_WARN_BUFFER_TOO_SMALL: + if ((Status == EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) { + // + // no need to check HostAdapterStatus and TargetStatus + // ParseInquiryData (ScsiDiskDevice); return EFI_SUCCESS; - - case EFI_NOT_READY: + } else if (Status == EFI_NOT_READY) { + // + // no need to check HostAdapterStatus and TargetStatus + // *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_INVALID_PARAMETER: - case EFI_UNSUPPORTED: + } else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) { + // + // no need to check HostAdapterStatus and TargetStatus + // *NeedRetry = FALSE; return EFI_DEVICE_ERROR; - + } // // go ahead to check HostAdapterStatus and TargetStatus // (EFI_TIMEOUT, EFI_DEVICE_ERROR) // - default: - break; - } - Status = CheckHostAdapterStatus (HostAdapterStatus); - switch (Status) { - case EFI_SUCCESS: - break; - - case EFI_TIMEOUT: - case EFI_NOT_READY: + if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) { *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { // // reset the scsi channel // @@ -920,19 +916,14 @@ Returns: } Status = CheckTargetStatus (TargetStatus); - switch (Status) { - case EFI_SUCCESS: - break; - - case EFI_NOT_READY: + if (Status == EFI_NOT_READY) { // // reset the scsi device // ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo); *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { *NeedRetry = FALSE; return EFI_DEVICE_ERROR; } @@ -1022,37 +1013,27 @@ ScsiDiskTestUnitReady ( &HostAdapterStatus, &TargetStatus ); - switch (Status) { - // - // no need to check HostAdapterStatus and TargetStatus - // - case EFI_NOT_READY: + if (Status == EFI_NOT_READY) { + // + // no need to check HostAdapterStatus and TargetStatus + // *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_INVALID_PARAMETER: - case EFI_UNSUPPORTED: + } else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) { + // + // no need to check HostAdapterStatus and TargetStatus + // *NeedRetry = FALSE; return EFI_DEVICE_ERROR; - + } // // go ahead to check HostAdapterStatus and TargetStatus // - default: - break; - } - Status = CheckHostAdapterStatus (HostAdapterStatus); - switch (Status) { - case EFI_SUCCESS: - break; - - case EFI_TIMEOUT: - case EFI_NOT_READY: + if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) { *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { // // reset the scsi channel // @@ -1062,19 +1043,14 @@ ScsiDiskTestUnitReady ( } Status = CheckTargetStatus (TargetStatus); - switch (Status) { - case EFI_SUCCESS: - break; - - case EFI_NOT_READY: + if (Status == EFI_NOT_READY) { // // reset the scsi device // ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo); *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { *NeedRetry = FALSE; return EFI_DEVICE_ERROR; } @@ -1258,42 +1234,35 @@ Returns: &DataLength, FALSE ); - switch (CommandStatus) { - // - // no need to check HostAdapterStatus and TargetStatus - // - case EFI_SUCCESS: + if (CommandStatus == EFI_SUCCESS) { + // + // no need to check HostAdapterStatus and TargetStatus + // GetMediaInfo (ScsiDiskDevice, &CapacityData); return EFI_SUCCESS; - - case EFI_NOT_READY: + } else if (CommandStatus == EFI_NOT_READY) { + // + // no need to check HostAdapterStatus and TargetStatus + // *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_INVALID_PARAMETER: - case EFI_UNSUPPORTED: + } else if ((CommandStatus == EFI_INVALID_PARAMETER) || (CommandStatus == EFI_UNSUPPORTED)) { + // + // no need to check HostAdapterStatus and TargetStatus + // *NeedRetry = FALSE; return EFI_DEVICE_ERROR; - + } // // go ahead to check HostAdapterStatus and TargetStatus // (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL) // - default: - break; - } - + Status = CheckHostAdapterStatus (HostAdapterStatus); - switch (Status) { - case EFI_SUCCESS: - break; - - case EFI_TIMEOUT: - case EFI_NOT_READY: + if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) { *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { // // reset the scsi channel // @@ -1303,19 +1272,14 @@ Returns: } Status = CheckTargetStatus (TargetStatus); - switch (Status) { - case EFI_SUCCESS: - break; - - case EFI_NOT_READY: + if (Status == EFI_NOT_READY) { // // reset the scsi device // ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo); *NeedRetry = TRUE; return EFI_DEVICE_ERROR; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { *NeedRetry = FALSE; return EFI_DEVICE_ERROR; } @@ -1506,40 +1470,20 @@ ScsiDiskRequestSenseKeys ( &HostAdapterStatus, &TargetStatus ); - switch (Status) { - - case EFI_SUCCESS: - - // - // fall through - // - case EFI_WARN_BUFFER_TOO_SMALL: + if ((Status == EFI_SUCCESS) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) { FallStatus = EFI_SUCCESS; - break; - - case EFI_TIMEOUT: - - // - // fall through - // - case EFI_NOT_READY: + } else if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) { *NeedRetry = TRUE; FallStatus = EFI_DEVICE_ERROR; - break; - - case EFI_INVALID_PARAMETER: - case EFI_UNSUPPORTED: + } else if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) { *NeedRetry = FALSE; FallStatus = EFI_DEVICE_ERROR; - break; - - case EFI_DEVICE_ERROR: + } else if (Status == EFI_DEVICE_ERROR) { if (AskResetIfError) { ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo); } FallStatus = EFI_DEVICE_ERROR; - break; } if (EFI_ERROR (FallStatus)) { @@ -1675,11 +1619,9 @@ Returns: UINT8 MaxRetry; BOOLEAN NeedRetry; EFI_SCSI_SENSE_DATA *SenseData; - UINT8 SenseDataLength; UINTN NumberOfSenseKeys; SenseData = NULL; - SenseDataLength = 0; NumberOfSenseKeys = 0; Status = EFI_SUCCESS; @@ -1789,11 +1731,9 @@ Returns: UINT8 MaxRetry; BOOLEAN NeedRetry; EFI_SCSI_SENSE_DATA *SenseData; - UINT8 SenseDataLength; UINTN NumberOfSenseKeys; SenseData = NULL; - SenseDataLength = 0; NumberOfSenseKeys = 0; Status = EFI_SUCCESS;