|
2
|
1 #ifndef CYGONCE_HAL_CACHE_H |
|
|
2 #define CYGONCE_HAL_CACHE_H |
|
|
3 |
|
|
4 //============================================================================= |
|
|
5 // |
|
|
6 // hal_cache.h |
|
|
7 // |
|
|
8 // HAL Cache control support (such as it is in the simulator) |
|
|
9 // |
|
|
10 //============================================================================= |
|
|
11 //####COPYRIGHTBEGIN#### |
|
|
12 // |
|
|
13 // ------------------------------------------- |
|
|
14 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
15 // Version 1.0 (the "License"); you may not use this file except in |
|
|
16 // compliance with the License. You may obtain a copy of the License at |
|
|
17 // http://sourceware.cygnus.com/ecos |
|
|
18 // |
|
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
21 // License for the specific language governing rights and limitations under |
|
|
22 // the License. |
|
|
23 // |
|
|
24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
25 // September 30, 1998. |
|
|
26 // |
|
|
27 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //============================================================================= |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
|
35 // Author(s): nickg, gthomas, hmt |
|
|
36 // Contributors: nickg, gthomas, hmt |
|
|
37 // Date: 1999-01-28 |
|
|
38 // Purpose: Define Interrupt support |
|
|
39 // Description: The macros defined here provide the HAL APIs for handling |
|
|
40 // the caches. |
|
|
41 // |
|
|
42 // Usage: |
|
|
43 // #include <cyg/hal/hal_cache.h> |
|
|
44 // ... |
|
|
45 // |
|
|
46 // |
|
|
47 //####DESCRIPTIONEND#### |
|
|
48 // |
|
|
49 //============================================================================= |
|
|
50 |
|
|
51 #include <pkgconf/hal.h> |
|
|
52 #include <pkgconf/hal_sparclite.h> |
|
|
53 |
|
|
54 #include <cyg/infra/cyg_type.h> |
|
|
55 |
|
|
56 //----------------------------------------------------------------------------- |
|
|
57 // SPARClite cache macros |
|
|
58 |
|
|
59 //----------------------------------------------------------------------------- |
|
|
60 // Cache dimensions |
|
|
61 |
|
|
62 // Data cache |
|
|
63 #define HAL_DCACHE_SIZE 0x800 // Size of data cache in bytes |
|
|
64 #define HAL_DCACHE_LINE_SIZE 4 // Size of a data cache line |
|
|
65 #define HAL_DCACHE_WAYS 4 // Associativity of the cache |
|
|
66 |
|
|
67 // Instruction cache |
|
|
68 #define HAL_ICACHE_SIZE 0x800 // Size of cache in bytes |
|
|
69 #define HAL_ICACHE_LINE_SIZE 4 // Size of a cache line |
|
|
70 #define HAL_ICACHE_WAYS 4 // Associativity of the cache |
|
|
71 |
|
|
72 #define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS)) |
|
|
73 #define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS)) |
|
|
74 |
|
|
75 //----------------------------------------------------------------------------- |
|
|
76 // Global control of data cache |
|
|
77 |
|
|
78 // Enable the data cache |
|
|
79 #define HAL_DCACHE_ENABLE() |
|
|
80 // Disable the data cache |
|
|
81 #define HAL_DCACHE_DISABLE() |
|
|
82 // Invalidate the entire cache |
|
|
83 #define HAL_DCACHE_INVALIDATE_ALL() |
|
|
84 // Synchronize the contents of the cache with memory. |
|
|
85 #define HAL_DCACHE_SYNC() |
|
|
86 |
|
|
87 // Set the data cache refill burst size |
|
|
88 //#define HAL_DCACHE_BURST_SIZE(_size_) |
|
|
89 |
|
|
90 // Set the data cache write mode |
|
|
91 //#define HAL_DCACHE_WRITE_MODE( _mode_ ) |
|
|
92 |
|
|
93 //#define HAL_DCACHE_WRITETHRU_MODE 0 |
|
|
94 //#define HAL_DCACHE_WRITEBACK_MODE 1 |
|
|
95 |
|
|
96 // Load the contents of the given address range into the data cache |
|
|
97 // and then lock the cache so that it stays there. |
|
|
98 //#define HAL_DCACHE_LOCK(_base_, _size_) |
|
|
99 |
|
|
100 // Undo a previous lock operation |
|
|
101 //#define HAL_DCACHE_UNLOCK(_base_, _size_) |
|
|
102 |
|
|
103 // Unlock entire cache |
|
|
104 //#define HAL_DCACHE_UNLOCK_ALL() |
|
|
105 |
|
|
106 //----------------------------------------------------------------------------- |
|
|
107 // Data cache line control |
|
|
108 |
|
|
109 // Allocate cache lines for the given address range without reading its |
|
|
110 // contents from memory. |
|
|
111 //#define HAL_DCACHE_ALLOCATE( _base_ , _size_ ) |
|
|
112 |
|
|
113 // Write dirty cache lines to memory and invalidate the cache entries |
|
|
114 // for the given address range. |
|
|
115 //#define HAL_DCACHE_FLUSH( _base_ , _size_ ) |
|
|
116 |
|
|
117 // Invalidate cache lines in the given range without writing to memory. |
|
|
118 //#define HAL_DCACHE_INVALIDATE( _base_ , _size_ ) |
|
|
119 |
|
|
120 // Write dirty cache lines to memory for the given address range. |
|
|
121 //#define HAL_DCACHE_STORE( _base_ , _size_ ) |
|
|
122 |
|
|
123 // Preread the given range into the cache with the intention of reading |
|
|
124 // from it later. |
|
|
125 //#define HAL_DCACHE_READ_HINT( _base_ , _size_ ) |
|
|
126 |
|
|
127 // Preread the given range into the cache with the intention of writing |
|
|
128 // to it later. |
|
|
129 //#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ ) |
|
|
130 |
|
|
131 // Allocate and zero the cache lines associated with the given range. |
|
|
132 //#define HAL_DCACHE_ZERO( _base_ , _size_ ) |
|
|
133 |
|
|
134 //----------------------------------------------------------------------------- |
|
|
135 // Global control of Instruction cache - use Data cache controls since they |
|
|
136 // are not separatable. |
|
|
137 |
|
|
138 // Enable the instruction cache |
|
|
139 #define HAL_ICACHE_ENABLE() HAL_DCACHE_ENABLE() |
|
|
140 |
|
|
141 // Disable the instruction cache |
|
|
142 #define HAL_ICACHE_DISABLE() HAL_DCACHE_DISABLE() |
|
|
143 |
|
|
144 // Invalidate the entire cache |
|
|
145 #define HAL_ICACHE_INVALIDATE_ALL() HAL_DCACHE_SYNC(); HAL_DCACHE_INVALIDATE_ALL() |
|
|
146 |
|
|
147 // Synchronize the contents of the cache with memory. |
|
|
148 #define HAL_ICACHE_SYNC() |
|
|
149 |
|
|
150 // Set the instruction cache refill burst size |
|
|
151 //#define HAL_ICACHE_BURST_SIZE(_size_) |
|
|
152 |
|
|
153 // Load the contents of the given address range into the instruction cache |
|
|
154 // and then lock the cache so that it stays there. |
|
|
155 //#define HAL_ICACHE_LOCK(_base_, _size_) |
|
|
156 |
|
|
157 // Undo a previous lock operation |
|
|
158 //#define HAL_ICACHE_UNLOCK(_base_, _size_) |
|
|
159 |
|
|
160 // Unlock entire cache |
|
|
161 //#define HAL_ICACHE_UNLOCK_ALL() |
|
|
162 |
|
|
163 //----------------------------------------------------------------------------- |
|
|
164 // Instruction cache line control |
|
|
165 |
|
|
166 // Invalidate cache lines in the given range without writing to memory. |
|
|
167 //#define HAL_ICACHE_INVALIDATE( _base_ , _size_ ) |
|
|
168 |
|
|
169 //----------------------------------------------------------------------------- |
|
|
170 #endif // ifndef CYGONCE_HAL_CACHE_H |
|
|
171 // End of hal_cache.h |