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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [snds/] [v2_0/] [include/] [hal_cache.h] - Blame information for rev 232

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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 Red Hat, 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 version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-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(KS32C_SYSCFG, syscfg);        \
83
    syscfg |= KS32C_SYSCFG_CE;                    \
84
    HAL_WRITE_UINT32(KS32C_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(KS32C_SYSCFG, syscfg);        \
92
    syscfg &= ~KS32C_SYSCFG_CE;                   \
93
    HAL_WRITE_UINT32(KS32C_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*)KS32C_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(KS32C_SYSCFG, syscfg);                \
118
    (_state_) = (syscfg & KS32C_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.