source: rtems/c/src/lib/libcpu/powerpc/shared/src/cache.c @ 54444d5

4.104.114.95
Last change on this file since 54444d5 was 54444d5, checked in by Till Straumann <strauman@…>, on 11/28/07 at 20:56:21

2007-11-28 Till Straumann <strauman@…>

  • shared/src/cache.c: removed redundant mpc8xx versions of flush/invalidate 1 cache line routines.
  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 *  Cache Management Support Routines for the MC68040
3 * Modified for MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
4 * Surrey Satellite Technology Limited (SSTL), 2001
5 *
6 *  $Id$
7 */
8
9#include <rtems.h>
10#include "cache_.h"
11#include <rtems/powerpc/registers.h>
12
13/*
14 * CACHE MANAGER: The following functions are CPU-specific.
15 * They provide the basic implementation for the rtems_* cache
16 * management routines. If a given function has no meaning for the CPU,
17 * it does nothing by default.
18 *
19 * FIXME: Some functions simply have not been implemented.
20 */
21 
22#if defined(ppc603) || defined(ppc603e) || defined(mpc8260) /* And possibly others */
23
24/* Helpful macros */
25#define PPC_Get_HID0( _value ) \
26  do { \
27      _value = 0;        /* to avoid warnings */ \
28      asm volatile( \
29          "mfspr %0, 0x3f0;"     /* get HID0 */ \
30          "isync" \
31          : "=r" (_value) \
32          : "0" (_value) \
33      ); \
34  } while (0)
35
36#define PPC_Set_HID0( _value ) \
37  do { \
38      asm volatile( \
39          "isync;" \
40          "mtspr 0x3f0, %0;"     /* load HID0 */ \
41          "isync" \
42          : "=r" (_value) \
43          : "0" (_value) \
44      ); \
45  } while (0)
46
47void _CPU_cache_enable_data (
48        void )
49{
50  uint32_t   value;
51  PPC_Get_HID0( value );
52  value |= HID0_DCE;        /* set DCE bit */
53  PPC_Set_HID0( value );
54}
55
56void _CPU_cache_disable_data (
57        void )
58{
59  uint32_t   value;
60  PPC_Get_HID0( value );
61  value &= ~HID0_DCE;        /* clear DCE bit */
62  PPC_Set_HID0( value );
63}
64
65void _CPU_cache_invalidate_entire_data (
66        void )
67{
68  uint32_t  value;
69  PPC_Get_HID0( value );
70  value |= HID0_DCI;        /* set data flash invalidate bit */
71  PPC_Set_HID0( value );
72  value &= ~HID0_DCI;        /* clear data flash invalidate bit */
73  PPC_Set_HID0( value );
74}
75
76void _CPU_cache_freeze_data (
77        void )
78{
79  uint32_t  value;
80  PPC_Get_HID0( value );
81  value |= HID0_DLOCK;        /* set data cache lock bit */
82  PPC_Set_HID0( value );
83}
84
85void _CPU_cache_unfreeze_data (
86        void )
87{
88  uint32_t  value;
89  PPC_Get_HID0( value );
90  value &= ~HID0_DLOCK;        /* set data cache lock bit */
91  PPC_Set_HID0( value );
92}
93
94void _CPU_cache_flush_entire_data (
95        void )
96{
97  /*
98   * FIXME: how can we do this?
99   */
100}
101
102void _CPU_cache_enable_instruction (
103        void )
104{
105  uint32_t   value;
106  PPC_Get_HID0( value );
107  value |= 0x00008000;       /* Set ICE bit */
108  PPC_Set_HID0( value );
109}
110
111void _CPU_cache_disable_instruction (
112        void )
113{
114  uint32_t   value;
115  PPC_Get_HID0( value );
116  value &= 0xFFFF7FFF;       /* Clear ICE bit */
117  PPC_Set_HID0( value );
118}
119
120
121void _CPU_cache_invalidate_entire_instruction (
122        void )
123{
124  uint32_t  value;
125  PPC_Get_HID0( value );
126  value |= HID0_ICFI;        /* set data flash invalidate bit */
127  PPC_Set_HID0( value );
128  value &= ~HID0_ICFI;        /* clear data flash invalidate bit */
129  PPC_Set_HID0( value );
130}
131
132void _CPU_cache_freeze_instruction (
133        void )
134{
135  uint32_t  value;
136  PPC_Get_HID0( value );
137  value |= HID0_ILOCK;        /* set instruction cache lock bit */
138  PPC_Set_HID0( value );
139}
140
141void _CPU_cache_unfreeze_instruction (
142        void )
143{
144  uint32_t  value;
145  PPC_Get_HID0( value );
146  value &= ~HID0_ILOCK;        /* set instruction cache lock bit */
147  PPC_Set_HID0( value );
148}
149
150#elif ( defined(mpx8xx) || defined(mpc860) || defined(mpc821) )
151
152#define mtspr(_spr,_reg) \
153  __asm__ volatile ( "mtspr %0, %1\n" : : "i" ((_spr)), "r" ((_reg)) )
154#define isync \
155  __asm__ volatile ("isync\n"::)
156
157void _CPU_cache_flush_entire_data ( void ) {}
158void _CPU_cache_invalidate_entire_data ( void ) {}
159void _CPU_cache_freeze_data ( void ) {}
160void _CPU_cache_unfreeze_data ( void ) {}
161
162void _CPU_cache_enable_data ( void )
163{
164  uint32_t   r1;
165  r1 = (0x2<<24);
166  mtspr( 568, r1 );
167  isync;
168}
169
170void _CPU_cache_disable_data ( void )
171{
172  uint32_t   r1;
173  r1 = (0x4<<24);
174  mtspr( 568, r1 );
175  isync;
176}
177
178void _CPU_cache_invalidate_entire_instruction ( void ) {}
179void _CPU_cache_freeze_instruction ( void ) {}
180void _CPU_cache_unfreeze_instruction ( void ) {}
181
182void _CPU_cache_enable_instruction ( void )
183{
184  uint32_t   r1;
185  r1 = (0x2<<24);
186  mtspr( 560, r1 );
187  isync;
188}
189
190void _CPU_cache_disable_instruction ( void )
191{
192  uint32_t   r1;
193  r1 = (0x4<<24);
194  mtspr( 560, r1 );
195  isync;
196}
197#endif
198
199void _CPU_cache_invalidate_1_data_line(
200        const void * _address )
201{
202  register const void *__address = _address;
203  asm volatile ( "dcbi 0,%0" :: "r"(__address) : "memory" );
204}
205
206void _CPU_cache_flush_1_data_line(
207        const void * _address )
208{
209  register const void *__address = _address;
210  asm volatile ( "dcbf 0,%0" :: "r" (__address) : "memory" );
211}
212
213
214void _CPU_cache_invalidate_1_instruction_line(
215        const void * _address )
216{
217  register const void *__address = _address;
218  asm volatile ( "icbi 0,%0" :: "r" (__address) : "memory");
219}
220
221/* end of file */
Note: See TracBrowser for help on using the repository browser.