source: rtems/c/src/lib/libcpu/m68k/mcf532x/cache/cachepd.c @ c2bb3add

4.104.114.95
Last change on this file since c2bb3add was c2bb3add, checked in by Joel Sherrill <joel.sherrill@…>, on 07/04/08 at 16:09:07

2008-07-04 Matthew Riek <matthew.riek@…>

  • Makefile.am, mcf532x/include/mcf532x.h, shared/cache/cache_.h: Add cache support for 5329. Enable the cache in copyback and write-through so we can assume that in BSP.
  • mcf532x/cache/cachepd.c: New file.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  Cache Management Support Routines for the MCF532x
3 *
4 *  $Id:
5 */
6
7#include <rtems.h>
8#include <mcf532x/mcf532x.h>
9
10#define m68k_set_cacr(_cacr) asm volatile ("movec %0,%%cacr" : : "d" (_cacr))
11
12/*
13 * Read/write copy of common cache
14 *  Default cache mode is *disabled* (cache only ACRx areas)
15 *  Allow CPUSHL to invalidate a cache line
16 *  Enable store buffer
17 */
18static uint32_t cacr_mode = MCF_CACR_ESB |
19                              MCF_CACR_DCM(3);
20
21/*
22 * Cannot be frozen
23 */
24void _CPU_cache_freeze_data(void)
25{
26}
27
28void _CPU_cache_unfreeze_data(void)
29{
30}
31
32void _CPU_cache_freeze_instruction(void)
33{
34}
35
36void _CPU_cache_unfreeze_instruction(void)
37{
38}
39
40void _CPU_cache_flush_1_data_line(const void *d_addr)
41{
42  register unsigned long adr = (((unsigned long) d_addr >> 4) & 0xff) << 4;
43
44  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
45  adr += 1;
46  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
47  adr += 1;
48  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
49  adr += 1;
50  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr)); 
51}
52
53void _CPU_cache_flush_entire_data(void)
54{
55  register unsigned long set, adr;
56 
57  for(set = 0; set < 256; ++set) {
58    adr = (set << 4);
59    asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
60    adr += 1;
61    asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
62    adr += 1;
63    asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
64    adr += 1;
65    asm volatile ("cpushl %%bc,(%0)" :: "a" (adr)); 
66  }
67}
68
69void _CPU_cache_enable_instruction(void)
70{
71  rtems_interrupt_level level;
72
73  rtems_interrupt_disable(level);
74  if(!(cacr_mode & MCF_CACR_CENB))
75  {
76    cacr_mode |= MCF_CACR_CENB;
77    m68k_set_cacr(cacr_mode);
78  }
79  rtems_interrupt_enable(level);
80}
81
82void _CPU_cache_disable_instruction(void)
83{
84  rtems_interrupt_level level;
85
86  rtems_interrupt_disable(level);
87  if((cacr_mode & MCF_CACR_CENB))
88  {
89    cacr_mode &= ~MCF_CACR_CENB;
90    m68k_set_cacr(cacr_mode);
91  }
92  rtems_interrupt_enable(level);
93}
94
95void _CPU_cache_invalidate_entire_instruction(void)
96{
97  m68k_set_cacr(cacr_mode | MCF_CACR_CINVA);
98}
99
100void _CPU_cache_invalidate_1_instruction_line(const void *addr)
101{
102  register unsigned long adr = (((unsigned long) addr >> 4) & 0xff) << 4;
103
104  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
105  adr += 1;
106  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
107  adr += 1;
108  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
109  adr += 1;
110  asm volatile ("cpushl %%bc,(%0)" :: "a" (adr));
111}
112
113void _CPU_cache_enable_data(void)
114{
115  /*
116   * The 532x has a unified data and instruction cache, so we call through
117   * to enable instruction.
118   */
119  _CPU_cache_enable_instruction();
120}
121
122void _CPU_cache_disable_data(void)
123{
124  /*
125   * The 532x has a unified data and instruction cache, so we call through
126   * to disable instruction.
127   */
128  _CPU_cache_disable_instruction();
129}
130
131void _CPU_cache_invalidate_entire_data(void)
132{
133  _CPU_cache_invalidate_entire_instruction();
134}
135
136void _CPU_cache_invalidate_1_data_line(const void *addr)
137{
138  _CPU_cache_invalidate_1_instruction_line(addr);
139}
Note: See TracBrowser for help on using the repository browser.