]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / pm / tests / timerc.c
1 /****************************************************************************
2 *
3 *                   SciTech OS Portability Manager Library
4 *
5 *  ========================================================================
6 *
7 *    The contents of this file are subject to the SciTech MGL Public
8 *    License Version 1.0 (the "License"); you may not use this file
9 *    except in compliance with the License. You may obtain a copy of
10 *    the License at http://www.scitechsoft.com/mgl-license.txt
11 *
12 *    Software distributed under the License is distributed on an
13 *    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 *    implied. See the License for the specific language governing
15 *    rights and limitations under the License.
16 *
17 *    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 *
19 *    The Initial Developer of the Original Code is SciTech Software, Inc.
20 *    All Rights Reserved.
21 *
22 *  ========================================================================
23 *
24 * Language:     ANSI C
25 * Environment:  Any
26 *
27 * Description:  Test program for the Zen Timer Library.
28 *
29 ****************************************************************************/
30
31 #include <stdio.h>
32 #include "pmapi.h"
33 #include "ztimer.h"
34
35 #define DELAY_SECS  10
36
37 /*-------------------------- Implementation -------------------------------*/
38
39 /* The following routine takes a long count in microseconds and outputs
40  * a string representing the count in seconds. It could be modified to
41  * return a pointer to a static string representing the count rather
42  * than printing it out.
43  */
44
45 void ReportTime(ulong count)
46 {
47     ulong   secs;
48
49     secs = count / 1000000L;
50     count = count - secs * 1000000L;
51     printf("Time taken: %lu.%06lu seconds\n",secs,count);
52 }
53
54 int     i,j;                                /* NON register variables! */
55
56 int main(void)
57 {
58 #ifdef  LONG_TEST
59     ulong   start,finish;
60 #endif
61
62     printf("Processor type: %d %ld MHz\n", CPU_getProcessorType(), CPU_getProcessorSpeed(true));
63
64     ZTimerInit();
65
66     /* Test the long period Zen Timer (we don't check for overflow coz
67      * it would take tooooo long!)
68      */
69
70     LZTimerOn();
71     for (j = 0; j < 10; j++)
72         for (i = 0; i < 20000; i++)
73             i = i;
74     LZTimerOff();
75     ReportTime(LZTimerCount());
76
77     /* Test the ultra long period Zen Timer */
78 #ifdef LONG_TEST
79     start = ULZReadTime();
80     delay(DELAY_SECS * 1000);
81     finish = ULZReadTime();
82     printf("Delay of %d secs took %d 1/10ths of a second\n",
83         DELAY_SECS,ULZElapsedTime(start,finish));
84 #endif
85
86     return 0;
87 }