mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Better handling of invalid LBA values
This commit is contained in:
parent
dab9e7aaa2
commit
60154b7c26
|
@ -512,5 +512,6 @@ void ATA::HDD_SetErrorAtTransferEnd()
|
|||
//Write errored sector to LBA
|
||||
currSect++;
|
||||
HDD_SetLBA(currSect);
|
||||
Console.Error("DEV9: ATA: Transfer from invalid LBA %lu", currSect);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,11 +94,12 @@ void ATA::ATAreadDMA8Mem(u8* pMem, int size)
|
|||
if ((udmaMode >= 0) &&
|
||||
(dev9.if_ctrl & SPD_IF_ATA_DMAEN) != 0)
|
||||
{
|
||||
if (size == 0)
|
||||
if (size == 0 || nsector == -1)
|
||||
return;
|
||||
DevCon.WriteLn("DEV9: DMA read, size %i, transferred %i, total size %i", size, rdTransferred, nsector * 512);
|
||||
|
||||
//read
|
||||
size = std::min(size, nsector * 512 - rdTransferred);
|
||||
memcpy(pMem, &readBuffer[rdTransferred], size);
|
||||
|
||||
rdTransferred += size;
|
||||
|
@ -119,9 +120,12 @@ void ATA::ATAwriteDMA8Mem(u8* pMem, int size)
|
|||
if ((udmaMode >= 0) &&
|
||||
(dev9.if_ctrl & SPD_IF_ATA_DMAEN) != 0)
|
||||
{
|
||||
if (nsector == -1)
|
||||
return;
|
||||
DevCon.WriteLn("DEV9: DMA write, size %i, transferred %i, total size %i", size, wrTransferred, nsector * 512);
|
||||
|
||||
//write
|
||||
size = std::min(size, nsector * 512 - wrTransferred);
|
||||
memcpy(¤tWrite[wrTransferred], pMem, size);
|
||||
|
||||
wrTransferred += size;
|
||||
|
@ -149,6 +153,8 @@ void ATA::HDD_ReadDMA(bool isLBA48)
|
|||
|
||||
if (!HDD_CanSeek())
|
||||
{
|
||||
Console.Error("DEV9: ATA: Transfer from invalid LBA %lu", HDD_GetLBA());
|
||||
nsector = -1;
|
||||
regStatus |= ATA_STAT_ERR;
|
||||
regError |= ATA_ERR_ID;
|
||||
PostCmdNoData();
|
||||
|
@ -169,6 +175,8 @@ void ATA::HDD_WriteDMA(bool isLBA48)
|
|||
|
||||
if (!HDD_CanSeek())
|
||||
{
|
||||
Console.Error("DEV9: ATA: Transfer from invalid LBA %lu", HDD_GetLBA());
|
||||
nsector = -1;
|
||||
regStatus |= ATA_STAT_ERR;
|
||||
regError |= ATA_ERR_ID;
|
||||
PostCmdNoData();
|
||||
|
|
Loading…
Reference in New Issue