OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [cma230/] [current/] [include/] [hal_cache.h] - Blame information for rev 856

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_CACHE_H
2
#define CYGONCE_HAL_CACHE_H
3
 
4
//=============================================================================
5
//
6
//      hal_cache.h
7
//
8
//      HAL cache control API
9
//
10
//=============================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   nickg, gthomas
46
// Contributors:        nickg, gthomas, msalter
47
// Date:        1998-09-28
48
// Purpose:     Cache control API
49
// Description: The macros defined here provide the HAL APIs for handling
50
//              cache control operations.
51
// Usage:
52
//              #include <cyg/hal/hal_cache.h>
53
//              ...
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
60
#include <cyg/infra/cyg_type.h>
61
 
62
#ifdef __CMA222
63
//-----------------------------------------------------------------------------
64
// Cache dimensions
65
 
66
#define HAL_UCACHE_SIZE                 0x2000   // Size of data cache in bytes
67
#define HAL_UCACHE_LINE_SIZE            16       // Size of a data cache line
68
#define HAL_UCACHE_WAYS                 4        // Associativity of the cache
69
#define HAL_UCACHE_SETS (HAL_UCACHE_SIZE/(HAL_UCACHE_LINE_SIZE*HAL_UCACHE_WAYS))
70
 
71
#define HAL_CACHE_UNIFIED   // Let programs know the caches are combined
72
 
73
//-----------------------------------------------------------------------------
74
// Global control of caches
75
 
76
// Note: the 'mrc' doesn't seem to work.
77
#if 0
78
// Enable the data cache
79
//    mrc  MMU_CP,0,r1,MMU_Control,c0
80
//    orr  r1,r1,#MMU_Control_C|MMU_Control_B
81
//    mcr  MMU_CP,0,r1,MMU_Control,c0    
82
 
83
#define HAL_UCACHE_ENABLE()                     \
84
{                                               \
85
    asm volatile ("mrc  p15,0,r1,c1,c0;"        \
86
                  "orr  r1,r1,#0x000C;"         \
87
                  "mcr  p15,0,r1,c1,c0;"        \
88
                  :                             \
89
                  :                             \
90
                  : "r1" /* Clobber list */     \
91
        );                                      \
92
                                                \
93
}
94
 
95
// Disable the data cache
96
#define HAL_UCACHE_DISABLE()                     \
97
{                                               \
98
    asm volatile ("mrc  p15,0,r1,c1,c0;"        \
99
                  "bic  r1,r1,#0x000C;"         \
100
                  "mcr  p15,0,r1,c1,c0;"        \
101
                  :                             \
102
                  :                             \
103
                  : "r1" /* Clobber list */     \
104
        );                                      \
105
                                                \
106
}
107
#else
108
#define HAL_UCACHE_ENABLE()                     \
109
{                                               \
110
    asm volatile ("mov  r1,#0x7D;"              \
111
                  "mcr  p15,0,r1,c1,c0;"        \
112
                  :                             \
113
                  :                             \
114
                  : "r1" /* Clobber list */     \
115
        );                                      \
116
                                                \
117
}
118
 
119
// Disable the data cache
120
#define HAL_UCACHE_DISABLE()                    \
121
{                                               \
122
    asm volatile ("mov  r1,#0x71;"              \
123
                  "mcr  p15,0,r1,c1,c0;"        \
124
                  :                             \
125
                  :                             \
126
                  : "r1" /* Clobber list */     \
127
        );                                      \
128
                                                \
129
}
130
#endif
131
 
132
// Is the cache turned on?
133
#define HAL_UCACHE_IS_ENABLED(_state_) _state_ = 1;
134
 
135
// Invalidate the entire cache
136
//    mcr  MMU_CP,0,r1,MMU_InvalidateCache,c0
137
#define HAL_UCACHE_INVALIDATE_ALL()             \
138
{                                               \
139
    asm volatile (                              \
140
        "mov    r1,#0;"                         \
141
        "mcr p15,0,r1,c7,c0,0;"                 \
142
        :                                       \
143
        :                                       \
144
        : "r1","memory" /* Clobber list */      \
145
    );                                          \
146
}
147
 
