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

4.115
Last change on this file since f9acc33 was f9acc33, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/11/11 at 09:46:53

2011-02-11 Ralf Corsépius <ralf.corsepius@…>

  • e500/mmu/mmu.c, mpc505/ictrl/ictrl.c, mpc505/timer/timer.c, mpc5xx/ictrl/ictrl.c, mpc5xx/timer/timer.c, mpc6xx/altivec/vec_sup.c, mpc6xx/clock/c_clock.c, mpc6xx/mmu/bat.c, mpc6xx/mmu/bat.h, mpc6xx/mmu/pte121.c, mpc8260/timer/timer.c, mpc8xx/timer/timer.c, new-exceptions/cpu.c, new-exceptions/bspsupport/ppc_exc_initialize.c, ppc403/clock/clock.c, ppc403/console/console.c, ppc403/console/console.c.polled, ppc403/console/console405.c, ppc403/irq/ictrl.c, ppc403/tty_drv/tty_drv.c, rtems/powerpc/cache.h, shared/include/powerpc-utility.h, shared/src/cache.c: Use "asm" instead of "asm" for improved c99-compliance.
  • Property mode set to 100644
File size: 5.4 KB
Line 
1/**
2 * @file
3 *
4 * #ingroup powerpc_shared
5 *
6 * @brief Source file for the Cache Manager PowerPC support.
7 */
8
9/*
10 *  Cache Management Support Routines for the MC68040
11 * Modified for MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
12 * Surrey Satellite Technology Limited (SSTL), 2001
13 *
14 *  $Id$
15 */
16
17#include <rtems.h>
18#include "cache_.h"
19#include <rtems/powerpc/registers.h>
20
21/*
22 * CACHE MANAGER: The following functions are CPU-specific.
23 * They provide the basic implementation for the rtems_* cache
24 * management routines. If a given function has no meaning for the CPU,
25 * it does nothing by default.
26 *
27 * FIXME: Some functions simply have not been implemented.
28 */
29
30#if defined(ppc603) || defined(ppc603e) || defined(mpc8260) /* And possibly others */
31
32/* Helpful macros */
33#define PPC_Get_HID0( _value ) \
34  do { \
35      _value = 0;        /* to avoid warnings */ \
36      __asm__ volatile( \
37          "mfspr %0, 0x3f0;"     /* get HID0 */ \
38          "isync" \
39          : "=r" (_value) \
40          : "0" (_value) \
41      ); \
42  } while (0)
43
44#define PPC_Set_HID0( _value ) \
45  do { \
46      __asm__ volatile( \
47          "isync;" \
48          "mtspr 0x3f0, %0;"     /* load HID0 */ \
49          "isync" \
50          : "=r" (_value) \
51          : "0" (_value) \
52      ); \
53  } while (0)
54
55void _CPU_cache_enable_data (
56        void )
57{
58  uint32_t   value;
59  PPC_Get_HID0( value );
60  value |= HID0_DCE;        /* set DCE bit */
61  PPC_Set_HID0( value );
62}
63
64void _CPU_cache_disable_data (
65        void )
66{
67  uint32_t   value;
68  PPC_Get_HID0( value );
69  value &= ~HID0_DCE;        /* clear DCE bit */
70  PPC_Set_HID0( value );
71}
72
73void _CPU_cache_invalidate_entire_data (
74        void )
75{
76  uint32_t  value;
77  PPC_Get_HID0( value );
78  value |= HID0_DCI;        /* set data flash invalidate bit */
79  PPC_Set_HID0( value );
80  value &= ~HID0_DCI;        /* clear data flash invalidate bit */
81  PPC_Set_HID0( value );
82}
83
84void _CPU_cache_freeze_data (
85        void )
86{
87  uint32_t  value;
88  PPC_Get_HID0( value );
89  value |= HID0_DLOCK;        /* set data cache lock bit */
90  PPC_Set_HID0( value );
91}
92
93void _CPU_cache_unfreeze_data (
94        void )
95{
96  uint32_t  value;
97  PPC_Get_HID0( value );
98  value &= ~HID0_DLOCK;        /* set data cache lock bit */
99  PPC_Set_HID0( value );
100}
101
102void _CPU_cache_flush_entire_data (
103        void )
104{
105  /*
106   * FIXME: how can we do this?
107   */
108}
109
110void _CPU_cache_enable_instruction (
111        void )
112{
113  uint32_t   value;
114  PPC_Get_HID0( value );
115  value |= 0x00008000;       /* Set ICE bit */
116  PPC_Set_HID0( value );
117}
118
119void _CPU_cache_disable_instruction (
120        void )
121{
122  uint32_t   value;
123  PPC_Get_HID0( value );
124  value &= 0xFFFF7FFF;       /* Clear ICE bit */
125  PPC_Set_HID0( value );
126}
127
128
129void _CPU_cache_invalidate_entire_instruction (
130        void )
131{
132  uint32_t  value;
133  PPC_Get_HID0( value );
134  value |= HID0_ICFI;        /* set data flash invalidate bit */
135  PPC_Set_HID0( value );
136  value &= ~HID0_ICFI;        /* clear data flash invalidate bit */
137  PPC_Set_HID0( value );
138}
139
140void _CPU_cache_freeze_instruction (
141        void )
142{
143  uint32_t  value;
144  PPC_Get_HID0( value );
145  value |= HID0_ILOCK;        /* set instruction cache lock bit */
146  PPC_Set_HID0( value );
147}
148
149void _CPU_cache_unfreeze_instruction (
150        void )
151{
152  uint32_t  value;
153  PPC_Get_HID0( value );
154  value &= ~HID0_ILOCK;        /* set instruction cache lock bit */
155  PPC_Set_HID0( value );
156}
157
158#elif ( defined(mpx8xx) || defined(mpc860) || defined(mpc821) )
159
160#define mtspr(_spr,_reg) \
161  __asm__ volatile ( "mtspr %0, %1\n" : : "i" ((_spr)), "r" ((_reg)) )
162#define isync \
163  __asm__ volatile ("isync\n"::)
164
165void _CPU_cache_flush_entire_data ( void ) {}
166void _CPU_cache_invalidate_entire_data ( void ) {}
167void _CPU_cache_freeze_data ( void ) {}
168void _CPU_cache_unfreeze_data ( void ) {}
169
170void _CPU_cache_enable_data ( void )
171{
172  uint32_t   r1;
173  r1 = (0x2<<24);
174  mtspr( 568, r1 );
175  isync;
176}
177
178void _CPU_cache_disable_data ( void )
179{
180  uint32_t   r1;
181  r1 = (0x4<<24);
182  mtspr( 568, r1 );
183  isync;
184}
185
186void _CPU_cache_invalidate_entire_instruction ( void ) {}
187void _CPU_cache_freeze_instruction ( void ) {}
188void _CPU_cache_unfreeze_instruction ( void ) {}
189
190void _CPU_cache_enable_instruction ( void )
191{
192  uint32_t   r1;
193  r1 = (0x2<<24);
194  mtspr( 560, r1 );
195  isync;
196}
197
198void _CPU_cache_disable_instruction ( void )
199{
200  uint32_t   r1;
201  r1 = (0x4<<24);
202  mtspr( 560, r1 );
203  isync;
204}
205
206#else
207
208#warning Most cache functions are not implemented
209
210void _CPU_cache_flush_entire_data(void)
211{
212        /* Void */
213}
214
215void _CPU_cache_invalidate_entire_data(void)
216{
217        /* Void */
218}
219
220void _CPU_cache_freeze_data(void)
221{
222        /* Void */
223}
224
225void _CPU_cache_unfreeze_data(void)
226{
227        /* Void */
228}
229
230void _CPU_cache_enable_data(void)
231{
232        /* Void */
233}
234
235void _CPU_cache_disable_data(void)
236{
237        /* Void */
238}
239
240void _CPU_cache_invalidate_entire_instruction(void)
241{
242        /* Void */
243}
244
245void _CPU_cache_freeze_instruction(void)
246{
247        /* Void */
248}
249
250void _CPU_cache_unfreeze_instruction(void)
251{
252        /* Void */
253}
254
255
256void _CPU_cache_enable_instruction(void)
257{
258        /* Void */
259}
260
261void _CPU_cache_disable_instruction(void)
262{
263        /* Void */
264}
265
266#endif
267
268void _CPU_cache_invalidate_1_data_line(
269        const void * _address )
270{
271  register const void *__address = _address;
272  __asm__ volatile ( "dcbi 0,%0" :: "r"(__address) : "memory" );
273}
274
275void _CPU_cache_flush_1_data_line(
276        const void * _address )
277{
278  register const void *__address = _address;
279  __asm__ volatile ( "dcbf 0,%0" :: "r" (__address) : "memory" );
280}
281
282
283void _CPU_cache_invalidate_1_instruction_line(
284        const void * _address )
285{
286  register const void *__address = _address;
287  __asm__ volatile ( "icbi 0,%0" :: "r" (__address) : "memory");
288}
289
290/* end of file */
Note: See TracBrowser for help on using the repository browser.