comparison packages/kernel/current/tests/kcache2.c @ 208:e0c0827131d1 ecos

Merge from eCos master repository on 2002-05-20-20:11:54-BST
author jlarmour
date Mon, 20 May 2002 22:19:26 +0000
parents 920b9b754b53
children d2c90368aeef
comparison
equal deleted inserted replaced
207:74c807ddde34 208:e0c0827131d1
3 // kcache2.c 3 // kcache2.c
4 // 4 //
5 // Cache feature/timing tests 5 // Cache feature/timing tests
6 // 6 //
7 //========================================================================== 7 //==========================================================================
8 //####COPYRIGHTBEGIN#### 8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // 9 // -------------------------------------------
10 // ------------------------------------------- 10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // The contents of this file are subject to the Red Hat eCos Public License 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Version 1.1 (the "License"); you may not use this file except in 12 //
13 // compliance with the License. You may obtain a copy of the License at 13 // eCos is free software; you can redistribute it and/or modify it under
14 // http://www.redhat.com/ 14 // the terms of the GNU General Public License as published by the Free
15 // 15 // Software Foundation; either version 2 or (at your option) any later version.
16 // Software distributed under the License is distributed on an "AS IS" 16 //
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // License for the specific language governing rights and limitations under 18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // the License. 19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // 20 // for more details.
21 // The Original Code is eCos - Embedded Configurable Operating System, 21 //
22 // released September 30, 1998. 22 // You should have received a copy of the GNU General Public License along
23 // 23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // The Initial Developer of the Original Code is Red Hat. 24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 // Portions created by Red Hat are 25 //
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. 26 // As a special exception, if other files instantiate templates or use macros
27 // All Rights Reserved. 27 // or inline functions from this file, or you compile this file and link it
28 // ------------------------------------------- 28 // with other works to produce a work based on this file, this file does not
29 // 29 // by itself cause the resulting work to be covered by the GNU General Public
30 //####COPYRIGHTEND#### 30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
32 //
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
35 //
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
31 //========================================================================== 40 //==========================================================================
32 //#####DESCRIPTIONBEGIN#### 41 //#####DESCRIPTIONBEGIN####
33 // 42 //
34 // Author(s): jskov, based on kcache1.c by dsm 43 // Author(s): jskov, based on kcache1.c by dsm
35 // Contributors: jskov 44 // Contributors: jskov
254 HAL_DCACHE_SYNC(); 263 HAL_DCACHE_SYNC();
255 HAL_DCACHE_DISABLE(); 264 HAL_DCACHE_DISABLE();
256 HAL_DCACHE_SYNC(); 265 HAL_DCACHE_SYNC();
257 HAL_DCACHE_INVALIDATE_ALL(); 266 HAL_DCACHE_INVALIDATE_ALL();
258 HAL_DCACHE_ENABLE(); 267 HAL_DCACHE_ENABLE();
259 HAL_RESTORE_INTERRUPTS(oldints);
260 268
261 aligned_p = (volatile cyg_uint8*) 269 aligned_p = (volatile cyg_uint8*)
262 (((unsigned long) &m[HAL_DCACHE_LINE_SIZE*2]) 270 (((unsigned long) &m[HAL_DCACHE_LINE_SIZE*2])
263 & ~(HAL_DCACHE_LINE_SIZE-1)); 271 & ~(HAL_DCACHE_LINE_SIZE-1));
264 272
265 HAL_DISABLE_INTERRUPTS(oldints);
266
267 aligned_p[0] = 42 + aligned_p[1]; // Load causes cache to be used! 273 aligned_p[0] = 42 + aligned_p[1]; // Load causes cache to be used!
268 274
269 HAL_DCACHE_STORE(aligned_p, HAL_DCACHE_LINE_SIZE); 275 HAL_DCACHE_STORE(aligned_p, HAL_DCACHE_LINE_SIZE);
270
271 HAL_RESTORE_INTERRUPTS(oldints);
272 276
273 CYG_TEST_CHECK(42 == aligned_p[0], 277 CYG_TEST_CHECK(42 == aligned_p[0],
274 "memory didn't contain flushed data"); 278 "memory didn't contain flushed data");
275 279
276 HAL_DCACHE_INVALIDATE_ALL(); // Discard... 280 HAL_DCACHE_INVALIDATE_ALL(); // Discard...
277 281
278 CYG_TEST_CHECK(42 == aligned_p[0], 282 CYG_TEST_CHECK(42 == aligned_p[0],
279 "memory didn't contain flushed data after invalidate all"); 283 "memory didn't contain flushed data after invalidate all");
284
285 HAL_RESTORE_INTERRUPTS(oldints);
280 } 286 }
281 #endif 287 #endif
282 288
283 // ------------------------------------------------------------------------- 289 // -------------------------------------------------------------------------
284 // Test of data cache total flush (sync). 290 // Test of data cache total flush (sync).
301 HAL_DCACHE_SYNC(); 307 HAL_DCACHE_SYNC();
302 HAL_DCACHE_DISABLE(); 308 HAL_DCACHE_DISABLE();
303 HAL_DCACHE_SYNC(); 309 HAL_DCACHE_SYNC();
304 HAL_DCACHE_INVALIDATE_ALL(); 310 HAL_DCACHE_INVALIDATE_ALL();
305 HAL_DCACHE_ENABLE(); 311 HAL_DCACHE_ENABLE();
306 HAL_RESTORE_INTERRUPTS(oldints);
307 312
308 aligned_p = (volatile cyg_uint8*) 313 aligned_p = (volatile cyg_uint8*)
309 (((unsigned long) &m[HAL_DCACHE_LINE_SIZE*2]) 314 (((unsigned long) &m[HAL_DCACHE_LINE_SIZE*2])
310 & ~(HAL_DCACHE_LINE_SIZE-1)); 315 & ~(HAL_DCACHE_LINE_SIZE-1));
311 316
312 HAL_DISABLE_INTERRUPTS(oldints);
313
314 aligned_p[0] = 42 + aligned_p[1]; // Load causes cache to be used! 317 aligned_p[0] = 42 + aligned_p[1]; // Load causes cache to be used!
315 aligned_p[HAL_DCACHE_LINE_SIZE] = 43 + aligned_p[HAL_DCACHE_LINE_SIZE + 1]; 318 aligned_p[HAL_DCACHE_LINE_SIZE] = 43 + aligned_p[HAL_DCACHE_LINE_SIZE + 1];
316 319
317 HAL_DCACHE_SYNC(); 320 HAL_DCACHE_SYNC();
318
319 HAL_RESTORE_INTERRUPTS(oldints);
320 321
321 CYG_TEST_CHECK(42 == aligned_p[0], 322 CYG_TEST_CHECK(42 == aligned_p[0],
322 "memory didn't contain flushed data"); 323 "memory didn't contain flushed data");
323 CYG_TEST_CHECK(43 == aligned_p[HAL_DCACHE_LINE_SIZE], 324 CYG_TEST_CHECK(43 == aligned_p[HAL_DCACHE_LINE_SIZE],
324 "memory didn't contain flushed data next block"); 325 "memory didn't contain flushed data next block");
327 328
328 CYG_TEST_CHECK(42 == aligned_p[0], 329 CYG_TEST_CHECK(42 == aligned_p[0],
329 "memory didn't contain flushed data after invalidate"); 330 "memory didn't contain flushed data after invalidate");
330 CYG_TEST_CHECK(43 == aligned_p[HAL_DCACHE_LINE_SIZE], 331 CYG_TEST_CHECK(43 == aligned_p[HAL_DCACHE_LINE_SIZE],
331 "memory didn't contain flushed data next block after invalidate"); 332 "memory didn't contain flushed data next block after invalidate");
333
334 HAL_RESTORE_INTERRUPTS(oldints);
332 335
333 HAL_ICACHE_INVALIDATE_ALL(); 336 HAL_ICACHE_INVALIDATE_ALL();
334 HAL_DCACHE_DISABLE(); 337 HAL_DCACHE_DISABLE();
335 338
336 CYG_TEST_CHECK(42 == aligned_p[0], 339 CYG_TEST_CHECK(42 == aligned_p[0],
467 HAL_DCACHE_SYNC(); 470 HAL_DCACHE_SYNC();
468 HAL_DCACHE_DISABLE(); 471 HAL_DCACHE_DISABLE();
469 HAL_DCACHE_SYNC(); 472 HAL_DCACHE_SYNC();
470 HAL_DCACHE_INVALIDATE_ALL(); 473 HAL_DCACHE_INVALIDATE_ALL();
471 HAL_DCACHE_ENABLE(); 474 HAL_DCACHE_ENABLE();
472 HAL_RESTORE_INTERRUPTS(oldints);
473 475
474 aligned_p = (volatile cyg_uint8*) 476 aligned_p = (volatile cyg_uint8*)
475 (((unsigned long) &m[HAL_DCACHE_LINE_SIZE*2]) 477 (((unsigned long) &m[HAL_DCACHE_LINE_SIZE*2])
476 & ~(HAL_DCACHE_LINE_SIZE-1)); 478 & ~(HAL_DCACHE_LINE_SIZE-1));
477
478 HAL_DISABLE_INTERRUPTS(oldints);
479 479
480 aligned_p[0] = 43 + aligned_p[1]; // Load causes cache to be used! 480 aligned_p[0] = 43 + aligned_p[1]; // Load causes cache to be used!
481 aligned_p[HAL_DCACHE_LINE_SIZE-1] = 43; 481 aligned_p[HAL_DCACHE_LINE_SIZE-1] = 43;
482 482
483 aligned_p[HAL_DCACHE_LINE_SIZE] = 42 + aligned_p[HAL_DCACHE_LINE_SIZE + 1]; 483 aligned_p[HAL_DCACHE_LINE_SIZE] = 42 + aligned_p[HAL_DCACHE_LINE_SIZE + 1];