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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [snds/] [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
//      hal_cache.h
6
//
7
//      HAL cache control API
8
//
9
//=============================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under    
16
// the terms of the GNU General Public License as published by the Free     
17
// Software Foundation; either version 2 or (at your option) any later      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
23
// for more details.                                                        
24
//
25
// You should have received a copy of the GNU General Public License        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):   nickg, gthomas
45
// Contributors:        nickg, gthomas
46
// Date:        1998-09-28
47
// Purpose:     Cache control API
48
// Description: The macros defined here provide the HAL APIs for handling
49
//              cache control operations.
50
// Usage:
51
//              #include <cyg/hal/hal_cache.h>
52
//              ...
53
//              
54
//
55
//####DESCRIPTIONEND####
56
//
57
//=============================================================================
58
 
59
#include <cyg/infra/cyg_type.h>
60
#include <cyg/hal/hal_io.h>
61
#include <cyg/hal/plf_io.h>
62
 
63
//-----------------------------------------------------------------------------
64
// Cache dimensions - one unified cache
65
 
66
#define HAL_CACHE_UNIFIED
67
 
68
#define HAL_UCACHE_SIZE                 0x2000   // Size of cache in bytes
69
#define HAL_UCACHE_LINE_SIZE            16       // Size of a cache line
70
#define HAL_UCACHE_WAYS                 2        // Associativity of the cache
71
 
72
#define HAL_UCACHE_SETS (HAL_UCACHE_SIZE/(HAL_UCACHE_LINE_SIZE*HAL_UCACHE_WAYS))
73
 
74
//-----------------------------------------------------------------------------
75
// Global control of cache
76
 
77
// Enable the cache
78
#define HAL_UCACHE_ENABLE()                     \
79
    CYG_MACRO_START                             \
80
    cyg_uint32 syscfg;                          \
81
    HAL_READ_UINT32(KS32C_SYSCFG, syscfg);        \
82
    syscfg |= KS32C_SYSCFG_CE;                    \
83
    HAL_WRITE_UINT32(KS32C_SYSCFG, syscfg);       \
84
    CYG_MACRO_END
85
 
86
// Disable the cache
87
#define HAL_UCACHE_DISABLE()                    \
88
    CYG_MACRO_START                             \
89
    cyg_uint32 syscfg;                          \
90
    HAL_READ_UINT32(KS32C_SYSCFG, syscfg);        \
91
    syscfg &= ~KS32C_SYSCFG_CE;                   \
92
    HAL_WRITE_UINT32(KS32C_SYSCFG, syscfg);       \
93
    CYG_MACRO_END
94
 
95
// Invalidate the entire cache
96
#define HAL_UCACHE_INVALIDATE_ALL()                             \
97
    CYG_MACRO_START                                             \
98
    register cyg_uint32* tag = (cyg_uint32*)KS32C_CACHE_TAG_ADDR; \
99
    register int i;                                             \
100
    for (i = 0; i < HAL_UCACHE_SETS/4; i++) {                   \
101
        *tag++ = 0;                                             \
102
        *tag++ = 0;                                             \
103
        *tag++ = 0;                                             \
104
        *tag++ = 0;                                             \
105
    }                                                           \
106
    CYG_MACRO_END
107
 
108
// Synchronize the contents of the cache with memory.
109
// No action necessary. Cache is write-through.
110
#define HAL_UCACHE_SYNC()
111
 
112
// Query the state of the cache
113
#define HAL_UCACHE_IS_ENABLED(_state_)                  \
114
    CYG_MACRO_START                                     \
115
    cyg_uint32 syscfg;                                  \
116
    HAL_READ_UINT32(KS32C_SYSCFG, syscfg);                \
117
    (_state_) = (syscfg & KS32C_SYSCFG_CE) ? 1 : 0;       \
118
    CYG_MACRO_END
119
 
120
// Purge contents of cache
121
#define HAL_UCACHE_PURGE_ALL()  HAL_UCACHE_INVALIDATE_ALL()
122
 
123
// Set the cache refill burst size
124
//#define HAL_UCACHE_BURST_SIZE(_size_)
125
 
126
// Set the cache write mode
127
//#define HAL_UCACHE_WRITE_MODE( _mode_ )
128
 
129
//#define HAL_UCACHE_WRITETHRU_MODE       0
130
//#define HAL_UCACHE_WRITEBACK_MODE       1
131
 
132
// Load the contents of the given address range into the cache
133
// and then lock the cache so that it stays there.
134
//#define HAL_UCACHE_LOCK(_base_, _size_)
135
 
136
// Undo a previous lock operation
137
//#define HAL_UCACHE_UNLOCK(_base_, _size_)
138
 
139
// Unlock entire cache
140
//#define HAL_UCACHE_UNLOCK_ALL()
141
 
142
//-----------------------------------------------------------------------------
143
// Cache line control
144
 
145
// Allocate cache lines for the given address range without reading its
146
// contents from memory.
147
//#define HAL_UCACHE_ALLOCATE( _base_ , _size_ )
148
 
149
// Write dirty cache lines to memory and invalidate the cache entries
150
// for the given address range.
151
//#define HAL_UCACHE_FLUSH( _base_ , _size_ )
152
 
153
// Invalidate cache lines in the given range without writing to memory.
154
//#define HAL_UCACHE_INVALIDATE( _base_ , _size_ )
155
 
156
// Write dirty cache lines to memory for the given address range.
157
//#define HAL_UCACHE_STORE( _base_ , _size_ )
158
 
159
// Preread the given range into the cache with the intention of reading
160
// from it later.
161
//#define HAL_UCACHE_READ_HINT( _base_ , _size_ )
162
 
163
// Preread the given range into the cache with the intention of writing
164
// to it later.
165
//#define HAL_UCACHE_WRITE_HINT( _base_ , _size_ )
166
 
167
// Allocate and zero the cache lines associated with the given range.
168
//#define HAL_UCACHE_ZERO( _base_ , _size_ )
169
 
170
//-----------------------------------------------------------------------------
171
 
172
//-----------------------------------------------------------------------------
173
// Data and instruction cache macros map onto the both-cache macros
174
 
175
//-----------------------------------------------------------------------------
176
// Global control of data cache
177
 
178
#define HAL_DCACHE_SIZE                 HAL_UCACHE_SIZE
179
#define HAL_DCACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
180
#define HAL_DCACHE_WAYS                 HAL_UCACHE_WAYS
181
#define HAL_DCACHE_SETS                 HAL_UCACHE_SETS
182
 
183
// Enable the data cache
184
#define HAL_DCACHE_ENABLE()             HAL_UCACHE_ENABLE()
185
 
186
// Disable the data cache
187
#define HAL_DCACHE_DISABLE()            HAL_UCACHE_DISABLE()
188
 
189
// Invalidate the entire cache
190
#define HAL_DCACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
191
 
192
// Synchronize the contents of the cache with memory.
193
#define HAL_DCACHE_SYNC()               HAL_UCACHE_SYNC()
194
 
195
// Query the state of the data cache
196
#define HAL_DCACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
197
 
198
// Set the data cache refill burst size
199
//#define HAL_DCACHE_BURST_SIZE(_size_)
200
 
201
// Set the data cache write mode
202
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
203
 
204
//#define HAL_DCACHE_WRITETHRU_MODE       0
205
//#define HAL_DCACHE_WRITEBACK_MODE       1
206
 
207
// Load the contents of the given address range into the data cache
208
// and then lock the cache so that it stays there.
209
//#define HAL_DCACHE_LOCK(_base_, _size_)
210
 
211
// Undo a previous lock operation
212
//#define HAL_DCACHE_UNLOCK(_base_, _size_)
213
 
214
// Unlock entire cache
215
//#define HAL_DCACHE_UNLOCK_ALL()
216
 
217
//-----------------------------------------------------------------------------
218
// Data cache line control
219
 
220
// Allocate cache lines for the given address range without reading its
221
// contents from memory.
222
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
223
 
224
// Write dirty cache lines to memory and invalidate the cache entries
225
// for the given address range.
226
//#define HAL_DCACHE_FLUSH( _base_ , _size_ )
227
 
228
// Invalidate cache lines in the given range without writing to memory.
229
//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ )
230
 
231
// Write dirty cache lines to memory for the given address range.
232
//#define HAL_DCACHE_STORE( _base_ , _size_ )
233
 
234
// Preread the given range into the cache with the intention of reading
235
// from it later.
236
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
237
 
238
// Preread the given range into the cache with the intention of writing
239
// to it later.
240
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
241
 
242
// Allocate and zero the cache lines associated with the given range.
243
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
244
 
245
//-----------------------------------------------------------------------------
246
// Global control of Instruction cache
247
 
248
#define HAL_ICACHE_SIZE                 HAL_UCACHE_SIZE
249
#define HAL_ICACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
250
#define HAL_ICACHE_WAYS                 HAL_UCACHE_WAYS
251
#define HAL_ICACHE_SETS                 HAL_UCACHE_SETS
252
 
253
// Enable the instruction cache
254
#define HAL_ICACHE_ENABLE()             HAL_UCACHE_ENABLE()
255
 
256
// Disable the instruction cache
257
#define HAL_ICACHE_DISABLE()            HAL_UCACHE_DISABLE()
258
 
259
// Invalidate the entire cache
260
#define HAL_ICACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
261
 
262
 
263
// Synchronize the contents of the cache with memory.
264
#define HAL_ICACHE_SYNC()               HAL_UCACHE_SYNC()
265
 
266
// Query the state of the instruction cache
267
#define HAL_ICACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
268
 
269
// Set the instruction cache refill burst size
270
//#define HAL_ICACHE_BURST_SIZE(_size_)
271
 
272
// Load the contents of the given address range into the instruction cache
273
// and then lock the cache so that it stays there.
274
 
275
//#define HAL_ICACHE_LOCK(_base_, _size_)
276
 
277
// Undo a previous lock operation
278
//#define HAL_ICACHE_UNLOCK(_base_, _size_)
279
 
280
// Unlock entire cache
281
//#define HAL_ICACHE_UNLOCK_ALL()
282
 
283
//-----------------------------------------------------------------------------
284
// Instruction cache line control
285
 
286
// Invalidate cache lines in the given range without writing to memory.
287
//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ )
288
 
289
#endif // ifndef CYGONCE_HAL_CACHE_H
290
// 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.