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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [calmrisc16/] [arch/] [current/] [include/] [hal_cache.h] - Blame information for rev 791

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
46
// Contributors:        nickg
47
// Date:        1998-02-17
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 <pkgconf/hal.h>
61
#include <cyg/infra/cyg_type.h>
62
 
63
#include <cyg/hal/var_cache.h>
64
 
65
 
66
//-----------------------------------------------------------------------------
67
// Cache dimensions.
68
// These really should be defined in var_cache.h. If they are not, then provide
69
// a set of numbers that are typical of many variants.
70
 
71
#ifndef HAL_DCACHE_SIZE
72
 
73
// Data cache
74
//#define HAL_DCACHE_SIZE                 0     // Size of data cache in bytes
75
//#define HAL_DCACHE_LINE_SIZE            0     // Size of a data cache line
76
//#define HAL_DCACHE_WAYS                 0     // Associativity of the cache
77
 
78
// Instruction cache
79
//#define HAL_ICACHE_SIZE                 0     // Size of cache in bytes
80
//#define HAL_ICACHE_LINE_SIZE            0     // Size of a cache line
81
//#define HAL_ICACHE_WAYS                 0     // Associativity of the cache
82
 
83
//#define HAL_DCACHE_SETS 0
84
//#define HAL_ICACHE_SETS 0
85
 
86
#endif
87
 
88
//-----------------------------------------------------------------------------
89
// Global control of data cache
90
 
91
// Enable the data cache
92
// There is no default mechanism for enabling or disabling the caches.
93
#ifndef HAL_DCACHE_ENABLE_DEFINED
94
#define HAL_DCACHE_ENABLE()
95
#endif
96
 
97
// Disable the data cache
98
#ifndef HAL_DCACHE_DISABLE_DEFINED
99
#define HAL_DCACHE_DISABLE()
100
#endif
101
 
102
#ifndef HAL_DCACHE_IS_ENABLED_DEFINED
103
#define HAL_DCACHE_IS_ENABLED(_state_) (_state_) = 1;
104
#endif
105
 
106
// Invalidate the entire cache
107
// We simply use HAL_DCACHE_SYNC() to do this. For writeback caches this
108
// is not quite what we want, but there is no index-invalidate operation
109
// available.
110
#ifndef HAL_DCACHE_INVALIDATE_ALL_DEFINED
111
#define HAL_DCACHE_INVALIDATE_ALL() HAL_DCACHE_SYNC()
112
#endif
113
 
114
// Synchronize the contents of the cache with memory.
115
// This uses the index-writeback-invalidate operation.
116
#ifndef HAL_DCACHE_SYNC_DEFINED
117
#define HAL_DCACHE_SYNC()                                               \
118
    CYG_MACRO_START                                                     \
119
    CYG_MACRO_END
120
#endif
121
 
122
// Set the data cache refill burst size
123
//#define HAL_DCACHE_BURST_SIZE(_size_)
124
 
125
// Set the data cache write mode
126
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
127
 
128
//#define HAL_DCACHE_WRITETHRU_MODE       0
129
//#define HAL_DCACHE_WRITEBACK_MODE       1
130
 
131
// Load the contents of the given address range into the data cache
132
// and then lock the cache so that it stays there.
133
// This uses the fetch-and-lock cache operation.
134
#ifndef HAL_DCACHE_LOCK_DEFINED
135
#define HAL_DCACHE_LOCK(_base_, _asize_)                                  \
136
    CYG_MACRO_START                                                       \
137
    CYG_MACRO_END
138
#endif
139
 
140
// Undo a previous lock operation.
141
// Do this by flushing the cache, which is defined to clear the lock bit.
142
#ifndef HAL_DCACHE_UNLOCK_DEFINED
143
#define HAL_DCACHE_UNLOCK(_base_, _size_) \
144
        HAL_DCACHE_FLUSH( _base_, _size_ )
145
#endif
146
 
147
// Unlock entire cache
148
#ifndef HAL_DCACHE_UNLOCK_ALL_DEFINED
149
#define HAL_DCACHE_UNLOCK_ALL() \
150
        HAL_DCACHE_INVALIDATE_ALL()
151
#endif
152
 
153
//-----------------------------------------------------------------------------
154
// Data cache line control
155
 
156
// Allocate cache lines for the given address range without reading its
157
// contents from memory.
158
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
159
 
