dtrace_asm.S revision 283676
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: stable/10/sys/cddl/dev/dtrace/mips/dtrace_asm.S 283676 2015-05-29 04:01:39Z markj $
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/*
52void dtrace_membar_producer(void)
53*/
54LEAF(dtrace_membar_producer)
55	j	ra
56	nop
57END(dtrace_membar_producer)
58
59/*
60void dtrace_membar_consumer(void)
61*/
62LEAF(dtrace_membar_consumer)
63	j	ra
64	nop
65END(dtrace_membar_consumer)
66
67/*
68dtrace_icookie_t dtrace_interrupt_disable(void)
69*/
70LEAF(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
78END(dtrace_interrupt_disable)
79
80/*
81void dtrace_interrupt_enable(dtrace_icookie_t cookie)
82*/
83LEAF(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
88not_enabled:
89	j	ra
90	nop
91END(dtrace_interrupt_enable)
92
93/*
94uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
95*/
96LEAF(dtrace_cas32)
971:
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
1052:	move	v0, t0
106	j	ra
107	nop
108END(dtrace_cas32)
109
110/*
111void *
112dtrace_casptr(void *target, void *cmp, void *new)
113*/
114LEAF(dtrace_casptr)
1151:
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
1232:	move	v0, t0
124	j	ra
125	nop
126END(dtrace_casptr)
127
128
129/*
130uintptr_t
131dtrace_fulword(void *addr)
132*/
133LEAF(dtrace_fulword)
134END(dtrace_fulword)
135
136/*
137uint8_t
138dtrace_fuword8_nocheck(void *addr)
139*/
140LEAF(dtrace_fuword8_nocheck)
141	lbu	v0, 0(a0)
142	j	ra
143	nop
144END(dtrace_fuword8_nocheck)
145
146/*
147uint16_t
148dtrace_fuword16_nocheck(void *addr)
149*/
150LEAF(dtrace_fuword16_nocheck)
151	lhu	v0, 0(a0)
152	j	ra
153	nop
154END(dtrace_fuword16_nocheck)
155
156/*
157uint32_t
158dtrace_fuword32_nocheck(void *addr)
159*/
160LEAF(dtrace_fuword32_nocheck)
161	lw	v0, 0(a0)
162	j	ra
163	nop
164END(dtrace_fuword32_nocheck)
165
166/*
167uint64_t
168dtrace_fuword64_nocheck(void *addr)
169*/
170LEAF(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
179END(dtrace_fuword64_nocheck)
180
181/*
182XXX: unoptimized
183void
184dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
185*/
186LEAF(dtrace_copy)
1871:
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
1972:
198	j	ra
199	nop
200END(dtrace_copy)
201
202/*
203XXX: Unoptimized. Check for flags on page boundaries only(?)
204void
205dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
206    volatile uint16_t *flags)
207*/
208LEAF(dtrace_copystr)
2091:
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
2242:
225	j	ra
226	nop
227END(dtrace_copystr)
228
229/*
230void dtrace_invop_init(void)
231*/
232LEAF(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
239END(dtrace_invop_init)
240
241/*
242void dtrace_invop_uninit(void)
243*/
244LEAF(dtrace_invop_uninit)
245	PTR_LA	t0, dtrace_invop_jump_addr
246	PTR_S	zero, 0(t0)
247	j	ra
248	nop
249END(dtrace_invop_uninit)
250
251/*
252uintptr_t
253dtrace_caller(int aframes)
254*/
255LEAF(dtrace_caller)
256	li	v0, -1
257	j	ra
258	nop
259END(dtrace_caller)
260