source: rtems/bsps/m68k/shared/cache/cache-mcf532x.c @ b82a4b4

Last change on this file since b82a4b4 was 4cf93658, checked in by Sebastian Huber <sebastian.huber@…>, on Jan 27, 2018 at 1:37:51 PM

bsps: Rework cache manager implementation

The previous cache manager support used a single souce file
(cache_manager.c) which included an implementation header (cache_.h).
This required the use of specialized include paths to find the right
header file. Change this to include a generic implementation header
(cacheimpl.h) in specialized source files.

Use the following directories and files:

  • bsps/shared/cache
  • bsps/@RTEMS_CPU@/shared/cache
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILY/start/cache.c

Update #3285.

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