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

4.104.114.84.95
Last change on this file since 48694da was 48694da, checked in by Joel Sherrill <joel.sherrill@…>, on 10/22/01 at 13:46:37

2001-10-22 Andy Dachs <a.dachs@…>

  • Makefile.am, README, configure.ac, new_exception_processing/cpu.h, shared/include/cpu.h, shared/include/cpuIdent.c, shared/src/cache.c: Added mpc8260 support.
  • Property mode set to 100644
File size: 3.2 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
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(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  unsigned32 value;
51  PPC_Get_HID0( value );
52  value |= 0x00004000;        /* set DCE bit */
53  PPC_Set_HID0( value );
54}
55
56void _CPU_cache_disable_data (
57        void )
58{
59  unsigned32 value;
60  PPC_Get_HID0( value );
61  value &= 0xFFFFBFFF;        /* clear DCE bit */
62  PPC_Set_HID0( value );
63}
64
65void _CPU_cache_enable_instruction (
66        void )
67{
68  unsigned32 value;
69  PPC_Get_HID0( value );
70  value |= 0x00008000;       /* Set ICE bit */
71  PPC_Set_HID0( value );
72}
73
74void _CPU_cache_disable_instruction (
75        void )
76{
77  unsigned32 value;
78  PPC_Get_HID0( value );
79  value &= 0xFFFF7FFF;       /* Clear ICE bit */
80  PPC_Set_HID0( value );
81}
82
83#elif ( defined(mpx8xx) || defined(mpc860) || defined(mpc821) )
84
85#define mtspr(_spr,_reg) \
86  __asm__ volatile ( "mtspr %0, %1\n" : : "i" ((_spr)), "r" ((_reg)) )
87#define isync \
88  __asm__ volatile ("isync\n"::)
89
90void _CPU_cache_flush_1_data_line(
91        const void * _address )
92{
93  register const void *__address = _address;
94  asm volatile ( "dcbf 0,%0" :: "r" (__address) );
95}
96
97void _CPU_cache_invalidate_1_data_line(
98        const void * _address )
99{
100  register const void *__address = _address;
101  asm volatile ( "dcbi 0,%0" :: "r" (__address) );
102}
103
104void _CPU_cache_flush_entire_data ( void ) {}
105void _CPU_cache_invalidate_entire_data ( void ) {}
106void _CPU_cache_freeze_data ( void ) {}
107void _CPU_cache_unfreeze_data ( void ) {}
108
109void _CPU_cache_enable_data ( void )
110{
111  unsigned32 r1;
112  r1 = (0x2<<24);
113  mtspr( 568, r1 );
114  isync;
115}
116
117void _CPU_cache_disable_data ( void )
118{
119  unsigned32 r1;
120  r1 = (0x4<<24);
121  mtspr( 568, r1 );
122  isync;
123}
124
125void _CPU_cache_invalidate_1_instruction_line(
126        const void * _address )
127{
128  register const void *__address = _address;
129  asm volatile ( "icbi 0,%0" :: "r" (__address) );
130}
131
132void _CPU_cache_invalidate_entire_instruction ( void ) {}
133void _CPU_cache_freeze_instruction ( void ) {}
134void _CPU_cache_unfreeze_instruction ( void ) {}
135
136void _CPU_cache_enable_instruction ( void )
137{
138  unsigned32 r1;
139  r1 = (0x2<<24);
140  mtspr( 560, r1 );
141  isync;
142}
143
144void _CPU_cache_disable_instruction ( void )
145{
146  unsigned32 r1;
147  r1 = (0x4<<24);
148  mtspr( 560, r1 );
149  isync;
150}
151#endif
152
153/* end of file */
Note: See TracBrowser for help on using the repository browser.