1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin OS Overview - Cache Demo
3   File:     cachedemo.c
4 
5   Copyright 1998, 1999 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: cachedemo.c,v $
14   Revision 1.2  02/20/2006 04:13:11  mitu
15   changed include path from dolphin/ to revolution/.
16 
17   Revision 1.1  01/13/2006 11:24:12  hiratsu
18   Initial check in.
19 
20 
21     1     6/04/99 3:04p Tianli01
22     Initial check-in
23 
24   $NoKeywords: $
25  *---------------------------------------------------------------------------*/
26 
27 #include <revolution.h>
28 
main(void)29 void main (void)
30 {
31     u32* cachedAddress;
32     u32* uncachedAddress;
33 
34     OSInit();
35 
36     cachedAddress   = (u32*)OSGetArenaLo();
37     uncachedAddress = OSCachedToUncached(cachedAddress);
38 
39     OSReport("STORE EXAMPLE\n");
40     *cachedAddress 	= 0xFFFF;
41     *uncachedAddress	= 0xAAAA;
42 
43     OSReport("Cache copy           = 0x%x\n", *cachedAddress);
44     OSReport("Physical memory copy = 0x%x\n", *uncachedAddress);
45 
46     DCStoreRange(cachedAddress, sizeof(u32));
47 
48     OSReport("After STORE, Cache copy           = 0x%x\n",
49 	     *cachedAddress);
50     OSReport("After STORE, Physical memory copy = 0x%x\n",
51 	     *uncachedAddress);
52 
53     OSReport("\nINVALIDATE EXAMPLE\n");
54     *cachedAddress 	= 0xFFFF;
55     *uncachedAddress	= 0xAAAA;
56 
57     OSReport("Cache copy           = 0x%x\n", *cachedAddress);
58     OSReport("Physical memory copy = 0x%x\n", *uncachedAddress);
59 
60     DCInvalidateRange(cachedAddress, sizeof(u32));
61 
62     OSReport("After INVALIDATE, Cache copy           = 0x%x\n",
63 	     *cachedAddress);
64     OSReport("After INVALIDATE, Physical memory copy = 0x%x\n",
65 	     *uncachedAddress);
66 
67     OSHalt("Demo complete");
68 }
69