summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-01-25 11:33:37 +0000
committerlersek <lersek@Edk2>2016-01-25 11:33:37 +0000
commitf6a683e01b6053493cd98b9e3a4364ed8d1bde80 (patch)
tree9f29642976419931b78acea4324623bf1170ce0b /MdeModulePkg
parent4e50241273b7e01cf2d7eb22ebf9f6a9d045b00b (diff)
downloadedk2-f6a683e01b6053493cd98b9e3a4364ed8d1bde80.zip
edk2-f6a683e01b6053493cd98b9e3a4364ed8d1bde80.tar.gz
edk2-f6a683e01b6053493cd98b9e3a4364ed8d1bde80.tar.bz2
MdeModulePkg/.../IdeMode: correctly report length of returned data
For some SCSI commands, notably INQUIRY, it's relatively common for the device to provide less data than we intended to read, and for this reason EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET makes InTransferLength and OutTransferLength read-write. Make ATAPI aware of this. This makes it possible to handle EFI_NOT_READY always, not just for read as done in r19685. I've chosen to use a break statement instead of calling CheckStatusRegister directly; the break statement reaches a pre-existing call the CheckStatusRegister function. This ensures that the assignment to *ByteCount is not missed, and adds a further sanity check to DRQClear. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19737 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
index 320ee90..6478f7b 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
@@ -1936,7 +1936,7 @@ AtaPacketReadWrite (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN EFI_IDE_REGISTERS *IdeRegisters,
IN OUT VOID *Buffer,
- IN UINT64 ByteCount,
+ IN OUT UINT32 *ByteCount,
IN BOOLEAN Read,
IN UINT64 Timeout
)
@@ -1947,17 +1947,18 @@ AtaPacketReadWrite (
EFI_STATUS Status;
UINT16 *PtrBuffer;
+ PtrBuffer = Buffer;
+ RequiredWordCount = *ByteCount >> 1;
+
//
// No data transfer is premitted.
//
- if (ByteCount == 0) {
+ if (RequiredWordCount == 0) {
return EFI_SUCCESS;
}
- PtrBuffer = Buffer;
- RequiredWordCount = (UINT32)RShiftU64(ByteCount, 1);
//
- // ActuralWordCount means the word count of data really transferred.
+ // ActualWordCount means the word count of data really transferred.
//
ActualWordCount = 0;
@@ -1967,14 +1968,16 @@ AtaPacketReadWrite (
// to see whether indicates device is ready to transfer data.
//
Status = DRQReady2 (PciIo, IdeRegisters, Timeout);
- if ((Status == EFI_NOT_READY) && Read) {
- //
- // Device provided less data than we intended to read -- exit early.
- //
- return CheckStatusRegister (PciIo, IdeRegisters);
- }
if (EFI_ERROR (Status)) {
- return Status;
+ if (Status == EFI_NOT_READY) {
+ //
+ // Device provided less data than we intended to read, or wanted less
+ // data than we intended to write, but it may still be successful.
+ //
+ break;
+ } else {
+ return Status;
+ }
}
//
@@ -2040,6 +2043,7 @@ AtaPacketReadWrite (
return EFI_DEVICE_ERROR;
}
+ *ByteCount = ActualWordCount << 1;
return Status;
}
@@ -2138,7 +2142,7 @@ AtaPacketCommandExecute (
PciIo,
IdeRegisters,
Packet->InDataBuffer,
- Packet->InTransferLength,
+ &Packet->InTransferLength,
TRUE,
Packet->Timeout
);
@@ -2147,7 +2151,7 @@ AtaPacketCommandExecute (
PciIo,
IdeRegisters,
Packet->OutDataBuffer,
- Packet->OutTransferLength,
+ &Packet->OutTransferLength,
FALSE,
Packet->Timeout
);