2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
8 #include <exec/memory.h>
9 #include <devices/trackdisk.h>
11 #include <proto/exec.h>
19 Yes, I know. This is the ugliest hack you have ever seen.
20 However, it does its job, and you are not supposed to be running
33 printf("Comparing\n");
34 for (foo
=0;foo
<256;foo
++)
36 for (bar
=0;bar
<512;bar
++)
38 if (buffer
[(foo
*512)+bar
] != buff2
[(foo
*512)+bar
])
40 printf("Mismatch in sector %d\n",(int)bar
);
46 int main ( int argc
, char *argv
[] )
49 struct timeval tv1
,tv2
;
55 printf("Usage: testide <startblock>\n\n");
56 printf("Be warned, this tool WILL irrevocably destroy data on\n");
57 printf("the primary master IDE hard disk. Do not run this\n");
58 printf("on a computer holding any important data whatsoever.\n");
62 base
= atoi(argv
[1])*512;
64 printf("ide.device test tool\n");
65 printf("Allocating two 128 KiB buffers\n");
67 buffer
= AllocMem(131072,MEMF_PUBLIC
);
68 buff2
= AllocMem(131072,MEMF_PUBLIC
);
70 printf("Initializing buffer\n");
73 buffer
[(x
*512)+y
] = x
;
75 printf("Creating MsgPort\n");
79 printf("Failed, aborting\n");
83 printf("Creating IORequest\n");
84 io
= (struct IOExtTD
*)CreateIORequest(mp
,sizeof(struct IOExtTD
));
87 printf("Failed, aborting\n");
91 printf("Opening ide.device\n");
92 if (OpenDevice("ide.device",0L,(struct IORequest
*)io
,0L))
94 printf("Failed, aborting\n");
98 printf("Writing single blocks\n");
101 io
->iotd_Req
.io_Length
= 512;
102 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
103 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
104 io
->iotd_Req
.io_Command
= CMD_WRITE
;
105 DoIO((struct IORequest
*)io
);
108 printf("Reading single blocks\n");
111 io
->iotd_Req
.io_Length
= 512;
112 io
->iotd_Req
.io_Data
= (buff2
+(x
*512));
113 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
114 io
->iotd_Req
.io_Command
= CMD_READ
;
115 DoIO((struct IORequest
*)io
);
120 printf("Writing entire buffer\n");
121 io
->iotd_Req
.io_Length
= 131072;
122 io
->iotd_Req
.io_Data
= buffer
;
123 io
->iotd_Req
.io_Offset
= base
;
124 io
->iotd_Req
.io_Command
= CMD_WRITE
;
125 DoIO((struct IORequest
*)io
);
129 printf("Writing single blocks\n");
132 io
->iotd_Req
.io_Length
= 512;
133 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
134 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
135 io
->iotd_Req
.io_Command
= CMD_WRITE
;
136 DoIO((struct IORequest
*)io
);
139 printf("Reading entire buffer\n");
140 io
->iotd_Req
.io_Length
= 131072;
141 io
->iotd_Req
.io_Data
= buff2
;
142 io
->iotd_Req
.io_Offset
= base
;
143 io
->iotd_Req
.io_Command
= CMD_READ
;
144 DoIO((struct IORequest
*)io
);
148 printf("Benching\n");
150 gettimeofday(&tv1
,NULL
);
153 io
->iotd_Req
.io_Length
= 131072;
154 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
155 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
156 io
->iotd_Req
.io_Command
= CMD_READ
;
157 DoIO((struct IORequest
*)io
);
159 gettimeofday(&tv2
,NULL
);
160 elapsed
= ((double)(((tv2
.tv_sec
* 1000000) + tv2
.tv_usec
) - ((tv1
.tv_sec
* 1000000) + tv1
.tv_usec
)))/1000000.;
162 printf(" Read 10 MiB in %f seconds (%f MiB/s\n",elapsed
,(10/elapsed
));
164 gettimeofday(&tv1
,NULL
);
167 io
->iotd_Req
.io_Length
= 131072;
168 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
169 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
170 io
->iotd_Req
.io_Command
= CMD_WRITE
;
171 DoIO((struct IORequest
*)io
);
173 gettimeofday(&tv2
,NULL
);
174 elapsed
= ((double)(((tv2
.tv_sec
* 1000000) + tv2
.tv_usec
) - ((tv1
.tv_sec
* 1000000) + tv1
.tv_usec
)))/1000000.;
176 printf("Wrote 10 MiB in %f seconds (%f MiB/s\n",elapsed
,(10/elapsed
));