Skip to content

Commit

Permalink
DEV9: implemented ATA SCE IDENTIFY DRIVE.
Browse files Browse the repository at this point in the history
Documented other ATA SCE commands.
  • Loading branch information
AKuHAK authored and refractionpcsx2 committed Sep 22, 2023
1 parent c3d31f1 commit 2115e92
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions pcsx2/DEV9/ATA/Commands/ATA_SCE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ void ATA::HDD_SCE()

switch (regFeature)
{
case 0xF1: // ATA_SCE_SECURITY_SET_PASSWORD
case 0xF2: // ATA_SCE_SECURITY_UNLOCK
case 0xF3: // ATA_SCE_SECURITY_ERASE_PREPARE
case 0xF4: // ATA_SCE_SECURITY_ERASE_UNIT
case 0xF5: // ATA_SCE_SECURITY_FREEZE_LOCK
case 0x20: // ATA_SCE_SECURITY_READ_ID
case 0x30: // ATA_SCE_SECURITY_WRITE_ID
Console.Error("DEV9: ATA: SCE command %x not implemented", regFeature);
CmdNoDataAbort();
break;
case 0xEC:
SCE_IDENTIFY_DRIVE();
break;
Expand All @@ -33,23 +43,45 @@ void ATA::HDD_SCE()
return;
}
}
//Has
//ATA_SCE_IDENTIFY_DRIVE @ 0xEC

//ATA_SCE_SECURITY_ERASE_PREPARE @ 0xF1
//ATA_SCE_SECURITY_ERASE_UNIT
//ATA_SCE_SECURITY_FREEZE_LOCK
//ATA_SCE_SECURITY_SET_PASSWORD
//ATA_SCE_SECURITY_UNLOCK

//ATA_SCE_SECURITY_WRITE_ID @ 0x20
//ATA_SCE_SECURITY_READ_ID @ 0x30
// All games that have ability to install data into HDD will verify HDD by checking that this command completes successfully. Resident Evil: Outbreak for example
// Only a few games/apps make use of the returned data, see Final Fantasy XI or the HDD Utility disks, neither of which work yet
// Also PSX DESR bioses use this response for HDD encryption and decryption.
// Use of external HDD ID (not implemented) file may be necessary for users with protected titles installed to the SCE HDD and then dumped.
// For example: PS2 BB Navigator, PlayOnline Viewer, Bomberman Online, Nobunaga No Yabou Online, Pop'n Taisen Puzzle-Dama Online

// PS2 ID Dumper can be used as test case
void ATA::SCE_IDENTIFY_DRIVE()
{
PreCmd();

//HDD_IdentifyDevice(); //Maybe?
// fill sceSec response with default data
memcpy(sceSec, "Sony Computer Entertainment Inc.", 32); // Always this magic header.
memcpy(sceSec + 0x20, "SCPH-20401", 10); // sometimes this matches HDD model, the rest 6 bytes filles with zeroes, or sometimes with spaces
memcpy(sceSec + 0x30, " 40", 4); // or " 120" for PSX DESR, reference for ps2 area size. The rest bytes filled with zeroes

sceSec[0x40] = 0; // 0x40 - 0x43 - 4-byte HDD internal SCE serial, does not match real HDD serial, currently hardcoded to 0x1000000
sceSec[0x41] = 0;
sceSec[0x42] = 0;
sceSec[0x43] = 0x01;

// purpose of next 12 bytes is unknown
sceSec[0x44] = 0; // always zero
sceSec[0x45] = 0; // always zero
sceSec[0x46] = 0x1a;
sceSec[0x47] = 0x01;
sceSec[0x48] = 0x02;
sceSec[0x49] = 0x20;
sceSec[0x4a] = 0; // always zero
sceSec[0x4b] = 0; // always zero
// next 4 bytes always these values
sceSec[0x4c] = 0x01;
sceSec[0x4d] = 0x03;
sceSec[0x4e] = 0x11;
sceSec[0x4f] = 0x01;
// 0x50 - 0x80 is a random unique block of data
// 0x80 and up - zero filled

// TODO: if exists *.hddid file (size - 128-512 bytes) along with HDD image, replace generic sceSec with its content

pioDRQEndTransferFunc = nullptr;
DRQCmdPIODataToHost(sceSec, 256 * 2, 0, 256 * 2, true);
Expand Down

0 comments on commit 2115e92

Please sign in to comment.