comparison packages/hal/common/current/tests/cache.c @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children 443894e2e912
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 /*=================================================================
2 //
3 // cache.c
4 //
5 // HAL Cache timing test
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Cygnus eCos Public License
12 // Version 1.0 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://sourceware.cygnus.com/ecos
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
26 // -------------------------------------------
27 //
28 //####COPYRIGHTEND####
29 //==========================================================================
30 //#####DESCRIPTIONBEGIN####
31 //
32 // Author(s): dsm
33 // Contributors: dsm, nickg
34 // Date: 1998-06-18
35 //####DESCRIPTIONEND####
36 */
37
38 #include <pkgconf/hal.h>
39
40 #include <cyg/infra/testcase.h>
41
42 #include <cyg/hal/hal_cache.h>
43
44 // -------------------------------------------------------------------------
45
46 #define MAXSIZE 1<<18
47
48 volatile char m[MAXSIZE];
49
50 // -------------------------------------------------------------------------
51
52 static void time0(register cyg_uint32 stride)
53 {
54 register cyg_uint32 j,k;
55 // cyg_tick_count_t count0, count1;
56 // cyg_ucount32 t;
57 register char c;
58
59 // count0 = current_time();
60
61 for(k=0; k<4000;k++) {
62 for(j=0; j<(HAL_DCACHE_SIZE/HAL_DCACHE_LINE_SIZE); j++) {
63 c=m[stride*j];
64 }
65 }
66
67 // count1 = current_time();
68 // t = count1 - count0;
69 // diag_printf("stride=%d, time=%d\n", stride, t);
70 }
71
72 // -------------------------------------------------------------------------
73
74 void time1(void)
75 {
76 cyg_uint32 i;
77
78 for(i=1; i<65; i+=i) {
79 time0(i);
80 }
81 }
82
83 // -------------------------------------------------------------------------
84 // This test could be improved by counting number of passes possible
85 // in a given number of ticks.
86
87 static void entry0( void )
88 {
89 HAL_ICACHE_INVALIDATE_ALL();
90 HAL_DCACHE_INVALIDATE_ALL();
91 HAL_ICACHE_DISABLE();
92 HAL_DCACHE_DISABLE();
93 CYG_TEST_INFO("Dcache off Icache off");
94 time1();
95
96 HAL_ICACHE_INVALIDATE_ALL();
97 HAL_DCACHE_INVALIDATE_ALL();
98 HAL_ICACHE_DISABLE();
99 HAL_DCACHE_ENABLE();
100 CYG_TEST_INFO("Dcache on Icache off");
101 time1();
102
103 HAL_ICACHE_INVALIDATE_ALL();
104 HAL_DCACHE_INVALIDATE_ALL();
105 HAL_ICACHE_ENABLE();
106 HAL_DCACHE_DISABLE();
107 CYG_TEST_INFO("Dcache off Icache on");
108 time1();
109
110 HAL_ICACHE_INVALIDATE_ALL();
111 HAL_DCACHE_INVALIDATE_ALL();
112 HAL_ICACHE_ENABLE();
113 HAL_DCACHE_ENABLE();
114 CYG_TEST_INFO("Dcache on Icache on");
115 time1();
116
117
118 HAL_ICACHE_INVALIDATE_ALL();
119 HAL_DCACHE_INVALIDATE_ALL();
120 HAL_ICACHE_DISABLE();
121 HAL_DCACHE_DISABLE();
122 CYG_TEST_INFO("Dcache off Icache off");
123 time1();
124
125
126 CYG_TEST_PASS_FINISH("End of test");
127 }
128
129 // -------------------------------------------------------------------------
130
131 void cache_main( void )
132 {
133 CYG_TEST_INIT();
134
135 entry0();
136
137 }
138
139 // -------------------------------------------------------------------------
140
141 externC void
142 cyg_start( void )
143 {
144 cache_main();
145 }
146
147 // -------------------------------------------------------------------------
148 /* EOF cache.c */