mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
4e50241273
commit
f6a683e01b
|
@ -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,15 +1968,17 @@ 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)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get current data transfer size from Cylinder Registers.
|
||||
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue