1 #include <exec/types.h>
3 #include <exec/memory.h>
4 #include <devices/trackdisk.h>
6 #include <proto/exec.h>
14 Yes, I know. This is the ugliest hack you have ever seen.
15 However, it does its job, and you are not supposed to be running
28 printf("Comparing\n");
29 for (foo
=0;foo
<256;foo
++)
31 for (bar
=0;bar
<512;bar
++)
33 if (buffer
[(foo
*512)+bar
] != buff2
[(foo
*512)+bar
])
35 printf("Mismatch in sector %d\n",(int)bar
);
41 int main ( int argc
, char *argv
[] )
44 struct timeval tv1
,tv2
;
50 printf("Usage: testide <startblock>\n\n");
51 printf("Be warned, this tool WILL irrevocably destroy data on\n");
52 printf("data on the primary master IDE harddisk. Do not run this\n");
53 printf("on a computer holding any important data whatsoever.\n");
57 base
= atoi(argv
[1])*512;
59 printf("ide.device test tool\n");
60 printf("Allocating two 128 KiB buffers\n");
62 buffer
= AllocMem(131072,MEMF_PUBLIC
);
63 buff2
= AllocMem(131072,MEMF_PUBLIC
);
65 printf("Initializing buffer\n");
68 buffer
[(x
*512)+y
] = x
;
70 printf("Creating MsgPort\n");
74 printf("Failed, aborting\n");
78 printf("Creating IORequest\n");
79 io
= (struct IOExtTD
*)CreateIORequest(mp
,sizeof(struct IOExtTD
));
82 printf("Failed, aborting\n");
86 printf("Opening ide.device\n");
87 if (OpenDevice("ide.device",0L,(struct IORequest
*)io
,0L))
89 printf("Failed, aborting\n");
93 printf("Writing single blocks\n");
96 io
->iotd_Req
.io_Length
= 512;
97 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
98 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
99 io
->iotd_Req
.io_Command
= CMD_WRITE
;
100 DoIO((struct IORequest
*)io
);
103 printf("Reading single blocks\n");
106 io
->iotd_Req
.io_Length
= 512;
107 io
->iotd_Req
.io_Data
= (buff2
+(x
*512));
108 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
109 io
->iotd_Req
.io_Command
= CMD_READ
;
110 DoIO((struct IORequest
*)io
);
115 printf("Writing entire buffer\n");
116 io
->iotd_Req
.io_Length
= 131072;
117 io
->iotd_Req
.io_Data
= buffer
;
118 io
->iotd_Req
.io_Offset
= base
;
119 io
->iotd_Req
.io_Command
= CMD_WRITE
;
120 DoIO((struct IORequest
*)io
);
124 printf("Writing single blocks\n");
127 io
->iotd_Req
.io_Length
= 512;
128 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
129 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
130 io
->iotd_Req
.io_Command
= CMD_WRITE
;
131 DoIO((struct IORequest
*)io
);
134 printf("Reading entire buffer\n");
135 io
->iotd_Req
.io_Length
= 131072;
136 io
->iotd_Req
.io_Data
= buff2
;
137 io
->iotd_Req
.io_Offset
= base
;
138 io
->iotd_Req
.io_Command
= CMD_READ
;
139 DoIO((struct IORequest
*)io
);
143 printf("Benching\n");
145 gettimeofday(&tv1
,NULL
);
148 io
->iotd_Req
.io_Length
= 131072;
149 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
150 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
151 io
->iotd_Req
.io_Command
= CMD_READ
;
152 DoIO((struct IORequest
*)io
);
154 gettimeofday(&tv2
,NULL
);
155 elapsed
= ((double)(((tv2
.tv_sec
* 1000000) + tv2
.tv_usec
) - ((tv1
.tv_sec
* 1000000) + tv1
.tv_usec
)))/1000000.;
157 printf(" Read 10 MiB in %f seconds (%f MiB/s\n",elapsed
,(10/elapsed
));
159 gettimeofday(&tv1
,NULL
);
162 io
->iotd_Req
.io_Length
= 131072;
163 io
->iotd_Req
.io_Data
= (buffer
+(x
*512));
164 io
->iotd_Req
.io_Offset
= (x
*512)+base
;
165 io
->iotd_Req
.io_Command
= CMD_WRITE
;
166 DoIO((struct IORequest
*)io
);
168 gettimeofday(&tv2
,NULL
);
169 elapsed
= ((double)(((tv2
.tv_sec
* 1000000) + tv2
.tv_usec
) - ((tv1
.tv_sec
* 1000000) + tv1
.tv_usec
)))/1000000.;
171 printf("Wrote 10 MiB in %f seconds (%f MiB/s\n",elapsed
,(10/elapsed
));