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

Subversion Repositories openrisc

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

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
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
#include <cyg/hal/hal_io.h>
62
#include <cyg/hal/plf_io.h>
63
 
64
//-----------------------------------------------------------------------------
65
// Cache dimensions - one unified cache
66
 
67
#define HAL_CACHE_UNIFIED
68
 
69
#define HAL_UCACHE_SIZE                 0x2000   // Size of cache in bytes
70
#define HAL_UCACHE_LINE_SIZE            16       // Size of a cache line
71
#define HAL_UCACHE_WAYS                 2        // Associativity of the cache
72
 
73
#define HAL_UCACHE_SETS (HAL_UCACHE_SIZE/(HAL_UCACHE_LINE_SIZE*HAL_UCACHE_WAYS))
74
 
75
//-----------------------------------------------------------------------------
76
// Global control of cache
77
 
78
// Enable the cache
79
#define HAL_UCACHE_ENABLE()                     \
80
    CYG_MACRO_START                             \
81
    cyg_uint32 syscfg;                          \
82
    HAL_READ_UINT32(E7T_SYSCFG, syscfg);        \
83
    syscfg |= E7T_SYSCFG_CE;                    \
84
    HAL_WRITE_UINT32(E7T_SYSCFG, syscfg);       \
85
    CYG_MACRO_END
86
 
87
// Disable the cache
88
#define HAL_UCACHE_DISABLE()                    \
89
    CYG_MACRO_START                             \
90
    cyg_uint32 syscfg;                          \
91
    HAL_READ_UINT32(E7T_SYSCFG, syscfg);        \
92
    syscfg &= ~E7T_SYSCFG_CE;                   \
93
    HAL_WRITE_UINT32(E7T_SYSCFG, syscfg);       \
94
    CYG_MACRO_END
95
 
96
// Invalidate the entire cache
97
#define HAL_UCACHE_INVALIDATE_ALL()                             \
98
    CYG_MACRO_START                                             \
99
    register cyg_uint32* tag = (cyg_uint32*)E7T_CACHE_TAG_ADDR; \
100
    register int i;                                             \
101
    for (i = 0; i < HAL_UCACHE_SETS/4; i++) {                   \
102
        *tag++ = 0;                                             \
103
        *tag++ = 0;                                             \
104
        *tag++ = 0;                                             \
105
        *tag++ = 0;                                             \
106
    }                                                           \
107
    CYG_MACRO_END
108
 
109
// Synchronize the contents of the cache with memory.
110
// No action necessary. Cache is write-through.
111
#define HAL_UCACHE_SYNC()
112
 
113
// Query the state of the cache
114
#define HAL_UCACHE_IS_ENABLED(_state_)                  \
115
    CYG_MACRO_START                                     \
116
    cyg_uint32 syscfg;                                  \
117
    HAL_READ_UINT32(E7T_SYSCFG, syscfg);                \
118
    (_state_) = (syscfg & E7T_SYSCFG_CE) ? 1 : 0;       \
119
    CYG_MACRO_END
120
 
121
// Purge contents of cache
122
#define HAL_UCACHE_PURGE_ALL()  HAL_UCACHE_INVALIDATE_ALL()
123
 
124
// Set the cache refill burst size
125
//#define HAL_UCACHE_BURST_SIZE(_size_)
126
 
127
// Set the cache write mode
128
//#define HAL_UCACHE_WRITE_MODE( _mode_ )
129
 
130
//#define HAL_UCACHE_WRITETHRU_MODE       0
131
//#define HAL_UCACHE_WRITEBACK_MODE       1
132
 
133
// Load the contents of the given address range into the cache
134
// and then lock the cache so that it stays there.
135
//#define HAL_UCACHE_LOCK(_base_, _size_)
136
 
137
// Undo a previous lock operation
138
//#define HAL_UCACHE_UNLOCK(_base_, _size_)
139
 
140
// Unlock entire cache
141
//#define HAL_UCACHE_UNLOCK_ALL()
142
 
143
//-----------------------------------------------------------------------------
144
// Cache line control
145
 
146
// Allocate cache lines for the given address range without reading its
147
// contents from memory.
148
//#define HAL_UCACHE_ALLOCATE( _base_ , _size_ )
149
 
150
// Write dirty cache lines to memory and invalidate the cache entries
151
// for the given address range.
152
//#define HAL_UCACHE_FLUSH( _base_ , _size_ )
153
 
