source: rtems/c/src/lib/libcpu/m68k/shared/cache/cache.c @ c758a4ec

4.104.115
Last change on this file since c758a4ec was c758a4ec, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/08/09 at 13:36:55

Whitespace removal.

  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[cf1f72e]1/*
2 *  Cache Management Support Routines for the MC68040
3 *
4 *  $Id$
5 */
6
7#include <rtems.h>
8#include "cache_.h"
9
[c758a4ec]10/*
[cf1f72e]11 *  Since the cacr is common to all mc680x0, provide macros
12 *  for masking values in that register.
13 */
14
[c758a4ec]15/*
[cf1f72e]16 *  Used to clear bits in the cacr.
17 */
18#define _CPU_CACR_AND(mask)                                        \
19  {                                                                \
20  register unsigned long _value = mask;                            \
21  register unsigned long _ctl = 0;                                 \
22  asm volatile ( "movec %%cacr, %0;           /* read the cacr */  \
23                  andl %2, %0;                /* and with _val */  \
24                  movec %1, %%cacr"           /* write the cacr */ \
25   : "=d" (_ctl) : "0" (_ctl), "d" (_value) : "%%cc" );            \
26  }
27
28
[c758a4ec]29/*
[cf1f72e]30 *  Used to set bits in the cacr.
31 */
32#define _CPU_CACR_OR(mask)                                         \
33        {                                                                \
34  register unsigned long _value = mask;                            \
35  register unsigned long _ctl = 0;                                 \
36  asm volatile ( "movec %%cacr, %0;           /* read the cacr */  \
37                  orl %2, %0;                 /* or with _val */   \
38                  movec %1, %%cacr"           /* write the cacr */ \
39   : "=d" (_ctl) : "0" (_ctl), "d" (_value) : "%%cc" );            \
40  }
41
[c758a4ec]42
[cf1f72e]43/*
44 * CACHE MANAGER: The following functions are CPU-specific.
45 * They provide the basic implementation for the rtems_* cache
46 * management routines. If a given function has no meaning for the CPU,
47 * it does nothing by default.
48 */
[0ee9cc1]49#if ( (defined(__mc68020__) && !defined(__mcpu32__)) || defined(__mc68030__) )
[cf1f72e]50
51#if defined(__mc68030__)
52
53/* Only the mc68030 has a data cache; it is writethrough only. */
54
[5e77d129]55void _CPU_cache_flush_1_data_line ( const void * d_addr ) {}
[baa6f32c]56void _CPU_cache_flush_entire_data ( void ) {}
[cf1f72e]57
[5e77d129]58void _CPU_cache_invalidate_1_data_line (
[cf1f72e]59  const void * d_addr )
60{
61  void * p_address = (void *) _CPU_virtual_to_physical( d_addr );
62  asm volatile ( "movec %0, %%caar" :: "a" (p_address) );      /* write caar */
63  _CPU_CACR_OR(0x00000400);
64}
65
[5e77d129]66void _CPU_cache_invalidate_entire_data ( void )
[cf1f72e]67{
68  _CPU_CACR_OR( 0x00000800 );
69}
70
[5e77d129]71void _CPU_cache_freeze_data ( void )
[cf1f72e]72{
73  _CPU_CACR_OR( 0x00000200 );
74}
75
[5e77d129]76void _CPU_cache_unfreeze_data ( void )
[cf1f72e]77{
78  _CPU_CACR_AND( 0xFFFFFDFF );
79}
80
[5e77d129]81void _CPU_cache_enable_data ( void )
[cf1f72e]82{
83  _CPU_CACR_OR( 0x00000100 );
84}
[5e77d129]85void _CPU_cache_disable_data (  void )
[cf1f72e]86{
87  _CPU_CACR_AND( 0xFFFFFEFF );
88}
89#endif
90
91
92/* Both the 68020 and 68030 have instruction caches */
93
[5e77d129]94void _CPU_cache_invalidate_1_instruction_line (
[cf1f72e]95  const void * d_addr )
96{
97  void * p_address = (void *) _CPU_virtual_to_physical( d_addr );
98  asm volatile ( "movec %0, %%caar" :: "a" (p_address) );      /* write caar */
99  _CPU_CACR_OR( 0x00000004 );
100}
101
[5e77d129]102void _CPU_cache_invalidate_entire_instruction ( void )
[cf1f72e]103{
104  _CPU_CACR_OR( 0x00000008 );
105}
106
[5e77d129]107void _CPU_cache_freeze_instruction ( void )
[cf1f72e]108{
109  _CPU_CACR_OR( 0x00000002);
110}
111
[5e77d129]112void _CPU_cache_unfreeze_instruction ( void )
[cf1f72e]113{
114  _CPU_CACR_AND( 0xFFFFFFFD );
115}
116
[5e77d129]117void _CPU_cache_enable_instruction ( void )
[cf1f72e]118{
119  _CPU_CACR_OR( 0x00000001 );
120}
121
[5e77d129]122void _CPU_cache_disable_instruction (   void )
[cf1f72e]123{
124  _CPU_CACR_AND( 0xFFFFFFFE );
125}
126
127
128#elif ( defined(__mc68040__) || defined (__mc68060__) )
129
130/* Cannot be frozen */
[5e77d129]131void _CPU_cache_freeze_data ( void ) {}
132void _CPU_cache_unfreeze_data ( void ) {}
133void _CPU_cache_freeze_instruction ( void ) {}
134void _CPU_cache_unfreeze_instruction ( void ) {}
[cf1f72e]135
[5e77d129]136void _CPU_cache_flush_1_data_line (
[cf1f72e]137  const void * d_addr )
138{
139  void * p_address = (void *) _CPU_virtual_to_physical( d_addr );
140  asm volatile ( "cpushl %%dc,(%0)" :: "a" (p_address) );
141}
142
[5e77d129]143void _CPU_cache_invalidate_1_data_line (
[cf1f72e]144  const void * d_addr )
145{
146  void * p_address = (void *) _CPU_virtual_to_physical( d_addr );
147  asm volatile ( "cinvl %%dc,(%0)" :: "a" (p_address) );
148}
149
[5e77d129]150void _CPU_cache_flush_entire_data ( void )
[cf1f72e]151{
152        asm volatile ( "cpusha %%dc" :: );
153}
154
[5e77d129]155void _CPU_cache_invalidate_entire_data ( void )
[cf1f72e]156{
157        asm volatile ( "cinva %%dc" :: );
158}
159
[5e77d129]160void _CPU_cache_enable_data ( void )
[cf1f72e]161{
162  _CPU_CACR_OR( 0x80000000 );
163}
164
[5e77d129]165void _CPU_cache_disable_data ( void )
[cf1f72e]166{
167  _CPU_CACR_AND( 0x7FFFFFFF );
168}
169
[5e77d129]170void _CPU_cache_invalidate_1_instruction_line (
[cf1f72e]171  const void * i_addr )
172{
173  void * p_address = (void *)  _CPU_virtual_to_physical( i_addr );
174  asm volatile ( "cinvl %%ic,(%0)" :: "a" (p_address) );
175}
176
[5e77d129]177void _CPU_cache_invalidate_entire_instruction ( void )
[cf1f72e]178{
179                asm volatile ( "cinva %%ic" :: );
180}
181
[5e77d129]182void _CPU_cache_enable_instruction ( void )
[cf1f72e]183{
184  _CPU_CACR_OR( 0x00008000 );
185}
186
[5e77d129]187void _CPU_cache_disable_instruction ( void )
[cf1f72e]188{
189        _CPU_CACR_AND( 0xFFFF7FFF );
190}
191#endif
192/* end of file */
Note: See TracBrowser for help on using the repository browser.