148
// Synchronize the contents of the cache with memory.
149
#define HAL_UCACHE_SYNC()                                               \
150
{                                                                       \
151
    cyg_uint32 *ROM = (cyg_uint32 *)0xE0000000;                         \
152
    int i;                                                              \
153
    volatile cyg_uint32 val;                                            \
154
    for (i = 0;  i < HAL_UCACHE_SETS;  i++) {                           \
155
        val = *ROM;                                                     \
156
        ROM += HAL_UCACHE_LINE_SIZE;                                    \
157
    }                                                                   \
158
}
159
 
160
// Purge contents of data cache
161
#define HAL_UCACHE_PURGE_ALL()  HAL_UCACHE_INVALIDATE_ALL()
162
 
163
//-----------------------------------------------------------------------------
164
// Data cache line control
165
 
166
// Write dirty cache lines to memory and invalidate the cache entries
167
// for the given address range.
168
#define HAL_UCACHE_FLUSH( _base_ , _size_ )  HAL_UCACHE_SYNC()
169
 
170
// Write dirty cache lines to memory for the given address range.
171
#define HAL_UCACHE_STORE( _base_ , _size_ )  HAL_UCACHE_SYNC()
172
 
173
#endif // ifdef __CMA222
174
 
175
#ifdef HAL_CACHE_UNIFIED
176
//-----------------------------------------------------------------------------
177
// Global control of data cache
178
 
179
#define HAL_DCACHE_SIZE                 HAL_UCACHE_SIZE
180
#define HAL_DCACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
181
#define HAL_DCACHE_WAYS                 HAL_UCACHE_WAYS
182
#define HAL_DCACHE_SETS                 HAL_UCACHE_SETS
183
 
184
// Enable the data cache
185
#define HAL_DCACHE_ENABLE()             HAL_UCACHE_ENABLE()
186
 
187
// Disable the data cache
188
#define HAL_DCACHE_DISABLE()            HAL_UCACHE_DISABLE()
189
 
190
// Invalidate the entire cache
191
#define HAL_DCACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
192
 
193
// Synchronize the contents of the cache with memory.
194
#define HAL_DCACHE_SYNC()               HAL_UCACHE_SYNC()
195
 
196
// Query the state of the data cache
197
#define HAL_DCACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
198
 
199
//-----------------------------------------------------------------------------
200
// Data cache line control
201
 
202
// Write dirty cache lines to memory and invalidate the cache entries
203
// for the given address range.
204
#define HAL_DCACHE_FLUSH( _base_ , _size_ )  HAL_UCACHE_FLUSH( _base_ , _size_ )
205
 
206
// Write dirty cache lines to memory for the given address range.
207
#define HAL_DCACHE_STORE( _base_ , _size_ )  HAL_UCACHE_STORE( _base_ , _size_ )
208
 
209
//-----------------------------------------------------------------------------
210
// Global control of Instruction cache - use Data cache controls since they
211
// are not separatable.
212
 
213
#define HAL_ICACHE_SIZE                 HAL_UCACHE_SIZE
214
#define HAL_ICACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
215
#define HAL_ICACHE_WAYS                 HAL_UCACHE_WAYS
216
#define HAL_ICACHE_SETS                 HAL_UCACHE_SETS
217
 
218
// Enable the instruction cache
219
#define HAL_ICACHE_ENABLE()      HAL_UCACHE_ENABLE()
220
 
221
// Disable the instruction cache
222
#define HAL_ICACHE_DISABLE()     HAL_UCACHE_DISABLE()
223
 
224
// Invalidate the entire cache
225
#define HAL_ICACHE_INVALIDATE_ALL()  HAL_UCACHE_INVALIDATE_ALL()
226
 
227
// Synchronize the contents of the cache with memory.
228
#define HAL_ICACHE_SYNC()        HAL_UCACHE_SYNC()
229
 
230
#else
231
//-----------------------------------------------------------------------------
232
// Cache dimensions
233
 
