RTEMS 6.1-rc2
Loading...
Searching...
No Matches
arm-data-cache-loop-set-way.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * SPDX-License-Identifier: BSD-2-Clause
14 *
15 * Copyright (C) 2018 embedded brains GmbH & Co. KG
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39.macro ARM_DATA_CACHE_LOOP_SET_WAY CRM
40
41 /* Get cache levels (LoC) from CLIDR */
42 mrc p15, 1, r1, c0, c0, 1
43 mov r2, r1, lsr #24
44 ands r2, r2, #0x7
45 beq 5f
46
47 /* Start with level 0 */
48 mov r3, #0
49
50 /* Flush level specified by r3 */
511:
52
53 /* Check cache type and skip this level if there is no data cache */
54 add r4, r3, r3, lsl #1
55 lsr r5, r1, r4
56 and r5, r5, #0x7
57 cmp r5, #2
58 blt 4f
59
60 /* Read CCSIDR */
61 lsl r4, r3, #1
62 mcr p15, 2, r4, c0, c0, 0
63 isb
64 mrc p15, 1, r5, c0, c0, 0
65
66 /* Get cache line power */
67 and r6, r5, #0x7
68 add r6, r6, #4
69
70 /* Get ways minus one */
71 mov r7, #0x3ff
72 ands r7, r7, r5, lsr #3
73
74 /* Get way shift */
75 clz r8, r7
76
77 /* Get sets minus one */
78 mov r9, #0x7fff
79 ands r9, r9, r5, lsr #13
80
81 /* Loop over ways */
822:
83 mov r10, r9
84
85 /* Loop over sets */
863:
87 orr r11, r4, r7, lsl r8
88 orr r11, r11, r10, lsl r6
89
90 /* Cache operation by set and way */
91 mcr p15, 0, r11, c7, \CRM, 2
92
93 subs r10, r10, #1
94 bge 3b
95 subs r7, r7, #1
96 bge 2b
97
98 /* Next level */
994:
100 add r3, r3, #1
101 cmp r2, r3
102 bgt 1b
103
104 /* Done */
1055:
106
107.endm