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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sh/] [sh3/] [v2_0/] [include/] [var_cache.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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 Red Hat, 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 version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// 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 along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//=============================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):   jskov
47
// Contributors:jskov
48
// Date:        1999-04-23
49
// Purpose:     Cache control API
50
// Description: The macros defined here provide the HAL APIs for handling
51
//              cache control operations.
52
// Usage:
53
//              #include <cyg/hal/hal_cache.h>
54
//              ...
55
//              
56
//
57
//####DESCRIPTIONEND####
58
//
59
//=============================================================================
60
 
61
#include <pkgconf/system.h>
62
#include <pkgconf/hal.h>
63
#include <cyg/infra/cyg_type.h>
64
#include <cyg/hal/hal_io.h>             // HAL_READ/WRITE macros
65
 
66
#include <cyg/hal/plf_cache.h>          // Platform cache definitions
67
 
68
#include CYGBLD_HAL_CPU_MODULES_H       // cache module specs
69
 
70
#include <cyg/hal/sh_regs.h>            // CYGARC_REG_ definitions
71
 
72
//-----------------------------------------------------------------------------
73
// Cache dimensions - one unified cache
74
 
75
#define HAL_CACHE_UNIFIED
76
 
77
#define HAL_UCACHE_SIZE                 CYGARC_SH_MOD_CAC_SIZE
78
#define HAL_UCACHE_LINE_SIZE            CYGARC_SH_MOD_CAC_LINE_SIZE
79
#define HAL_UCACHE_WAYS                 CYGARC_SH_MOD_CAC_WAYS
80
 
81
// Cache addressing information
82
#define CYGARC_REG_CACHE_ADDRESS_BASE   CYGARC_SH_MOD_CAC_ADDRESS_BASE
83
#define CYGARC_REG_CACHE_ADDRESS_TOP    CYGARC_SH_MOD_CAC_ADDRESS_TOP
84
#define CYGARC_REG_CACHE_ADDRESS_STEP   CYGARC_SH_MOD_CAC_ADDRESS_STEP
85
 
86
// Writing this to a cache address entry forces a flush of the line if
87
// it is dirty.
88
#define CYGARC_REG_CACHE_ADDRESS_FLUSH  CYGARC_SH_MOD_CAC_ADDRESS_FLUSH
89
 
90
#define HAL_UCACHE_SETS (HAL_UCACHE_SIZE/(HAL_UCACHE_LINE_SIZE*HAL_UCACHE_WAYS))
91
 
92
//-----------------------------------------------------------------------------
93
// Global control of cache
94
 
95
// This is all handled in assembly (see variant.S) due to a requirement about
96
// not fiddling the cache from cachable memory.
97
 
98
externC void cyg_hal_cache_enable(void);
99
externC void cyg_hal_cache_disable(void);
100
externC void cyg_hal_cache_invalidate_all(void);
101
externC void cyg_hal_cache_sync(void);
102
externC void cyg_hal_cache_sync_region(cyg_haladdress base,
103
                                       cyg_haladdrword len);
104
externC void cyg_hal_cache_write_mode(int mode);
105
 
106
// Enable the cache
107
#define HAL_UCACHE_ENABLE() cyg_hal_cache_enable()
108
 
109
// Disable the cache
110
#define HAL_UCACHE_DISABLE() cyg_hal_cache_disable()
111
 
112
// Invalidate the entire cache
113
#define HAL_UCACHE_INVALIDATE_ALL() cyg_hal_cache_invalidate_all()
114
 
115
// Synchronize the contents of the cache with memory.
116
#define HAL_UCACHE_SYNC() cyg_hal_cache_sync()
117
 
118
// Query the state of the cache (does not affect the caching)
119
#define HAL_UCACHE_IS_ENABLED(_state_)                  \
120
    CYG_MACRO_START                                     \
121
    cyg_uint32 _tmp;                                    \
122
    HAL_READ_UINT32(CYGARC_REG_CCR, _tmp);              \
123
    (_state_) = (_tmp & CYGARC_REG_CCR_CE) ? 1 : 0;     \
124
    CYG_MACRO_END
125
 
126
// Set the cache refill burst size
127
//#define HAL_UCACHE_BURST_SIZE(_size_)
128
 
129
// Set the cache write mode
130
#define HAL_UCACHE_WRITE_MODE( _mode_ )         \
131
    CYG_MACRO_START                             \
132
    cyg_uint32 _m_;                             \
133
    if (HAL_UCACHE_WRITETHRU_MODE == _mode_)    \
134
      _m_ = CYGARC_REG_CCR_WT;                  \
135
    else                                        \
136
      _m_ = CYGARC_REG_CCR_CB;                  \
137
    cyg_hal_cache_write_mode(_m_);              \
138
    CYG_MACRO_END
139
 
140
#define HAL_UCACHE_WRITETHRU_MODE       0
141
#define HAL_UCACHE_WRITEBACK_MODE       1
142
 
143
// This macro allows the client to specify separate modes for the two
144
// regions.
145
#define HAL_UCACHE_WRITE_MODE_SH( _mode_ ) cyg_hal_cache_write_mode(_mode_)
146
 
147
// Load the contents of the given address range into the cache
148
// and then lock the cache so that it stays there.
149
//#define HAL_UCACHE_LOCK(_base_, _size_)
150
 
151
// Undo a previous lock operation
152
//#define HAL_UCACHE_UNLOCK(_base_, _size_)
153
 
154
// Unlock entire cache
155
//#define HAL_UCACHE_UNLOCK_ALL()
156
 
157
//-----------------------------------------------------------------------------
158
// Cache line control
159
 
160
// Allocate cache lines for the given address range without reading its
161
// contents from memory.
162
//#define HAL_UCACHE_ALLOCATE( _base_ , _size_ )
163
 
164
// Write dirty cache lines to memory and invalidate the cache entries
165
// for the given address range.
166
#define HAL_UCACHE_FLUSH( _base_ , _size_ ) \
167
 cyg_hal_cache_sync_region((cyg_haladdress) _base_, (cyg_haladdrword)_size_)
168
 
169
// Invalidate cache lines in the given range without writing to memory.
170
//#define HAL_UCACHE_INVALIDATE( _base_ , _size_ )
171
 
172
// Write dirty cache lines to memory for the given address range.
173
//#define HAL_UCACHE_STORE( _base_ , _size_ )
174
 
175
 
176
// Preread the given range into the cache with the intention of reading
177
// from it later.
178
//#define HAL_UCACHE_READ_HINT( _base_ , _size_ )
179
 
180
// Preread the given range into the cache with the intention of writing
181
// to it later.
182
//#define HAL_UCACHE_WRITE_HINT( _base_ , _size_ )
183
 
184
// Allocate and zero the cache lines associated with the given range.
185
//#define HAL_UCACHE_ZERO( _base_ , _size_ )
186
 
187
 
188
//-----------------------------------------------------------------------------
189
// Data and instruction cache macros map onto the both-cache macros
190
 
191
//-----------------------------------------------------------------------------
192
// Global control of data cache
193
 
194
#define HAL_DCACHE_SIZE                 HAL_UCACHE_SIZE
195
#define HAL_DCACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
196
#define HAL_DCACHE_WAYS                 HAL_UCACHE_WAYS
197
#define HAL_DCACHE_SETS                 HAL_UCACHE_SETS
198
 
199
// Enable the data cache
200
#define HAL_DCACHE_ENABLE()             HAL_UCACHE_ENABLE()
201
 
202
// Disable the data cache
203
#define HAL_DCACHE_DISABLE()            HAL_UCACHE_DISABLE()
204
 
205
// Invalidate the entire cache
206
#define HAL_DCACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
207
 
208
// Synchronize the contents of the cache with memory.
209
#define HAL_DCACHE_SYNC()               HAL_UCACHE_SYNC()
210
 
211
// Query the state of the data cache
212
#define HAL_DCACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
213
 
214
// Set the data cache refill burst size
215
//#define HAL_DCACHE_BURST_SIZE(_size_)
216
 
217
// Set the data cache write mode
218
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
219
 
220
//#define HAL_DCACHE_WRITETHRU_MODE       0
221
//#define HAL_DCACHE_WRITEBACK_MODE       1
222
 
223
// Load the contents of the given address range into the data cache
224
// and then lock the cache so that it stays there.
225
//#define HAL_DCACHE_LOCK(_base_, _size_)
226
 
227
// Undo a previous lock operation
228
//#define HAL_DCACHE_UNLOCK(_base_, _size_)
229
 
230
// Unlock entire cache
231
//#define HAL_DCACHE_UNLOCK_ALL()
232
 
233
//-----------------------------------------------------------------------------
234
// Data cache line control
235
 
236
// Allocate cache lines for the given address range without reading its
237
// contents from memory.
238
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
239
 
240
// Write dirty cache lines to memory and invalidate the cache entries
241
// for the given address range.
242
#define HAL_DCACHE_FLUSH( _base_ , _size_ ) HAL_UCACHE_FLUSH( _base_, _size_ )
243
 
244
// Invalidate cache lines in the given range without writing to memory.
245
//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ )
246
 
247
// Write dirty cache lines to memory for the given address range.
248
//#define HAL_DCACHE_STORE( _base_ , _size_ )
249
 
250
// Preread the given range into the cache with the intention of reading
251
// from it later.
252
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
253
 
254
// Preread the given range into the cache with the intention of writing
255
// to it later.
256
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
257
 
258
// Allocate and zero the cache lines associated with the given range.
259
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
260
 
261
//-----------------------------------------------------------------------------
262
// Global control of Instruction cache
263
 
264
#define HAL_ICACHE_SIZE                 HAL_UCACHE_SIZE
265
#define HAL_ICACHE_LINE_SIZE            HAL_UCACHE_LINE_SIZE
266
#define HAL_ICACHE_WAYS                 HAL_UCACHE_WAYS
267
#define HAL_ICACHE_SETS                 HAL_UCACHE_SETS
268
 
269
// Enable the instruction cache
270
#define HAL_ICACHE_ENABLE()             HAL_UCACHE_ENABLE()
271
 
272
// Disable the instruction cache
273
#define HAL_ICACHE_DISABLE()            HAL_UCACHE_DISABLE()
274
 
275
// Invalidate the entire cache
276
#define HAL_ICACHE_INVALIDATE_ALL()     HAL_UCACHE_INVALIDATE_ALL()
277
 
278
 
279
// Synchronize the contents of the cache with memory.
280
#define HAL_ICACHE_SYNC()               HAL_UCACHE_SYNC()
281
 
282
// Query the state of the instruction cache
283
#define HAL_ICACHE_IS_ENABLED(_state_)  HAL_UCACHE_IS_ENABLED(_state_)
284
 
285
// Set the instruction cache refill burst size
286
//#define HAL_ICACHE_BURST_SIZE(_size_)
287
 
288
// Load the contents of the given address range into the instruction cache
289
// and then lock the cache so that it stays there.
290
 
291
//#define HAL_ICACHE_LOCK(_base_, _size_)
292
 
293
// Undo a previous lock operation
294
//#define HAL_ICACHE_UNLOCK(_base_, _size_)
295
 
296
// Unlock entire cache
297
//#define HAL_ICACHE_UNLOCK_ALL()
298
 
299
//-----------------------------------------------------------------------------
300
// Instruction cache line control
301
 
302
// Invalidate cache lines in the given range without writing to memory.
303
//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ )
304
 
305
//-----------------------------------------------------------------------------
306
#endif // ifndef CYGONCE_VAR_CACHE_H
307
// 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.