160
// Write dirty cache lines to memory and invalidate the cache entries
161
// for the given address range.
162
// This uses the hit-writeback-invalidate cache operation.
163
#ifndef HAL_DCACHE_FLUSH_DEFINED
164
#define HAL_DCACHE_FLUSH( _base_ , _asize_ )                              \
165
    CYG_MACRO_START                                                       \
166
    CYG_MACRO_END
167
#endif
168
 
169
// Invalidate cache lines in the given range without writing to memory.
170
// This uses the hit-invalidate cache operation.
171
#ifndef HAL_DCACHE_INVALIDATE_DEFINED
172
#define HAL_DCACHE_INVALIDATE( _base_ , _asize_ )                       \
173
    CYG_MACRO_START                                                     \
174
    CYG_MACRO_END
175
#endif
176
 
177
// Write dirty cache lines to memory for the given address range.
178
// This uses the hit-writeback cache operation.
179
#ifndef HAL_DCACHE_STORE_DEFINED
180
#define HAL_DCACHE_STORE( _base_ , _asize_ )                              \
181
    CYG_MACRO_START                                                       \
182
    CYG_MACRO_END
183
#endif
184
 
185
// Preread the given range into the cache with the intention of reading
186
// from it later.
187
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
188
 
189
// Preread the given range into the cache with the intention of writing
190
// to it later.
191
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
192
 
193
// Allocate and zero the cache lines associated with the given range.
194
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
195
 
196
//-----------------------------------------------------------------------------
197
// Global control of Instruction cache
198
 
199
// Enable the instruction cache
200
// There is no default mechanism for enabling or disabling the caches.
201
#ifndef HAL_ICACHE_ENABLE_DEFINED
202
#define HAL_ICACHE_ENABLE()
203
#endif
204
 
205
// Disable the instruction cache
206
#ifndef HAL_ICACHE_DISABLE_DEFINED
207
#define HAL_ICACHE_DISABLE()
208
#endif
209
 
210
#ifndef HAL_ICACHE_IS_ENABLED_DEFINED
211
#define HAL_ICACHE_IS_ENABLED(_state_) (_state_) = 1;
212
#endif
213
 
214
// Invalidate the entire cache
215
// This uses the index-invalidate cache operation.
216
#ifndef HAL_ICACHE_INVALIDATE_ALL_DEFINED
217
#define HAL_ICACHE_INVALIDATE_ALL()                                           \
218
    CYG_MACRO_START                                                           \
219
    CYG_MACRO_END
220
#endif
221
 
222
// Synchronize the contents of the cache with memory.
223
// Simply force the cache to reload.
224
#ifndef HAL_ICACHE_SYNC_DEFINED
225
#define HAL_ICACHE_SYNC() HAL_ICACHE_INVALIDATE_ALL()
226
#endif
227
 
228
// Set the instruction cache refill burst size
229
//#define HAL_ICACHE_BURST_SIZE(_size_)
230
 
231
// Load the contents of the given address range into the instruction cache
232
// and then lock the cache so that it stays there.
233
// This uses the fetch-and-lock cache operation.
234
#ifndef HAL_ICACHE_LOCK_DEFINED
235
#define HAL_ICACHE_LOCK(_base_, _asize_)                                  \
236
    CYG_MACRO_START                                                       \
237
    CYG_MACRO_END
238
#endif
239
 
240
// Undo a previous lock operation.
241
// Do this by invalidating the cache, which is defined to clear the lock bit.
242
#ifndef HAL_ICACHE_UNLOCK_DEFINED
243
#define HAL_ICACHE_UNLOCK(_base_, _size_) \
244
        HAL_ICACHE_INVALIDATE( _base_, _size_ )
245
#endif
246
 
247
// Unlock entire cache
248
//#define HAL_ICACHE_UNLOCK_ALL()
249
 
250
//-----------------------------------------------------------------------------
251
// Instruction cache line control
252
 
253
// Invalidate cache lines in the given range without writing to memory.
254
// This uses the hit-invalidate cache operation.
255
#ifndef HAL_ICACHE_INVALIDATE_DEFINED
256
#define HAL_ICACHE_INVALIDATE( _base_ , _asize_ )                       \
257
    CYG_MACRO_START                                                     \
258
    CYG_MACRO_END
259
#endif
260
 
261
 
262
//-----------------------------------------------------------------------------
263
#endif // ifndef CYGONCE_HAL_CACHE_H
264
// 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.