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