234
// Data cache
235
//#define HAL_DCACHE_SIZE                 0    // Size of data cache in bytes
236
//#define HAL_DCACHE_LINE_SIZE            0    // Size of a data cache line
237
//#define HAL_DCACHE_WAYS                 0    // Associativity of the cache
238
 
239
// Instruction cache
240
//#define HAL_ICACHE_SIZE                 0    // Size of cache in bytes
241
//#define HAL_ICACHE_LINE_SIZE            0    // Size of a cache line
242
//#define HAL_ICACHE_WAYS                 0    // Associativity of the cache
243
 
244
//#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS))
245
//#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS))
246
 
247
 
248
//-----------------------------------------------------------------------------
249
// Global control of data cache
250
 
251
// Enable the data cache
252
#define HAL_DCACHE_ENABLE()
253
 
254
// Disable the data cache
255
#define HAL_DCACHE_DISABLE()
256
 
257
// Invalidate the entire cache
258
#define HAL_DCACHE_INVALIDATE_ALL()
259
 
260
// Synchronize the contents of the cache with memory.
261
#define HAL_DCACHE_SYNC()
262
 
263
// Purge contents of data cache
264
#define HAL_DCACHE_PURGE_ALL()
265
 
266
// Set the data cache refill burst size
267
//#define HAL_DCACHE_BURST_SIZE(_size_)
268
 
269
// Set the data cache write mode
270
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
271
 
272
//#define HAL_DCACHE_WRITETHRU_MODE       0
273
//#define HAL_DCACHE_WRITEBACK_MODE       1
274
 
275
// Load the contents of the given address range into the data cache
276
// and then lock the cache so that it stays there.
277
//#define HAL_DCACHE_LOCK(_base_, _size_)
278
 
279
// Undo a previous lock operation
280
//#define HAL_DCACHE_UNLOCK(_base_, _size_)
281
 
282
// Unlock entire cache
283
//#define HAL_DCACHE_UNLOCK_ALL()
284
 
285
//-----------------------------------------------------------------------------
286
// Data cache line control
287
 
288
// Allocate cache lines for the given address range without reading its
289
// contents from memory.
290
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
291
 
292
// Write dirty cache lines to memory and invalidate the cache entries
293
// for the given address range.
294
//#define HAL_DCACHE_FLUSH( _base_ , _size_ )
295
 
296
// Invalidate cache lines in the given range without writing to memory.
297
//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ )
298
 
299
// Write dirty cache lines to memory for the given address range.
300
//#define HAL_DCACHE_STORE( _base_ , _size_ )
301
 
302
// Preread the given range into the cache with the intention of reading
303
// from it later.
304
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
305
 
306
// Preread the given range into the cache with the intention of writing
307
// to it later.
308
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
309
 
310
// Allocate and zero the cache lines associated with the given range.
311
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
312
 
313
//-----------------------------------------------------------------------------
314
// Global control of Instruction cache
315
 
316
// Enable the instruction cache
317
#define HAL_ICACHE_ENABLE()
318
 
319
// Disable the instruction cache
320
#define HAL_ICACHE_DISABLE()
321
 
322
// Invalidate the entire cache
323
#define HAL_ICACHE_INVALIDATE_ALL()
324
 
325
// Synchronize the contents of the cache with memory.
326
#define HAL_ICACHE_SYNC()
327
 
328
// Set the instruction cache refill burst size
329
//#define HAL_ICACHE_BURST_SIZE(_size_)
330
 
331
// Load the contents of the given address range into the instruction cache
332
// and then lock the cache so that it stays there.
333
//#define HAL_ICACHE_LOCK(_base_, _size_)
334
 
335
// Undo a previous lock operation
336
//#define HAL_ICACHE_UNLOCK(_base_, _size_)
337
 
338
// Unlock entire cache
339
//#define HAL_ICACHE_UNLOCK_ALL()
340
 
341
//-----------------------------------------------------------------------------
342
// Instruction cache line control
343
 
344
// Invalidate cache lines in the given range without writing to memory.
345
//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ )
346
 
347
//-----------------------------------------------------------------------------
348
#endif // ifndef HAL_CACHE_UNIFIED
349
#endif // ifndef CYGONCE_HAL_CACHE_H
350
// End of hal_cache.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.