xref: /freebsd/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S (revision 9bc300465e48e19d794d88d0c158a2adb92c7197)
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#include <sys/elf_common.h>
33
34#include <machine/armreg.h>
35#include <machine/asm.h>
36
37#include "assym.inc"
38
39/*
40void dtrace_membar_producer(void)
41*/
42ENTRY(dtrace_membar_producer)
43	RET
44END(dtrace_membar_producer)
45
46/*
47void dtrace_membar_consumer(void)
48*/
49ENTRY(dtrace_membar_consumer)
50	RET
51END(dtrace_membar_consumer)
52
53/*
54dtrace_icookie_t dtrace_interrupt_disable(void)
55*/
56ENTRY(dtrace_interrupt_disable)
57	mrs	x0, daif
58	msr	daifset, #2
59	RET
60END(dtrace_interrupt_disable)
61
62/*
63void dtrace_interrupt_enable(dtrace_icookie_t cookie)
64*/
65ENTRY(dtrace_interrupt_enable)
66	msr	daif, x0
67	RET
68END(dtrace_interrupt_enable)
69/*
70uint8_t
71dtrace_fuword8_nocheck(void *addr)
72*/
73ENTRY(dtrace_fuword8_nocheck)
74	ldtrb	w0, [x0]
75	RET
76END(dtrace_fuword8_nocheck)
77
78/*
79uint16_t
80dtrace_fuword16_nocheck(void *addr)
81*/
82ENTRY(dtrace_fuword16_nocheck)
83	ldtrh	w0, [x0]
84	RET
85END(dtrace_fuword16_nocheck)
86
87/*
88uint32_t
89dtrace_fuword32_nocheck(void *addr)
90*/
91ENTRY(dtrace_fuword32_nocheck)
92	ldtr	w0, [x0]
93	RET
94END(dtrace_fuword32_nocheck)
95
96/*
97uint64_t
98dtrace_fuword64_nocheck(void *addr)
99*/
100ENTRY(dtrace_fuword64_nocheck)
101	ldtr	x0, [x0]
102	RET
103END(dtrace_fuword64_nocheck)
104
105/*
106void
107dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size)
108*/
109ENTRY(dtrace_copy)
110	cbz	x2, 2f		/* If len == 0 then skip loop */
1111:
112	ldtrb	w4, [x0]	/* Load from uaddr */
113	add	x0, x0, #1
114	strb	w4, [x1], #1	/* Store in kaddr */
115	sub	x2, x2, #1	/* len-- */
116	cbnz	x2, 1b
1172:
118	RET
119END(dtrace_copy)
120
121/*
122void
123dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
124    volatile uint16_t *flags)
125XXX: Check for flags?
126*/
127ENTRY(dtrace_copystr)
128	cbz     x2, 2f          /* If len == 0 then skip loop */
1291:
130	ldtrb	w4, [x0]	/* Load from uaddr */
131	add	x0, x0, #1
132	strb    w4, [x1], #1    /* Store in kaddr */
133	cbz     w4, 2f          /* If == 0 then break */
134	sub     x2, x2, #1      /* len-- */
135	cbnz    x2, 1b
1362:
137	RET
138END(dtrace_copystr)
139
140/*
141uintptr_t
142dtrace_caller(int aframes)
143*/
144ENTRY(dtrace_caller)
145	mov	x0, #-1
146	RET
147END(dtrace_caller)
148
149/*
150uint32_t
151dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
152*/
153ENTRY(dtrace_cas32)
1541:	ldxr	w3, [x0]	/* Load target */
155	cmp	w3, w1		/* Check if *target == cmp */
156	bne	2f		/* No, return */
157	stxr	w12, w2, [x0]	/* Store new to target */
158	cbnz	w12, 1b		/* Try again if store not succeed */
1592:	mov	w0, w3		/* Return the value loaded from target */
160	RET
161END(dtrace_cas32)
162
163/*
164void *
165dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)
166*/
167ENTRY(dtrace_casptr)
1681:	ldxr	x3, [x0]	/* Load target */
169	cmp	x3, x1		/* Check if *target == cmp */
170	bne	2f		/* No, return */
171	stxr	w12, x2, [x0]	/* Store new to target */
172	cbnz	w12, 1b		/* Try again if store not succeed */
1732:	mov	x0, x3		/* Return the value loaded from target */
174	RET
175END(dtrace_casptr)
176
177GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
178