]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/arm/cpufunc_asm_armv7.S
Remove unused functions on armv6. Some of the cache handling code is still
[FreeBSD/FreeBSD.git] / sys / arm / arm / cpufunc_asm_armv7.S
1 /*-
2  * Copyright (c) 2010 Per Odlund <per.odlund@armagedon.se>
3  * Copyright (C) 2011 MARVELL INTERNATIONAL LTD.
4  * All rights reserved.
5  *
6  * Developed by Semihalf.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of MARVELL nor the names of contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32
33 #include <machine/asm.h>
34 __FBSDID("$FreeBSD$");
35
36 #include <machine/sysreg.h>
37
38         .cpu cortex-a8
39
40 .Lcoherency_level:
41         .word   _C_LABEL(arm_cache_loc)
42 .Lcache_type:
43         .word   _C_LABEL(arm_cache_type)
44 .Larmv7_dcache_line_size:
45         .word   _C_LABEL(arm_dcache_min_line_size)
46 .Larmv7_icache_line_size:
47         .word   _C_LABEL(arm_icache_min_line_size)
48 .Larmv7_idcache_line_size:
49         .word   _C_LABEL(arm_idcache_min_line_size)
50 .Lway_mask:
51         .word   0x3ff
52 .Lmax_index:
53         .word   0x7fff
54 .Lpage_mask:
55         .word   0xfff
56
57 #define PT_NOS          (1 << 5)
58 #define PT_S            (1 << 1)
59 #define PT_INNER_NC     0
60 #define PT_INNER_WT     (1 << 0)
61 #define PT_INNER_WB     ((1 << 0) | (1 << 6))
62 #define PT_INNER_WBWA   (1 << 6)
63 #define PT_OUTER_NC     0
64 #define PT_OUTER_WT     (2 << 3)
65 #define PT_OUTER_WB     (3 << 3)
66 #define PT_OUTER_WBWA   (1 << 3)
67
68 #ifdef SMP
69 #define PT_ATTR (PT_S|PT_INNER_WBWA|PT_OUTER_WBWA|PT_NOS)
70 #else
71 #define PT_ATTR (PT_INNER_WBWA|PT_OUTER_WBWA)
72 #endif
73
74 ENTRY(armv7_setttb)
75         dsb
76         orr     r0, r0, #PT_ATTR
77         mcr     CP15_TTBR0(r0)
78         isb
79 #ifdef SMP
80         mcr     CP15_TLBIALLIS
81 #else
82         mcr     CP15_TLBIALL
83 #endif
84         dsb
85         isb
86         RET
87 END(armv7_setttb)
88
89 #ifdef ELF_TRAMPOLINE
90 /* Based on algorithm from ARM Architecture Reference Manual */
91 ENTRY(armv7_dcache_wbinv_all)
92         stmdb   sp!, {r4, r5, r6, r7, r8, r9}
93
94         /* Get cache level */
95         ldr     r0, .Lcoherency_level
96         ldr     r3, [r0]
97         cmp     r3, #0
98         beq     Finished
99         /* For each cache level */
100         mov     r8, #0
101 Loop1:
102         /* Get cache type for given level */
103         mov     r2, r8, lsl #2
104         add     r2, r2, r2
105         ldr     r0, .Lcache_type
106         ldr     r1, [r0, r2]
107
108         /* Get line size */
109         and     r2, r1, #7
110         add     r2, r2, #4
111
112         /* Get number of ways */
113         ldr     r4, .Lway_mask
114         ands    r4, r4, r1, lsr #3
115         clz     r5, r4
116
117         /* Get max index */
118         ldr     r7, .Lmax_index
119         ands    r7, r7, r1, lsr #13
120 Loop2:
121         mov     r9, r4
122 Loop3:
123         mov     r6, r8, lsl #1
124         orr     r6, r6, r9, lsl r5
125         orr     r6, r6, r7, lsl r2
126
127         /* Clean and invalidate data cache by way/index */
128         mcr     CP15_DCCISW(r6)
129         subs    r9, r9, #1
130         bge     Loop3
131         subs    r7, r7, #1
132         bge     Loop2
133 Skip:
134         add     r8, r8, #1
135         cmp     r3, r8
136         bne Loop1
137 Finished:
138         dsb
139         ldmia   sp!, {r4, r5, r6, r7, r8, r9}
140         RET
141 END(armv7_dcache_wbinv_all)
142
143 ENTRY(armv7_idcache_wbinv_all)
144         stmdb   sp!, {lr}
145         bl armv7_dcache_wbinv_all
146 #ifdef SMP
147         mcr     CP15_ICIALLUIS
148 #else
149         mcr     CP15_ICIALLU
150 #endif
151         dsb
152         isb
153         ldmia   sp!, {lr}
154         RET
155 END(armv7_idcache_wbinv_all)
156 #endif
157
158 ENTRY(armv7_cpu_sleep)
159         dsb                             /* data synchronization barrier */
160         wfi                             /* wait for interrupt */
161         RET
162 END(armv7_cpu_sleep)
163
164 ENTRY(armv7_drain_writebuf)
165         dsb
166         RET
167 END(armv7_drain_writebuf)
168
169 ENTRY(armv7_sev)
170         dsb
171         sev
172         nop
173         RET
174 END(armv7_sev)