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

Subversion Repositories openrisc

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

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 CYGHWR_MEMORY_LAYOUT_H
63
 
64
#include <cyg/infra/cyg_type.h>
65
 
66
#include <cyg/hal/mips-regs.h>
67
 
68
#include <cyg/hal/plf_cache.h>
69
 
70
 
71
//=============================================================================
72
// Area to use for cache scrubbing. This must be a cache sized area in
73
// cachable space which can be cleared. Defaults to use the area reserved
74
// for shared PCI memory space.
75
#ifndef CYGHWR_HAL_MIPS_RM7000_CACHE_SCRUB_BASE
76
# define CYGHWR_HAL_MIPS_RM7000_CACHE_SCRUB_BASE  CYGMEM_SECTION_pci_window
77
#endif
78
 
79
//=============================================================================
80
// QED RM7000A
81
 
82
#ifdef CYGPKG_HAL_MIPS_RM7000A
83
 
84
//-----------------------------------------------------------------------------
85
// Cache dimensions
86
 
87
// Data cache
88
#define HAL_DCACHE_SIZE                 CYGHWR_HAL_DCACHE_SIZE // size in bytes
89
#define HAL_DCACHE_LINE_SIZE            32      // Size of a data cache line
90
#define HAL_DCACHE_WAYS                 4       // Associativity of the cache
91
 
92
// Instruction cache
93
#define HAL_ICACHE_SIZE                 CYGHWR_HAL_ICACHE_SIZE // size in bytes
94
#define HAL_ICACHE_LINE_SIZE            32      // Size of a cache line
95
#define HAL_ICACHE_WAYS                 4       // Associativity of the cache
96
 
97
#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS))
98
#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS))
99
 
100
//-----------------------------------------------------------------------------
101
// Global control of data cache
102
 
103
//-----------------------------------------------------------------------------
104
//The RM7000 mostly uses the default MIPS cache controls defined in
105
//hal_cache.h Here we define the cache enable and disable macros. The
106
//only control we appear to have is the kseg0 cache state in
107
//config0. So all these macros at present manipulate this.
108
 
109
#ifndef HAL_DCACHE_ENABLE_DEFINED
110
#define HAL_DCACHE_ENABLE()                     \
111
CYG_MACRO_START                                 \
112
    asm volatile ( "mfc0   $2,$16\n"            \
113
                   "nop; nop; nop\n"            \
114
                   "la     $3,0xFFFFFFF8\n"     \
115
                   "and    $2,$2,$3\n"          \
116
                   "ori    $2,$2,3\n"           \
117
                   "mtc0   $2,$16\n"            \
118
                   "nop; nop; nop;\n"           \
119
                   :                            \
120
                   :                            \
121
                   : "$2", "$3"                 \
122
                   );                           \
123
CYG_MACRO_END
124
#define HAL_DCACHE_ENABLE_DEFINED
125
#endif
126
 
127
// Disable the data cache
128
#ifndef HAL_DCACHE_DISABLE_DEFINED
129
#define HAL_DCACHE_DISABLE()                    \
130
CYG_MACRO_START                                 \
131
    asm volatile ( "mfc0   $2,$16\n"            \
132
                   "nop; nop; nop\n"            \
133
                   "la     $3,0xFFFFFFF8\n"     \
134
                   "and    $2,$2,$3\n"          \
135
                   "ori    $2,$2,2\n"           \
136
                   "mtc0   $2,$16\n"            \
137
                   "nop; nop; nop;\n"           \
138
                   :                            \
139
                   :                            \
140
                   : "$2", "$3"                 \
141
                   );                           \
142
CYG_MACRO_END
143
#define HAL_DCACHE_DISABLE_DEFINED
144
#endif
145
 
146
#ifndef HAL_DCACHE_IS_ENABLED_DEFINED
147
#define HAL_DCACHE_IS_ENABLED(_state_)          \
148
CYG_MACRO_START                                 \
149
    CYG_WORD32 _cstate_;                        \
150
    asm volatile ( "mfc0   %0,$16\n"            \
151
                   : "=r"(_cstate_)             \
152
                   );                           \
153
    if( (_cstate_ & 7) == 2 ) _state_ = 0;      \
154
    else _state_ = 1;                           \
155
CYG_MACRO_END
156
#define HAL_DCACHE_IS_ENABLED_DEFINED
157
#endif
158
 
159
#ifndef HAL_ICACHE_ENABLE_DEFINED
160
#define HAL_ICACHE_ENABLE() HAL_DCACHE_ENABLE()
161
#define HAL_ICACHE_ENABLE_DEFINED
162
#endif
163
 
164
// Disable the instruction cache
165
#ifndef HAL_ICACHE_DISABLE_DEFINED
166
#define HAL_ICACHE_DISABLE() HAL_DCACHE_DISABLE()
167
#define HAL_ICACHE_DISABLE_DEFINED
168
#endif
169
 
170
#ifndef HAL_ICACHE_IS_ENABLED_DEFINED
171
#define HAL_ICACHE_IS_ENABLED(_state_) HAL_DCACHE_IS_ENABLED(_state_)
172
#define HAL_ICACHE_IS_ENABLED_DEFINED
173
#endif
174
 
175
#if 0 // FIXME: Need this for RM7000A also?
176
// TX49 cache instruction must not affect the line it executes out of,
177
// so disable instruction cache before invalidating it.
178
#define HAL_ICACHE_INVALIDATE_ALL_DEFINED
179
#define HAL_ICACHE_INVALIDATE_ALL()                                           \
180
    CYG_MACRO_START                                                           \
181
    register CYG_ADDRESS _baddr_ = 0x80000000;                                \
182
    register CYG_ADDRESS _addr_ = 0x80000000;                                 \
183
    register CYG_WORD _state_;                                                \
184
    _HAL_ASM_SET_MIPS_ISA(3);                                                 \
185
    HAL_ICACHE_IS_ENABLED( _state_ );                                         \
186
    HAL_ICACHE_DISABLE();                                                     \
187
    for( ; _addr_ < _baddr_+HAL_ICACHE_SIZE; _addr_ += HAL_ICACHE_LINE_SIZE ) \
188
    { _HAL_ASM_ICACHE_ALL_WAYS(0x00, _addr_); }                               \
189
    if( _state_ ) HAL_ICACHE_ENABLE();                                        \
190
    _HAL_ASM_SET_MIPS_ISA(0);                                                 \
191
    CYG_MACRO_END
192
#endif
193
 
194
#endif // CYGPKG_HAL_MIPS_RM7000A
195
 
196
 
197
//-----------------------------------------------------------------------------
198
#endif // ifndef CYGONCE_VAR_CACHE_H
199
// 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.