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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [ppc40x/] [v2_0/] [include/] [var_cache.h] - Blame information for rev 723

Go to most recent revision | 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
//      var_cache.h
6
//
7
//      Variant 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
46
// Contributors:nickg, jskov
47
// Date:        2000-04-02
48
// Purpose:     Variant cache control API
49
// Description: The macros defined here provide the HAL APIs for handling
50
//              cache control operations on the PPC60x variant CPUs.
51
// Usage:       Is included via the architecture cache header:
52
//              #include <cyg/hal/hal_cache.h>
53
//              ...
54
//
55
//####DESCRIPTIONEND####
56
//
57
//=============================================================================
58
 
59
#include <pkgconf/hal.h>
60
#include <cyg/infra/cyg_type.h>
61
 
62
#include <cyg/hal/ppc_regs.h>
63
 
64
#include <cyg/hal/plf_cache.h>
65
 
66
 
67
//-----------------------------------------------------------------------------
68
// Cache dimensions
69
 
70
// Data cache
71
#define HAL_DCACHE_SIZE                 8192    // Size of data cache in bytes
72
#define HAL_DCACHE_LINE_SIZE            16      // Size of a data cache line
73
#define HAL_DCACHE_WAYS                 2       // Associativity of the cache
74
 
75
// Instruction cache
76
#define HAL_ICACHE_SIZE                 16384   // Size of cache in bytes
77
#define HAL_ICACHE_LINE_SIZE            16      // Size of a cache line
78
#define HAL_ICACHE_WAYS                 2       // Associativity of the cache
79
 
80
#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS))
81
#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS))
82
 
83
//-----------------------------------------------------------------------------
84
// Global control of data cache
85
 
86
// Enable the data cache - this is implicit whenever the MMU is turned on
87
#define HAL_DCACHE_ENABLE()
88
 
89
// Disable the data cache
90
#define HAL_DCACHE_DISABLE()
91
 
92
// Invalidate the entire cache
93
#define HAL_DCACHE_INVALIDATE_ALL()                             \
94
    CYG_MACRO_START                                             \
95
    int _i_, _ix_, _indx_;                                      \
96
    _indx_ = 0;                                                 \
97
    _ix_ = HAL_DCACHE_SIZE/2;                                   \
98
    for (_i_ = 0;  _i_ < HAL_DCACHE_SETS;  _i_++) {             \
99
/*        asm volatile ("dcbf 0,%0;" :: "r"(_indx_));           */  \
100
/*        asm volatile ("dcbf %1,%0;" :: "r"(_indx_), "r"(_ix_)); */\
101
        asm volatile ("dccci 0,%0;" :: "r"(_indx_));            \
102
        _indx_ += HAL_DCACHE_LINE_SIZE;                         \
103
    }                                                           \
104
    CYG_MACRO_END
105
 
106
// Synchronize the contents of the cache with memory.                                   
107
#define HAL_DCACHE_SYNC()                                                               \
108
    CYG_MACRO_START                                                                     \
109
    int _indx_;                                                                         \
110
    for (_indx_ = 0;  _indx_ < HAL_DCACHE_SIZE;  _indx_ += HAL_DCACHE_LINE_SIZE) {      \
111
        asm volatile ("dcbf 0,%0;" :: "r"(_indx_));                                     \
112
    }                                                                                   \
113
    CYG_MACRO_END
114
 
115
// Query the state of the data cache
116
#define HAL_DCACHE_IS_ENABLED(_state_)          \
117
    CYG_MACRO_START                             \
118
    (_state_) = 1;                              \
119
    CYG_MACRO_END
120
 
121
// Set the data cache refill burst size
122
//#define HAL_DCACHE_BURST_SIZE(_size_)
123
 
124
// Set the data cache write mode
125
//#define HAL_DCACHE_WRITE_MODE( _mode_ )
126
 
127
//#define HAL_DCACHE_WRITETHRU_MODE       0
128
//#define HAL_DCACHE_WRITEBACK_MODE       1
129
 
130
// Load the contents of the given address range into the data cache
131
// and then lock the cache so that it stays there.
132
//#define HAL_DCACHE_LOCK(_base_, _size_)
133
 
134
// Undo a previous lock operation
135
//#define HAL_DCACHE_UNLOCK(_base_, _size_)
136
 
137
// Unlock entire cache
138
#define HAL_DCACHE_UNLOCK_ALL()
139
 
140
//-----------------------------------------------------------------------------
141
// Data cache line control
142
 
143
// Allocate cache lines for the given address range without reading its
144
// contents from memory.
145
//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ )
146
 
147
// Write dirty cache lines to memory and invalidate the cache entries
148
// for the given address range.
149
//#define HAL_DCACHE_FLUSH( _base_ , _size_ )
150
 
151
// Invalidate cache lines in the given range without writing to memory.
152
//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ )
153
 
154
// Write dirty cache lines to memory for the given address range.
155
//#define HAL_DCACHE_STORE( _base_ , _size_ )
156
 
157
// Preread the given range into the cache with the intention of reading
158
// from it later.
159
//#define HAL_DCACHE_READ_HINT( _base_ , _size_ )
160
 
161
// Preread the given range into the cache with the intention of writing
162
// to it later.
163
//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ )
164
 
165
// Allocate and zero the cache lines associated with the given range.
166
//#define HAL_DCACHE_ZERO( _base_ , _size_ )
167
 
168
//-----------------------------------------------------------------------------
169
// Global control of Instruction cache
170
 
171
// Enable the instruction cache
172
#define HAL_ICACHE_ENABLE()
173
 
174
// Disable the instruction cache
175
#define HAL_ICACHE_DISABLE()
176
 
177
// Invalidate the entire cache
178
#define HAL_ICACHE_INVALIDATE_ALL()                     \
179
    CYG_MACRO_START                                     \
180
    int _i_, _indx_;                                    \
181
    _indx_ = 0;                                         \
182
    for (_i_ = 0;  _i_ < HAL_ICACHE_SETS;  _i_++) {     \
183
        asm volatile ("iccci 0,%0;" :: "r"(_indx_));    \
184
        _indx_ += HAL_ICACHE_LINE_SIZE;                 \
185
    }                                                   \
186
    CYG_MACRO_END
187
 
188
// Synchronize the contents of the cache with memory.
189
#define HAL_ICACHE_SYNC()  HAL_ICACHE_INVALIDATE_ALL()
190
 
191
// Query the state of the instruction cache
192
#define HAL_ICACHE_IS_ENABLED(_state_)          \
193
    CYG_MACRO_START                             \
194
    (_state_) = 1;                              \
195
    CYG_MACRO_END
196
 
197
// Set the instruction cache refill burst size
198
//#define HAL_ICACHE_BURST_SIZE(_size_)
199
 
200
// Load the contents of the given address range into the instruction cache
201
// and then lock the cache so that it stays there.
202
//#define HAL_ICACHE_LOCK(_base_, _size_)
203
 
204
// Undo a previous lock operation
205
//#define HAL_ICACHE_UNLOCK(_base_, _size_)
206
 
207
// Unlock entire cache
208
#define HAL_ICACHE_UNLOCK_ALL()
209
 
210
//-----------------------------------------------------------------------------
211
// Instruction cache line control
212
 
213
// Invalidate cache lines in the given range without writing to memory.
214
//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ )
215
 
216
//-----------------------------------------------------------------------------
217
#endif // ifndef CYGONCE_VAR_CACHE_H
218
// 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.