Files
rtems/bsps/m68k/shared/cache/cache-mcf532x.c
Sebastian Huber 4cf93658ef 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.
2018-01-31 12:49:09 +01:00

144 lines
3.1 KiB
C

/**
* @file
*
* Cache Management Support Routines for the MCF532x
*/
#include <rtems.h>
#include <mcf532x/mcf532x.h>
#include "cache.h"
#define m68k_set_cacr(_cacr) \
__asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr))
/*
* Read/write copy of common cache
* Default cache mode is *disabled* (cache only ACRx areas)
* Allow CPUSHL to invalidate a cache line
* Enable store buffer
*/
static uint32_t cacr_mode = MCF_CACR_ESB |
MCF_CACR_DCM(3);
/*
* Cannot be frozen
*/
static void _CPU_cache_freeze_data(void)
{
}
static void _CPU_cache_unfreeze_data(void)
{
}
static void _CPU_cache_freeze_instruction(void)
{
}
static void _CPU_cache_unfreeze_instruction(void)
{
}
static void _CPU_cache_flush_1_data_line(const void *d_addr)
{
register unsigned long adr = (((unsigned long) d_addr >> 4) & 0xff) << 4;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
}
static void _CPU_cache_flush_entire_data(void)
{
register unsigned long set, adr;
for(set = 0; set < 256; ++set) {
adr = (set << 4);
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
}
}
static void _CPU_cache_enable_instruction(void)
{
rtems_interrupt_level level;
rtems_interrupt_disable(level);
if(!(cacr_mode & MCF_CACR_CENB))
{
cacr_mode |= MCF_CACR_CENB;
m68k_set_cacr(cacr_mode);
}
rtems_interrupt_enable(level);
}
static void _CPU_cache_disable_instruction(void)
{
rtems_interrupt_level level;
rtems_interrupt_disable(level);
if((cacr_mode & MCF_CACR_CENB))
{
cacr_mode &= ~MCF_CACR_CENB;
m68k_set_cacr(cacr_mode);
}
rtems_interrupt_enable(level);
}
static void _CPU_cache_invalidate_entire_instruction(void)
{
m68k_set_cacr(cacr_mode | MCF_CACR_CINVA);
}
static void _CPU_cache_invalidate_1_instruction_line(const void *addr)
{
register unsigned long adr = (((unsigned long) addr >> 4) & 0xff) << 4;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
adr += 1;
__asm__ volatile ("cpushl %%bc,(%0)" :: "a" (adr));
}
static void _CPU_cache_enable_data(void)
{
/*
* The 532x has a unified data and instruction cache, so we call through
* to enable instruction.
*/
_CPU_cache_enable_instruction();
}
static void _CPU_cache_disable_data(void)
{
/*
* The 532x has a unified data and instruction cache, so we call through
* to disable instruction.
*/
_CPU_cache_disable_instruction();
}
static void _CPU_cache_invalidate_entire_data(void)
{
_CPU_cache_invalidate_entire_instruction();
}
static void _CPU_cache_invalidate_1_data_line(const void *addr)
{
_CPU_cache_invalidate_1_instruction_line(addr);
}
#include "../../../shared/cache/cacheimpl.h"