DEV9: Add ATA commands used by PS2 Linux (#11925)

This commit is contained in:
TheLastRar 2024-10-20 01:05:34 +01:00 committed by GitHub
parent ab21d22514
commit 82f741e1dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 0 deletions

View File

@ -244,6 +244,7 @@ private:
void HDD_FlushCache();
void HDD_InitDevParameters();
void HDD_ReadVerifySectors(bool isLBA48);
void HDD_Recalibrate();
void HDD_SeekCmd();
void HDD_SetFeatures();
void HDD_SetMultipleMode();
@ -264,6 +265,7 @@ private:
void HDD_Smart();
void SMART_SetAutoSaveAttribute();
void SMART_SaveAttribute();
void SMART_ExecuteOfflineImmediate();
void SMART_EnableOps(bool enable);
void SMART_ReturnStatus();

View File

@ -57,6 +57,27 @@ void ATA::HDD_ReadVerifySectors(bool isLBA48)
PostCmdNoData();
}
void ATA::HDD_Recalibrate()
{
if (!PreCmd())
return;
DevCon.WriteLn("DEV9: HDD_Recalibrate");
lba48 = false;
// Report minimum address (LBA 0 or CHS 0/0/1).
// SetLBA currently only supports LBA, so set the regs directly.
regSelect = regSelect & 0xf0;
regHcyl = 0;
regLcyl = 0;
regSector = (regSelect & 0x40) ? 0 : 1;
// If recalibrate fails, we would set ATA_STAT_ERR in regStatus and ATA_ERR_TRACK0 in regError.
// we will never fail, so set ATA_STAT_SEEK in regStatus to indicate we finished seeking.
regStatus |= ATA_STAT_SEEK;
PostCmdNoData();
}
void ATA::HDD_SeekCmd()
{
if (!PreCmd())
@ -65,6 +86,7 @@ void ATA::HDD_SeekCmd()
regStatus &= ~ATA_STAT_SEEK;
lba48 = false;
if (HDD_CanSeek())
{
regStatus |= ATA_STAT_ERR;

View File

@ -35,6 +35,7 @@ void ATA::HDD_Smart()
SMART_SetAutoSaveAttribute();
return;
case 0xD3: //SMART_ATTR_SAVE
SMART_SaveAttribute();
return;
case 0xDA: //SMART_STATUS (is fault in disk?)
SMART_ReturnStatus();
@ -80,6 +81,13 @@ void ATA::SMART_SetAutoSaveAttribute()
PostCmdNoData();
}
void ATA::SMART_SaveAttribute()
{
PreCmd();
// Stub
PostCmdNoData();
}
void ATA::SMART_ExecuteOfflineImmediate()
{
PreCmd();

View File

@ -11,6 +11,9 @@ void ATA::IDE_ExecCmd(u16 value)
case 0x00:
HDD_Nop();
break;
case 0x10:
HDD_Recalibrate();
break;
case 0x20:
HDD_ReadSectors(false);
break;
@ -50,6 +53,9 @@ void ATA::IDE_ExecCmd(u16 value)
case 0xC4:
HDD_ReadMultiple(false);
break;
case 0xC6:
HDD_SetMultipleMode();
break;
case 0xC8:
HDD_ReadDMA(false);
break;