source: rtems/bsps/arm/shared/cache/cache-cp15.c @ 4cf93658

5
Last change on this file since 4cf93658 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: 4.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup arm
5 *
6 * @brief ARM cache defines and implementation.
7 */
8
9/*
10 * Copyright (c) 2009-2011 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <libcpu/arm-cp15.h>
24#include "cache-cp15.h"
25
26#define CPU_DATA_CACHE_ALIGNMENT 32
27#define CPU_INSTRUCTION_CACHE_ALIGNMENT 32
28#if defined(__ARM_ARCH_7A__)
29/* Some/many ARM Cortex-A cores have L1 data line length 64 bytes */
30#define CPU_MAXIMAL_CACHE_ALIGNMENT 64
31#endif
32
33#define CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS \
34          ARM_CACHE_L1_CPU_SUPPORT_PROVIDES_RANGE_FUNCTIONS
35
36
37static inline void _CPU_cache_flush_1_data_line(const void *d_addr)
38{
39  arm_cache_l1_flush_1_data_line(d_addr);
40}
41
42static inline void
43_CPU_cache_flush_data_range(
44  const void *d_addr,
45  size_t      n_bytes
46)
47{
48  _ARM_Data_synchronization_barrier();
49  arm_cache_l1_flush_data_range(
50    d_addr,
51    n_bytes
52  );
53  #if !defined(__ARM_ARCH_7A__)
54  arm_cp15_drain_write_buffer();
55  #endif
56 _ARM_Data_synchronization_barrier();
57}
58
59static inline void _CPU_cache_invalidate_1_data_line(const void *d_addr)
60{
61  arm_cache_l1_invalidate_1_data_line(d_addr);
62}
63
64static inline void
65_CPU_cache_invalidate_data_range(
66  const void *addr_first,
67  size_t     n_bytes
68)
69{
70  arm_cache_l1_invalidate_data_range(
71    addr_first,
72    n_bytes
73  );
74}
75
76static inline void _CPU_cache_freeze_data(void)
77{
78  /* TODO */
79}
80
81static inline void _CPU_cache_unfreeze_data(void)
82{
83  /* TODO */
84}
85
86static inline void _CPU_cache_invalidate_1_instruction_line(const void *d_addr)
87{
88  arm_cache_l1_invalidate_1_instruction_line(d_addr);
89}
90
91static inline void
92_CPU_cache_invalidate_instruction_range( const void *i_addr, size_t n_bytes)
93{
94  arm_cache_l1_invalidate_instruction_range( i_addr, n_bytes );
95  _ARM_Instruction_synchronization_barrier();
96}
97
98static inline void _CPU_cache_freeze_instruction(void)
99{
100  /* TODO */
101}
102
103static inline void _CPU_cache_unfreeze_instruction(void)
104{
105  /* TODO */
106}
107
108static inline void _CPU_cache_flush_entire_data(void)
109{
110  _ARM_Data_synchronization_barrier();
111  #if defined(__ARM_ARCH_7A__)
112  arm_cp15_data_cache_clean_all_levels();
113  #else
114  arm_cp15_data_cache_clean_and_invalidate();
115  arm_cp15_drain_write_buffer();
116  #endif
117  _ARM_Data_synchronization_barrier();
118}
119
120static inline void _CPU_cache_invalidate_entire_data(void)
121{
122  #if defined(__ARM_ARCH_7A__)
123  arm_cp15_data_cache_invalidate_all_levels();
124  #else
125  arm_cp15_data_cache_invalidate();
126  #endif
127}
128
129static inline void _CPU_cache_enable_data(void)
130{
131  rtems_interrupt_level level;
132  uint32_t ctrl;
133
134  rtems_interrupt_local_disable(level);
135  ctrl = arm_cp15_get_control();
136  ctrl |= ARM_CP15_CTRL_C;
137  arm_cp15_set_control(ctrl);
138  rtems_interrupt_local_enable(level);
139}
140
141static inline void _CPU_cache_disable_data(void)
142{
143  rtems_interrupt_level level;
144  uint32_t ctrl;
145
146  rtems_interrupt_local_disable(level);
147  arm_cp15_data_cache_test_and_clean_and_invalidate();
148  ctrl = arm_cp15_get_control();
149  ctrl &= ~ARM_CP15_CTRL_C;
150  arm_cp15_set_control(ctrl);
151  rtems_interrupt_local_enable(level);
152}
153
154static inline void _CPU_cache_invalidate_entire_instruction(void)
155{
156  arm_cache_l1_invalidate_entire_instruction();
157  _ARM_Instruction_synchronization_barrier();
158}
159
160static inline void _CPU_cache_enable_instruction(void)
161{
162  rtems_interrupt_level level;
163  uint32_t ctrl;
164
165  rtems_interrupt_local_disable(level);
166  ctrl = arm_cp15_get_control();
167  ctrl |= ARM_CP15_CTRL_I;
168  arm_cp15_set_control(ctrl);
169  rtems_interrupt_local_enable(level);
170}
171
172static inline void _CPU_cache_disable_instruction(void)
173{
174  rtems_interrupt_level level;
175  uint32_t ctrl;
176
177  rtems_interrupt_local_disable(level);
178  ctrl = arm_cp15_get_control();
179  ctrl &= ~ARM_CP15_CTRL_I;
180  arm_cp15_set_control(ctrl);
181  rtems_interrupt_local_enable(level);
182}
183
184#include "../../shared/cache/cacheimpl.h"
Note: See TracBrowser for help on using the repository browser.