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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [m68k/] [mcf52xx/] [mcf5272/] [proc/] [current/] [include/] [proc_cache.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_PROC_CACHE_H
2
#define CYGONCE_PROC_CACHE_H
3
//=============================================================================
4
//
5
//      proc_cache.h
6
//
7
//      Cache details for an mcf5272
8
//
9
//=============================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 2003, 2004, 2006, 2008 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):   bartv
45
// Date:        2003-06-04
46
//
47
//####DESCRIPTIONEND####
48
//=============================================================================
49
 
50
#include <cyg/infra/cyg_type.h>
51
#include <cyg/hal/var_io.h>
52
 
53
// An mcf5272 has a 1k direct-mapped instruction cache, 64 lines * 16 bytes.
54
// There is no data cache. The cache control register is write-only so it
55
// is necessary to keep a soft copy.
56
 
57
externC cyg_uint32   hal_mcf5272_cacr;
58
 
59
#define HAL_ICACHE_SIZE         1024
60
#define HAL_ICACHE_LINE_SIZE      16
61
#define HAL_ICACHE_WAYS           64
62
#define HAL_ICACHE_SETS            1
63
 
64
#define HAL_ICACHE_ENABLE()                                                                     \
65
    CYG_MACRO_START                                                                             \
66
    hal_mcf5272_cacr = (hal_mcf5272_cacr & ~HAL_MCFxxxx_CACR_CINV) | HAL_MCFxxxx_CACR_CENB;     \
67
    asm volatile ( "movec.l %0,%%cacr\n" : : "d" (hal_mcf5272_cacr) : "memory") ;               \
68
    CYG_MACRO_END
69
 
70
#define HAL_ICACHE_DISABLE()                                                                    \
71
    CYG_MACRO_START                                                                             \
72
    hal_mcf5272_cacr &= ~(HAL_MCFxxxx_CACR_CENB | HAL_MCFxxxx_CACR_CINV);                       \
73
    asm volatile ( "movec.l %0,%%cacr\n" : : "d" (hal_mcf5272_cacr) : "memory") ;               \
74
    CYG_MACRO_END
75
 
76
#define HAL_ICACHE_IS_ENABLED(_state_)                              \
77
    CYG_MACRO_START                                                 \
78
    _state_ = (0 != (hal_mcf5272_cacr & HAL_MCFxxxx_CACR_CENB));    \
79
    CYG_MACRO_END
80
 
81
// A full cache invalidate takes 64 cycles. This is expensive if only one
82
// or two lines need to be invalidated, but doing the arithmetic and tests
83
// needed to affect just the necessary lines would also take quite a few
84
// cycles. Hence it is simpler to just invalidate the lot.
85
#define HAL_ICACHE_INVALIDATE_ALL()                                                                         \
86
    CYG_MACRO_START                                                                                         \
87
    asm volatile ( "movec.l %0,%%cacr\n" : : "d" (hal_mcf5272_cacr | HAL_MCFxxxx_CACR_CINV) : "memory" );   \
88
    CYG_MACRO_END
89
 
90
#define HAL_ICACHE_INVALIDATE(_base_, _size_)           \
91
    CYG_MACRO_START                                     \
92
    HAL_ICACHE_INVALIDATE_ALL();                        \
93
    CYG_MACRO_END
94
 
95
#define HAL_ICACHE_SYNC()                               \
96
    CYG_MACRO_START                                     \
97
    HAL_ICACHE_INVALIDATE_ALL();                        \
98
    CYG_MACRO_END
99
 
100
#endif // ifndef CYGONCE_PROC_CACHE_H
101
// End of proc_cache.h
102
 

powered by: WebSVN 2.1.0

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