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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mn10300/] [am31/] [current/] [src/] [var_misc.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      var_misc.c
4
//
5
//      HAL CPU variant miscellaneous functions
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    nickg
43
// Contributors: nickg, jlarmour
44
// Date:         1999-01-21
45
// Purpose:      HAL miscellaneous functions
46
// Description:  This file contains miscellaneous functions provided by the
47
//               HAL.
48
//
49
//####DESCRIPTIONEND####
50
//
51
//========================================================================*/
52
 
53
#include <pkgconf/hal.h>
54
 
55
#include <cyg/infra/cyg_type.h>         // Base types
56
#include <cyg/infra/cyg_trac.h>         // tracing macros
57
#include <cyg/infra/cyg_ass.h>          // assertion macros
58
 
59
#include <cyg/hal/hal_cache.h>
60
 
61
/*------------------------------------------------------------------------*/
62
/* Variant specific initialization routine.                               */
63
 
64
void hal_variant_init(void)
65
{
66
}
67
 
68
/*------------------------------------------------------------------------*/
69
/* Cache functions.                                                       */
70
 
71
#if !defined(CYG_HAL_MN10300_AM31_SIM)
72
void cyg_hal_dcache_store(CYG_ADDRWORD base, int size)
73
{
74
#if 0    
75
    volatile register CYG_BYTE *way0 = HAL_DCACHE_PURGE_WAY0;
76
    volatile register CYG_BYTE *way1 = HAL_DCACHE_PURGE_WAY1;
77
    register int i;
78
    register CYG_ADDRWORD state;
79
 
80
    HAL_DCACHE_IS_ENABLED(state);
81
    if (state)
82
        HAL_DCACHE_DISABLE();
83
 
84
    way0 += base & 0x000007f0;
85
    way1 += base & 0x000007f0;
86
    for( i = 0; i < size; i += HAL_DCACHE_LINE_SIZE )
87
    {
88
        *(CYG_ADDRWORD *)way0 = 0;
89
        *(CYG_ADDRWORD *)way1 = 0;
90
        way0 += HAL_DCACHE_LINE_SIZE;
91
        way1 += HAL_DCACHE_LINE_SIZE;
92
    }
93
    if (state)
94
        HAL_DCACHE_ENABLE();
95
#else
96
 
97
    // Despite several people trying to understand it, the above code
98
    // still does not work correctly. Whether this is a result of the
99
    // AM31 hardware being faulty, or simply a problem with register
100
    // pressure causing the values of some variables to be lost as a
101
    // result of the purge we are not sure. Similar code on the AM33
102
    // works perfectly, but that processor has more registers to play
103
    // with.  The following code, taken from CygMon, works correctly,
104
    // and does not appear to exhibit the problems of the code above.
105
    // It's only drawback is that it purges the entire cache. However,
106
    // this is permitted under the definition of the cache macros, so
107
    // this is not a major concern at present.
108
 
109
    __asm__ (
110
              ".equ CHCTR,        0x20000070;"
111
              ".equ CHCTR_ICEN,   0x0001;"
112
              ".equ CHCTR_DCEN,   0x0002;"
113
              ".equ CHCTR_ICBUSY, 0x0004;"
114
              ".equ CHCTR_DCBUSY, 0x0008;"
115
              ".equ CHCTR_ICINV,  0x0010;"
116
              ".equ CHCTR_DCINV,  0x0020;"
117
              ".equ DCACHE_PURGE_WAY0_START, 0x28400000;"
118
              ".equ DCACHE_PURGE_WAY0_END,   0x28400800;"
119
              ".equ DCACHE_PURGE_WAY1_START, 0x28401000;"
120
              ".equ DCACHE_PURGE_WAY1_END,   0x28401800;"
121
 
122
              "mov CHCTR,a0;"
123
 
124
              /* DCACHE */
125
 
126
              /* first check if dcache enabled */
127
              "mov (a0),d0;"
128
              "btst CHCTR_DCEN,d0;"
129
              /* if not, jump to end */
130
              "beq 2f;"
131
 
132
              /* if so, we have to disable the cache */
133
              "and 0xfffffffd,d0;"
134
              "mov d0,(a0);"
135
 
136
              /* wait for it to stop being busy */
137
              "setlb;"
138
              "nop;"
139
              "mov (a0),d0;"
140
              "btst CHCTR_DCBUSY,d0;"
141
              "lne;"
142
 
143
              /* now purge the dcache */
144
              "mov DCACHE_PURGE_WAY0_START,a1;"
145
              "1:"
146
              "mov (0,a1),d0;"
147
              "add 0x10,a1;"
148
              "cmp DCACHE_PURGE_WAY0_END,a1;"
149
              "bne 1b;"
150
              "mov DCACHE_PURGE_WAY1_START,a1;"
151
              "1:"
152
              "mov (0,a1),d0;"
153
              "add 0x10,a1;"
154
              "cmp DCACHE_PURGE_WAY1_END,a1;"
155
              "bne 1b;"
156
 
157
              /* wait for it to stop being busy */
158
              "setlb;"
159
              "nop;"
160
              "mov (a0),d0;"
161
              "btst CHCTR_DCBUSY,d0;"
162
              "lne;"
163
 
164
              /* and re-enable */
165
              "or CHCTR_DCEN,d0;"
166
              "mov d0,(a0);"
167
 
168
              "2:"
169
 
170
              :
171
              :
172
              : "a0", "a1", "d0"
173
        );
174
 
175
#endif    
176
}
177
#endif
178
 
179
 
180
/*------------------------------------------------------------------------*/
181
/* End of var_misc.c                                                      */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.