Skip to content

Commit be49dfb

Browse files
authored
Merge pull request #907 from uyjulian/ata_vendor_specific
Add definitions for ATA vendor specific commands to command table
2 parents 249b18d + c9542e6 commit be49dfb

4 files changed

Lines changed: 46 additions & 0 deletions

File tree

common/include/atahw.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,22 @@ enum ATA_C_CODES {
169169
ATA_C_RESTORE_ELEMENTS_AND_REBUILD = 0x7D,
170170
ATA_C_SEEK_7EH = 0x7E,
171171
ATA_C_SEEK_7FH = 0x7F,
172+
ATA_C_VENDOR_SPECIFIC_80H = 0x80,
173+
ATA_C_VENDOR_SPECIFIC_81H = 0x81,
174+
ATA_C_VENDOR_SPECIFIC_82H = 0x82,
175+
ATA_C_VENDOR_SPECIFIC_83H = 0x83,
176+
ATA_C_VENDOR_SPECIFIC_84H = 0x84,
177+
ATA_C_VENDOR_SPECIFIC_85H = 0x85,
178+
ATA_C_VENDOR_SPECIFIC_86H = 0x86,
172179
ATA_C_CFA_TRANSLATE_SECTOR = 0x87,
180+
ATA_C_VENDOR_SPECIFIC_88H = 0x88,
181+
ATA_C_VENDOR_SPECIFIC_89H = 0x89,
182+
ATA_C_VENDOR_SPECIFIC_8AH = 0x8A,
183+
ATA_C_VENDOR_SPECIFIC_8BH = 0x8B,
184+
ATA_C_VENDOR_SPECIFIC_8CH = 0x8C,
185+
ATA_C_VENDOR_SPECIFIC_8DH = 0x8D,
173186
ATA_C_SCE_SECURITY_CONTROL = 0x8e,
187+
ATA_C_VENDOR_SPECIFIC_8FH = 0x8F,
174188
ATA_C_EXECUTE_DEVICE_DIAGNOSTIC = 0x90,
175189
ATA_C_INITIALIZE_DEVICE_PARAMETERS = 0x91,
176190
ATA_C_DOWNLOAD_MICROCODE = 0x92,
@@ -181,6 +195,7 @@ enum ATA_C_CODES {
181195
ATA_C_IDLE_97H = 0x97,
182196
ATA_C_CHECK_POWER_MODE_98H = 0x98,
183197
ATA_C_SLEEP_99H = 0x99,
198+
ATA_C_VENDOR_SPECIFIC_9AH = 0x9A,
184199
ATA_C_ZAC_MANAGEMENT_OUT = 0x9F,
185200
ATA_C_PACKET = 0xa0,
186201
ATA_C_IDENTIFY_PACKET_DEVICE,
@@ -192,6 +207,9 @@ enum ATA_C_CODES {
192207
ATA_C_NV_CACHE = 0xb6,
193208
ATA_C_CFA_KEY_MANAGEMENT = 0xb9,
194209
ATA_C_CFA_ERASE_SECTORS = 0xc0,
210+
ATA_C_VENDOR_SPECIFIC_C1H = 0xC1,
211+
ATA_C_VENDOR_SPECIFIC_C2H = 0xC2,
212+
ATA_C_VENDOR_SPECIFIC_C3H = 0xC3,
195213
ATA_C_READ_MULTIPLE = 0xc4,
196214
ATA_C_WRITE_MULTIPLE,
197215
ATA_C_SET_MULTIPLE_MODE,
@@ -228,15 +246,23 @@ enum ATA_C_CODES {
228246

229247
ATA_C_SET_FEATURES = 0xef,
230248

249+
ATA_C_VENDOR_SPECIFIC_F0H = 0xF0,
231250
ATA_C_SECURITY_SET_PASSWORD = 0xf1,
232251
ATA_C_SECURITY_UNLOCK,
233252
ATA_C_SECURITY_ERASE_PREPARE,
234253
ATA_C_SECURITY_ERASE_UNIT,
235254
ATA_C_SECURITY_FREEZE_LOCK,
236255
ATA_C_SECURITY_DISABLE_PASSWORD,
237256

257+
ATA_C_VENDOR_SPECIFIC_F7H = 0xF7,
238258
ATA_C_READ_NATIVE_MAX_ADDRESS = 0xf8,
239259
ATA_C_SET_MAX_ADDRESS,
260+
ATA_C_VENDOR_SPECIFIC_FAH = 0xFA,
261+
ATA_C_VENDOR_SPECIFIC_FBH = 0xFB,
262+
ATA_C_VENDOR_SPECIFIC_FCH = 0xFC,
263+
ATA_C_VENDOR_SPECIFIC_FDH = 0xFD,
264+
ATA_C_VENDOR_SPECIFIC_FEH = 0xFE,
265+
ATA_C_VENDOR_SPECIFIC_FFH = 0xFF,
240266
};
241267

242268
enum ATA_SCE_SECURITY_CODES {

iop/dev9/atad/include/atad.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ extern int sceAtaSmartSaveAttr(int device);
7272
extern int sceAtaFlushCache(int device);
7373
extern int sceAtaIdleImmediate(int device);
7474

75+
/* Unofficial APIs follow. */
7576
extern int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors, int dir);
77+
extern int ata_set_command_type(int command, int type);
7678

7779
#define atad_IMPORTS_start DECLARE_IMPORT_TABLE(atad, 1, 3)
7880
#define atad_IMPORTS_end END_IMPORT_TABLE
@@ -93,6 +95,7 @@ extern int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors,
9395
#define I_sceAtaFlushCache DECLARE_IMPORT(17, sceAtaFlushCache)
9496
#define I_sceAtaIdleImmediate DECLARE_IMPORT(18, sceAtaIdleImmediate)
9597
#define I_ata_device_sector_io64 DECLARE_IMPORT(19, ata_device_sector_io64)
98+
#define I_ata_set_command_type DECLARE_IMPORT(20, ata_set_command_type)
9699

97100
// Backward-compatibility definitions
98101
#define ata_get_devinfo sceAtaInit

iop/dev9/atad/src/exports.tab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ DECLARE_EXPORT_TABLE(atad, 1, 3)
2222
DECLARE_EXPORT(sceAtaFlushCache)
2323
DECLARE_EXPORT(sceAtaIdleImmediate)
2424
DECLARE_EXPORT(ata_device_sector_io64)
25+
DECLARE_EXPORT(ata_set_command_type)
2526
END_EXPORT_TABLE
2627

2728
void _retonly() {}

iop/dev9/atad/src/ps2atad.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,18 @@ static int ata_device_select(int device)
508508
return ata_wait_bus_busy();
509509
}
510510

511+
static int g_atad_search_command = 0;
512+
static int g_atad_search_type = 0;
513+
514+
/* Export 20 */
515+
int ata_set_command_type(int command, int type)
516+
{
517+
g_atad_search_command = command;
518+
g_atad_search_type = type;
519+
520+
return 0;
521+
}
522+
511523
/* Export 6 */
512524
/*
513525
28-bit LBA:
@@ -564,6 +576,10 @@ int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector,
564576
}
565577
}
566578

579+
// Unofficial: allow overriding the command type if not handled in table
580+
if (!type && searchcmd == g_atad_search_command)
581+
type = g_atad_search_type;
582+
567583
if (!(atad_cmd_state.type = type & 0x7F)) // Non-SONY: ignore the 48-bit LBA flag.
568584
return ATA_RES_ERR_CMD;
569585

0 commit comments

Comments
 (0)