]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/cddl/dev/dtrace/mips/dtrace_asm.S
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / cddl / dev / dtrace / mips / dtrace_asm.S
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  *
22  * $FreeBSD$
23  */
24 /*
25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28
29 #define _ASM
30 #define _LOCORE
31 #define LOCORE
32
33 #include <sys/cpuvar_defs.h>
34 #include <sys/dtrace.h>
35
36 #include <machine/asm.h>
37 #include <machine/cpu.h>
38 #include <machine/cpuregs.h>
39 #include <machine/regnum.h>
40
41 #include "assym.s"
42
43         .set    noreorder               # Noreorder is default style!
44
45 /*
46  * Primitives
47  */
48
49         .text
50
51 /*
52 void dtrace_membar_producer(void)
53 */
54 LEAF(dtrace_membar_producer)
55         j       ra
56         nop
57 END(dtrace_membar_producer)
58
59 /*
60 void dtrace_membar_consumer(void)
61 */
62 LEAF(dtrace_membar_consumer)
63         j       ra
64         nop
65 END(dtrace_membar_consumer)
66
67 /*
68 dtrace_icookie_t dtrace_interrupt_disable(void)
69 */
70 LEAF(dtrace_interrupt_disable)
71         mfc0    t0, MIPS_COP_0_STATUS
72         move    v0, t0
73         and     v0, v0, MIPS_SR_INT_IE
74         and     t0, t0, ~MIPS_SR_INT_IE
75         mtc0    t0, MIPS_COP_0_STATUS
76         j       ra
77         nop
78 END(dtrace_interrupt_disable)
79
80 /*
81 void dtrace_interrupt_enable(dtrace_icookie_t cookie)
82 */
83 LEAF(dtrace_interrupt_enable)
84         mfc0    t0, MIPS_COP_0_STATUS
85         beqz    a0, not_enabled
86         or      t0, t0, MIPS_SR_INT_IE
87         mtc0    t0, MIPS_COP_0_STATUS
88 not_enabled:
89         j       ra
90         nop
91 END(dtrace_interrupt_enable)
92
93 /*
94 uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
95 */
96 LEAF(dtrace_cas32)
97 1:
98         move    t1, a2
99         ll      t0, 0(a0)
100         bne     t0, a1, 2f
101         nop
102         sc      t1, 0(a0)
103         beqz    t1, 1b
104         nop
105 2:      move    v0, t0
106         j       ra
107         nop
108 END(dtrace_cas32)
109
110 /*
111 void *
112 dtrace_casptr(void *target, void *cmp, void *new)
113 */
114 LEAF(dtrace_casptr)
115 1:
116         move    t1, a2
117         PTR_LL  t0, 0(a0)
118         bne     t0, a1, 2f
119         nop
120         PTR_SC  t1, 0(a0)
121         beqz    t1, 1b
122         nop
123 2:      move    v0, t0
124         j       ra
125         nop
126 END(dtrace_casptr)
127
128
129 /*
130 uintptr_t
131 dtrace_fulword(void *addr)
132 */
133 LEAF(dtrace_fulword)
134 END(dtrace_fulword)
135
136 /*
137 uint8_t
138 dtrace_fuword8_nocheck(void *addr)
139 */
140 LEAF(dtrace_fuword8_nocheck)
141         lbu     v0, 0(a0)
142         j       ra
143         nop
144 END(dtrace_fuword8_nocheck)
145
146 /*
147 uint16_t
148 dtrace_fuword16_nocheck(void *addr)
149 */
150 LEAF(dtrace_fuword16_nocheck)
151         lhu     v0, 0(a0)
152         j       ra
153         nop
154 END(dtrace_fuword16_nocheck)
155
156 /*
157 uint32_t
158 dtrace_fuword32_nocheck(void *addr)
159 */
160 LEAF(dtrace_fuword32_nocheck)
161         lw      v0, 0(a0)
162         j       ra
163         nop
164 END(dtrace_fuword32_nocheck)
165
166 /*
167 uint64_t
168 dtrace_fuword64_nocheck(void *addr)
169 */
170 LEAF(dtrace_fuword64_nocheck)
171 #if defined(__mips_n64) || defined(__mips_n32)
172         ld      v0, 0(a0)
173 #else
174         lw      v1,4(a0)
175         lw      v0,0(a0)
176 #endif
177         j       ra
178         nop
179 END(dtrace_fuword64_nocheck)
180
181 /*
182 XXX: unoptimized
183 void
184 dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
185 */
186 LEAF(dtrace_copy)
187 1:
188         beqz    a2, 2f
189         nop
190         lbu     t0, 0(a0)
191         sb      t0, 0(a1)
192         PTR_ADDU        a0, a0, 1
193         PTR_ADDU        a1, a1, 1
194         INT_SUBU        a2, a2, 1
195         j       1b
196         nop
197 2:
198         j       ra
199         nop
200 END(dtrace_copy)
201
202 /*
203 XXX: Unoptimized. Check for flags on page boundaries only(?)
204 void
205 dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
206     volatile uint16_t *flags)
207 */
208 LEAF(dtrace_copystr)
209 1:
210         lbu     t0, 0(a0)
211         sb      t0, 0(a1)
212         PTR_ADDU        a0, a0, 1
213         PTR_ADDU        a1, a1, 1
214         INT_SUBU        a2, a2, 1
215         beqz    t0, 2f
216         nop
217         lhu     t1, (a3)
218         and     t1, t1, CPU_DTRACE_BADADDR
219         bnez    t1, 2f
220         nop
221
222         bnez    a2, 1b
223         nop
224 2:
225         j       ra
226         nop
227 END(dtrace_copystr)
228
229 /*
230 void dtrace_invop_init(void)
231 */
232 LEAF(dtrace_invop_init)
233         /* XXX: impement it properly */
234         PTR_LA  t0, dtrace_invop_jump_addr
235         /* dla  t1, dtrace_invop_start */
236         PTR_S   zero, 0(t0)
237         j       ra
238         nop
239 END(dtrace_invop_init)
240
241 /*
242 void dtrace_invop_uninit(void)
243 */
244 LEAF(dtrace_invop_uninit)
245         PTR_LA  t0, dtrace_invop_jump_addr
246         PTR_S   zero, 0(t0)
247         j       ra
248         nop
249 END(dtrace_invop_uninit)
250
251 /*
252 uintptr_t
253 dtrace_caller(int aframes)
254 */
255 LEAF(dtrace_caller)
256         li      v0, -1
257         j       ra
258         nop
259 END(dtrace_caller)