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 * Portions Copyright 2012,2013 Justin Hibbits <jhibbits@freebsd.org>
23 *
24 * $FreeBSD: stable/10/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S 283676 2015-05-29 04:01:39Z markj $
25 */
26/*
27 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28 * Use is subject to license terms.
29 */
30
31#include "assym.s"
32
33#define _ASM
34
35#include <sys/cpuvar_defs.h>
36#include <sys/dtrace.h>
37
38#include <machine/asm.h>
39/*
40#include <machine/cpu.h>
41*/
42
43/*
44 * Primitives
45 */
46
47        .text
48
49/*
50void dtrace_membar_producer(void)
51*/
52ASENTRY_NOPROF(dtrace_membar_producer)
53	sync
54	blr
55END(dtrace_membar_producer)
56
57/*
58void dtrace_membar_consumer(void)
59*/
60ASENTRY_NOPROF(dtrace_membar_consumer)
61	isync
62	blr
63END(dtrace_membar_consumer)
64
65/*
66dtrace_icookie_t dtrace_interrupt_disable(void)
67*/
68ASENTRY_NOPROF(dtrace_interrupt_disable)
69	mfmsr	%r3
70	andi.	%r0,%r3,~PSL_EE@l
71	mtmsr	%r0
72	blr
73END(dtrace_interrupt_disable)
74
75/*
76void dtrace_interrupt_enable(dtrace_icookie_t cookie)
77*/
78ASENTRY_NOPROF(dtrace_interrupt_enable)
79	mtmsr	%r3
80	blr
81END(dtrace_interrupt_enable)
82
83/*
84uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
85*/
86ASENTRY_NOPROF(dtrace_cas32)
871:
88	lwarx	%r0,0,%r3
89	cmpw	%r4,%r0
90	bne	2f
91	stwcx.	%r5,0,%r3
92	bne	1b
932:	mr	%r3,%r0
94	blr
95END(dtrace_cas32)
96
97/*
98void *
99dtrace_casptr(void *target, void *cmp, void *new)
100*/
101ASENTRY_NOPROF(dtrace_casptr)
102#ifdef __powerpc64__
1031:
104	ldarx	%r0,0,%r3
105	cmpd	%r4,%r0
106	bne	2f
107	stdcx.	%r5,0,%r3
108	bne	1b
109#else
1101:
111	lwarx	%r0,0,%r3
112	cmpw	%r4,%r0
113	bne	2f
114	stwcx.	%r5,0,%r3
115	bne	1b
116#endif
1172:	mr	%r3,%r0
118	blr
119END(dtrace_casptr)
120
121
122/*
123XXX: unoptimized
124void
125dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
126*/
127ASENTRY_NOPROF(dtrace_copy)
128	subi	%r7,%r3,1
129	subi	%r8,%r4,1
130	mtctr	%r5
1311:
132	lbzu	%r3,1(%r7)
133	stbu	%r3,1(%r8)
134	bdnz	1b
1352:
136	blr
137END(dtrace_copy)
138
139/*
140void
141dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
142    volatile uint16_t *flags)
143*/
144ASENTRY_NOPROF(dtrace_copystr)
145	addme	%r7,%r3
146	addme	%r8,%r4
1471:
148	lbzu	%r3,1(%r7)
149	stbu	%r3,1(%r8)
150	addme	%r5,%r5
151	beq	2f
152	or	%r3,%r3,%r3
153	beq	2f
154	andi.	%r0,%r5,0x0fff
155	beq	2f
156	lwz	%r0,0(%r6)
157	andi.	%r0,%r0,CPU_DTRACE_BADADDR
158	beq	1b
1592:
160	blr
161END(dtrace_copystr)
162
163/*
164uintptr_t
165dtrace_caller(int aframes)
166*/
167ASENTRY_NOPROF(dtrace_caller)
168	li	%r3, -1
169	blr
170END(dtrace_caller)
171