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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [tx49/] [v2_0/] [include/] [var_cache.h] - Blame information for rev 249

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
//
6
//      var_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 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):   nickg
47
// Contributors:nickg, jskov
48
// Date:        2000-05-09
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/imp_cache.h>
54
//              ...
55
//              
56
//
57
//####DESCRIPTIONEND####
58
//
59
//=============================================================================
60
 
61
#include <pkgconf/hal.h>
62
#include <cyg/infra/cyg_type.h>
63
 
64
#include <cyg/hal/mips-regs.h>
65
 
66
#include <cyg/hal/plf_cache.h>
67
 
68
//=============================================================================
69
// Toshiba TX4955
70
 
71
#ifdef CYGPKG_HAL_MIPS_TX4955
72
 
73
//-----------------------------------------------------------------------------
74
// Cache dimensions
75
 
76
// Data cache
77
#define HAL_DCACHE_SIZE                 CYGHWR_HAL_DCACHE_SIZE // size in bytes
78
#define HAL_DCACHE_LINE_SIZE            32      // Size of a data cache line
79
#define HAL_DCACHE_WAYS                 4       // Associativity of the cache
80
 
81
// Instruction cache
82
#define HAL_ICACHE_SIZE                 CYGHWR_HAL_ICACHE_SIZE // size in bytes
83
#define HAL_ICACHE_LINE_SIZE            32      // Size of a cache line
84
#define HAL_ICACHE_WAYS                 4       // Associativity of the cache
85
 
86
#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS))
87
#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS))
88
 
89
#define HAL_MIPS_CACHE_INSN_USES_LSB
90
 
91
//-----------------------------------------------------------------------------
92
// Cache controls
93
 
94
// Register $16 is Config register (controls cache state)
95
 
96
// Config Register fields
97
#define CYGARC_REG_CONFIG_ICE      0x00020000 // Instruction cache enable
98
#define CYGARC_REG_CONFIG_DCE      0x00010000 // Data cache enable
99
 
100
 
101
//-----------------------------------------------------------------------------
102
// Global control of data cache
103
 
104
// Enable the data cache
105
// This uses a bit in the config register, which is TX49 specific.
106
#define HAL_DCACHE_ENABLE_DEFINED
107
#define HAL_DCACHE_ENABLE()                             \
108
    CYG_MACRO_START                                     \
109
    cyg_uint32 tmp;                                     \
110
    asm volatile ("mfc0 %0,$16;"                        \
111
                  "and  %0,%0,%1;"                      \
112
                  "mtc0 %0,$16;"                        \
113
                  : "=&r" (tmp)                         \
114
                  : "r" (~CYGARC_REG_CONFIG_DCE)        \
115
                 );                                     \
116
    CYG_MACRO_END
117
 
118
// Disable the data cache
119
#define HAL_DCACHE_DISABLE_DEFINED
120
#define HAL_DCACHE_DISABLE()                            \
121
    CYG_MACRO_START                                     \
122
    cyg_uint32 tmp;                                     \
123
    asm volatile ("mfc0 %0,$16;"                        \
124
                  "or   %0,%0,%1;"                      \
125
                  "mtc0 %0,$16;"                        \
126
                  : "=&r" (tmp)                         \
127
                  : "r" (CYGARC_REG_CONFIG_DCE)         \
128
                 );                                     \
129
    CYG_MACRO_END
130
 
131
#define HAL_DCACHE_IS_ENABLED_DEFINED
132
#define HAL_DCACHE_IS_ENABLED(_state_)          \
133
    CYG_MACRO_START                             \
134
    cyg_uint32 _cstate_;                        \
135
    asm volatile ( "mfc0   %0,$16\n"            \
136
                   : "=r"(_cstate_)             \
137
                   );                           \
138
    if( _cstate_ & CYGARC_REG_CONFIG_DCE)       \
139
       _state_ = 0;                             \
140
    else                                        \
141
      _state_ = 1;                              \
142
    CYG_MACRO_END
143
 
144
// Architecture HAL defines other operations
145
 
146
 
147
//-----------------------------------------------------------------------------
148
// Global control of Instruction cache
149
 
150
// Enable the instruction cache
151
#define HAL_ICACHE_ENABLE_DEFINED
152
#define HAL_ICACHE_ENABLE()                             \
153
    CYG_MACRO_START                                     \
154
    cyg_uint32 tmp;                                     \
155
    asm volatile ("mfc0 %0,$16;"                        \
156
                  "and  %0,%0,%1;"                      \
157
                  "mtc0 %0,$16;"                        \
158
                  : "=&r" (tmp)                         \
159
                  : "r" (~CYGARC_REG_CONFIG_ICE)        \
160
                 );                                     \
161
    CYG_MACRO_END
162
 
163
// Disable the instruction cache
164
#define HAL_ICACHE_DISABLE_DEFINED
165
#define HAL_ICACHE_DISABLE()                            \
166
    CYG_MACRO_START                                     \
167
    cyg_uint32 tmp;                                     \
168
    asm volatile ("mfc0 %0,$16;"                        \
169
                  "or   %0,%0,%1;"                      \
170
                  "mtc0 %0,$16;"                        \
171
                  : "=&r" (tmp)                         \
172
                  : "r" (CYGARC_REG_CONFIG_ICE)         \
173
                 );                                     \
174
    CYG_MACRO_END
175
 
176
#define HAL_ICACHE_IS_ENABLED_DEFINED
177
#define HAL_ICACHE_IS_ENABLED(_state_)          \
178
    CYG_MACRO_START                             \
179
    cyg_uint32 _cstate_;                        \
180
    asm volatile ( "mfc0   %0,$16\n"            \
181
                   : "=r"(_cstate_)             \
182
                   );                           \
183
    if( _cstate_ & CYGARC_REG_CONFIG_ICE)       \
184
       _state_ = 0;                             \
185
    else                                        \
186
      _state_ = 1;                              \
187
    CYG_MACRO_END
188
 
189
// TX49 cache instruction must not affect the line it executes out of,
190
// so disable instruction cache before invalidating it.
191
#define HAL_ICACHE_INVALIDATE_ALL_DEFINED
192
#define HAL_ICACHE_INVALIDATE_ALL()                                           \
193
    CYG_MACRO_START                                                           \
194
    register CYG_ADDRESS _baddr_ = 0x80000000;                                \
195
    register CYG_ADDRESS _addr_ = 0x80000000;                                 \
196
    register CYG_WORD _state_;                                                \
197
    _HAL_ASM_SET_MIPS_ISA(3);                                                 \
198
    HAL_ICACHE_IS_ENABLED( _state_ );                                         \
199
    HAL_ICACHE_DISABLE();                                                     \
200
    for( ; _addr_ < _baddr_+HAL_ICACHE_SIZE; _addr_ += HAL_ICACHE_LINE_SIZE ) \
201
    { _HAL_ASM_ICACHE_ALL_WAYS(0x00, _addr_); }                               \
202
    if( _state_ ) HAL_ICACHE_ENABLE();                                        \
203
    _HAL_ASM_SET_MIPS_ISA(0);                                                 \
204
    CYG_MACRO_END
205
 
206
// Architecture HAL defines other operations
207
 
208
#endif // CYGPKG_HAL_MIPS_TX4955
209
 
210
 
211
//-----------------------------------------------------------------------------
212
#endif // ifndef CYGONCE_VAR_CACHE_H
213
// 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.