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

Subversion Repositories openrisc

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

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
//      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):   hmt, nickg
46
// Contributors:        nickg
47
// Date:        2001-05-24
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/var_cache.h>
53
//              ...
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
60
#include <pkgconf/hal.h>
61
#include <cyg/infra/cyg_type.h>
62
 
63
#include <cyg/hal/plf_cache.h>
64
 
65
//-----------------------------------------------------------------------------
66
// Cache sizes.
67
 
68
// Data cache
69
#define HAL_DCACHE_SIZE                 (8*1024)        // Size of data cache in bytes
70
#define HAL_DCACHE_LINE_SIZE            16              // Size of a data cache line
71
#define HAL_DCACHE_WAYS                 1               // Associativity of the cache
72
 
73
// Instruction cache
74
#define HAL_ICACHE_SIZE                 (16*1024)       // Size of cache in bytes
75
#define HAL_ICACHE_LINE_SIZE            16              // Size of a cache line
76
#define HAL_ICACHE_WAYS                 1               // Associativity of the cache
77
 
78
#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS))
79
#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS))
80
 
81
//-----------------------------------------------------------------------------
82
// The uPD985xx mostly uses the default MIPS cache controls defined in
83
// hal_cache.h Here we define the cache enable and disable macros. The only
84
// control we appear to have is the kseg0 cache state in config0. So all
85
// these macros at present manipulate this.
86
 
87
#ifndef HAL_DCACHE_ENABLE_DEFINED
88
#define HAL_DCACHE_ENABLE()                     \
89
CYG_MACRO_START                                 \
90
    asm volatile ( "mfc0   $2,$16\n"            \
91
                   "nop; nop; nop\n"            \
92
                   "la     $3,0xFFFFFFF8\n"     \
93
                   "and    $2,$2,$3\n"          \
94
                   "ori    $2,$2,3\n"           \
95
                   "mtc0   $2,$16\n"            \
96
                   "nop; nop; nop; nop;\n"      \
97
                   "nop; nop; nop; nop;\n"      \
98
                   "nop; nop; nop; nop;\n"      \
99
                   "nop; nop; nop; nop;\n"      \
100
                   :                            \
101
                   :                            \
102
                   : "$2", "$3"                 \
103
                   );                           \
104
CYG_MACRO_END
105
#define HAL_DCACHE_ENABLE_DEFINED
106
#endif
107
 
108
// Disable the data cache
109
#ifndef HAL_DCACHE_DISABLE_DEFINED
110
#define HAL_DCACHE_DISABLE()                    \
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,2\n"           \
117
                   "mtc0   $2,$16\n"            \
118
                   "nop; nop; nop; nop;\n"      \
119
                   "nop; nop; nop; nop;\n"      \
120
                   "nop; nop; nop; nop;\n"      \
121
                   "nop; nop; nop; nop;\n"      \
122
                   :                            \
123
                   :                            \
124
                   : "$2", "$3"                 \
125
                   );                           \
126
CYG_MACRO_END
127
#define HAL_DCACHE_DISABLE_DEFINED
128
#endif
129
 
130
#ifndef HAL_DCACHE_IS_ENABLED_DEFINED
131
#define HAL_DCACHE_IS_ENABLED(_state_)          \
132
CYG_MACRO_START                                 \
133
    CYG_WORD32 _cstate_;                        \
134
    asm volatile ( "mfc0   %0,$16\n"            \
135
                   "nop; nop; nop\n"            \
136
                   : "=r"(_cstate_)             \
137
                   );                           \
138
    if( (_cstate_ & 7) == 2 ) _state_ = 0;      \
139
    else _state_ = 1;                           \
140
CYG_MACRO_END
141
#define HAL_DCACHE_IS_ENABLED_DEFINED
142
#endif
143
 
144
#ifndef HAL_ICACHE_ENABLE_DEFINED
145
#define HAL_ICACHE_ENABLE() HAL_DCACHE_ENABLE()
146
#define HAL_ICACHE_ENABLE_DEFINED
147
#endif
148
 
149
// Disable the instruction cache
150
#ifndef HAL_ICACHE_DISABLE_DEFINED
151
#define HAL_ICACHE_DISABLE() HAL_DCACHE_DISABLE()
152
#define HAL_ICACHE_DISABLE_DEFINED
153
#endif
154
 
155
#ifndef HAL_ICACHE_IS_ENABLED_DEFINED
156
#define HAL_ICACHE_IS_ENABLED(_state_) HAL_DCACHE_IS_ENABLED(_state_)
157
#define HAL_ICACHE_IS_ENABLED_DEFINED
158
#endif
159
 
160
//-----------------------------------------------------------------------------
161
// The VR4300 has no cache locking facility so we define the guard macros
162
// to disable the definitions in hal_arch.h.
163
 
164
#define HAL_DCACHE_LOCK_DEFINED
165
#define HAL_DCACHE_UNLOCK_DEFINED
166
#define HAL_DCACHE_UNLOCK_ALL_DEFINED
167
 
168
#define HAL_ICACHE_LOCK_DEFINED
169
#define HAL_ICACHE_UNLOCK_DEFINED
170
 
171
//-----------------------------------------------------------------------------
172
#endif // ifndef CYGONCE_VAR_CACHE_H
173
// 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.