Skip to content

Commit 3e46a44

Browse files
authored
Merge pull request #920 from pcm720/dvrpcfw-atad-fixes-211
atad: report PS2 area size as LBA48 disk capacity for LBA48-aware DVRP firmware
2 parents 61a4b3f + 873208c commit 3e46a44

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

iop/dev9/atad/src/ps2atad.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,16 +1291,6 @@ static int ata_init_devices(ata_devinfo_t *devinfo)
12911291
either words(61:60) for 28-bit or words(103:100) for 48-bit. */
12921292
devinfo[i].lba48 = (ata_param[ATA_ID_COMMAND_SETS_SUPPORTED] & 0x0400) != 0;
12931293

1294-
/* Check for "PS2LBA48" magic in reserved words 121-124 */
1295-
if (ata_dvrp_workaround &&
1296-
ata_param[121] == 0x4456 &&
1297-
ata_param[122] == 0x524c &&
1298-
ata_param[123] == 0x4241 &&
1299-
ata_param[124] == 0x3438) {
1300-
M_PRINTF("LBA48-capable DVRP firmware detected, disabling the workaround\n");
1301-
ata_dvrp_workaround = 0;
1302-
}
1303-
13041294
/* Save the total sector counts before we overwrite ata_param with the value of Sony identify drive command. */
13051295
total_sectors_nonlba48 = (ata_param[ATA_ID_SECTOTAL_HI] << 16) | ata_param[ATA_ID_SECTOTAL_LO];
13061296
if (ata_param[ATA_ID_48BIT_SECTOTAL_HI]) {
@@ -1341,10 +1331,22 @@ static int ata_init_devices(ata_devinfo_t *devinfo)
13411331
/* If this device is emulated through the DVRP, use the non-48-bit LBA size. */
13421332
if (ata_dvrp_workaround) {
13431333
devinfo[i].total_sectors = total_sectors_nonlba48;
1334+
/* Check for "PS2LBA48" magic in reserved words 121-124 */
1335+
/* PS2 area size is still stored in the 28-bit LBA size */
1336+
if (ata_param[121] == 0x4456 &&
1337+
ata_param[122] == 0x524c &&
1338+
ata_param[123] == 0x4241 &&
1339+
ata_param[124] == 0x3438) {
1340+
M_PRINTF("LBA48-capable DVRP firmware detected, disabling the workaround\n");
1341+
ata_dvrp_workaround = 0;
1342+
devinfo[i].total_sectors_lba48 = total_sectors_nonlba48;
1343+
} else {
1344+
devinfo[i].total_sectors_lba48 = total_sectors_lba48;
1345+
}
13441346
} else {
13451347
devinfo[i].total_sectors = total_sectors_lba48;
1348+
devinfo[i].total_sectors_lba48 = total_sectors_lba48;
13461349
}
1347-
devinfo[i].total_sectors_lba48 = total_sectors_lba48;
13481350
} else {
13491351
devinfo[i].total_sectors = total_sectors_nonlba48;
13501352
devinfo[i].total_sectors_lba48 = total_sectors_nonlba48;

0 commit comments

Comments
 (0)