2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
10 # $Id: hdd.c 1511 2009-01-15 09:11:30Z radad $
16 IRX_ID("hdd_driver", 1, 1);
18 iop_device_ops_t hddOps
={
27 (void*)hddUnsupported
,
29 (void*)hddUnsupported
,
30 (void*)hddUnsupported
,
35 (void*)hddUnsupported
,
37 (void*)hddUnsupported
,
38 (void*)hddUnsupported
,
39 (void*)hddUnsupported
,
40 (void*)hddUnsupported
,
41 (void*)hddUnsupported
,
43 (void*)hddUnsupported
,
44 (void*)hddUnsupported
,
47 iop_device_t hddFioDev
={
49 IOP_DT_BLOCK
| IOP_DT_FSEXT
,
52 (struct _iop_device_ops
*)&hddOps
,
56 hdd_device_t hddDeviceBuf
[2]={
62 0x2B, 0x17, 0x16, 0x01, 0x58, 0x3B, 0x17, 0x15,
63 0x08, 0x0D, 0x0C, 0x1D, 0x0A, 0x58, 0x3D, 0x16,
64 0x0C, 0x1D, 0x0A, 0x0C, 0x19, 0x11, 0x16, 0x15,
65 0x1D, 0x16, 0x0C, 0x58, 0x31, 0x16, 0x1B, 0x56
70 int inputError(char *input
)
72 printf("ps2hdd: Error: Usage: %s [-o <maxOpen>] [-n <maxcache>]\n", input
);
76 void printStartup(void)
78 printf("ps2hdd: PS2 APA Driver v1.1 (c) 2003 Vector\n");
82 int unlockDrive(u32 device
)
86 if((rv
=getIlinkID(id
))==0)
87 return atadSceUnlock(device
, id
);
91 int _start(int argc
, char **argv
)
104 if((input
=strrchr(argv
[0], '/')))
112 if(argv
[0][0] != '-')
114 if(strcmp("-o", argv
[0])==0){
117 return inputError(input
);
118 i
=strtol(argv
[0], 0, 10);
122 else if(strcmp("-n", argv
[0])==0){
125 return inputError(input
);
126 i
=strtol(*argv
, 0, 10);
133 printf("ps2hdd: max open = %ld, %d buffers\n", maxOpen
, cacheSize
);
135 printf("ps2hdd: %02d:%02d:%02d %02d/%02d/%d\n",
136 tm
.hour
, tm
.min
, tm
.sec
, tm
.month
, tm
.day
, tm
.year
);
139 if(!(hddInfo
=atadInit((u16
)i
))){
140 printf("ps2hdd: Error: ata initialization failed.\n");
143 if(hddInfo
->exists
!=0 && hddInfo
->has_packet
==0){
144 hddDeviceBuf
[i
].status
--;
145 hddDeviceBuf
[i
].totalLBA
=hddInfo
->total_sectors
;
146 hddDeviceBuf
[i
].partitionMaxSize
=apaGetPartitionMax(hddInfo
->total_sectors
);
147 if(unlockDrive(i
)==0)
148 hddDeviceBuf
[i
].status
--;
149 printf("ps2hdd: disk%d: 0x%08lx sectors, max 0x%08lx\n", i
,
150 hddDeviceBuf
[i
].totalLBA
, hddDeviceBuf
[i
].partitionMaxSize
);
153 fileSlots
=allocMem(maxOpen
*sizeof(hdd_file_slot_t
));
155 memset(fileSlots
, 0, maxOpen
*sizeof(hdd_file_slot_t
));
157 cacheInit(cacheSize
);
160 if(hddDeviceBuf
[i
].status
<2){
161 if(journalResetore(i
)!=0)
163 if(apaGetFormat(i
, (int *)&hddDeviceBuf
[i
].format
))
164 hddDeviceBuf
[i
].status
--;
165 printf("ps2hdd: drive status %ld, format version %08lx\n",
166 hddDeviceBuf
[i
].status
, hddDeviceBuf
[i
].format
);
170 if(AddDrv(&hddFioDev
)==0)
172 printf("ps2hdd: driver start.\n");