source: rtems/bsps/arm/shared/cache/cache-l2c-310.c @ ba85655

5
Last change on this file since ba85655 was ba85655, checked in by Sebastian Huber <sebastian.huber@…>, on 12/21/18 at 09:16:02

ARM_CACHE_L1_CPU_SUPPORT_PROVIDES_RANGE_FUNCTIONS

Remove this superfluous define.

Update #3667.

  • Property mode set to 100644
File size: 35.3 KB
Line 
1/**
2 * @ingroup L2C-310_cache
3 *
4 * @brief Cache definitions and functions.
5 *
6 * This file implements handling for the ARM L2C-310 cache controller
7 */
8
9/*
10 * Authorship
11 * ----------
12 * This software was created by
13 *     R. Claus <claus@slac.stanford.edu>, 2013,
14 *       Stanford Linear Accelerator Center, Stanford University.
15 *
16 * Acknowledgement of sponsorship
17 * ------------------------------
18 * This software was produced by
19 *     the Stanford Linear Accelerator Center, Stanford University,
20 *     under Contract DE-AC03-76SFO0515 with the Department of Energy.
21 *
22 * Government disclaimer of liability
23 * ----------------------------------
24 * Neither the United States nor the United States Department of Energy,
25 * nor any of their employees, makes any warranty, express or implied, or
26 * assumes any legal liability or responsibility for the accuracy,
27 * completeness, or usefulness of any data, apparatus, product, or process
28 * disclosed, or represents that its use would not infringe privately owned
29 * rights.
30 *
31 * Stanford disclaimer of liability
32 * --------------------------------
33 * Stanford University makes no representations or warranties, express or
34 * implied, nor assumes any liability for the use of this software.
35 *
36 * Stanford disclaimer of copyright
37 * --------------------------------
38 * Stanford University, owner of the copyright, hereby disclaims its
39 * copyright and all other rights in this software.  Hence, anyone may
40 * freely use it for any purpose without restriction.
41 *
42 * Maintenance of notices
43 * ----------------------
44 * In the interest of clarity regarding the origin and status of this
45 * SLAC software, this and all the preceding Stanford University notices
46 * are to remain affixed to any copy or derivative of this software made
47 * or distributed by the recipient and are to be affixed to any copy of
48 * software made or distributed by the recipient that contains a copy or
49 * derivative of this software.
50 *
51 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
52 */
53
54#include <assert.h>
55#include <bsp.h>
56#include <bsp/fatal.h>
57#include <libcpu/arm-cp15.h>
58#include <rtems/rtems/intr.h>
59#include <bsp/arm-release-id.h>
60#include <bsp/arm-errata.h>
61
62#include "cache-cp15.h"
63
64/* These two defines also ensure that the rtems_cache_* functions have bodies */
65#define CPU_DATA_CACHE_ALIGNMENT ARM_CACHE_L1_CPU_DATA_ALIGNMENT
66#define CPU_INSTRUCTION_CACHE_ALIGNMENT ARM_CACHE_L1_CPU_INSTRUCTION_ALIGNMENT
67#if defined(__ARM_ARCH_7A__)
68/* Some/many ARM Cortex-A cores have L1 data line length 64 bytes */
69#define CPU_MAXIMAL_CACHE_ALIGNMENT 64
70#endif
71#define CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS
72#define CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS
73
74#define L2C_310_DATA_LINE_MASK ( CPU_DATA_CACHE_ALIGNMENT - 1 )
75#define L2C_310_INSTRUCTION_LINE_MASK \
76  ( CPU_INSTRUCTION_CACHE_ALIGNMENT \
77    - 1 )
78#define L2C_310_NUM_WAYS 8
79#define L2C_310_WAY_MASK ( ( 1 << L2C_310_NUM_WAYS ) - 1 )
80
81#define L2C_310_MIN( a, b ) \
82  ((a < b) ? (a) : (b))
83
84#define L2C_310_MAX_LOCKING_BYTES (4 * 1024)
85
86
87/* RTL release number as can be read from cache_id register */
88#define L2C_310_RTL_RELEASE_R0_P0 0x0
89#define L2C_310_RTL_RELEASE_R1_P0 0x2
90#define L2C_310_RTL_RELEASE_R2_P0 0x4
91#define L2C_310_RTL_RELEASE_R3_P0 0x5
92#define L2C_310_RTL_RELEASE_R3_P1 0x6
93#define L2C_310_RTL_RELEASE_R3_P2 0x8
94#define L2C_310_RTL_RELEASE_R3_P3 0x9
95
96#define BSP_ARM_L2C_310_RTL_RELEASE (BSP_ARM_L2C_310_ID & L2C_310_ID_RTL_MASK)
97
98/**
99 * @defgroup L2C-310_cache Cache Support
100 * @ingroup arm_shared
101 * @brief Cache Functions and Defitions
102 * @{
103 */
104
105
106/**
107 * @brief L2CC Register Offsets
108 */
109typedef struct {
110  /** @brief Cache ID */
111  uint32_t cache_id;
112#define L2C_310_ID_RTL_MASK 0x3f
113#define L2C_310_ID_PART_MASK ( 0xf << 6 )
114#define L2C_310_ID_PART_L210 ( 1 << 6 )
115#define L2C_310_ID_PART_L310 ( 3 << 6 )
116#define L2C_310_ID_IMPL_MASK ( 0xff << 24 )
117  /** @brief Cache type */
118  uint32_t cache_type;
119/** @brief 1 if data banking implemented, 0 if not */
120#define L2C_310_TYPE_DATA_BANKING_MASK 0x80000000
121/** @brief 11xy, where: x=1 if pl310_LOCKDOWN_BY_MASTER is defined, otherwise 0 */
122#define L2C_310_TYPE_CTYPE_MASK 0x1E000000
123/** @brief y=1 if pl310_LOCKDOWN_BY_LINE is defined, otherwise 0. */
124#define L2C_310_TYPE_CTYPE_SHIFT 25
125/** @brief 1 for Harvard architecture, 0 for unified architecture */
126#define L2C_310_TYPE_HARVARD_MASK 0x01000000
127/** @brief Data cache way size = 2 Exp(value + 2) KB */
128#define L2C_310_TYPE_SIZE_D_WAYS_MASK 0x00700000
129#define L2C_310_TYPE_SIZE_D_WAYS_SHIFT 20
130/** @brief Assoziativity aka number of data ways = (value * 8) + 8 */
131#define L2C_310_TYPE_NUM_D_WAYS_MASK 0x00040000
132#define L2C_310_TYPE_NUM_D_WAYS_SHIFT 18
133/** @brief Data cache line length 00 - 32 */
134#define L2C_310_TYPE_LENGTH_D_LINE_MASK 0x00003000
135#define L2C_310_TYPE_LENGTH_D_LINE_SHIFT 12
136#define L2C_310_TYPE_LENGTH_D_LINE_VAL_32 0x0
137/** @brief Instruction cache way size = 2 Exp(value + 2) KB */
138#define L2C_310_TYPE_SIZE_I_WAYS_MASK 0x00000700
139#define L2C_310_TYPE_SIZE_I_WAYS_SHIFT 8
140/** @brief Assoziativity aka number of instruction ways = (value * 8) + 8 */
141#define L2C_310_TYPE_NUM_I_WAYS_MASK 0x00000040
142#define L2C_310_TYPE_NUM_I_WAYS_SHIFT 6
143/** @brief Instruction cache line length 00 - 32 */
144#define L2C_310_TYPE_LENGTH_I_LINE_MASK 0x00000003
145#define L2C_310_TYPE_LENGTH_I_LINE_SHIFT 0
146#define L2C_310_TYPE_LENGTH_I_LINE_VAL_32 0x0
147
148  uint8_t reserved_8[0x100 - 8];
149  uint32_t ctrl; /* Control */
150/** @brief Enables the L2CC */
151#define L2C_310_CTRL_ENABLE 0x00000001
152
153#define L2C_310_CTRL_EXCL_CONFIG (1 << 12)
154
155  /** @brief Auxiliary control */
156  uint32_t aux_ctrl;
157
158/** @brief Early BRESP Enable */
159#define L2C_310_AUX_EBRESPE_MASK 0x40000000
160
161/** @brief Instruction Prefetch Enable */
162#define L2C_310_AUX_IPFE_MASK 0x20000000
163
164/** @brief Data Prefetch Enable */
165#define L2C_310_AUX_DPFE_MASK 0x10000000
166
167/** @brief Non-secure interrupt access control */
168#define L2C_310_AUX_NSIC_MASK 0x08000000
169
170/** @brief Non-secure lockdown enable */
171#define L2C_310_AUX_NSLE_MASK 0x04000000
172
173/** @brief Cache replacement policy */
174#define L2C_310_AUX_CRP_MASK 0x02000000
175
176/** @brief Force write allocate */
177#define L2C_310_AUX_FWE_MASK 0x01800000
178
179/** @brief Shared attribute override enable */
180#define L2C_310_AUX_SAOE_MASK 0x00400000
181
182/** @brief Parity enable */
183#define L2C_310_AUX_PE_MASK 0x00200000
184
185/** @brief Event monitor bus enable */
186#define L2C_310_AUX_EMBE_MASK 0x00100000
187
188/** @brief Way-size */
189#define L2C_310_AUX_WAY_SIZE_MASK 0x000E0000
190#define L2C_310_AUX_WAY_SIZE_SHIFT 17
191
192/** @brief Way-size */
193#define L2C_310_AUX_ASSOC_MASK 0x00010000
194
195/** @brief Shared attribute invalidate enable */
196#define L2C_310_AUX_SAIE_MASK 0x00002000
197
198/** @brief Exclusive cache configuration */
199#define L2C_310_AUX_EXCL_CACHE_MASK 0x00001000
200
201/** @brief Store buffer device limitation Enable */
202#define L2C_310_AUX_SBDLE_MASK 0x00000800
203
204/** @brief High Priority for SO and Dev Reads Enable */
205#define L2C_310_AUX_HPSODRE_MASK 0x00000400
206
207/** @brief Full line of zero enable */
208#define L2C_310_AUX_FLZE_MASK 0x00000001
209
210/** @brief Enable all prefetching, */
211#define L2C_310_AUX_REG_DEFAULT_MASK \
212  ( L2C_310_AUX_WAY_SIZE_MASK & ( 0x3 << L2C_310_AUX_WAY_SIZE_SHIFT ) ) \
213  | L2C_310_AUX_PE_MASK      /* Prefetch enable */ \
214  | L2C_310_AUX_SAOE_MASK    /* Shared attribute override enable */ \
215  | L2C_310_AUX_CRP_MASK     /* Cache replacement policy */ \
216  | L2C_310_AUX_DPFE_MASK    /* Data prefetch enable */ \
217  | L2C_310_AUX_IPFE_MASK    /* Instruction prefetch enable */ \
218  | L2C_310_AUX_EBRESPE_MASK /* Early BRESP enable */
219
220#define L2C_310_AUX_REG_ZERO_MASK 0xFFF1FFFF
221
222/** @brief 1 cycle of latency, there is no additional latency fot tag RAM */
223#define L2C_310_RAM_1_CYCLE_LAT_VAL 0x00000000
224/** @brief 2 cycles of latency for tag RAM */
225#define L2C_310_RAM_2_CYCLE_LAT_VAL 0x00000001
226/** @brief 3 cycles of latency for tag RAM */
227#define L2C_310_RAM_3_CYCLE_LAT_VAL 0x00000002
228/** @brief 4 cycles of latency for tag RAM */
229#define L2C_310_RAM_4_CYCLE_LAT_VAL 0x00000003
230/** @brief 5 cycles of latency for tag RAM */
231#define L2C_310_RAM_5_CYCLE_LAT_VAL 0x00000004
232/** @brief 6 cycles of latency for tag RAM */
233#define L2C_310_RAM_6_CYCLE_LAT_VAL 0x00000005
234/** @brief 7 cycles of latency for tag RAM */
235#define L2C_310_RAM_7_CYCLE_LAT_VAL 0x00000006
236/** @brief 8 cycles of latency for tag RAM */
237#define L2C_310_RAM_8_CYCLE_LAT_VAL 0x00000007
238/** @brief Shift left setup latency values by this value */
239#define L2C_310_RAM_SETUP_SHIFT 0x00000000
240/** @brief Shift left read latency values by this value */
241#define L2C_310_RAM_READ_SHIFT 0x00000004
242/** @brief Shift left write latency values by this value */
243#define L2C_310_RAM_WRITE_SHIFT 0x00000008
244/** @brief Mask for RAM setup latency */
245#define L2C_310_RAM_SETUP_LAT_MASK 0x00000007
246/** @brief Mask for RAM read latency */
247#define L2C_310_RAM_READ_LAT_MASK 0x00000070
248/** @brief Mask for RAM read latency */
249#define L2C_310_RAM_WRITE_LAT_MASK 0x00000700
250  /** @brief Latency for tag RAM */
251  uint32_t tag_ram_ctrl;
252/* @brief Latency for tag RAM */
253#define L2C_310_TAG_RAM_DEFAULT_LAT \
254  ( ( L2C_310_RAM_2_CYCLE_LAT_VAL << L2C_310_RAM_SETUP_SHIFT ) \
255    | ( L2C_310_RAM_2_CYCLE_LAT_VAL << L2C_310_RAM_READ_SHIFT ) \
256    | ( L2C_310_RAM_2_CYCLE_LAT_VAL << L2C_310_RAM_WRITE_SHIFT ) )
257  /** @brief Latency for data RAM */
258  uint32_t data_ram_ctrl;
259/** @brief Latency for data RAM */
260#define L2C_310_DATA_RAM_DEFAULT_MASK \
261  ( ( L2C_310_RAM_2_CYCLE_LAT_VAL << L2C_310_RAM_SETUP_SHIFT ) \
262    | ( L2C_310_RAM_3_CYCLE_LAT_VAL << L2C_310_RAM_READ_SHIFT ) \
263    | ( L2C_310_RAM_2_CYCLE_LAT_VAL << L2C_310_RAM_WRITE_SHIFT ) )
264
265  uint8_t reserved_110[0x200 - 0x110];
266
267  /** @brief Event counter control */
268  uint32_t ev_ctrl;
269
270  /** @brief Event counter 1 configuration */
271  uint32_t ev_cnt1_cfg;
272
273  /** @brief Event counter 0 configuration */
274  uint32_t ev_cnt0_cfg;
275
276  /** @brief Event counter 1 value */
277  uint32_t ev_cnt1;
278
279  /** @brief Event counter 0 value */
280  uint32_t ev_cnt0;
281
282  /** @brief Interrupt enable mask */
283  uint32_t int_mask;
284
285  /** @brief Masked   interrupt status (read-only)*/
286  uint32_t int_mask_status;
287
288  /** @brief Unmasked interrupt status */
289  uint32_t int_raw_status;
290
291  /** @brief Interrupt clear */
292  uint32_t int_clr;
293
294/**
295 * @name Interrupt bit masks
296 *
297 * @{
298 */
299
300/** @brief DECERR from L3 */
301#define L2C_310_INT_DECERR_MASK 0x00000100
302
303/** @brief SLVERR from L3 */
304#define L2C_310_INT_SLVERR_MASK 0x00000080
305
306/** @brief Error on L2 data RAM (Read) */
307#define L2C_310_INT_ERRRD_MASK 0x00000040
308
309/** @brief Error on L2 tag RAM (Read) */
310#define L2C_310_INT_ERRRT_MASK 0x00000020
311
312/** @brief Error on L2 data RAM (Write) */
313#define L2C_310_INT_ERRWD_MASK 0x00000010
314
315/** @brief Error on L2 tag RAM (Write) */
316#define L2C_310_INT_ERRWT_MASK 0x00000008
317
318/** @brief Parity Error on L2 data RAM (Read) */
319#define L2C_310_INT_PARRD_MASK 0x00000004
320
321/** @brief Parity Error on L2 tag RAM (Read) */
322#define L2C_310_INT_PARRT_MASK 0x00000002
323
324/** @brief Event Counter1/0 Overflow Increment */
325#define L2C_310_INT_ECNTR_MASK 0x00000001
326
327/** @} */
328
329  uint8_t reserved_224[0x730 - 0x224];
330
331  /** @brief Drain the STB */
332  uint32_t cache_sync;
333  uint8_t reserved_734[0x740 - 0x734];
334  /** @brief ARM Errata 753970 for pl310-r3p0 */
335  uint32_t dummy_cache_sync_reg;
336  uint8_t reserved_744[0x770 - 0x744];
337
338  /** @brief Invalidate line by PA */
339  uint32_t inv_pa;
340  uint8_t reserved_774[0x77c - 0x774];
341
342  /** @brief Invalidate by Way */
343  uint32_t inv_way;
344  uint8_t reserved_780[0x7b0 - 0x780];
345
346  /** @brief Clean Line by PA */
347  uint32_t clean_pa;
348  uint8_t reserved_7b4[0x7b8 - 0x7b4];
349
350  /** @brief Clean Line by Set/Way */
351  uint32_t clean_index;
352
353  /** @brief Clean by Way */
354  uint32_t clean_way;
355  uint8_t reserved_7c0[0x7f0 - 0x7c0];
356
357  /** @brief Clean and Invalidate Line by PA */
358  uint32_t clean_inv_pa;
359  uint8_t reserved_7f4[0x7f8 - 0x7f4];
360
361  /** @brief Clean and Invalidate Line by Set/Way */
362  uint32_t clean_inv_indx;
363
364  /** @brief Clean and Invalidate by Way */
365  uint32_t clean_inv_way;
366
367  /** @brief Data        lock down 0 */
368  uint32_t d_lockdown_0;
369
370  /** @brief Instruction lock down 0 */
371  uint32_t i_lockdown_0;
372
373  /** @brief Data        lock down 1 */
374  uint32_t d_lockdown_1;
375
376  /** @brief Instruction lock down 1 */
377  uint32_t i_lockdown_1;
378
379  /** @brief Data        lock down 2 */
380  uint32_t d_lockdown_2;
381
382  /** @brief Instruction lock down 2 */
383  uint32_t i_lockdown_2;
384
385  /** @brief Data        lock down 3 */
386  uint32_t d_lockdown_3;
387
388  /** @brief Instruction lock down 3 */
389  uint32_t i_lockdown_3;
390
391  /** @brief Data        lock down 4 */
392  uint32_t d_lockdown_4;
393
394  /** @brief Instruction lock down 4 */
395  uint32_t i_lockdown_4;
396
397  /** @brief Data        lock down 5 */
398  uint32_t d_lockdown_5;
399
400  /** @brief Instruction lock down 5 */
401  uint32_t i_lockdown_5;
402
403  /** @brief Data        lock down 6 */
404  uint32_t d_lockdown_6;
405
406  /** @brief Instruction lock down 6 */
407  uint32_t i_lockdown_6;
408
409  /** @brief Data        lock down 7 */
410  uint32_t d_lockdown_7;
411
412  /** @brief Instruction lock down 7 */
413  uint32_t i_lockdown_7;
414
415  uint8_t reserved_940[0x950 - 0x940];
416
417  /** @brief Lockdown by Line Enable */
418  uint32_t lock_line_en;
419
420  /** @brief Cache lockdown by way */
421  uint32_t unlock_way;
422
423  uint8_t reserved_958[0xc00 - 0x958];
424
425  /** @brief Address range redirect, part 1 */
426  uint32_t addr_filtering_start;
427
428  /** @brief Address range redirect, part 2 */
429  uint32_t addr_filtering_end;
430
431/** @brief Address filtering valid bits*/
432#define L2C_310_ADDR_FILTER_VALID_MASK 0xFFF00000
433
434/** @brief Address filtering enable bit*/
435#define L2C_310_ADDR_FILTER_ENABLE_MASK 0x00000001
436
437  uint8_t reserved_c08[0xf40 - 0xc08];
438
439  /** @brief Debug control */
440  uint32_t debug_ctrl;
441
442/** @brief Debug SPIDEN bit */
443#define L2C_310_DEBUG_SPIDEN_MASK 0x00000004
444
445/** @brief Debug DWB bit, forces write through */
446#define L2C_310_DEBUG_DWB_MASK 0x00000002
447
448/** @brief Debug DCL bit, disables cache line fill */
449#define L2C_310_DEBUG_DCL_MASK 0x00000002
450
451  uint8_t reserved_f44[0xf60 - 0xf44];
452
453  /** @brief Purpose prefetch enables */
454  uint32_t prefetch_ctrl;
455/** @brief Prefetch offset */
456#define L2C_310_PREFETCH_OFFSET_MASK 0x0000001F
457  uint8_t reserved_f64[0xf80 - 0xf64];
458
459  /** @brief Purpose power controls */
460  uint32_t power_ctrl;
461} L2CC;
462
463rtems_interrupt_lock l2c_310_lock = RTEMS_INTERRUPT_LOCK_INITIALIZER(
464  "L2-310 cache controller"
465);
466
467/* Errata table for the LC2 310 Level 2 cache from ARM.
468* Information taken from ARMs
469* "CoreLink controllers and peripherals
470* - System controllers
471* - L2C-310 Level 2 Cache Controller
472* - Revision r3p3
473* - Software Developer Errata Notice
474* - ARM CoreLink Level 2 Cache Controller (L2C-310 or PL310),
475*   r3 releases Software Developers Errata Notice"
476* Please see this document for more information on these erratas */
477#if BSP_ARM_L2C_310_RTL_RELEASE == L2C_310_RTL_RELEASE_R3_P0
478#define L2C_310_ERRATA_IS_APPLICABLE_753970
479#endif
480
481static bool l2c_310_errata_is_applicable_727913(
482  uint32_t rtl_release
483)
484{
485  bool is_applicable = false;
486
487  switch ( rtl_release ) {
488    case L2C_310_RTL_RELEASE_R3_P3:
489    case L2C_310_RTL_RELEASE_R3_P2:
490    case L2C_310_RTL_RELEASE_R3_P1:
491    case L2C_310_RTL_RELEASE_R2_P0:
492    case L2C_310_RTL_RELEASE_R1_P0:
493    case L2C_310_RTL_RELEASE_R0_P0:
494      is_applicable = false;
495      break;
496    case L2C_310_RTL_RELEASE_R3_P0:
497      is_applicable = true;
498      break;
499    default:
500      assert( 0 );
501      break;
502  }
503
504  return is_applicable;
505}
506
507static bool l2c_310_errata_is_applicable_727914(
508  uint32_t rtl_release
509)
510{
511  bool is_applicable = false;
512
513  switch ( rtl_release ) {
514    case L2C_310_RTL_RELEASE_R3_P3:
515    case L2C_310_RTL_RELEASE_R3_P2:
516    case L2C_310_RTL_RELEASE_R3_P1:
517    case L2C_310_RTL_RELEASE_R2_P0:
518    case L2C_310_RTL_RELEASE_R1_P0:
519    case L2C_310_RTL_RELEASE_R0_P0:
520      is_applicable = false;
521      break;
522    case L2C_310_RTL_RELEASE_R3_P0:
523      is_applicable = true;
524      break;
525    default:
526      assert( 0 );
527      break;
528  }
529
530  return is_applicable;
531}
532
533static bool l2c_310_errata_is_applicable_727915(
534  uint32_t rtl_release
535)
536{
537  bool is_applicable = false;
538
539  switch ( rtl_release ) {
540    case L2C_310_RTL_RELEASE_R3_P3:
541    case L2C_310_RTL_RELEASE_R3_P2:
542    case L2C_310_RTL_RELEASE_R3_P1:
543    case L2C_310_RTL_RELEASE_R1_P0:
544    case L2C_310_RTL_RELEASE_R0_P0:
545      is_applicable = false;
546      break;
547    case L2C_310_RTL_RELEASE_R3_P0:
548    case L2C_310_RTL_RELEASE_R2_P0:
549      is_applicable = true;
550      break;
551    default:
552      assert( 0 );
553      break;
554  }
555
556  return is_applicable;
557}
558
559static bool l2c_310_errata_is_applicable_729806(
560  uint32_t rtl_release
561)
562{
563  bool is_applicable = false;
564
565  switch ( rtl_release ) {
566    case L2C_310_RTL_RELEASE_R3_P3:
567    case L2C_310_RTL_RELEASE_R3_P2:
568    case L2C_310_RTL_RELEASE_R2_P0:
569    case L2C_310_RTL_RELEASE_R1_P0:
570    case L2C_310_RTL_RELEASE_R0_P0:
571      is_applicable = false;
572      break;
573    case L2C_310_RTL_RELEASE_R3_P1:
574    case L2C_310_RTL_RELEASE_R3_P0:
575      is_applicable = true;
576      break;
577    default:
578      assert( 0 );
579      break;
580  }
581
582  return is_applicable;
583}
584
585static bool l2c_310_errata_is_applicable_729815(
586  uint32_t rtl_release
587)
588{
589  bool is_applicable = false;
590
591  switch ( rtl_release ) {
592    case L2C_310_RTL_RELEASE_R3_P3:
593    case L2C_310_RTL_RELEASE_R1_P0:
594    case L2C_310_RTL_RELEASE_R0_P0:
595      is_applicable = false;
596      break;
597    case L2C_310_RTL_RELEASE_R3_P2:
598    case L2C_310_RTL_RELEASE_R3_P1:
599    case L2C_310_RTL_RELEASE_R3_P0:
600    case L2C_310_RTL_RELEASE_R2_P0:
601      is_applicable = true;
602      break;
603    default:
604      assert( 0 );
605      break;
606  }
607
608  return is_applicable;
609}
610
611static bool l2c_310_errata_is_applicable_742884(
612  uint32_t rtl_release
613)
614{
615  bool is_applicable = false;
616
617  switch ( rtl_release ) {
618    case L2C_310_RTL_RELEASE_R3_P3:
619    case L2C_310_RTL_RELEASE_R3_P2:
620    case L2C_310_RTL_RELEASE_R3_P0:
621    case L2C_310_RTL_RELEASE_R2_P0:
622    case L2C_310_RTL_RELEASE_R1_P0:
623    case L2C_310_RTL_RELEASE_R0_P0:
624      is_applicable = false;
625      break;
626    case L2C_310_RTL_RELEASE_R3_P1:
627      is_applicable = true;
628      break;
629    default:
630      assert( 0 );
631      break;
632  }
633
634  return is_applicable;
635}
636
637static bool l2c_310_errata_is_applicable_752271(
638  uint32_t rtl_release
639)
640{
641  bool is_applicable = false;
642
643  switch ( rtl_release ) {
644    case L2C_310_RTL_RELEASE_R3_P3:
645    case L2C_310_RTL_RELEASE_R3_P2:
646    case L2C_310_RTL_RELEASE_R2_P0:
647    case L2C_310_RTL_RELEASE_R1_P0:
648    case L2C_310_RTL_RELEASE_R0_P0:
649      is_applicable = false;
650      break;
651    case L2C_310_RTL_RELEASE_R3_P1:
652    case L2C_310_RTL_RELEASE_R3_P0:
653      is_applicable = true;
654      break;
655    default:
656      assert( 0 );
657      break;
658  }
659
660  return is_applicable;
661}
662
663static bool l2c_310_errata_is_applicable_765569(
664  uint32_t rtl_release
665)
666{
667  bool is_applicable = false;
668
669  switch ( rtl_release ) {
670    case L2C_310_RTL_RELEASE_R3_P3:
671    case L2C_310_RTL_RELEASE_R3_P2:
672    case L2C_310_RTL_RELEASE_R3_P1:
673    case L2C_310_RTL_RELEASE_R3_P0:
674    case L2C_310_RTL_RELEASE_R2_P0:
675    case L2C_310_RTL_RELEASE_R1_P0:
676    case L2C_310_RTL_RELEASE_R0_P0:
677      is_applicable = true;
678      break;
679    default:
680      assert( 0 );
681      break;
682  }
683
684  return is_applicable;
685}
686
687static bool l2c_310_errata_is_applicable_769419(
688  uint32_t rtl_release
689)
690{
691  bool is_applicable = false;
692
693  switch ( rtl_release ) {
694    case L2C_310_RTL_RELEASE_R3_P3:
695    case L2C_310_RTL_RELEASE_R3_P2:
696      is_applicable = false;
697      break;
698    case L2C_310_RTL_RELEASE_R3_P1:
699    case L2C_310_RTL_RELEASE_R3_P0:
700    case L2C_310_RTL_RELEASE_R2_P0:
701    case L2C_310_RTL_RELEASE_R1_P0:
702    case L2C_310_RTL_RELEASE_R0_P0:
703      is_applicable = true;
704      break;
705    default:
706      assert( 0 );
707      break;
708  }
709
710  return is_applicable;
711}
712
713#if BSP_ARM_L2C_310_RTL_RELEASE == L2C_310_RTL_RELEASE_R0_P0 \
714   || BSP_ARM_L2C_310_RTL_RELEASE == L2C_310_RTL_RELEASE_R1_P0
715#define L2C_310_ERRATA_IS_APPLICABLE_588369
716#endif
717
718#ifdef CACHE_ERRATA_CHECKS_FOR_IMPLEMENTED_ERRATAS
719static bool l2c_310_errata_is_applicable_754670(
720  uint32_t rtl_release
721)
722{
723  bool is_applicable = false;
724
725  switch ( rtl_release ) {
726    case L2C_310_RTL_RELEASE_R3_P3:
727    case L2C_310_RTL_RELEASE_R3_P2:
728    case L2C_310_RTL_RELEASE_R3_P1:
729    case L2C_310_RTL_RELEASE_R3_P0:
730    case L2C_310_RTL_RELEASE_R2_P0:
731    case L2C_310_RTL_RELEASE_R1_P0:
732    case L2C_310_RTL_RELEASE_R0_P0:
733      is_applicable = true;
734    break;
735    default:
736      assert( 0 );
737      break;
738  }
739
740  return is_applicable;
741}
742#endif /* CACHE_ERRATA_CHECKS_FOR_IMPLEMENTED_ERRATAS */
743
744/* The common workaround for this erratum would be to add a
745 * data synchronization barrier to the beginning of the abort handler.
746 * But for RTEMS a call of the abort handler means a fatal condition anyway.
747 * So there is no need to handle this erratum */
748#define CACHE_ARM_ERRATA_775420_HANDLER()                   \
749  if( arm_errata_is_applicable_processor_errata_775420 ) {  \
750  }                                                         \
751
752static void l2c_310_check_errata( uint32_t rtl_release )
753{
754  /* This erratum gets handled within the sources */
755  /* Unhandled erratum present: 588369 Errata 588369 says that clean + inv may
756   * keep the cache line if it was clean. See ARMs documentation on the erratum
757   * for a workaround */
758  /* assert( ! l2c_310_errata_is_applicable_588369( rtl_release ) ); */
759
760  /* Unhandled erratum present: 727913 Prefetch dropping feature can cause
761   * incorrect behavior when PL310 handles reads that cross cache line
762   * boundary */
763  assert( ! l2c_310_errata_is_applicable_727913( rtl_release ) );
764
765  /* Unhandled erratum present: 727914 Double linefill feature can cause
766   * deadlock */
767  assert( ! l2c_310_errata_is_applicable_727914( rtl_release ) );
768
769  /* Unhandled erratum present: 727915 Background Clean and Invalidate by Way
770   * operation can cause data corruption */
771  assert( ! l2c_310_errata_is_applicable_727915( rtl_release ) );
772
773  /* Unhandled erratum present: 729806 Speculative reads from the Cortex-A9
774   * MPCore processor can cause deadlock */
775  assert( ! l2c_310_errata_is_applicable_729806( rtl_release ) );
776
777  if( l2c_310_errata_is_applicable_729815( rtl_release ) )
778  {
779    volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
780
781    assert( 0 == ( l2cc->aux_ctrl & L2C_310_AUX_HPSODRE_MASK ) );
782
783    /* Erratum: 729815 The “High Priority for SO and Dev reads” feature can
784     * cause Quality of Service issues to cacheable read transactions*/
785
786    /* Conditions
787       This problem occurs when the following conditions are met:
788       1. Bit[10] “High Priority for SO and Dev reads enable” of the PL310
789          Auxiliary Control Register is set to 1.
790       2. PL310 receives a cacheable read that misses in the L2 cache.
791       3. PL310 receives a continuous flow of Strongly Ordered or Device
792          reads that take all address slots in the master interface.
793       Workaround
794       A workaround is only necessary in systems that are able to issue a
795       continuous flow of Strongly Ordered or Device reads. In such a case,
796       the workaround is to disable the “High Priority for SO and Dev reads”
797       feature. This is the default behavior.*/
798  }
799
800  /* Unhandled erratum present: 742884 Double linefill feature might introduce
801   * circular dependency and deadlock */
802  assert( ! l2c_310_errata_is_applicable_742884( rtl_release ) );
803
804  /* Unhandled erratum present: 752271 Double linefill feature can cause data
805   * corruption */
806  assert( ! l2c_310_errata_is_applicable_752271( rtl_release ) );
807
808  /* This erratum can not be worked around: 754670 A continuous write flow can
809   * stall a read targeting the same memory area
810   * But this erratum does not lead to any data corruption */
811  /* assert( ! l2c_310_errata_is_applicable_754670() ); */
812
813  if( l2c_310_errata_is_applicable_765569( rtl_release ) )
814  {
815    volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
816
817    assert( !( ( l2cc->aux_ctrl & L2C_310_AUX_IPFE_MASK
818                 || l2cc->aux_ctrl & L2C_310_AUX_DPFE_MASK )
819               && ( ( l2cc->prefetch_ctrl & L2C_310_PREFETCH_OFFSET_MASK )
820                    == 23 ) ) );
821
822    /* Unhandled erratum present: 765569 Prefetcher can cross 4KB boundary if
823     * offset is programmed with value 23 */
824
825    /* Conditions
826       This problem occurs when the following conditions are met:
827       1. One of the Prefetch Enable bits (bits [29:28] of the Auxiliary or
828          Prefetch Control Register) is set HIGH.
829       2. The prefetch offset bits are programmed with value 23 (5'b10111).
830       Workaround
831       A workaround for this erratum is to program the prefetch offset with any
832       value except 23.*/
833  }
834
835  /* Unhandled erratum present: 769419 No automatic Store Buffer drain,
836   * visibility of written data requires an explicit Cache */
837  assert( ! l2c_310_errata_is_applicable_769419( rtl_release ) );
838}
839
840static inline void
841l2c_310_sync( volatile L2CC *l2cc )
842{
843#ifdef L2C_310_ERRATA_IS_APPLICABLE_753970
844  l2cc->dummy_cache_sync_reg = 0;
845#else
846  l2cc->cache_sync = 0;
847#endif
848}
849
850static inline void
851l2c_310_flush_1_line( volatile L2CC *l2cc, uint32_t d_addr )
852{
853#ifdef L2C_310_ERRATA_IS_APPLICABLE_588369
854  /*
855  * Errata 588369 says that clean + inv may keep the
856  * cache line if it was clean, the recommended
857  * workaround is to clean then invalidate the cache
858  * line, with write-back and cache linefill disabled.
859  */
860  l2cc->clean_pa     = d_addr;
861  l2c_310_sync( l2cc );
862  l2cc->inv_pa       = d_addr;
863#else
864  l2cc->clean_inv_pa = d_addr;
865#endif
866}
867
868static inline void
869l2c_310_flush_range( const void* d_addr, const size_t n_bytes )
870{
871  /* Back starting address up to start of a line and invalidate until ADDR_LAST */
872  uint32_t       adx               = (uint32_t)d_addr
873    & ~L2C_310_DATA_LINE_MASK;
874  const uint32_t ADDR_LAST         =
875    (uint32_t)( (size_t)d_addr + n_bytes - 1 );
876  volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
877
878  if ( n_bytes == 0 ) {
879    return;
880  }
881
882  for (; adx <= ADDR_LAST; adx += CPU_DATA_CACHE_ALIGNMENT ) {
883    l2c_310_flush_1_line( l2cc, adx );
884  }
885
886  l2c_310_sync( l2cc );
887}
888
889static inline void
890l2c_310_flush_entire( void )
891{
892  volatile L2CC               *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
893  rtems_interrupt_lock_context lock_context;
894
895  /* Only flush if level 2 cache is active */
896  if( ( l2cc->ctrl & L2C_310_CTRL_ENABLE ) != 0 ) {
897
898    /* ensure ordering with previous memory accesses */
899    _ARM_Data_memory_barrier();
900
901    rtems_interrupt_lock_acquire( &l2c_310_lock, &lock_context );
902    l2cc->clean_inv_way = L2C_310_WAY_MASK;
903
904    while ( l2cc->clean_inv_way & L2C_310_WAY_MASK ) {};
905
906    /* Wait for the flush to complete */
907    l2c_310_sync( l2cc );
908
909    rtems_interrupt_lock_release( &l2c_310_lock, &lock_context );
910  }
911}
912
913static inline void
914l2c_310_invalidate_1_line( const void *d_addr )
915{
916  volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
917
918
919  l2cc->inv_pa = (uint32_t) d_addr;
920  l2c_310_sync( l2cc );
921}
922
923static inline void
924l2c_310_invalidate_range( const void* d_addr, const size_t n_bytes )
925{
926  /* Back starting address up to start of a line and invalidate until ADDR_LAST */
927  uint32_t       adx               = (uint32_t)d_addr
928    & ~L2C_310_DATA_LINE_MASK;
929  const uint32_t ADDR_LAST         =
930    (uint32_t)( (size_t)d_addr + n_bytes - 1 );
931  volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
932
933  if ( n_bytes == 0 ) {
934    return;
935  }
936
937  for (; adx <= ADDR_LAST; adx += CPU_DATA_CACHE_ALIGNMENT ) {
938    /* Invalidate L2 cache line */
939    l2cc->inv_pa = adx;
940  }
941
942  l2c_310_sync( l2cc );
943}
944
945
946static inline void
947l2c_310_invalidate_entire( void )
948{
949  volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
950
951  /* Invalidate the caches */
952
953  /* ensure ordering with previous memory accesses */
954  _ARM_Data_memory_barrier();
955
956  l2cc->inv_way = L2C_310_WAY_MASK;
957
958  while ( l2cc->inv_way & L2C_310_WAY_MASK ) ;
959
960  /* Wait for the invalidate to complete */
961  l2c_310_sync( l2cc );
962}
963
964static inline void
965l2c_310_clean_and_invalidate_entire( void )
966{
967  volatile L2CC               *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
968  rtems_interrupt_lock_context lock_context;
969
970  if( ( l2cc->ctrl & L2C_310_CTRL_ENABLE ) != 0 ) {
971    /* Invalidate the caches */
972
973    /* ensure ordering with previous memory accesses */
974    _ARM_Data_memory_barrier();
975
976    rtems_interrupt_lock_acquire( &l2c_310_lock, &lock_context );
977    l2cc->clean_inv_way = L2C_310_WAY_MASK;
978
979    while ( l2cc->clean_inv_way & L2C_310_WAY_MASK ) ;
980
981    /* Wait for the invalidate to complete */
982    l2c_310_sync( l2cc );
983
984    rtems_interrupt_lock_release( &l2c_310_lock, &lock_context );
985  }
986}
987
988static inline void
989l2c_310_freeze( void )
990{
991  /* To be implemented as needed, if supported
992   by hardware at all */
993}
994
995static inline void
996l2c_310_unfreeze( void )
997{
998  /* To be implemented as needed, if supported
999   by hardware at all */
1000}
1001
1002static inline size_t
1003l2c_310_get_cache_size( void )
1004{
1005  size_t         size       = 0;
1006  volatile L2CC *l2cc       = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
1007  uint32_t       cache_type = l2cc->cache_type;
1008  uint32_t       way_size;
1009  uint32_t       num_ways;
1010
1011  way_size = (cache_type & L2C_310_TYPE_SIZE_D_WAYS_MASK)
1012    >> L2C_310_TYPE_SIZE_D_WAYS_SHIFT;
1013  num_ways = (cache_type & L2C_310_TYPE_NUM_D_WAYS_MASK)
1014    >> L2C_310_TYPE_NUM_D_WAYS_SHIFT;
1015
1016  assert( way_size <= 0x07 );
1017  assert( num_ways <= 0x01 );
1018  if(  way_size <= 0x07 && num_ways <= 0x01 ) {
1019    if( way_size == 0x00 ) {
1020      way_size = 16 * 1024;
1021    } else if( way_size == 0x07 ) {
1022      way_size = 512 * 1024;
1023    } else {
1024      way_size = (1 << (way_size - 1)) * 16 * 1024;
1025    }
1026    switch( num_ways ) {
1027      case 0:
1028        num_ways = 8;
1029        break;
1030      case 1:
1031        num_ways = 16;
1032        break;
1033      default:
1034        num_ways = 0;
1035        break;
1036    }
1037    size = way_size * num_ways;
1038  }
1039  return size;
1040}
1041
1042static void l2c_310_unlock( volatile L2CC *l2cc )
1043{
1044  l2cc->d_lockdown_0 = 0;
1045  l2cc->i_lockdown_0 = 0;
1046  l2cc->d_lockdown_1 = 0;
1047  l2cc->i_lockdown_1 = 0;
1048  l2cc->d_lockdown_2 = 0;
1049  l2cc->i_lockdown_2 = 0;
1050  l2cc->d_lockdown_3 = 0;
1051  l2cc->i_lockdown_3 = 0;
1052  l2cc->d_lockdown_4 = 0;
1053  l2cc->i_lockdown_4 = 0;
1054  l2cc->d_lockdown_5 = 0;
1055  l2cc->i_lockdown_5 = 0;
1056  l2cc->d_lockdown_6 = 0;
1057  l2cc->i_lockdown_6 = 0;
1058  l2cc->d_lockdown_7 = 0;
1059  l2cc->i_lockdown_7 = 0;
1060}
1061
1062static void l2c_310_wait_for_background_ops( volatile L2CC *l2cc )
1063{
1064  while ( l2cc->inv_way & L2C_310_WAY_MASK ) ;
1065
1066  while ( l2cc->clean_way & L2C_310_WAY_MASK ) ;
1067
1068  while ( l2cc->clean_inv_way & L2C_310_WAY_MASK ) ;
1069}
1070
1071/* We support only the L2C-310 revisions r3p2 and r3p3 cache controller */
1072
1073#if (BSP_ARM_L2C_310_ID & L2C_310_ID_PART_MASK) \
1074  != L2C_310_ID_PART_L310
1075#error "invalid L2-310 cache controller part number"
1076#endif
1077
1078#if (BSP_ARM_L2C_310_RTL_RELEASE != L2C_310_RTL_RELEASE_R3_P2) \
1079  && (BSP_ARM_L2C_310_RTL_RELEASE != L2C_310_RTL_RELEASE_R3_P3)
1080#error "invalid L2-310 cache controller RTL revision"
1081#endif
1082
1083static inline void
1084l2c_310_enable( void )
1085{
1086  volatile L2CC *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
1087  uint32_t cache_id = l2cc->cache_id;
1088  uint32_t rtl_release = cache_id & L2C_310_ID_RTL_MASK;
1089  uint32_t id_mask = L2C_310_ID_IMPL_MASK | L2C_310_ID_PART_MASK;
1090  uint32_t ctrl;
1091
1092  /*
1093   * Do we actually have an L2C-310 cache controller?  Has BSP_ARM_L2C_310_BASE
1094   * been configured correctly?
1095   */
1096  if (
1097    (BSP_ARM_L2C_310_ID & id_mask) != (cache_id & id_mask)
1098      || rtl_release < BSP_ARM_L2C_310_RTL_RELEASE
1099  ) {
1100    bsp_fatal( ARM_FATAL_L2C_310_UNEXPECTED_ID );
1101  }
1102
1103  l2c_310_check_errata( rtl_release );
1104
1105  ctrl = l2cc->ctrl;
1106
1107  if ( ( ctrl & L2C_310_CTRL_EXCL_CONFIG ) != 0 ) {
1108    bsp_fatal( ARM_FATAL_L2C_310_EXCLUSIVE_CONFIG );
1109  }
1110
1111  /* Only enable if L2CC is currently disabled */
1112  if( ( ctrl & L2C_310_CTRL_ENABLE ) == 0 ) {
1113    uint32_t aux_ctrl;
1114    int ways;
1115
1116    /* Make sure that I&D is not locked down when starting */
1117    l2c_310_unlock( l2cc );
1118
1119    l2c_310_wait_for_background_ops( l2cc );
1120
1121    aux_ctrl = l2cc->aux_ctrl;
1122
1123    if ( (aux_ctrl & ( 1 << 16 )) != 0 ) {
1124      ways = 16;
1125    } else {
1126      ways = 8;
1127    }
1128
1129    if ( ways != L2C_310_NUM_WAYS ) {
1130      bsp_fatal( ARM_FATAL_L2C_310_UNEXPECTED_NUM_WAYS );
1131    }
1132
1133    /* Set up the way size */
1134    aux_ctrl &= L2C_310_AUX_REG_ZERO_MASK; /* Set way_size to 0 */
1135    aux_ctrl |= L2C_310_AUX_REG_DEFAULT_MASK;
1136
1137    l2cc->aux_ctrl = aux_ctrl;
1138
1139    /* Set up the latencies */
1140    l2cc->tag_ram_ctrl  = L2C_310_TAG_RAM_DEFAULT_LAT;
1141    l2cc->data_ram_ctrl = L2C_310_DATA_RAM_DEFAULT_MASK;
1142
1143    l2c_310_invalidate_entire();
1144
1145    /* Clear the pending interrupts */
1146    l2cc->int_clr = l2cc->int_raw_status;
1147
1148    /* Enable the L2CC */
1149    l2cc->ctrl = ctrl | L2C_310_CTRL_ENABLE;
1150  }
1151}
1152
1153static inline void
1154l2c_310_disable( void )
1155{
1156  volatile L2CC               *l2cc = (volatile L2CC *) BSP_ARM_L2C_310_BASE;
1157  rtems_interrupt_lock_context lock_context;
1158
1159  if ( l2cc->ctrl & L2C_310_CTRL_ENABLE ) {
1160    /* Clean and Invalidate L2 Cache */
1161    l2c_310_flush_entire();
1162    rtems_interrupt_lock_acquire( &l2c_310_lock, &lock_context );
1163
1164    l2c_310_wait_for_background_ops( l2cc );
1165
1166    /* Disable the L2 cache */
1167    l2cc->ctrl &= ~L2C_310_CTRL_ENABLE;
1168    rtems_interrupt_lock_release( &l2c_310_lock, &lock_context );
1169  }
1170}
1171
1172static inline void
1173_CPU_cache_enable_data( void )
1174{
1175  l2c_310_enable();
1176}
1177
1178static inline void
1179_CPU_cache_disable_data( void )
1180{
1181  arm_cache_l1_disable_data();
1182  l2c_310_disable();
1183}
1184
1185static inline void
1186_CPU_cache_enable_instruction( void )
1187{
1188  l2c_310_enable();
1189}
1190
1191static inline void
1192_CPU_cache_disable_instruction( void )
1193{
1194  arm_cache_l1_disable_instruction();
1195  l2c_310_disable();
1196}
1197
1198static inline void
1199_CPU_cache_flush_data_range(
1200  const void *d_addr,
1201  size_t      n_bytes
1202)
1203{
1204  arm_cache_l1_flush_data_range(
1205    d_addr,
1206    n_bytes
1207  );
1208  l2c_310_flush_range(
1209    d_addr,
1210    n_bytes
1211  );
1212}
1213
1214static inline void
1215_CPU_cache_flush_entire_data( void )
1216{
1217  arm_cache_l1_flush_entire_data();
1218  l2c_310_flush_entire();
1219}
1220
1221static inline void
1222_CPU_cache_invalidate_data_range(
1223  const void *addr_first,
1224  size_t     n_bytes
1225)
1226{
1227  l2c_310_invalidate_range(
1228    addr_first,
1229    n_bytes
1230  );
1231  arm_cache_l1_invalidate_data_range(
1232    addr_first,
1233    n_bytes
1234  );
1235}
1236
1237static inline void
1238_CPU_cache_invalidate_entire_data( void )
1239{
1240  /* This is broadcast within the cluster */
1241  arm_cache_l1_flush_entire_data();
1242
1243  /* forces the address out past level 2 */
1244  l2c_310_clean_and_invalidate_entire();
1245
1246  /*This is broadcast within the cluster */
1247  arm_cache_l1_clean_and_invalidate_entire_data();
1248}
1249
1250static inline void
1251_CPU_cache_freeze_data( void )
1252{
1253  arm_cache_l1_freeze_data();
1254  l2c_310_freeze();
1255}
1256
1257static inline void
1258_CPU_cache_unfreeze_data( void )
1259{
1260  arm_cache_l1_unfreeze_data();
1261  l2c_310_unfreeze();
1262}
1263
1264static inline void
1265_CPU_cache_invalidate_instruction_range( const void *i_addr, size_t n_bytes)
1266{
1267  arm_cache_l1_invalidate_instruction_range( i_addr, n_bytes );
1268}
1269
1270static inline void
1271_CPU_cache_invalidate_entire_instruction( void )
1272{
1273  arm_cache_l1_invalidate_entire_instruction();
1274}
1275
1276static inline void
1277_CPU_cache_freeze_instruction( void )
1278{
1279  arm_cache_l1_freeze_instruction();
1280  l2c_310_freeze();
1281}
1282
1283static inline void
1284_CPU_cache_unfreeze_instruction( void )
1285{
1286  arm_cache_l1_unfreeze_instruction();
1287  l2c_310_unfreeze();
1288}
1289
1290static inline size_t
1291_CPU_cache_get_data_cache_size( const uint32_t level )
1292{
1293  size_t size = 0;
1294
1295  switch( level )
1296  {
1297    case 1:
1298      size = arm_cache_l1_get_data_cache_size();
1299    break;
1300    case 0:
1301    case 2:
1302      size = l2c_310_get_cache_size();
1303    break;
1304    default:
1305      size = 0;
1306    break;
1307  }
1308  return size;
1309}
1310
1311static inline size_t
1312_CPU_cache_get_instruction_cache_size( const uint32_t level )
1313{
1314  size_t size = 0;
1315
1316  switch( level )
1317  {
1318    case 1:
1319      size = arm_cache_l1_get_instruction_cache_size();
1320      break;
1321    case 0:
1322    case 2:
1323      size = l2c_310_get_cache_size();
1324      break;
1325    default:
1326      size = 0;
1327      break;
1328  }
1329  return size;
1330}
1331
1332#include "../../shared/cache/cacheimpl.h"
Note: See TracBrowser for help on using the repository browser.