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

5
Last change on this file since b82a4b4 was 4cf93658, checked in by Sebastian Huber <sebastian.huber@…>, on 01/27/18 at 13:37:51

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
RevLine 
[b8b2f19]1/**
2 *  @file
[c2bb3add]3 *
[b8b2f19]4 *  Cache Management Support Routines for the MCF532x
[c2bb3add]5 */
6
7#include <rtems.h>
8#include <mcf532x/mcf532x.h>
[4cf93658]9#include "cache.h"
[c2bb3add]10
[92a8cee]11#define m68k_set_cacr(_cacr) \
12  __asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr))
[c2bb3add]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 */
[4cf93658]26static void _CPU_cache_freeze_data(void)
[c2bb3add]27{
28}
29
[4cf93658]30static void _CPU_cache_unfreeze_data(void)
[c2bb3add]31{
32}
33
[4cf93658]34static void _CPU_cache_freeze_instruction(void)
[c2bb3add]35{
36}
37
[4cf93658]38static void _CPU_cache_unfreeze_instruction(void)
[c2bb3add]39{
40}
41
[4cf93658]42static void _CPU_cache_flush_1_data_line(const void *d_addr)
[c2bb3add]43{
44  register unsigned long adr = (((unsigned long) d_addr >> 4) & 0xff) << 4;
45
[8525cff]46  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]47  adr += 1;
[8525cff]48  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]49  adr += 1;
[8525cff]50  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]51  adr += 1;
[8525cff]52  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]53}
54
[4cf93658]55static void _CPU_cache_flush_entire_data(void)
[c2bb3add]56{
57  register unsigned long set, adr;
[023f1dd9]58
[c2bb3add]59  for(set = 0; set < 256; ++set) {
60    adr = (set << 4);
[8525cff]61    __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]62    adr += 1;
[8525cff]63    __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]64    adr += 1;
[8525cff]65    __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]66    adr += 1;
[8525cff]67    __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]68  }
69}
70
[4cf93658]71static void _CPU_cache_enable_instruction(void)
[c2bb3add]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
[4cf93658]84static void _CPU_cache_disable_instruction(void)
[c2bb3add]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
[4cf93658]97static void _CPU_cache_invalidate_entire_instruction(void)
[c2bb3add]98{
99  m68k_set_cacr(cacr_mode | MCF_CACR_CINVA);
100}
101
[4cf93658]102static void _CPU_cache_invalidate_1_instruction_line(const void *addr)
[c2bb3add]103{
104  register unsigned long adr = (((unsigned long) addr >> 4) & 0xff) << 4;
105
[8525cff]106  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]107  adr += 1;
[8525cff]108  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]109  adr += 1;
[8525cff]110  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]111  adr += 1;
[8525cff]112  __asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
[c2bb3add]113}
114
[4cf93658]115static void _CPU_cache_enable_data(void)
[c2bb3add]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
[4cf93658]124static void _CPU_cache_disable_data(void)
[c2bb3add]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
[4cf93658]133static void _CPU_cache_invalidate_entire_data(void)
[c2bb3add]134{
135  _CPU_cache_invalidate_entire_instruction();
136}
137
[4cf93658]138static void _CPU_cache_invalidate_1_data_line(const void *addr)
[c2bb3add]139{
140  _CPU_cache_invalidate_1_instruction_line(addr);
[023f1dd9]141}
[4cf93658]142
143#include "../../../shared/cache/cacheimpl.h"
Note: See TracBrowser for help on using the repository browser.