154
// Invalidate cache lines in the given range without writing to memory.
155
//#define HAL_UCACHE_INVALIDATE( _base_ , _size_ )
156
 
157
// Write dirty cache lines to memory for the given address range.
158
//#define HAL_UCACHE_STORE( _base_ , _size_ )
159
 
160
// Preread the given range into the cache with the intention of reading
161
// from it later.
162
//#define HAL_UCACHE_READ_HINT( _base_ , _size_ )
163
 
164
// Preread the given range into the cache with the intention of writing
165
// to it later.
166
//#define HAL_UCACHE_WRITE_HINT( _base_ , _size_ )
167
 
168
// Allocate and zero the cache lines associated with the given range.
169
//#define HAL_UCACHE_ZERO( _base_ , _size_ )
170
 
171
//-----------------------------------------------------------------------------
172
 
173
//-----------------------------------------------------------------------------
174
// Data and instruction cache macros map onto the both-cache macros
175
 
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
// Set the data cache refill burst size
200
//#define HAL_DCACHE_BURST_SIZE(_size_)
201
 
202
// Set the data cache write mode
203
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
204
 
205
//#define HAL_DCACHE_WRITETHRU_MODE       0
206
//#define HAL_DCACHE_WRITEBACK_MODE       1
207
 
208
// Load the contents of the given address range into the data cache
209
// and then lock the cache so that it stays there.
210
//#define HAL_DCACHE_LOCK(_base_, _size_)
211
 
212
// Undo a previous lock operation
213
//#define HAL_DCACHE_UNLOCK(_base_, _size_)
214
 
215
// Unlock entire cache
216
//#define HAL_DCACHE_UNLOCK_ALL()
217
 
218
//-----------------------------------------------------------------------------
219
// Data cache line control
220
 
221
// Allocate cache lines for the given address range without reading its
222
// contents from memory.
223
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
224
 
225
// Write dirty cache lines to memory and invalidate the cache entries
226
// for the given address range.
227
//#define HAL_DCACHE_FLUSH( _base_ , _size_ )
228
 
229
// Invalidate cache lines in the given range without writing to memory.
230
//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ )
231
 
232
// Write dirty cache lines to memory for the given address range.
233
//#define HAL_DCACHE_STORE( _base_ , _size_ )
234
 
235
// Preread the given range into the cache with the intention of reading
236
// from it later.
237
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
238
 
239
// Preread the given range into the cache with the intention of writing
240
// to it later.
241
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
242
 
243
// Allocate and zero the cache lines associated with the given range.
244
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
245
 
246
//-----------------------------------------------------------------------------
247
// Global control of Instruction cache
248
 
249
#define HAL_ICACHE_SIZE                 HAL_UCACHE_SIZE
250
#define HAL_ICACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
251
#define HAL_ICACHE_WAYS                 HAL_UCACHE_WAYS
252
#define HAL_ICACHE_SETS                 HAL_UCACHE_SETS
253
 
254
// Enable the instruction cache
255
#define HAL_ICACHE_ENABLE()             HAL_UCACHE_ENABLE()
256
 
257
// Disable the instruction cache
258
#define HAL_ICACHE_DISABLE()            HAL_UCACHE_DISABLE()
259
 
260
// Invalidate the entire cache
261
#define HAL_ICACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
262
 
263
 
264
// Synchronize the contents of the cache with memory.
265
#define HAL_ICACHE_SYNC()               HAL_UCACHE_SYNC()
266
 
267
// Query the state of the instruction cache
268
#define HAL_ICACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
269
 
270
// Set the instruction cache refill burst size
271
//#define HAL_ICACHE_BURST_SIZE(_size_)
272
 
273
// Load the contents of the given address range into the instruction cache
274
// and then lock the cache so that it stays there.
275
 
276
//#define HAL_ICACHE_LOCK(_base_, _size_)
277
 
278
// Undo a previous lock operation
279
//#define HAL_ICACHE_UNLOCK(_base_, _size_)
280
 
281
// Unlock entire cache
282
//#define HAL_ICACHE_UNLOCK_ALL()
283
 
284
//-----------------------------------------------------------------------------
285
// Instruction cache line control
286
 
287
// Invalidate cache lines in the given range without writing to memory.
288
//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ )
289
 
290
#endif // ifndef CYGONCE_HAL_CACHE_H
291
// 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.