2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
5 Desc: Disk subsystem Benchmarking Utility..
8 Based on DiskSpeed v4.2 by Michael Sinz
11 /*********************************************************************************************/
14 # include <proto/alib.h>
18 # include <proto/icon.h>
22 # include <proto/exec.h>
26 # include <proto/dos.h>
30 # include <proto/timer.h>
33 #ifndef PROTO_UTILITY_H
34 # include <proto/utility.h>
37 #ifndef PROTO_INTUITION_H
38 # include <proto/intuition.h>
41 #ifndef PROTO_GRAPHICS_H
42 # include <proto/graphics.h>
45 #ifndef PROTO_MUIMASTER_H
46 # include <proto/muimaster.h>
49 #ifndef PROTO_LAYERS_H
50 # include <proto/layers.h>
53 /*********************************************************************************************/
55 #include <exec/resident.h>
56 #include <exec/execbase.h>
58 #include <libraries/coolimages.h>
59 #include <libraries/mui.h>
61 #include <zune/customclasses.h>
62 #include <zune/aboutwindow.h>
64 #include <aros/locale.h>
67 #include <exec/ports.h>
68 #include <devices/timer.h>
70 #include <dos/dosextens.h>
71 #include <devices/trackdisk.h>
72 #include <intuition/intuition.h>
73 #include <intuition/gadgetclass.h>
74 #include <intuition/screens.h>
75 #include <workbench/workbench.h>
76 #include <workbench/startup.h>
78 #include <clib/exec_protos.h>
79 #include <clib/dos_protos.h>
80 #include <clib/timer_protos.h>
81 #include <clib/intuition_protos.h>
82 #include <clib/icon_protos.h>
84 /*********************************************************************************************/
86 struct DiskSpeedMUI_Intern
{
88 Object
*disk_app
; /* our application itself.. */
89 Object
*disk_main_win
; /* The Main Benchmark Window */
90 Object
*disk_config_win
; /* The Configuration Window */
91 Object
*disk_about_win
; /* The Main Benchmark Window */
103 Object
*configobj
; /* Open Config Window gadget */
108 Object
*conokobj
; /* Configuration Windows OK gadget */
109 Object
*consaveobj
; /* Configuration Windows Save gadget */
110 Object
*conuseobj
; /* Configuration Windows Use gadget */
111 Object
*concancelobj
; /* Configuration Windows Cancel gadget */
114 struct DiskSpeedConfig_Intern
{
116 Object
*dir_checkmark
; /* Benchmark Configuration Option Objects */
118 Object
*seek_checkmark
;
119 Object
*nocpu_checkmark
;
127 Object
*long_checkmark
;
128 Object
*word_checkmark
;
129 Object
*byte_checkmark
;
131 Object
*fast_checkmark
;
132 Object
*chip_checkmark
;
135 struct DiskSpeedMUI_Intern diskspeedmui_intern
;
136 struct DiskSpeedConfig_Intern diskspeedmui_config
;
147 /*********************************************************************************************/
155 # include <aros/debug.h>
157 /*********************************************************************************************/
160 # include "ScsiSpeed_rev.h"
162 # include "DiskSpeed_rev.h"
163 #endif /* SCSI_SPEED */
165 /*********************************************************************************************/
167 #define VERS APPNAME " 4.10"
168 #define VSTRING APPNAME " 4.10 (" DATE ")\n\r"
169 #define VERSTAG "\0$VER: " APPNAME " 4.10 (" DATE ")"
170 #define CXVERSION VERS " (" DATE ")"
171 #define STR_SEPERATOR "------------------------------------------------------------------"
173 const char COPYRIGHT
[] = "Aros " VERS
" Copyright © 2004-2016 The AROS Development Team" VERSTAG
;
176 # define MSG_BYTES_READ MSG_BYTES_READ_S
177 const char RESULTS_FILE
[] = APPNAME
".Results";
179 # define MSG_BYTES_READ MSG_BYTES_READ_N
180 const char FILE_STRING
[] = "%04lx " APPNAME
" Test File ";
181 const char TEST_DIR
[] = " " APPNAME
" Test Directory ";
182 const char RESULTS_FILE
[] = APPNAME
".Results";
183 #endif /* SCSI_SPEED */
185 /*********************************************************************************************/
187 Timer related stuff...
192 struct MsgPort
*tmPort
;
193 struct timerequest
*tmReq
;
194 struct timeval tmVal
;
199 /*********************************************************************************************/
201 Our Disk/ScsiSpeed global structure...
206 struct Window
*Window
; /* The DiskSpeed window... */
207 struct RenderInfo
*ri
; /* MKSoft Render Info */
211 struct IOExtTD DiskIO
; /* Disk IO request */
213 #endif /* SCSI_SPEED */
215 BPTR Output
; /* The output file handle! */
216 struct Process
*Me
; /* Pointer to my process... */
217 struct SpeedTimer
*timer
; /* Pointer to a timer structure */
221 struct FileInfoBlock
*fib
; /* Pointer to a FileInfoBlock */
223 #endif /* !SCSI_SPEED */
226 struct MinList TextList
; /* The list the results test is linked to... */
227 struct DisplayList
*List
; /* The "List" gadget */
229 ULONG Min_Time
; /* Minimum tmVal in seconds for a test */
230 ULONG Base_CPU
; /* Base CPU available... */
231 ULONG CPU_Total
; /* Sum of CPU availability */
232 ULONG CPU_Count
; /* Count of CPU availability */
234 /* Testing parameters */
235 unsigned short HighDMA
; /* Set to TRUE for high video DMA... */
236 unsigned short Test_DIR
; /* Set to test directory stuff */
237 unsigned short Test_SEEK
; /* Set to test SEEK/READ */
240 ULONG Align_Types
; /* Set bits of alignment types... */
241 ULONG Mem_TYPES
; /* Set memory type flags to test... */
242 ULONG Test_Size
[4]; /* The four test sizes... */
244 short StringVectors
[5*2*4];
245 short ActionVectors
[5*2*2];
248 char Device
[256]; /* Device name under test... */
249 char Comments
[256]; /* Comments string gadget... */
250 char Undo
[256]; /* Our one UNDO buffer... */
253 char CPU_Type
[22]; /* Processor name in this string (plus NULL) */
254 char Exec_Ver
[14]; /* Version of Exec */
257 char tmp1
[128]; /* Temporary buffer space... */
258 char tmp2
[128]; /* Temporary buffer space... */
261 struct DiskSpeed
*global
;
263 /*********************************************************************************************/
265 #define DEVICE_GADGET 1
266 #define COMMENT_GADGET 2
267 #define TEST_GADGET 3
268 #define SAVE_GADGET 4
269 #define STOP_GADGET 5
271 /*********************************************************************************************/
273 This is the minimum timeval for test that can be extended/shorted automatically
274 This number should not be set too low otherwise the test results will be
275 inaccurate due to timer granularity. (in seconds)
280 #define MIN_TEST_TIME 20
282 #else /* SCSI_SPEED */
284 #define MIN_TEST_TIME 8
285 #define NUM_FILES 200
287 #endif /* SCSI_SPEED */
289 /*********************************************************************************************/
291 This section of code is used to test CPU availability.
296 ULONG _CPU_Use_Base
; /* Set to TRUE in order to use CPU... */
297 ULONG _CPU_State_Flag
; /* Used to control this routine... */
298 ULONG _CPU_Count_Low
; /* The low-order word for CPU count */
299 ULONG _CPU_Count_High
; /* The high-order word for CPU count */
300 ULONG CPU_Task
; /* The task pointer... */
303 struct Task
*Init_CPU_Available( struct CPU_AVAIL
*CPU_AVAIL_struct
);
304 void Free_CPU_Available( struct CPU_AVAIL
*CPU_AVAIL_struct
);
305 void CPU_Calibrate( struct CPU_AVAIL
*CPU_AVAIL_struct
);
307 /*********************************************************************************************/
308 unsigned short BusyPointer
[36] =
310 0x0000, 0x0000, 0x0400, 0x07C0, 0x0000, 0x07C0, 0x0100, 0x0380, 0x0000,
311 0x07E0, 0x07C0, 0x1FF8, 0x1FF0, 0x3FEC, 0x3FF8, 0x7FDE, 0x3FF8, 0x7FBE,
312 0x7FFC, 0xFF7F, 0x7EFC, 0xFFFF, 0x7FFC, 0xFFFF, 0x3FF8, 0x7FFE, 0x3FF8,
313 0x7FFE, 0x1FF0, 0x3FFC, 0x07C0, 0x1FF8, 0x0000, 0x07E0, 0x0000, 0x0000
317 These two defines set up and clear the BusyPointer...
320 #define SetWait(x) SetPointer(x,BusyPointer,16L,16L,-6L,0L)
321 #define ClearWait(x) ClearPointer(x)
323 #if !defined(__AROS__)
324 /*********************************************************************************************/
325 static struct Catalog
*MyCatalog
;
327 static char *GetString(LONG num
)
329 const struct CatCompArrayType
*x
= CatCompArray
;
334 if (x
->cca_ID
== num
)
341 s
= GetCatalogStr(MyCatalog
, num
, s
);
346 static IPTR
getv(APTR obj
, ULONG tag
)
349 GetAttr(tag
, obj
, &x
);
353 /*********************************************************************************************/
354 /*********************************************************************************************/
355 /*********************************************************************************************/
357 This routine returns the amount of timeval in the timer...
358 The number returned is in Seconds...
361 static ULONG
Read_Timer(struct SpeedTimer
*spt
)
363 struct Library
*TimerBase
= (struct Library
*)(spt
->tmReq
->tr_node
.io_Device
);
365 /* Get the current timeval... */
366 spt
->tmReq
->tr_node
.io_Command
= TR_GETSYSTIME
;
367 spt
->tmReq
->tr_node
.io_Flags
= IOF_QUICK
;
368 DoIO((struct IORequest
*)(spt
->tmReq
));
370 /* Subtract last timer result and store as the timer result */
371 SubTime(&(spt
->tmReq
->tr_time
),&(spt
->tmVal
));
372 return(spt
->tmReq
->tr_time
.tv_secs
);
379 static void Start_Timer(struct SpeedTimer
*spt
)
381 /* Get the current timeval... */
382 spt
->tmReq
->tr_node
.io_Command
= TR_GETSYSTIME
;
383 spt
->tmReq
->tr_node
.io_Flags
= IOF_QUICK
;
384 DoIO((struct IORequest
*)(spt
->tmReq
));
386 /* Store current timeval as the timer result */
387 spt
->tmVal
= spt
->tmReq
->tr_time
;
390 This here is a nasty trick... Since the timer device
391 has a low resolution, we wait until we get to the exact
392 cross-over from one TICK to the next. We know that the
393 tick value is larger than 10 so if the difference
394 between two calls to the timer is > 10 then it must
395 have been a TICK that just went through. This is
396 not "friendly" code but since we are testing the system
397 and it is not "application" code, it is not a problem.
400 while ((spt
->tmReq
->tr_time
.tv_micro
-spt
->tmVal
.tv_micro
) < 10)
402 /* Store current timeval as the timer result */
403 spt
->tmVal
= spt
->tmReq
->tr_time
;
405 /* Get the current timeval... */
406 spt
->tmReq
->tr_node
.io_Command
= TR_GETSYSTIME
;
407 spt
->tmReq
->tr_node
.io_Flags
= IOF_QUICK
;
408 DoIO((struct IORequest
*)(spt
->tmReq
));
411 /* Store current timeval as the timer result */
412 spt
->tmVal
= spt
->tmReq
->tr_time
;
419 static void Stop_Timer(struct SpeedTimer
*spt
)
421 struct Library
*TimerBase
= (struct Library
*)(spt
->tmReq
->tr_node
.io_Device
);
423 /* Get the current timeval. */
424 spt
->tmReq
->tr_node
.io_Command
= TR_GETSYSTIME
;
425 spt
->tmReq
->tr_node
.io_Flags
= IOF_QUICK
;
427 DoIO((struct IORequest
*)(spt
->tmReq
));
429 /* Subtract last timer result and store as the timer result */
430 SubTime(&(spt
->tmReq
->tr_time
),&(spt
->tmVal
));
431 spt
->tmVal
=spt
->tmReq
->tr_time
;
435 Free a SpeedTimer structure as best as possible. Do all of the error checks
436 here since this will also be called for partial timer initializations.
439 static void Free_Timer(struct SpeedTimer
*spt
)
447 if (spt
->Open
) CloseDevice((struct IORequest
*)(spt
->tmReq
));
448 DeleteIORequest((struct IORequest
*)(spt
->tmReq
));
450 DeleteMsgPort(spt
->tmPort
);
452 FreeMem(spt
,sizeof(struct SpeedTimer
));
457 Initialize a SpeedTimer structure. It will return NULL if it did not work.
460 static struct SpeedTimer
*Init_Timer(void)
462 struct SpeedTimer
*spt
;
464 if ((spt
= AllocMem(sizeof(struct SpeedTimer
),MEMF_PUBLIC
|MEMF_CLEAR
)))
467 if ((spt
->tmPort
= CreateMsgPort()))
469 if ((spt
->tmReq
= (struct timerequest
*)CreateIORequest(spt
->tmPort
,sizeof(struct timerequest
))))
471 if (!OpenDevice(TIMERNAME
,UNIT_MICROHZ
,(struct IORequest
*)(spt
->tmReq
),0L)) spt
->Open
= TRUE
;
484 Now, for the routines that will pull in the lines and display them as
485 needed in the display...
488 static void AddDisplayLine(struct DiskSpeed
*global
,const char *line
)
490 ULONG size
= strlen(line
);
492 if (diskspeedmui_intern
.disk_main_win
) /* add the line to the zune listview */
494 DoMethod(diskspeedmui_intern
.resultlv
, MUIM_List_InsertSingle
, (IPTR
)line
, MUIV_List_Insert_Bottom
);
495 DoMethod(diskspeedmui_intern
.resultlv
, MUIM_List_Jump
, 0x7fffffff);
496 DoMethod(diskspeedmui_intern
.disk_app
, MUIM_Application_CheckRefresh
);
498 else if (global
->Output
)
500 Write(global
->Output
,(APTR
)line
,size
);
501 Write(global
->Output
,"\n",1);
507 static LONG
Check_Quit(struct DiskSpeed
*global
)
511 if (SetSignal(0,SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
) worked
= FALSE
;
513 if (!worked
) AddDisplayLine(global
,GetString(MSG_USERINT
));
519 It knows that the Y value is fixed point by n-digits...
522 static ULONG
MaxDivide(ULONG x
,ULONG y
,ULONG digits
)
525 ULONG num
= 0; /* Number of 10 units adjusted for so far */
527 while ((x
<399999999) && (num
<digits
))
536 if (num
== digits
) y
+=5; /* Round it if last digit... */
541 else result
= -1; /* MAX INT if y=0 */
547 Build a string and add it to the display of results.
548 This routine knows how to take the timer results and the CPU
549 results and format them into a string with the given header
550 and the given unit of measure.
553 static VOID
Display_Result(struct DiskSpeed
*global
,const char *Header
,ULONG number
,const char *Units
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
555 char *st_string
= global
->tmp1
;
557 ULONG clicks
= 0; /* To figure out the number of clicks/second */
561 /* First, make sure (as best as possible) that the CPU values are right */
562 CPU_AVAIL_struct
->_CPU_State_Flag
= TRUE
;
563 Delay(1); /* Let it run into the TRUE _CPU_State_Flag */
565 /* 1,000,000 micro = 1 second... */
566 tmVal
= (global
->timer
->tmVal
.tv_secs
* 1000000) + global
->timer
->tmVal
.tv_micro
;
567 /* tmVal is now in micro seconds... */
569 number
=MaxDivide(number
,tmVal
,6);
571 strcpy(format
,"%s %9ld %s");
574 strcpy(format
,"%s < %ld %s");
578 if (global
->Base_CPU
)
580 tmp_time
= tmVal
; /* For below... */
582 while (CPU_AVAIL_struct
->_CPU_Count_High
)
584 /* Adjust the tmVal and the CPU count as needed */
585 tmp_time
= tmp_time
>> 1;
586 CPU_AVAIL_struct
->_CPU_Count_Low
= CPU_AVAIL_struct
->_CPU_Count_Low
>> 1;
587 if (CPU_AVAIL_struct
->_CPU_Count_High
& 1) CPU_AVAIL_struct
->_CPU_Count_Low
+= 0x80000000;
588 CPU_AVAIL_struct
->_CPU_Count_High
= CPU_AVAIL_struct
->_CPU_Count_High
>> 1;
591 clicks
= MaxDivide(CPU_AVAIL_struct
->_CPU_Count_Low
,tmp_time
,6);
592 clicks
= (MaxDivide(clicks
,global
->Base_CPU
,3)+5)/10;
593 global
->CPU_Total
+= clicks
;
596 strcat(format
,GetString(MSG_CPUAVAIL
));
599 sprintf(st_string
,format
,Header
,number
,Units
,clicks
);
601 AddDisplayLine(global
,st_string
);
604 static VOID
Display_Error(struct DiskSpeed
*global
,const char *test
)
606 sprintf(global
->tmp1
,GetString(MSG_ERR_FAIL
),test
);
607 AddDisplayLine(global
,global
->tmp1
);
612 static BOOL
SpeedTest(struct DiskSpeed
*global
,ULONG size
,ULONG offset
,ULONG mem_type
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
616 char *mem
; /* What we really allocated */
621 AddDisplayLine(global
,"");
624 if (mem_type
& MEMF_CHIP
) type
= "CHIP";
627 if (offset
& 2) type2
= "WORD";
628 if (offset
& 1) type2
= "BYTE";
630 /* Round to block sizes */
631 size
= (size
+511) & (~511);
633 if ((mem
= AllocMem(size
+offset
,mem_type
|MEMF_PUBLIC
)))
635 /* Set up memory... */
636 buffer
= &(mem
[offset
]);
638 sprintf(global
->tmp1
,GetString(MSG_TSTBUFF
),size
,type
,type2
);
639 AddDisplayLine(global
,global
->tmp1
);
643 Start_Timer(global
->timer
);
644 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
645 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
647 global
->DiskIO
.iotd_Req
.io_Command
= CMD_READ
;
648 global
->DiskIO
.iotd_Req
.io_Flags
= 0;
649 global
->DiskIO
.iotd_Req
.io_Length
= size
;
650 global
->DiskIO
.iotd_Req
.io_Data
= buffer
;
651 global
->DiskIO
.iotd_Req
.io_Offset
= count
;
653 DoIO((struct IORequest
*)&global
->DiskIO
);
654 count
+= global
->DiskIO
.iotd_Req
.io_Actual
;
656 if (global
->DiskIO
.iotd_Req
.io_Error
)
659 Display_Error(global
,GetString(MSG_ERR_RDEV
));
662 Stop_Timer(global
->timer
);
664 if (worked
) Display_Result(global
,GetString(MSG_BYTES_READ
),count
,GetString(MSG_BYTE_UNITS
), CPU_AVAIL_struct
);
666 Free_CPU_Available(CPU_AVAIL_struct
);
667 FreeMem(mem
,size
+offset
);
671 sprintf(global
->tmp1
,GetString(MSG_SKIPMEM
),size
,type
);
672 AddDisplayLine(global
,global
->tmp1
);
678 #else /* SCSI_SPEED */
681 In order to keep the file create test fair, it must always do
682 the same number of files. The way filing systems work, many times
683 the get slower as the number of files in a directory grow
686 static LONG
CreateFileTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
691 STRPTR st_string
= global
->tmp1
; /* For speed reasons */
693 Start_Timer(global
->timer
);
694 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
696 for (count
=0;(count
<NUM_FILES
) && (worked
&= Check_Quit(global
));count
++)
698 sprintf(st_string
,FILE_STRING
,(unsigned long)count
);
699 if (file
= Open(st_string
,MODE_NEWFILE
)) Close(file
);
702 Display_Error(global
,GetString(MSG_ERR_CFILE
));
707 Stop_Timer(global
->timer
);
709 if (worked
) Display_Result(global
,GetString(MSG_FILE_CREATE
),NUM_FILES
,GetString(MSG_FILE_UNITS
), CPU_AVAIL_struct
);
711 Free_CPU_Available(CPU_AVAIL_struct
);
716 static LONG
OpenFileTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
721 STRPTR st_string
= global
->tmp1
;
723 Start_Timer(global
->timer
);
724 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
725 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
727 sprintf(st_string
,FILE_STRING
,(unsigned long)(count
% NUM_FILES
));
729 if (file
=Open(st_string
,MODE_OLDFILE
)) Close(file
);
732 Display_Error(global
,GetString(MSG_ERR_OFILE
));
736 Stop_Timer(global
->timer
);
738 if (worked
) Display_Result(global
,GetString(MSG_FILE_OPEN
),count
,GetString(MSG_FILE_UNITS
), CPU_AVAIL_struct
);
740 Free_CPU_Available(CPU_AVAIL_struct
);
744 static LONG
ScanDirectoryTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
750 Start_Timer(global
->timer
);
751 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
752 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
756 if (!ExNext(lock
,global
->fib
)) lock
= NULL
;
761 CurrentDir(lock
= CurrentDir(NULL
));
762 if (Examine(lock
,global
->fib
)) count
++;
765 Display_Error(global
,GetString(MSG_ERR_DIRSCAN
));
770 Stop_Timer(global
->timer
);
772 if (worked
) Display_Result(global
,GetString(MSG_FILE_SCAN
),count
,GetString(MSG_FILE_UNITS
), CPU_AVAIL_struct
);
774 Free_CPU_Available(CPU_AVAIL_struct
);
779 In order to keep the file delete test fair, it must always do
780 the same number of files. The way filing systems work, many times
781 the get slower as the number of files in a directory grow
784 static LONG
DeleteFileTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
788 STRPTR st_string
= global
->tmp1
;
790 Start_Timer(global
->timer
);
791 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
793 for (count
= 0;(count
<NUM_FILES
) && (worked
&= Check_Quit(global
));count
++)
795 sprintf(st_string
,FILE_STRING
,(unsigned long)count
);
796 if (!DeleteFile(st_string
))
798 Display_Error(global
,GetString(MSG_ERR_DFILE
));
803 Stop_Timer(global
->timer
);
805 if (worked
) Display_Result(global
,GetString(MSG_FILE_DELETE
),NUM_FILES
,GetString(MSG_FILE_UNITS
), CPU_AVAIL_struct
);
807 Free_CPU_Available(CPU_AVAIL_struct
);
812 static LONG
SeekReadTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
822 /* First we build a file by writing the ROM to disk... */
823 if (file
= Open(FILE_STRING
,MODE_NEWFILE
))
825 size
= 0x40000; /* Start by asking for 256K */
826 while (size
&& (!(buf
= AllocMem(size
,MEMF_PUBLIC
)))) size
= size
>>1;
831 /* Write a 256K file... */
832 count
= 0x40000/size
;
833 while ((count
>0) && (worked
&=Check_Quit(global
)))
836 if (size
!= Write(file
,buf
,size
))
839 Display_Error(global
,GetString(MSG_ERR_SEEK
));
844 else Display_Error(global
,GetString(MSG_ERR_SEEK
));
846 Start_Timer(global
->timer
);
847 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
848 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
850 Seek(file
,pos
,OFFSET_BEGINNING
);
851 Read(file
,buffer
,64);
854 Seek(file
,-(pos
+64),OFFSET_END
);
855 Read(file
,buffer
,64);
858 Seek(file
,-(pos
+(size
/3)),OFFSET_CURRENT
);
859 Read(file
,buffer
,64);
862 /* Come up with another position... */
863 pos
=(pos
+(size
/11)) % (size
/3);
865 Stop_Timer(global
->timer
);
867 if (worked
) Display_Result(global
,GetString(MSG_SEEK_READ
),count
,GetString(MSG_SEEK_UNITS
), CPU_AVAIL_struct
);
869 Free_CPU_Available(CPU_AVAIL_struct
);
872 DeleteFile(FILE_STRING
);
874 else Display_Error(global
,GetString(MSG_ERR_SEEK
));
879 static BOOL
SpeedTest(struct DiskSpeed
*global
,ULONG size
,ULONG offset
,ULONG mem_type
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
883 char *mem
; /* What we really allocated */
891 AddDisplayLine(global
,"");
894 if (mem_type
& MEMF_CHIP
) type
="CHIP";
897 if (offset
& 2) type2
="WORD";
898 if (offset
& 1) type2
="BYTE";
900 if ((mem
=AllocMem(size
+offset
,mem_type
|MEMF_PUBLIC
)))
902 /* Set up memory... */
903 buffer
=&(mem
[offset
]);
905 for (loop
=0;loop
<size
;loop
++) buffer
[loop
]=(unsigned short )loop
;
907 sprintf(global
->tmp1
,GetString(MSG_TSTBUFF
),size
,type
,type2
);
908 AddDisplayLine(global
,global
->tmp1
);
913 Start_Timer(global
->timer
);
914 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
915 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
919 if (file
) Close(file
);
920 DeleteFile(FILE_STRING
);
921 if (!(file
= Open(FILE_STRING
,MODE_NEWFILE
)))
923 Display_Error(global
,GetString(MSG_ERR_CFILE
));
926 times
= 0x40000/size
; /* Try to make file at least 256K size */
930 if (size
!= Write(file
,buffer
,size
))
932 Display_Error(global
,GetString(MSG_ERR_CFILE
));
939 Stop_Timer(global
->timer
);
941 if (worked
) Display_Result(global
,GetString(MSG_BYTES_CREATE
),count
,GetString(MSG_BYTE_UNITS
), CPU_AVAIL_struct
);
943 /* Fill out the file... */
944 if (file
) while ((worked
&= Check_Quit(global
)) && (times
>0))
946 Write(file
,buffer
,size
);
950 if (file
) Close(file
);
953 if (worked
) if (!(file
=Open(FILE_STRING
,MODE_OLDFILE
)))
955 Display_Error(global
,GetString(MSG_ERR_WFILE
));
962 Start_Timer(global
->timer
);
963 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
964 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
968 Seek(file
,0,OFFSET_BEGINNING
);
969 times
= 0x40000/size
; /* Try to make file at least 256K size */
971 if (size
!= Write(file
,buffer
,size
))
973 Display_Error(global
,GetString(MSG_ERR_WFILE
));
979 Stop_Timer(global
->timer
);
981 if (worked
) Display_Result(global
,GetString(MSG_BYTES_WRITE
),count
,GetString(MSG_BYTE_UNITS
), CPU_AVAIL_struct
);
983 if (file
) Close(file
);
986 if (worked
) if (!(file
= Open(FILE_STRING
,MODE_OLDFILE
)))
988 Display_Error(global
,GetString(MSG_ERR_RFILE
));
995 Start_Timer(global
->timer
);
996 Init_CPU_Available(CPU_AVAIL_struct
); /* Start counting free CPU cycles... */
997 while ((worked
&= Check_Quit(global
)) && (Read_Timer(global
->timer
) < global
->Min_Time
))
1001 Seek(file
,0,OFFSET_BEGINNING
);
1002 times
= 0x40000/size
; /* Try to make file at least 256K size */
1004 if (size
!= Read(file
,buffer
,size
))
1006 Display_Error(global
,GetString(MSG_ERR_RFILE
));
1012 Stop_Timer(global
->timer
);
1016 for (loop
=0;loop
<size
;loop
++) worked
&= (buffer
[loop
] == (char)loop
);
1017 if (!worked
) AddDisplayLine(global
,GetString(MSG_ERR_DATA
));
1020 if (worked
) Display_Result(global
,GetString(MSG_BYTES_READ
),count
,GetString(MSG_BYTE_UNITS
),CPU_AVAIL_struct
);
1022 if (file
) Close(file
);
1024 Free_CPU_Available(CPU_AVAIL_struct
);
1025 FreeMem(mem
,size
+offset
);
1026 DeleteFile(FILE_STRING
);
1030 sprintf(global
->tmp1
,GetString(MSG_SKIPMEM
),size
,type
);
1031 AddDisplayLine(global
,global
->tmp1
);
1038 Clean up (remove) all of the files in the current directory...
1041 static void CleanUpFiles(struct DiskSpeed
*global
)
1045 CurrentDir(lock
= CurrentDir(NULL
)); /* Get current directory lock */
1049 if (Examine(lock
,global
->fib
))
1051 if (ExNext(lock
,global
->fib
)) DeleteFile(global
->fib
->fib_FileName
);
1058 #endif /* SCSI_SPEED */
1060 static void DoTests(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
1062 char *st_string
=global
->tmp1
;
1071 #endif /* !SCSI_SPEED */
1074 Ok, so now we are ready to run... Display the
1078 strcpy(st_string
,GetString(MSG_PROCESSOR
));
1079 strcat(st_string
,global
->CPU_Type
);
1080 #if defined(__AROS__)
1081 strcat(st_string
,GetString(MSG_BLDAROS
));
1083 strcat(st_string
,GetString(MSG_BLDMOS
));
1085 strcat(st_string
,global
->Exec_Ver
);
1086 if (global
->HighDMA
) strcat(st_string
,GetString(MSG_DMAHIGH
));
1087 else strcat(st_string
,GetString(MSG_DMANORM
));
1088 strcat(st_string
,GetString(MSG_VIDDMA
));
1089 AddDisplayLine(global
,st_string
);
1092 Now, if we are in 2.0 OS, we can also find out the number of buffers
1093 (maybe) on that device. This is important.
1097 sprintf(st_string
,"Device: %s",global
->Device
);
1101 fstring
= "Device: %s Buffers: <information unavailable>";
1103 if (DOSBase
->dl_lib
.lib_Version
> 36L)
1107 Ok, so we can now try to get a reading of the buffers
1108 for the place we are about to test...
1110 Note: Since we are in the "CURRENTDIR" of the test disk,
1111 we are using "" as the "device" to which to call AddBuffers()
1113 if ((buffers
= AddBuffers("",0)) > 0) fstring
="Device: %s Buffers: %ld";
1116 sprintf(st_string
,fstring
,global
->Device
,buffers
);
1118 #endif /* SCSI_SPEED */
1120 AddDisplayLine(global
,st_string
);
1122 if (global
->Comments
[0])
1124 strcpy(st_string
,GetString(MSG_CMMNTS
));
1125 strcat(st_string
,global
->Comments
);
1126 AddDisplayLine(global
,st_string
);
1129 AddDisplayLine(global
,"");
1131 if (CPU_AVAIL_struct
->_CPU_Use_Base
) Delay(60); /* Make sure filesystem has flushed... */
1133 Init_CPU_Available(CPU_AVAIL_struct
);
1134 if (CPU_AVAIL_struct
->_CPU_Use_Base
) Delay(225); /* Get a quick reading (~4.5 seconds) */
1136 Free_CPU_Available(CPU_AVAIL_struct
);
1138 if (CPU_AVAIL_struct
->_CPU_Use_Base
)
1141 Now, generate a countdown value that is aprox 3 times 4.5 second...
1143 CPU_AVAIL_struct
->_CPU_Use_Base
= (CPU_AVAIL_struct
->_CPU_Count_Low
* 3) + 1;
1144 CPU_AVAIL_struct
->_CPU_Count_Low
= CPU_AVAIL_struct
->_CPU_Use_Base
;
1147 Start_Timer(global
->timer
);
1148 CPU_Calibrate(CPU_AVAIL_struct
);
1149 Stop_Timer(global
->timer
);
1153 If it looks like we did not get a good reading,
1154 set up _CPU_Use_Base to 0 in order to turn off
1158 if (global
->timer
->tmVal
.tv_secs
< 4)
1160 AddDisplayLine(global
,GetString(MSG_ERR_CALIB1
));
1161 AddDisplayLine(global
,GetString(MSG_ERR_CALIB2
));
1162 CPU_AVAIL_struct
->_CPU_Use_Base
= 0;
1164 else CPU_AVAIL_struct
->_CPU_Use_Base
= MaxDivide(CPU_AVAIL_struct
->_CPU_Use_Base
,(global
->timer
->tmVal
.tv_secs
* 1000000) + global
->timer
->tmVal
.tv_micro
,6);
1167 global
->Base_CPU
= CPU_AVAIL_struct
->_CPU_Use_Base
;
1169 if (CPU_AVAIL_struct
->_CPU_Use_Base
) sprintf(st_string
,GetString(MSG_CPUSPD
),(((CPU_AVAIL_struct
->_CPU_Use_Base
/500)+1) >> 1 ));
1170 else strcpy(st_string
,GetString(MSG_NOCPU
));
1171 AddDisplayLine(global
,st_string
);
1172 AddDisplayLine(global
,"");
1174 global
->CPU_Total
= 0L;
1175 global
->CPU_Count
= 0L;
1177 working
= Check_Quit(global
);
1181 if (working
&& global
->Test_DIR
)
1183 AddDisplayLine(global
,GetString(MSG_TSTMANP
));
1184 if (working
) working
= CreateFileTest(global
, CPU_AVAIL_struct
);
1185 if (working
) working
= OpenFileTest(global
, CPU_AVAIL_struct
);
1186 if (working
) working
= ScanDirectoryTest(global
, CPU_AVAIL_struct
);
1187 if (working
) working
= DeleteFileTest(global
, CPU_AVAIL_struct
);
1190 if (working
&& global
->Test_SEEK
)
1192 AddDisplayLine(global
,"");
1193 if (working
) working
= SeekReadTest(global
, CPU_AVAIL_struct
);
1196 #endif /* !SCSI_SPEED */
1198 /* Now for some of the more complex tests */
1199 /* result=SpeedTest(global,Buffer,offset,mem_type); */
1201 memtype
= MEMF_FAST
;
1204 if (memtype
& global
->Mem_TYPES
) for (offset
= 4;offset
>0;offset
=offset
>> 1) if (offset
& global
->Align_Types
)
1206 for (size
= 0;size
<4;size
++) if (global
->Test_Size
[size
])
1208 if (working
) working
= SpeedTest(global
,global
->Test_Size
[size
],offset
&3,memtype
, CPU_AVAIL_struct
);
1212 if (memtype
& MEMF_CHIP
) memtype
= 0;
1213 else memtype
= MEMF_CHIP
;
1218 CleanUpFiles(global
);
1220 #endif /* !SCSI_SPEED */
1222 if ((working
) && (global
->CPU_Count
))
1224 AddDisplayLine(global
,"");
1225 global
->CPU_Total
= (((global
->CPU_Total
<< 1) / global
->CPU_Count
)+1) >> 1;
1226 global
->CPU_Count
= (((global
->Base_CPU
* global
->CPU_Total
) / 50000)+1) >> 1;
1227 sprintf(st_string
,GetString(MSG_AVGCPU
),global
->CPU_Total
,global
->CPU_Count
);
1228 AddDisplayLine(global
,st_string
);
1234 static void StartTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
1241 oldwindow
= global
->Me
->pr_WindowPtr
;
1242 global
->Me
->pr_WindowPtr
= (APTR
)(-1L);
1244 if (diskspeedmui_intern
.resultlv
)
1245 DoMethod(diskspeedmui_intern
.resultlv
, MUIM_List_Clear
);
1247 AddDisplayLine(global
,COPYRIGHT
);
1248 AddDisplayLine(global
,STR_SEPERATOR
);
1250 st_string
= global
->Device
;
1253 if (*st_string
== ':') unit
= st_string
;
1264 while ((unit
) && (*unit
))
1266 if ((*unit
< '0') || (*unit
>'9')) unit
= NULL
;
1270 scsi_unit
+= *unit
-'0';
1278 memset(&(global
->DiskIO
),0,sizeof(struct IOExtTD
));
1279 if ((global
->DiskIO
.iotd_Req
.io_Message
.mn_ReplyPort
= CreateMsgPort()))
1281 if (!OpenDevice(global
->Device
,scsi_unit
, (struct IORequest
*)&global
->DiskIO
, 0))
1285 DoTests(global
, CPU_AVAIL_struct
);
1286 CloseDevice((struct IORequest
*)&global
->DiskIO
);
1288 DeleteMsgPort(global
->DiskIO
.iotd_Req
.io_Message
.mn_ReplyPort
);
1290 if (unit
) AddDisplayLine(global
,GetString(MSG_ERR_NODEV
));
1292 else AddDisplayLine(global
,GetString(MSG_ERR_BADSPEC
));
1294 if (st_string
) *st_string
= ':';
1296 global
->Me
->pr_WindowPtr
= oldwindow
;
1299 #else /* SCSI_SPEED */
1301 static void StartTest(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
1307 oldwindow
= global
->Me
->pr_WindowPtr
;
1308 global
->Me
->pr_WindowPtr
= (APTR
)(-1L);
1310 AddDisplayLine(global
,COPYRIGHT
);
1311 AddDisplayLine(global
,STR_SEPERATOR
);
1313 if (lock
= Lock(global
->Device
,ACCESS_READ
))
1315 lock
= CurrentDir(lock
);
1316 if (newlock
= CreateDir(TEST_DIR
))
1319 if (newlock
= Lock(TEST_DIR
,ACCESS_READ
))
1321 newlock
= CurrentDir(newlock
);
1324 Now do all of the tests...
1327 DoTests(global
, CPU_AVAIL_struct
);
1329 newlock
= CurrentDir(newlock
);
1332 else AddDisplayLine(global
,GetString(MSG_ERR_BADDIR
));
1333 DeleteFile(TEST_DIR
);
1335 else AddDisplayLine(global
,GetString(MSG_ERR_NODIR
));
1336 lock
= CurrentDir(lock
);
1339 else AddDisplayLine(global
,GetString(MSG_ERR_NOLOCK
));
1341 global
->Me
->pr_WindowPtr
= oldwindow
;
1344 #endif /* SCSI_SPEED */
1346 static VOID
SetVersionStrings(struct DiskSpeed
*global
)
1348 // UWORD flags = ((struct ExecBase *)(SysBase))->AttnFlags;
1349 ULONG sysVer
= ((struct ExecBase
*)(SysBase
))->LibNode
.lib_Version
;
1350 ULONG sofVer
= ((struct ExecBase
*)(SysBase
))->SoftVer
;
1353 #if defined(__PPC__)
1354 strcpy( global
->CPU_Type
,"PPC" );
1356 strcpy( global
->CPU_Type
,"i386" );
1358 // st_string = &( global->CPU_Type[1] );
1360 sprintf(global
->Exec_Ver
,"%ld.%ld",(long) sysVer
,(long) sofVer
);
1364 A simple string check that also works with '=' at the end of the string
1367 static char *Check_String(char *arg
,char *match
)
1372 D(bug("ParseArg() in Check_String()\n"));
1377 if (*st_string
== '=')
1385 if (stricmp(arg
,match
))
1387 if (next
) *next
= '=';
1393 else next
= st_string
;
1400 This routine closes down the GUI
1403 static void Close_GUI(struct DiskSpeed
*global
)
1407 MUI_DisposeObject(diskspeedmui_intern
.disk_app
);
1408 CloseLibrary(MUIMasterBase
);
1412 static Object
*MakeCheck (CONST_STRPTR label
, ULONG id
, ULONG checked
)
1414 Object
*obj
= MUI_MakeObject(MUIO_Checkmark
, (IPTR
)label
);
1417 SetAttrs(obj
, MUIA_CycleChain
, 1, MUIA_ObjectID
, id
, MUIA_Selected
, checked
, TAG_DONE
);
1422 static APTR
MakeButton(const char *string
)
1425 if (obj
= MUI_MakeObject(MUIO_Button
, (IPTR
)string
))
1426 SetAttrs(obj
, MUIA_CycleChain
, 1, TAG_DONE
);
1433 This routine is used to open the GUI...
1436 static APTR
Open_GUI(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
, struct DiskObject
*dobj
, int load_config
)
1438 // BOOL worked = FALSE;
1440 D(bug("Open_GUI()\n"));
1442 if ((MUIMasterBase
)&&(!diskspeedmui_intern
.disk_app
))
1444 sprintf(global
->tmp1
,GetString(MSG_MAIN_WINTITLE
),APPNAME
);
1445 sprintf(global
->tmp2
,GetString(MSG_Welcome
),
1447 GetString(MSG_W_DEVICE
));
1449 GetString(MSG_W_FILESYS
));
1450 #endif /* SCSI_SPEED */
1452 diskspeedmui_intern
.disk_app
= ApplicationObject
,
1453 MUIA_Application_DiskObject
, (IPTR
)dobj
,
1454 MUIA_Application_Title
, (IPTR
)APPNAME
,
1455 MUIA_Application_Version
, (IPTR
)CXVERSION
,
1456 MUIA_Application_Copyright
, (IPTR
)"Copyright © 1995-2016, The AROS Development Team",
1457 MUIA_Application_Author
, (IPTR
)"The AROS Development Team",
1458 MUIA_Application_Description
, (IPTR
)GetString(MSG_DESCRIPTION
),
1459 MUIA_Application_Base
, (IPTR
)APPNAME
,
1460 MUIA_Application_Menustrip
, (IPTR
)(MenustripObject
,
1461 MUIA_Family_Child
, (IPTR
)(MenuObject
,
1462 MUIA_Menuitem_Title
, (IPTR
)GetString(WORD_MENU_Project
),
1463 MUIA_Family_Child
, (IPTR
)(diskspeedmui_intern
.about_item
= MenuitemObject
,
1464 MUIA_Menuitem_Title
, (IPTR
)GetString(WORD_MENU_About
),
1466 MUIA_Family_Child
, (IPTR
)(diskspeedmui_intern
.quit_item
= MenuitemObject
,
1467 MUIA_Menuitem_Title
, (IPTR
)GetString(WORD_MENU_Quit
),
1471 SubWindow
, (IPTR
)(diskspeedmui_intern
.disk_main_win
= WindowObject
,
1472 MUIA_Window_Title
, global
->tmp1
,
1473 MUIA_Window_ID
, MAKE_ID('D','W','I','N'),
1474 MUIA_Window_Activate
, TRUE
,
1475 MUIA_Window_Height
, MUIV_Window_Height_Visible(50),
1476 MUIA_Window_Width
, MUIV_Window_Width_Visible(60),
1477 WindowContents
, VGroup
,
1478 Child
, VGroup
, /* Main Panel */
1480 MUIA_Background
, MUII_GroupBack
,
1481 Child
, (IPTR
)(diskspeedmui_intern
.welctext
= TextObject
,
1483 MUIA_Text_Contents
, global
->tmp2
,
1487 MUIA_HorizWeight
,100,
1488 Child
, Label(GetString(MSG_DEVICE
)),
1489 Child
, (IPTR
)(diskspeedmui_intern
.devicestr
= StringObject
,
1491 MUIA_CycleChain
, TRUE
,
1492 MUIA_String_MaxLen
, 255,
1493 MUIA_String_Contents
, global
->Device
,
1495 Child
, Label(GetString(MSG_CMMNTS
)),
1496 Child
, (IPTR
)(diskspeedmui_intern
.commentstr
= StringObject
,
1498 MUIA_CycleChain
, TRUE
,
1499 MUIA_String_MaxLen
, 255,
1502 Child
, (IPTR
)(diskspeedmui_intern
.configobj
= CoolImageIDButton(NULL
, COOL_INFOIMAGE_ID
)),
1504 Child
, ListviewObject
, /* Our results view */
1505 MUIA_Listview_List
, diskspeedmui_intern
.resultlv
= ListObject
,
1507 MUIA_Listview_Input
, FALSE
,
1508 /*MUIA_List_Title, TRUE,*/
1509 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1510 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1514 Child
, HGroup
, /* save/use/cancel button row */
1516 MUIA_Group_SameWidth
, TRUE
,
1517 Child
, (IPTR
)(diskspeedmui_intern
.beginobj
= CoolImageIDButton(GetString(MSG_START_TEST
), COOL_DOTIMAGE_ID
)),
1519 /*Child, diskspeedmui_intern.stopobj = CoolImageIDButton(GetString(MSG_STOP_TEST), COOL_CANCELIMAGE_ID),*/
1520 Child
, (IPTR
)(diskspeedmui_intern
.saveobj
= CoolImageIDButton(GetString(MSG_SAVE_RESULTS
), COOL_SAVEIMAGE_ID
)),
1524 //NEXT WINDOW.. ABOUT
1525 SubWindow
, (IPTR
)(diskspeedmui_intern
.disk_about_win
= AboutWindowObject
,
1526 MUIA_AboutWindow_Authors
, (IPTR
) TAGLIST
1536 NAME("Adam Chodorowski"),
1537 NAME("Fabio Alemagna")
1541 //NEXT WINDOW.. CONFIG
1542 SubWindow
, (IPTR
)(diskspeedmui_intern
.disk_config_win
= WindowObject
,
1543 MUIA_Window_Title
, (IPTR
)GetString(MSG_CONFIG_WINTITLE
),
1544 MUIA_Window_ID
, MAKE_ID('C','W','I','N'),
1545 WindowContents
, VGroup
,
1547 MUIA_Group_VertSpacing
, 0,
1550 MUIA_Group_VertSpacing
, 2,
1551 MUIA_Background
, MUII_GroupBack
,
1556 Child
, (IPTR
)(diskspeedmui_config
.dir_checkmark
= MakeCheck(NULL
, MAKE_ID('C','D','I','R'), TRUE
)),
1557 Child
, (IPTR
) LLabel("DIR"),
1559 Child
, (IPTR
)(diskspeedmui_config
.seek_checkmark
= MakeCheck(NULL
, MAKE_ID('S','E','E','K'), TRUE
)),
1560 Child
, (IPTR
) LLabel("SEEK"),
1561 Child
, (IPTR
)(diskspeedmui_config
.nocpu_checkmark
= MakeCheck(NULL
, MAKE_ID('N','C','P','U'), TRUE
)),
1562 Child
, (IPTR
) LLabel("NOCPU"),
1566 /*MUIA_Background, MUII_GroupBack,*/
1567 Child
, (IPTR
) CLabel("MINTIME"),
1568 Child
,(IPTR
)(diskspeedmui_config
.mintime
= StringObject
,
1571 MUIA_ObjectID
, MAKE_ID('M','I','N','T'),
1572 MUIA_String_Accept
, (IPTR
)"0123456789",
1578 End
, /* Misc Options */
1581 GroupFrameT(GetString(MSG_RWBUFS
)),
1582 MUIA_Group_VertSpacing
, 0,
1585 MUIA_Group_VertSpacing
, 2,
1586 Child
, LLabel(GetString(MSG_BUF1TXT
)),
1588 Child
,(IPTR
)(diskspeedmui_config
.buffer1
= StringObject
,
1591 MUIA_ObjectID
, MAKE_ID('B','U','F','1'),
1592 MUIA_String_Accept
, (IPTR
)"0123456789",
1593 MUIA_String_Format
, MUIV_String_Format_Right
,
1595 Child
, LLabel(GetString(MSG_BUF2TXT
)),
1597 Child
,(IPTR
)(diskspeedmui_config
.buffer2
= StringObject
,
1600 MUIA_ObjectID
, MAKE_ID('B','U','F','2'),
1601 MUIA_String_Accept
, (IPTR
)"0123456789",
1602 MUIA_String_Format
, MUIV_String_Format_Right
,
1604 Child
, LLabel(GetString(MSG_BUF3TXT
)),
1606 Child
,(IPTR
)(diskspeedmui_config
.buffer3
= StringObject
,
1609 MUIA_ObjectID
, MAKE_ID('B','U','F','3'),
1610 MUIA_String_Accept
, (IPTR
)"0123456789",
1611 MUIA_String_Format
, MUIV_String_Format_Right
,
1613 Child
, LLabel(GetString(MSG_BUF4TXT
)),
1615 Child
,(IPTR
)(diskspeedmui_config
.buffer4
= StringObject
,
1618 MUIA_ObjectID
, MAKE_ID('B','U','F','4'),
1619 MUIA_String_Accept
, (IPTR
)"0123456789",
1620 MUIA_String_Format
, MUIV_String_Format_Right
,
1624 End
, /* Buffer Sizes */
1626 GroupFrameT(GetString(MSG_RWBUFS
)),
1627 MUIA_Group_VertSpacing
, 0,
1632 MUIA_Group_VertSpacing
, 2,
1633 Child
, (IPTR
)(diskspeedmui_config
.long_checkmark
= MakeCheck(NULL
, MAKE_ID('L','O','N','G'), TRUE
)),
1634 Child
, (IPTR
) LLabel("LONG"),
1635 Child
, (IPTR
)(diskspeedmui_config
.word_checkmark
= MakeCheck(NULL
, MAKE_ID('W','O','R','D'), TRUE
)),
1636 Child
, (IPTR
) LLabel("WORD"),
1637 Child
, (IPTR
)(diskspeedmui_config
.byte_checkmark
= MakeCheck(NULL
, MAKE_ID('B','Y','T','E'), TRUE
)),
1638 Child
, (IPTR
) LLabel("BYTE"),
1642 MUIA_Group_VertSpacing
, 2,
1643 Child
, (IPTR
)(diskspeedmui_config
.fast_checkmark
= MakeCheck(NULL
, MAKE_ID('F','A','S','T'), TRUE
)),
1644 Child
, (IPTR
) LLabel("FAST"),
1645 Child
, (IPTR
)(diskspeedmui_config
.chip_checkmark
= MakeCheck(NULL
, MAKE_ID('C','H','I','P'), TRUE
)),
1646 Child
, (IPTR
) LLabel("CHIP"),
1651 End
, /* Buffer Types */
1652 // Child, diskspeedmui_intern.conokobj = CoolImageIDButton(GetString(MSG_OK), COOL_DOTIMAGE_ID),
1654 Child
, (IPTR
)(diskspeedmui_intern
.consaveobj
= MakeButton(GetString(MSG_GAD_SAVE
))),
1656 Child
, (IPTR
)(diskspeedmui_intern
.conuseobj
= MakeButton(GetString(MSG_GAD_USE
))),
1658 Child
, (IPTR
)(diskspeedmui_intern
.concancelobj
= MakeButton(GetString(MSG_GAD_CANCEL
))),
1664 if (diskspeedmui_intern
.disk_app
)
1670 ** Ditched config items stored to icon tooltypes. However DRIVE and COMMENT
1671 ** options are recognized still.
1674 DoMethod(diskspeedmui_intern
.disk_app
, MUIM_Application_Load
, MUIV_Application_Load_ENV
);
1680 if ((s
= FindToolType(dobj
->do_ToolTypes
, "DRIVE")))
1682 strcpy(global
->Device
, s
);
1685 if ((s
= FindToolType(dobj
->do_ToolTypes
, "COMMENT")))
1687 strcpy(global
->Comments
, s
);
1692 DoMethod(diskspeedmui_intern
.disk_main_win
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1694 DoMethod(diskspeedmui_intern
.configobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)diskspeedmui_intern
.disk_config_win
, 3, MUIM_Set
, MUIA_Window_Open
, TRUE
);
1696 // DoMethod(diskspeedmui_intern.stopobj, MUIM_Notify, MUIA_Pressed, FALSE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, RETURNID_STOP);
1697 DoMethod(diskspeedmui_intern
.saveobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, RETURNID_SAVE
);
1698 DoMethod(diskspeedmui_intern
.beginobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, RETURNID_BEGIN
);
1700 DoMethod(diskspeedmui_intern
.disk_config_win
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)diskspeedmui_intern
.disk_config_win
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
1701 DoMethod(diskspeedmui_intern
.consaveobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, RETURNID_SAVECONFIG
);
1702 DoMethod(diskspeedmui_intern
.conuseobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, RETURNID_USECONFIG
);
1703 DoMethod(diskspeedmui_intern
.concancelobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, MUIV_Notify_Window
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
1705 DoMethod(diskspeedmui_intern
.disk_about_win
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, MUIV_Notify_Window
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
1707 DoMethod(diskspeedmui_intern
.quit_item
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1708 DoMethod(diskspeedmui_intern
.about_item
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
, (IPTR
)diskspeedmui_intern
.disk_about_win
, 3, MUIM_Set
, MUIA_Window_Open
, TRUE
);
1711 set(diskspeedmui_intern
.configobj
, MUIA_HorizWeight
, 0); /* Set up the weight for the image ( so it takes up least space..) */
1713 set(diskspeedmui_intern
.commentstr
, MUIA_String_Contents
, global
->Comments
);
1714 set(diskspeedmui_intern
.devicestr
, MUIA_String_Contents
, global
->Device
);
1716 /* Set some reasonable values if saved values are rubbish */
1717 if (!getv(diskspeedmui_config
.mintime
, MUIA_String_Integer
))
1718 set(diskspeedmui_config
.mintime
, MUIA_String_Integer
, global
->Min_Time
);
1720 if (!getv(diskspeedmui_config
.buffer1
, MUIA_String_Integer
))
1721 set(diskspeedmui_config
.buffer1
, MUIA_String_Integer
, global
->Test_Size
[0]);
1723 if (!getv(diskspeedmui_config
.buffer2
, MUIA_String_Integer
))
1724 set(diskspeedmui_config
.buffer2
, MUIA_String_Integer
, global
->Test_Size
[1]);
1726 if (!getv(diskspeedmui_config
.buffer3
, MUIA_String_Integer
))
1727 set(diskspeedmui_config
.buffer3
, MUIA_String_Integer
, global
->Test_Size
[2]);
1729 if (!getv(diskspeedmui_config
.buffer4
, MUIA_String_Integer
))
1730 set(diskspeedmui_config
.buffer4
, MUIA_String_Integer
, global
->Test_Size
[3]);
1734 set( diskspeedmui_config
.dir_checkmark
, MUIA_Disabled
, TRUE
);
1735 set( diskspeedmui_config
.seek_checkmark
, MUIA_Disabled
, TRUE
);
1736 set( diskspeedmui_config
.long_checkmark
, MUIA_Selected
, TRUE
);
1737 set( diskspeedmui_config
.long_checkmark
, MUIA_Disabled
, TRUE
);
1738 set( diskspeedmui_config
.word_checkmark
, MUIA_Disabled
, TRUE
);
1739 set( diskspeedmui_config
.byte_checkmark
, MUIA_Disabled
, TRUE
);
1740 #else /* SCSI_SPEED */
1741 if (global
->Test_DIR
) set( diskspeedmui_config
.dir_checkmark
, MUIA_Selected
,TRUE
);
1742 if (global
->Test_SEEK
) set( diskspeedmui_config
.seek_checkmark
, MUIA_Selected
,TRUE
);
1743 if (global
->Align_Types
& 4) set( diskspeedmui_config
.long_checkmark
, MUIA_Selected
, TRUE
);
1744 if (global
->Align_Types
& 2) set( diskspeedmui_config
.word_checkmark
, MUIA_Selected
, TRUE
);
1745 if (global
->Align_Types
& 1) set( diskspeedmui_config
.byte_checkmark
, MUIA_Selected
, TRUE
);
1746 #endif /* SCSI_SPEED */
1747 if (CPU_AVAIL_struct
->_CPU_Use_Base
==0) set( diskspeedmui_config
.nocpu_checkmark
, MUIA_Selected
,TRUE
);
1749 if (global
->Mem_TYPES
& MEMF_FAST
) set( diskspeedmui_config
.fast_checkmark
,MUIA_Selected
,TRUE
);
1750 if (global
->Mem_TYPES
& MEMF_CHIP
) set( diskspeedmui_config
.chip_checkmark
,MUIA_Selected
,TRUE
);
1752 if (SysBase
->MaxLocMem
== 0)
1753 set( diskspeedmui_config
.chip_checkmark
, MUIA_Disabled
, TRUE
);
1757 return(diskspeedmui_intern
.disk_app
);
1761 This routine will append to the end of a file the results currently in memory...
1763 static void Save_Results(struct DiskSpeed
*global
)
1768 if ((fh
= Open(RESULTS_FILE
,MODE_OLDFILE
)))
1770 Seek(fh
,0,OFFSET_END
);
1771 Write(fh
,"\n\n\n",2);
1773 else fh
= Open(RESULTS_FILE
,MODE_NEWFILE
);
1777 node
= (struct Node
*)(global
->TextList
.mlh_Head
);
1778 while (node
->ln_Succ
)
1780 Write(fh
,node
->ln_Name
,strlen(node
->ln_Name
));
1782 node
= node
->ln_Succ
;
1790 This routine will retrieve the config settings from the MUI_Objects
1792 static void GET_Config(struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
1794 //BOOL error = TRUE;
1798 Ok, now get the information back out...
1801 get(diskspeedmui_config
.mintime
, MUIA_String_Integer
, &global
->Min_Time
);
1803 get(diskspeedmui_config
.buffer1
, MUIA_String_Integer
, &global
->Test_Size
[0]);
1804 get(diskspeedmui_config
.buffer2
, MUIA_String_Integer
, &global
->Test_Size
[1]);
1805 get(diskspeedmui_config
.buffer3
, MUIA_String_Integer
, &global
->Test_Size
[2]);
1806 get(diskspeedmui_config
.buffer4
, MUIA_String_Integer
, &global
->Test_Size
[3]);
1810 get( diskspeedmui_config
.dir_checkmark
, MUIA_Selected
, &tmp
);
1811 if (tmp
) global
->Test_DIR
=1;
1814 global
->Test_SEEK
=0;
1815 get( diskspeedmui_config
.seek_checkmark
, MUIA_Selected
, &tmp
);
1816 if (tmp
) global
->Test_SEEK
=1;
1818 CPU_AVAIL_struct
->_CPU_Use_Base
=1;
1819 get( diskspeedmui_config
.nocpu_checkmark
, MUIA_Selected
, &tmp
);
1820 if (tmp
) CPU_AVAIL_struct
->_CPU_Use_Base
=0;
1822 global
->Align_Types
&= (~4);
1823 get( diskspeedmui_config
.long_checkmark
, MUIA_Selected
,&tmp
);
1824 if (tmp
) global
->Align_Types
|= 1<<2;
1826 global
->Align_Types
&= (~2);
1827 get( diskspeedmui_config
.word_checkmark
, MUIA_Selected
,&tmp
);
1828 if (tmp
) global
->Align_Types
|= 1<<1;
1830 global
->Align_Types
&= (~1);
1831 get( diskspeedmui_config
.byte_checkmark
, MUIA_Selected
,&tmp
);
1832 if (tmp
) global
->Align_Types
|= 1;
1834 global
->Mem_TYPES
&= (~MEMF_FAST
);
1835 get( diskspeedmui_config
.fast_checkmark
,MUIA_Selected
,&tmp
);
1836 if (tmp
) global
->Mem_TYPES
|= (1 * MEMF_FAST
);
1838 global
->Mem_TYPES
&= (~MEMF_CHIP
);
1839 if (SysBase
->MaxLocMem
)
1841 get( diskspeedmui_config
.chip_checkmark
,MUIA_Selected
,&tmp
);
1842 if (tmp
) global
->Mem_TYPES
|= (1 * MEMF_CHIP
);
1845 set (diskspeedmui_intern
.disk_config_win
, MUIA_Window_Open
, FALSE
);
1849 DRIVE/K - select drive (Default is current directory or scsi.device:6)
1850 COMMENT/K - set comment string
1851 ALL/S - select all tests
1852 DIR/S - setect DIR tests
1853 SEEK/S - select SEEK tests
1854 CHIP/S - select CHIP memory buffer tests
1855 FAST/S - select FAST memory buffer tests
1856 LONG/S - select LONG aligned tests
1857 WORD/S - select WORD aligned tests
1858 BYTE/S - select BYTE aligned tests
1859 NOCPU/S - turn off CPU availability tests
1860 BUF1/K/N - select buffer size 1
1861 BUF2/K/N - select buffer size 2
1862 BUF3/K/N - select buffer size 3
1863 BUF4/K/N - select buffer size 4
1864 MINTIME/K/N - select the minimum test tmVal (default=8) in seconds
1865 WINDOW/S - use the GUI even though started from the CLI
1869 do the command line parsing here...
1871 static LONG
ParseArg(struct DiskSpeed
*global
,int argc
,char *argv
[],int start
,struct CPU_AVAIL
*CPU_AVAIL_struct
)
1876 LONG working
= TRUE
;
1877 LONG window
= FALSE
;
1879 D(bug("ParseArg()\n"));
1882 global
->Align_Types
= 4;
1883 #endif /* SCSI_SPEED */
1885 for (loop
= start
;loop
<argc
;loop
++)
1887 if (loop
>= 10) break;
1888 D(bug("ParseArg() in loop(argv=%ld,argc=%ld,start=%ld,loop=%ld))\n",argv
,argc
,start
,loop
));
1892 D(bug("ParseArg() Arg = ?\n"));
1896 else if ((next
=Check_String(arg
,"DRIVE")))
1898 D(bug("ParseArg() Arg = DRIVE\n"));
1902 if (loop
<argc
) next
= argv
[loop
];
1904 if (strlen(next
)>255) *next
= '\0';
1905 if (*next
) strcpy(global
->Device
,next
);
1906 else working
= FALSE
;
1908 else if ((next
=Check_String(arg
,"COMMENT")))
1910 D(bug("ParseArg() Arg = COMMENT\n"));
1914 if (loop
<argc
) next
= argv
[loop
];
1916 if (strlen(next
)>255) *next
= '\0';
1917 if (*next
) strcpy(global
->Comments
,next
);
1918 else working
= FALSE
;
1920 else if (Check_String(arg
,"ALL"))
1922 D(bug("ParseArg() Arg = ALL\n"));
1927 global
->Test_DIR
= TRUE
;
1928 global
->Test_SEEK
= TRUE
;
1929 global
->Align_Types
= 4|2|1;
1931 #endif /* !SCSI_SPEED */
1933 global
->Mem_TYPES
= (SysBase
->MaxLocMem
? MEMF_CHIP
: 0) | MEMF_FAST
;
1935 else if ((next
= Check_String(arg
,"BUF1")))
1937 D(bug("ParseArg() Arg = BUF1\n"));
1941 if (loop
<argc
) next
= argv
[loop
];
1943 if (*next
) stcd_l(next
,(long *)&(global
->Test_Size
[0]));
1946 else if ((next
= Check_String(arg
,"BUF2")))
1948 D(bug("ParseArg() Arg = BUF2\n"));
1952 if (loop
<argc
) next
= argv
[loop
];
1954 if (*next
) stcd_l(next
,(long *)&(global
->Test_Size
[1]));
1955 else working
= FALSE
;
1957 else if ((next
= Check_String(arg
,"BUF3")))
1959 D(bug("ParseArg() Arg = BUF3\n"));
1963 if (loop
<argc
) next
= argv
[loop
];
1965 if (*next
) stcd_l(next
,(long *)&(global
->Test_Size
[2]));
1966 else working
= FALSE
;
1968 else if ((next
= Check_String(arg
,"BUF4")))
1970 D(bug("ParseArg() Arg = BUF4\n"));
1974 if (loop
<argc
) next
=argv
[loop
];
1976 if (*next
) stcd_l(next
,(long *)&(global
->Test_Size
[3]));
1977 else working
= FALSE
;
1979 else if ((next
= Check_String(arg
,"MINTIME")))
1981 D(bug("ParseArg() Arg = MINTIME\n"));
1985 if (loop
<argc
) next
= argv
[loop
];
1987 if (*next
) stcd_l(next
,(long *)&(global
->Min_Time
));
1988 else working
= FALSE
;
1992 else if (Check_String(arg
,"DIR")) global
->Test_DIR
= TRUE
;
1993 else if (Check_String(arg
,"SEEK")) global
->Test_SEEK
= TRUE
;
1994 else if (Check_String(arg
,"LONG")) global
->Align_Types
|= 4;
1995 else if (Check_String(arg
,"WORD")) global
->Align_Types
|= 2;
1996 else if (Check_String(arg
,"BYTE")) global
->Align_Types
|= 1;
1998 #endif /* !SCSI_SPEED */
2000 else if (Check_String(arg
,"CHIP")) global
->Mem_TYPES
|=MEMF_CHIP
;
2001 else if (Check_String(arg
,"FAST")) global
->Mem_TYPES
|= MEMF_FAST
;
2002 else if (Check_String(arg
,"NOCPU")) CPU_AVAIL_struct
->_CPU_Use_Base
= FALSE
;
2003 else if (Check_String(arg
,"WINDOW")) window
= TRUE
;
2005 { /* Did not match, so error */
2006 D(bug("ParseArg() NO ARG MATCHES\n"));
2012 D(bug("ParseArg() loop().. FINISHED\n"));
2014 if (global
->Min_Time
< 1) global
->Min_Time
= 1;
2016 D(bug("ParseArg() - preparing to open MUI window\n"));
2018 if (working
&& window
) working
= Open_GUI(global
,CPU_AVAIL_struct
, NULL
, 0) != NULL
;
2023 void GrabComment (char *theString
)
2025 strcpy(global
->Comments
, theString
);
2028 void GrabDevice (char *theString
)
2030 strcpy(global
->Device
, theString
);
2033 static void HandleAll (struct DiskSpeed
*global
, struct CPU_AVAIL
*CPU_AVAIL_struct
)
2037 diskspeedmui_intern
.app_ret_val
= FALSE
;
2039 set (diskspeedmui_intern
.disk_main_win
, MUIA_Window_Open
, TRUE
);
2043 returnid
= (LONG
) DoMethod(diskspeedmui_intern
.disk_app
, MUIM_Application_NewInput
, (IPTR
) &sigs
);
2045 if (returnid
== MUIV_Application_ReturnID_Quit
)
2047 diskspeedmui_intern
.app_ret_val
= TRUE
;
2051 if ((returnid
== RETURNID_SAVECONFIG
) || (returnid
== RETURNID_USECONFIG
) || (returnid
== RETURNID_BEGIN
) || (returnid
== RETURNID_STOP
) || (returnid
== RETURNID_SAVE
)) break;
2055 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
2056 if (sigs
& SIGBREAKF_CTRL_C
) break;
2062 case RETURNID_BEGIN
:
2066 GET_Config(global
, CPU_AVAIL_struct
);
2068 GetAttr(MUIA_String_Contents
, diskspeedmui_intern
.commentstr
, &str1
);
2069 GetAttr(MUIA_String_Contents
, diskspeedmui_intern
.devicestr
, &str2
);
2071 strcpy(global
->Comments
, (char *)str1
);
2072 strcpy(global
->Device
, (char *)str2
);
2074 set(diskspeedmui_intern
.disk_app
, MUIA_Application_Sleep
, TRUE
);
2075 StartTest(global
, CPU_AVAIL_struct
);
2076 set(diskspeedmui_intern
.disk_app
, MUIA_Application_Sleep
, FALSE
);
2081 /* In order to support this the GUI would need to be threaded */
2086 Save_Results(global
);
2089 case RETURNID_SAVECONFIG
:
2090 DoMethod(diskspeedmui_intern
.disk_app
, MUIM_Application_Save
, MUIV_Application_Save_ENVARC
); /* fall through to USECONFIG */
2091 case RETURNID_USECONFIG
:
2092 DoMethod(diskspeedmui_intern
.disk_app
, MUIM_Application_Save
, MUIV_Application_Save_ENV
);
2093 set(diskspeedmui_intern
.disk_config_win
, MUIA_Window_Open
, FALSE
);
2101 This routine is called when we want to run from a GUI
2102 Normally, it is only called when started from Workbench
2103 or when the CLI WINDOW option is given...
2105 static void FromWanderer(struct DiskSpeed
*global
,int argc
,char *argv
[], struct CPU_AVAIL
*CPU_AVAIL_struct
)
2107 struct WBStartup
*startup
;
2108 struct WBArg
*wbarg
;
2110 startup
= (struct WBStartup
*) argv
;
2112 // D(bug("FromWanderer()\n"));
2114 if ((wbarg
= startup
->sm_ArgList
) && (startup
->sm_NumArgs
))
2117 struct DiskObject
*icon
;
2119 Check if we were started as a project and
2120 use that icon insted...
2122 if ((startup
->sm_NumArgs
) > 1) wbarg
++;
2124 lock
= CurrentDir(wbarg
->wa_Lock
);
2125 icon
= GetDiskObject(wbarg
->wa_Name
);
2131 global
->Test_DIR
= TRUE
;
2132 global
->Test_SEEK
= TRUE
;
2133 global
->Align_Types
= 4|2|1;
2134 global
->Mem_TYPES
= MEMF_CHIP
| MEMF_FAST
;
2138 D(bug("FromWanderer() - launching GUI\n"));
2140 if (Open_GUI(global
,CPU_AVAIL_struct
, icon
, 1))
2144 HandleAll(global
,CPU_AVAIL_struct
);
2145 if (diskspeedmui_intern
.app_ret_val
== TRUE
)
2146 { Close_GUI(global
);
2153 FreeDiskObject(icon
);
2157 D(bug("FromWanderer() Finished..\n"));
2161 This is the CLI starting point. We do the command line parsing here...
2163 static void FromCLI(struct DiskSpeed
*global
,int argc
,char *argv
[], struct CPU_AVAIL
*CPU_AVAIL_struct
)
2165 if (ParseArg(global
,argc
,argv
,1,CPU_AVAIL_struct
))
2167 if ( diskspeedmui_intern
.disk_app
)
2171 HandleAll(global
,CPU_AVAIL_struct
);
2172 if (diskspeedmui_intern
.app_ret_val
== TRUE
)
2173 { Close_GUI(global
);
2178 else StartTest(global
, CPU_AVAIL_struct
);
2183 AddDisplayLine(global
,"DRIVE/K,ALL/S,CHIP/S,FAST/S,NOCPU/S,BUF1/K/N,BUF2/K/N,BUF3/K/N,BUF4/K/N,MINTIME/K/N,WINDOW/S");
2185 #else /* SCSI_SPEED */
2186 AddDisplayLine(global
,"DRIVE/K,ALL/S,DIR/S,SEEK/S,CHIP/S,FAST/S,LONG/S,WORD/S,BYTE/S,NOCPU/S,BUF1/K/N,BUF2/K/N,BUF3/K/N,BUF4/K/N,MINTIME/K/N,WINDOW/S");
2188 #endif /* SCSI_SPEED */
2192 int main(int argc
, char *argv
[])
2194 struct DiskSpeed
*global
;
2195 struct CPU_AVAIL
*CPU_AVAIL_struct
;
2197 if ((CPU_AVAIL_struct
= AllocMem(sizeof(struct CPU_AVAIL
),MEMF_PUBLIC
|MEMF_CLEAR
)))
2199 CPU_AVAIL_struct
->_CPU_Use_Base
= TRUE
; /* We want to test with CPU */
2201 if ((global
= AllocMem(sizeof(struct DiskSpeed
),MEMF_PUBLIC
|MEMF_CLEAR
)))
2203 #if !defined(__AROS__)
2204 MyCatalog
= OpenCatalog(NULL
, "DiskSpeed.catalog", OC_BuiltInLanguage
, "english", TAG_DONE
);
2206 NEWLIST((struct List
*)&(global
->TextList
));
2207 SetVersionStrings(global
);
2208 global
->Me
= (struct Process
*)FindTask(NULL
);
2210 /* Standard MinTime */
2211 global
->Min_Time
=MIN_TEST_TIME
;
2213 /* Standard sizes */
2214 global
->Test_Size
[0] = 0x200;
2215 global
->Test_Size
[1] = 0x1000;
2216 global
->Test_Size
[2] = 0x8000;
2217 global
->Test_Size
[3] = 0x40000;
2219 if ((global
->timer
= Init_Timer()))
2221 #if defined (__MORPHOS__)
2222 strcpy(global
->Device
, SysBase
->MaxLocMem
? "scsi.device:0" : "ide.device:0");
2224 strcpy(global
->Device
, "ata.device:0");
2227 Now either set up Window or Output
2228 depending on where we were started...
2230 If we can not get Output, we set up the window...
2232 if ((argc
) && (global
->Output
=Output())) FromCLI(global
,argc
,argv
,CPU_AVAIL_struct
);
2233 else FromWanderer(global
,argc
,argv
,CPU_AVAIL_struct
);
2235 Free_Timer(global
->timer
);
2238 if ((global
->fib
= AllocMem(sizeof(struct FileInfoBlock
),MEMF_PUBLIC
)))
2240 if ((global
->timer
= Init_Timer()))
2243 if((lock
= Lock("",ACCESS_READ
)))
2246 NameFromLock(lock
, global
->Device
, sizeof(global
->Device
));
2249 if ((p
= strchr(global
->Device
, ':')))
2255 Now either set up Window or Output
2256 depending on where we were started...
2258 If we can not get Output, we set up the window...
2260 if ((argc
) && ((global
->Output
= Output()))) FromCLI(global
,argc
,argv
,CPU_AVAIL_struct
);
2261 else FromWanderer( global
,argc
,argv
,CPU_AVAIL_struct
);
2263 Free_Timer(global
->timer
);
2265 FreeMem(global
->fib
,sizeof(struct FileInfoBlock
));
2268 #endif /* SCSI_SPEED */
2269 #if !defined(__AROS__)
2270 CloseCatalog(MyCatalog
);
2272 FreeMem(global
,sizeof(struct DiskSpeed
));
2274 FreeMem(CPU_AVAIL_struct
,sizeof(struct CPU_AVAIL
));