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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sh/] [sh3/] [current/] [include/] [var_cache.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_VAR_CACHE_H
2
#define CYGONCE_VAR_CACHE_H
3
 
4
//=============================================================================
5
//
6
//      var_cache.h
7
//
8
//      HAL variant 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):   jskov
46
// Contributors:jskov
47
// Date:        1999-04-23
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/system.h>
61
#include <pkgconf/hal.h>
62
#include <cyg/infra/cyg_type.h>
63
#include <cyg/hal/hal_io.h>             // HAL_READ/WRITE macros
64
 
65
#include <cyg/hal/plf_cache.h>          // Platform cache definitions
66
 
67
#include CYGBLD_HAL_CPU_MODULES_H       // cache module specs
68
 
69
#include <cyg/hal/sh_regs.h>            // CYGARC_REG_ definitions
70
 
71
//-----------------------------------------------------------------------------
72
// Cache dimensions - one unified cache
73
 
74
#define HAL_CACHE_UNIFIED
75
 
76
#define HAL_UCACHE_SIZE                 CYGARC_SH_MOD_CAC_SIZE
77
#define HAL_UCACHE_LINE_SIZE            CYGARC_SH_MOD_CAC_LINE_SIZE
78
#define HAL_UCACHE_WAYS                 CYGARC_SH_MOD_CAC_WAYS
79
 
80
// Cache addressing information
81
#define CYGARC_REG_CACHE_ADDRESS_BASE   CYGARC_SH_MOD_CAC_ADDRESS_BASE
82
#define CYGARC_REG_CACHE_ADDRESS_TOP    CYGARC_SH_MOD_CAC_ADDRESS_TOP
83
#define CYGARC_REG_CACHE_ADDRESS_STEP   CYGARC_SH_MOD_CAC_ADDRESS_STEP
84
 
85
// Writing this to a cache address entry forces a flush of the line if
86
// it is dirty.
87
#define CYGARC_REG_CACHE_ADDRESS_FLUSH  CYGARC_SH_MOD_CAC_ADDRESS_FLUSH
88
 
89
#define HAL_UCACHE_SETS (HAL_UCACHE_SIZE/(HAL_UCACHE_LINE_SIZE*HAL_UCACHE_WAYS))
90
 
91
//-----------------------------------------------------------------------------
92
// Global control of cache
93
 
94
// This is all handled in assembly (see variant.S) due to a requirement about
95
// not fiddling the cache from cachable memory.
96
 
97
externC void cyg_hal_cache_enable(void);
98
externC void cyg_hal_cache_disable(void);
99
externC void cyg_hal_cache_invalidate_all(void);
100
externC void cyg_hal_cache_sync(void);
101
externC void cyg_hal_cache_sync_region(cyg_haladdress base,
102
                                       cyg_haladdrword len);
103
externC void cyg_hal_cache_write_mode(int mode);
104
 
105
// Enable the cache
106
#define HAL_UCACHE_ENABLE() cyg_hal_cache_enable()
107
 
108
// Disable the cache
109
#define HAL_UCACHE_DISABLE() cyg_hal_cache_disable()
110
 
111
// Invalidate the entire cache
112
#define HAL_UCACHE_INVALIDATE_ALL() cyg_hal_cache_invalidate_all()
113
 
114
// Synchronize the contents of the cache with memory.
115
#define HAL_UCACHE_SYNC() cyg_hal_cache_sync()
116
 
117
// Query the state of the cache (does not affect the caching)
118
#define HAL_UCACHE_IS_ENABLED(_state_)                  \
119
    CYG_MACRO_START                                     \
120
    cyg_uint32 _tmp;                                    \
121
    HAL_READ_UINT32(CYGARC_REG_CCR, _tmp);              \
122
    (_state_) = (_tmp & CYGARC_REG_CCR_CE) ? 1 : 0;     \
123
    CYG_MACRO_END
124
 
125
// Set the cache refill burst size
126
//#define HAL_UCACHE_BURST_SIZE(_size_)
127
 
128
// Set the cache write mode
129
#define HAL_UCACHE_WRITE_MODE( _mode_ )         \
130
    CYG_MACRO_START                             \
131
    cyg_uint32 _m_;                             \
132
    if (HAL_UCACHE_WRITETHRU_MODE == _mode_)    \
133
      _m_ = CYGARC_REG_CCR_WT;                  \
134
    else                                        \
135
      _m_ = CYGARC_REG_CCR_CB;                  \
136
    cyg_hal_cache_write_mode(_m_);              \
137
    CYG_MACRO_END
138
 
139
#define HAL_UCACHE_WRITETHRU_MODE       0
140
#define HAL_UCACHE_WRITEBACK_MODE       1
141
 
142
// This macro allows the client to specify separate modes for the two
143
// regions.
144
#define HAL_UCACHE_WRITE_MODE_SH( _mode_ ) cyg_hal_cache_write_mode(_mode_)
145
 
146
// Load the contents of the given address range into the cache
147
// and then lock the cache so that it stays there.
148
//#define HAL_UCACHE_LOCK(_base_, _size_)
149
 
150
// Undo a previous lock operation
151
//#define HAL_UCACHE_UNLOCK(_base_, _size_)
152
 
153
// Unlock entire cache
154
//#define HAL_UCACHE_UNLOCK_ALL()
155
 
156
//-----------------------------------------------------------------------------
157
// Cache line control
158
 
159
// Allocate cache lines for the given address range without reading its
160
// contents from memory.
161
//#define HAL_UCACHE_ALLOCATE( _base_ , _size_ )
162
 
163
// Write dirty cache lines to memory and invalidate the cache entries
164
// for the given address range.
165
#define HAL_UCACHE_FLUSH( _base_ , _size_ ) \
166
 cyg_hal_cache_sync_region((cyg_haladdress) _base_, (cyg_haladdrword)_size_)
167
 
168
// Invalidate cache lines in the given range without writing to memory.
169
//#define HAL_UCACHE_INVALIDATE( _base_ , _size_ )
170
 
171
// Write dirty cache lines to memory for the given address range.
172
//#define HAL_UCACHE_STORE( _base_ , _size_ )
173
 
174
 
175
// Preread the given range into the cache with the intention of reading
176
// from it later.
177
//#define HAL_UCACHE_READ_HINT( _base_ , _size_ )
178
 
179
// Preread the given range into the cache with the intention of writing
180
// to it later.
181
//#define HAL_UCACHE_WRITE_HINT( _base_ , _size_ )
182
 
183
// Allocate and zero the cache lines associated with the given range.
184
//#define HAL_UCACHE_ZERO( _base_ , _size_ )
185
 
186
 
187
//-----------------------------------------------------------------------------
188
// Data and instruction cache macros map onto the both-cache macros
189
 
190
//-----------------------------------------------------------------------------
191
// Global control of data cache
192
 
193
#define HAL_DCACHE_SIZE                 HAL_UCACHE_SIZE
194
#define HAL_DCACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
195
#define HAL_DCACHE_WAYS                 HAL_UCACHE_WAYS
196
#define HAL_DCACHE_SETS                 HAL_UCACHE_SETS
197
 
198
// Enable the data cache
199
#define HAL_DCACHE_ENABLE()             HAL_UCACHE_ENABLE()
200
 
201
// Disable the data cache
202
#define HAL_DCACHE_DISABLE()            HAL_UCACHE_DISABLE()
203
 
204
// Invalidate the entire cache
205
#define HAL_DCACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
206
 
207
// Synchronize the contents of the cache with memory.
208
#define HAL_DCACHE_SYNC()               HAL_UCACHE_SYNC()
209
 
210
// Query the state of the data cache
211
#define HAL_DCACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
212
 
213
// Set the data cache refill burst size
214
//#define HAL_DCACHE_BURST_SIZE(_size_)
215
 
216
// Set the data cache write mode
217
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
218
 
219
//#define HAL_DCACHE_WRITETHRU_MODE       0
220
//#define HAL_DCACHE_WRITEBACK_MODE       1
221
 
222
// Load the contents of the given address range into the data cache
223
// and then lock the cache so that it stays there.
224
//#define HAL_DCACHE_LOCK(_base_, _size_)
225
 
226
// Undo a previous lock operation
227
//#define HAL_DCACHE_UNLOCK(_base_, _size_)
228
 
229
// Unlock entire cache
230
//#define HAL_DCACHE_UNLOCK_ALL()
231
 
232
//-----------------------------------------------------------------------------
233
// Data cache line control
234
 
235
// Allocate cache lines for the given address range without reading its
236
// contents from memory.
237
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
238
 
239
// Write dirty cache lines to memory and invalidate the cache entries
240
// for the given address range.
241
#define HAL_DCACHE_FLUSH( _base_ , _size_ ) HAL_UCACHE_FLUSH( _base_, _size_ )
242
 
243
// Invalidate cache lines in the given range without writing to memory.
244
//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ )
245
 
246
// Write dirty cache lines to memory for the given address range.
247
//#define HAL_DCACHE_STORE( _base_ , _size_ )
248
 
249
// Preread the given range into the cache with the intention of reading
250
// from it later.
251
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
252
 
253
// Preread the given range into the cache with the intention of writing
254
// to it later.
255
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
256
 
257
// Allocate and zero the cache lines associated with the given range.
258
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
259
 
260
//-----------------------------------------------------------------------------
261
// Global control of Instruction cache
262
 
263
#define HAL_ICACHE_SIZE                 HAL_UCACHE_SIZE
264
#define HAL_ICACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
265
#define HAL_ICACHE_WAYS                 HAL_UCACHE_WAYS
266
#define HAL_ICACHE_SETS                 HAL_UCACHE_SETS
267
 
268
// Enable the instruction cache
269
#define HAL_ICACHE_ENABLE()             HAL_UCACHE_ENABLE()
270
 
271
// Disable the instruction cache
272
#define HAL_ICACHE_DISABLE()            HAL_UCACHE_DISABLE()
273
 
274
// Invalidate the entire cache
275
#define HAL_ICACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
276
 
277
 
278
// Synchronize the contents of the cache with memory.
279
#define HAL_ICACHE_SYNC()               HAL_UCACHE_SYNC()
280
 
281
// Query the state of the instruction cache
282
#define HAL_ICACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
283
 
284
// Set the instruction cache refill burst size
285
//#define HAL_ICACHE_BURST_SIZE(_size_)
286
 
287
// Load the contents of the given address range into the instruction cache
288
// and then lock the cache so that it stays there.
289
 
290
//#define HAL_ICACHE_LOCK(_base_, _size_)
291
 
292
// Undo a previous lock operation
293
//#define HAL_ICACHE_UNLOCK(_base_, _size_)
294
 
295
// Unlock entire cache
296
//#define HAL_ICACHE_UNLOCK_ALL()
297
 
298
//-----------------------------------------------------------------------------
299
// Instruction cache line control
300
 
301
// Invalidate cache lines in the given range without writing to memory.
302
//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ )
303
 
304
//-----------------------------------------------------------------------------
305
#endif // ifndef CYGONCE_VAR_CACHE_H
306
// End of var_cache.h

powered by: WebSVN 2.1.0

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