xref: /freebsd/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S (revision 734e82fe33aa764367791a7d603b383996c6b40b)
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/*
23 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#define _ASM
28#define _LOCORE
29
30#include <sys/cpuvar_defs.h>
31#include <sys/dtrace.h>
32
33#include <machine/armreg.h>
34#include <machine/asm.h>
35
36#include "assym.inc"
37
38/*
39void dtrace_membar_producer(void)
40*/
41ENTRY(dtrace_membar_producer)
42	RET
43END(dtrace_membar_producer)
44
45/*
46void dtrace_membar_consumer(void)
47*/
48ENTRY(dtrace_membar_consumer)
49	RET
50END(dtrace_membar_consumer)
51
52/*
53dtrace_icookie_t dtrace_interrupt_disable(void)
54*/
55ENTRY(dtrace_interrupt_disable)
56	mrs	x0, daif
57	msr	daifset, #2
58	RET
59END(dtrace_interrupt_disable)
60
61/*
62void dtrace_interrupt_enable(dtrace_icookie_t cookie)
63*/
64ENTRY(dtrace_interrupt_enable)
65	msr	daif, x0
66	RET
67END(dtrace_interrupt_enable)
68/*
69uint8_t
70dtrace_fuword8_nocheck(void *addr)
71*/
72ENTRY(dtrace_fuword8_nocheck)
73	ldtrb	w0, [x0]
74	RET
75END(dtrace_fuword8_nocheck)
76
77/*
78uint16_t
79dtrace_fuword16_nocheck(void *addr)
80*/
81ENTRY(dtrace_fuword16_nocheck)
82	ldtrh	w0, [x0]
83	RET
84END(dtrace_fuword16_nocheck)
85
86/*
87uint32_t
88dtrace_fuword32_nocheck(void *addr)
89*/
90ENTRY(dtrace_fuword32_nocheck)
91	ldtr	w0, [x0]
92	RET
93END(dtrace_fuword32_nocheck)
94
95/*
96uint64_t
97dtrace_fuword64_nocheck(void *addr)
98*/
99ENTRY(dtrace_fuword64_nocheck)
100	ldtr	x0, [x0]
101	RET
102END(dtrace_fuword64_nocheck)
103
104/*
105void
106dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size)
107*/
108ENTRY(dtrace_copy)
109	cbz	x2, 2f		/* If len == 0 then skip loop */
1101:
111	ldtrb	w4, [x0]	/* Load from uaddr */
112	add	x0, x0, #1
113	strb	w4, [x1], #1	/* Store in kaddr */
114	sub	x2, x2, #1	/* len-- */
115	cbnz	x2, 1b
1162:
117	RET
118END(dtrace_copy)
119
120/*
121void
122dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
123    volatile uint16_t *flags)
124XXX: Check for flags?
125*/
126ENTRY(dtrace_copystr)
127	cbz     x2, 2f          /* If len == 0 then skip loop */
1281:
129	ldtrb	w4, [x0]	/* Load from uaddr */
130	add	x0, x0, #1
131	strb    w4, [x1], #1    /* Store in kaddr */
132	cbz     w4, 2f          /* If == 0 then break */
133	sub     x2, x2, #1      /* len-- */
134	cbnz    x2, 1b
1352:
136	RET
137END(dtrace_copystr)
138
139/*
140uintptr_t
141dtrace_caller(int aframes)
142*/
143ENTRY(dtrace_caller)
144	mov	x0, #-1
145	RET
146END(dtrace_caller)
147
148/*
149uint32_t
150dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
151*/
152ENTRY(dtrace_cas32)
1531:	ldxr	w3, [x0]	/* Load target */
154	cmp	w3, w1		/* Check if *target == cmp */
155	bne	2f		/* No, return */
156	stxr	w12, w2, [x0]	/* Store new to target */
157	cbnz	w12, 1b		/* Try again if store not succeed */
1582:	mov	w0, w3		/* Return the value loaded from target */
159	RET
160END(dtrace_cas32)
161
162/*
163void *
164dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)
165*/
166ENTRY(dtrace_casptr)
1671:	ldxr	x3, [x0]	/* Load target */
168	cmp	x3, x1		/* Check if *target == cmp */
169	bne	2f		/* No, return */
170	stxr	w12, x2, [x0]	/* Store new to target */
171	cbnz	w12, 1b		/* Try again if store not succeed */
1722:	mov	x0, x3		/* Return the value loaded from target */
173	RET
174END(dtrace_casptr)
175