PS2SDK
PS2 Homebrew Libraries
atad.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #ifndef __ATAD_H__
17 #define __ATAD_H__
18 
19 #include <types.h>
20 #include <irx.h>
21 
22 /* These are used with the dir parameter of ata_device_sector_io(). */
23 #define ATA_DIR_READ 0
24 #define ATA_DIR_WRITE 1
25 
26 typedef struct _ata_devinfo
27 {
29  s32 exists;
31  s32 has_packet;
33  u32 total_sectors;
35  u32 security_status;
37  u32 lba48;
41 
42 /* Error definitions. */
43 #define ATA_RES_ERR_NOTREADY -501
44 #define ATA_RES_ERR_TIMEOUT -502
45 #define ATA_RES_ERR_IO -503
46 #define ATA_RES_ERR_NODATA -504
47 #define ATA_RES_ERR_NODEV -505
48 #define ATA_RES_ERR_CMD -506
49 #define ATA_RES_ERR_LOCKED -509
50 #define ATA_RES_ERR_ICRC -510
51 
52 extern ata_devinfo_t *sceAtaInit(int device);
53 
54 extern int sceAtaSoftReset(void);
55 
56 extern int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command);
57 extern int sceAtaWaitResult(void);
58 
59 extern int sceAtaGetError(void);
60 
61 extern int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir);
62 
63 // DRM functions that were meant to keep users from sharing disks (and hence the contained content). Supported by only Sony-modified HDDs (e.g. the SCPH-20400).
64 extern int sceAtaSecuritySetPassword(int device, void *password);
65 extern int sceAtaSecurityUnLock(int device, void *password);
66 extern int sceAtaSecurityEraseUnit(int device);
67 
68 extern int sceAtaIdle(int device, int period);
69 extern int sceAtaGetSceId(int device, void *data);
70 extern int sceAtaSmartReturnStatus(int device);
71 extern int sceAtaSmartSaveAttr(int device);
72 extern int sceAtaFlushCache(int device);
73 extern int sceAtaIdleImmediate(int device);
74 
75 extern int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors, int dir);
76 
77 #define atad_IMPORTS_start DECLARE_IMPORT_TABLE(atad, 1, 3)
78 #define atad_IMPORTS_end END_IMPORT_TABLE
79 
80 #define I_sceAtaInit DECLARE_IMPORT(4, sceAtaInit)
81 #define I_sceAtaSoftReset DECLARE_IMPORT(5, sceAtaSoftReset)
82 #define I_sceAtaExecCmd DECLARE_IMPORT(6, sceAtaExecCmd)
83 #define I_sceAtaWaitResult DECLARE_IMPORT(7, sceAtaWaitResult)
84 #define I_sceAtaGetError DECLARE_IMPORT(8, sceAtaGetError)
85 #define I_sceAtaDmaTransfer DECLARE_IMPORT(9, sceAtaDmaTransfer)
86 #define I_sceAtaSecuritySetPassword DECLARE_IMPORT(10, sceAtaSecuritySetPassword)
87 #define I_sceAtaSecurityUnLock DECLARE_IMPORT(11, sceAtaSecurityUnLock)
88 #define I_sceAtaSecurityEraseUnit DECLARE_IMPORT(12, sceAtaSecurityEraseUnit)
89 #define I_sceAtaIdle DECLARE_IMPORT(13, sceAtaIdle)
90 #define I_sceAtaGetSceId DECLARE_IMPORT(14, sceAtaGetSceId)
91 #define I_sceAtaSmartReturnStatus DECLARE_IMPORT(15, sceAtaSmartReturnStatus)
92 #define I_sceAtaSmartSaveAttr DECLARE_IMPORT(16, sceAtaSmartSaveAttr)
93 #define I_sceAtaFlushCache DECLARE_IMPORT(17, sceAtaFlushCache)
94 #define I_sceAtaIdleImmediate DECLARE_IMPORT(18, sceAtaIdleImmediate)
95 #define I_ata_device_sector_io64 DECLARE_IMPORT(19, ata_device_sector_io64)
96 
97 // Backward-compatibility definitions
98 #define ata_get_devinfo sceAtaInit
99 #define ata_reset_devices sceAtaSoftReset
100 #define ata_io_start sceAtaExecCmd
101 #define ata_io_finish sceAtaWaitResult
102 #define ata_get_error sceAtaGetError
103 #define ata_device_sector_io sceAtaDmaTransfer
104 #define ata_device_sce_sec_set_password sceAtaSecuritySetPassword
105 #define ata_device_sce_sec_unlock sceAtaSecurityUnLock
106 #define ata_device_sce_sec_erase sceAtaSecurityEraseUnit
107 #define ata_device_idle sceAtaIdle
108 #define ata_device_sce_identify_drive sceAtaGetSceId
109 #define ata_device_smart_get_status sceAtaSmartReturnStatus
110 #define ata_device_smart_save_attr sceAtaSmartSaveAttr
111 #define ata_device_flush_cache sceAtaFlushCache
112 #define ata_device_idle_immediate sceAtaIdleImmediate
113 #define ata_device_dma_transfer sceAtaDmaTransfer
114 
115 #define I_ata_get_devinfo I_sceAtaInit
116 #define I_ata_reset_devices I_sceAtaSoftReset
117 #define I_ata_io_start I_sceAtaExecCmd
118 #define I_ata_io_finish I_sceAtaWaitResult
119 #define I_ata_get_error I_sceAtaGetError
120 #define I_ata_device_sector_io I_sceAtaDmaTransfer
121 #define I_ata_device_sce_sec_set_password I_sceAtaSecuritySetPassword
122 #define I_ata_device_sce_sec_unlock I_sceAtaSecurityUnLock
123 #define I_ata_device_sce_sec_erase I_sceAtaSecurityEraseUnit
124 #define I_ata_device_idle I_sceAtaIdle
125 #define I_ata_device_sce_identify_drive I_sceAtaGetSceId
126 #define I_ata_device_smart_get_status I_sceAtaSmartReturnStatus
127 #define I_ata_device_smart_save_attr I_sceAtaSmartSaveAttr
128 #define I_ata_device_flush_cache I_sceAtaFlushCache
129 #define I_ata_device_idle_immediate I_sceAtaIdleImmediate
130 #define I_ata_device_dma_transfer I_sceAtaDmaTransfer
131 
132 #endif /* __ATAD_H__ */
_ata_devinfo::has_packet
s32 has_packet
Definition: xatapi.c:42
_ata_devinfo
Definition: xatapi.c:39
_ata_devinfo::security_status
u32 security_status
Definition: xatapi.c:44
_ata_devinfo::exists
s32 exists
Definition: xatapi.c:41
irx.h
_ata_devinfo::total_sectors
u32 total_sectors
Definition: xatapi.c:43
_ata_devinfo::total_sectors_lba48
u32 total_sectors_lba48
Definition: atad.h:39
_ata_devinfo::lba48
u32 lba48
Definition: xatapi.c:45