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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [upd985xx/] [current/] [include/] [var_cache.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_VAR_CACHE_H
2
#define CYGONCE_VAR_CACHE_H
3
//=============================================================================
4
//
5
//      var_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 Free Software Foundation, 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      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY 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        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):   hmt, nickg
45
// Contributors:        nickg
46
// Date:        2001-05-24
47
// Purpose:     Cache control API
48
// Description: The macros defined here provide the HAL APIs for handling
49
//              cache control operations.
50
// Usage:
51
//              #include <cyg/hal/var_cache.h>
52
//              ...
53
//              
54
//
55
//####DESCRIPTIONEND####
56
//
57
//=============================================================================
58
 
59
#include <pkgconf/hal.h>
60
#include <cyg/infra/cyg_type.h>
61
 
62
#include <cyg/hal/plf_cache.h>
63
 
64
//-----------------------------------------------------------------------------
65
// Cache sizes.
66
 
67
// Data cache
68
#define HAL_DCACHE_SIZE                 (8*1024)        // Size of data cache in bytes
69
#define HAL_DCACHE_LINE_SIZE            16              // Size of a data cache line
70
#define HAL_DCACHE_WAYS                 1               // Associativity of the cache
71
 
72
// Instruction cache
73
#define HAL_ICACHE_SIZE                 (16*1024)       // Size of cache in bytes
74
#define HAL_ICACHE_LINE_SIZE            16              // Size of a cache line
75
#define HAL_ICACHE_WAYS                 1               // Associativity of the cache
76
 
77
#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS))
78
#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS))
79
 
80
//-----------------------------------------------------------------------------
81
// The uPD985xx mostly uses the default MIPS cache controls defined in
82
// hal_cache.h Here we define the cache enable and disable macros. The only
83
// control we appear to have is the kseg0 cache state in config0. So all
84
// these macros at present manipulate this.
85
 
86
#ifndef HAL_DCACHE_ENABLE_DEFINED
87
#define HAL_DCACHE_ENABLE()                     \
88
CYG_MACRO_START                                 \
89
    asm volatile ( "mfc0   $2,$16\n"            \
90
                   "nop; nop; nop\n"            \
91
                   "la     $3,0xFFFFFFF8\n"     \
92
                   "and    $2,$2,$3\n"          \
93
                   "ori    $2,$2,3\n"           \
94
                   "mtc0   $2,$16\n"            \
95
                   "nop; nop; nop; nop;\n"      \
96
                   "nop; nop; nop; nop;\n"      \
97
                   "nop; nop; nop; nop;\n"      \
98
                   "nop; nop; nop; nop;\n"      \
99
                   :                            \
100
                   :                            \
101
                   : "$2", "$3"                 \
102
                   );                           \
103
CYG_MACRO_END
104
#define HAL_DCACHE_ENABLE_DEFINED
105
#endif
106
 
107
// Disable the data cache
108
#ifndef HAL_DCACHE_DISABLE_DEFINED
109
#define HAL_DCACHE_DISABLE()                    \
110
CYG_MACRO_START                                 \
111
    asm volatile ( "mfc0   $2,$16\n"            \
112
                   "nop; nop; nop\n"            \
113
                   "la     $3,0xFFFFFFF8\n"     \
114
                   "and    $2,$2,$3\n"          \
115
                   "ori    $2,$2,2\n"           \
116
                   "mtc0   $2,$16\n"            \
117
                   "nop; nop; nop; nop;\n"      \
118
                   "nop; nop; nop; nop;\n"      \
119
                   "nop; nop; nop; nop;\n"      \
120
                   "nop; nop; nop; nop;\n"      \
121
                   :                            \
122
                   :                            \
123
                   : "$2", "$3"                 \
124
                   );                           \
125
CYG_MACRO_END
126
#define HAL_DCACHE_DISABLE_DEFINED
127
#endif
128
 
129
#ifndef HAL_DCACHE_IS_ENABLED_DEFINED
130
#define HAL_DCACHE_IS_ENABLED(_state_)          \
131
CYG_MACRO_START                                 \
132
    CYG_WORD32 _cstate_;                        \
133
    asm volatile ( "mfc0   %0,$16\n"            \
134
                   "nop; nop; nop\n"            \
135
                   : "=r"(_cstate_)             \
136
                   );                           \
137
    if( (_cstate_ & 7) == 2 ) _state_ = 0;      \
138
    else _state_ = 1;                           \
139
CYG_MACRO_END
140
#define HAL_DCACHE_IS_ENABLED_DEFINED
141
#endif
142
 
143
#ifndef HAL_ICACHE_ENABLE_DEFINED
144
#define HAL_ICACHE_ENABLE() HAL_DCACHE_ENABLE()
145
#define HAL_ICACHE_ENABLE_DEFINED
146
#endif
147
 
148
// Disable the instruction cache
149
#ifndef HAL_ICACHE_DISABLE_DEFINED
150
#define HAL_ICACHE_DISABLE() HAL_DCACHE_DISABLE()
151
#define HAL_ICACHE_DISABLE_DEFINED
152
#endif
153
 
154
#ifndef HAL_ICACHE_IS_ENABLED_DEFINED
155
#define HAL_ICACHE_IS_ENABLED(_state_) HAL_DCACHE_IS_ENABLED(_state_)
156
#define HAL_ICACHE_IS_ENABLED_DEFINED
157
#endif
158
 
159
//-----------------------------------------------------------------------------
160
// The VR4300 has no cache locking facility so we define the guard macros
161
// to disable the definitions in hal_arch.h.
162
 
163
#define HAL_DCACHE_LOCK_DEFINED
164
#define HAL_DCACHE_UNLOCK_DEFINED
165
#define HAL_DCACHE_UNLOCK_ALL_DEFINED
166
 
167
#define HAL_ICACHE_LOCK_DEFINED
168
#define HAL_ICACHE_UNLOCK_DEFINED
169
 
170
//-----------------------------------------------------------------------------
171
#endif // ifndef CYGONCE_VAR_CACHE_H
172
// 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.