dtrace_asm.S revision 248457
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: head/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S 248457 2013-03-18 05:30:18Z jhibbits $
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	blr
54END(dtrace_membar_producer)
55
56/*
57void dtrace_membar_consumer(void)
58*/
59ASENTRY_NOPROF(dtrace_membar_consumer)
60	blr
61END(dtrace_membar_consumer)
62
63/*
64dtrace_icookie_t dtrace_interrupt_disable(void)
65*/
66ASENTRY_NOPROF(dtrace_interrupt_disable)
67	mfmsr	%r3
68	andi.	%r0,%r3,~PSL_EE@l
69	mtmsr	%r0
70	blr
71END(dtrace_interrupt_disable)
72
73/*
74void dtrace_interrupt_enable(dtrace_icookie_t cookie)
75*/
76ASENTRY_NOPROF(dtrace_interrupt_enable)
77	mtmsr	%r3
78	blr
79END(dtrace_interrupt_enable)
80
81/*
82uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
83*/
84ASENTRY_NOPROF(dtrace_cas32)
851:
86	lwarx	%r0,0,%r3
87	cmpw	%r4,%r0
88	bne	2f
89	stwcx.	%r5,0,%r3
90	bne	1b
912:	mr	%r3,%r0
92	blr
93END(dtrace_cas32)
94
95/*
96void *
97dtrace_casptr(void *target, void *cmp, void *new)
98*/
99ASENTRY_NOPROF(dtrace_casptr)
1001:
101	lwarx	%r0,0,%r3
102	cmpw	%r4,%r0
103	bne	2f
104	stwcx.	%r5,0,%r3
105	bne	1b
1062:	mr	%r3,%r0
107	blr
108END(dtrace_casptr)
109
110
111/*
112XXX: unoptimized
113void
114dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
115*/
116ASENTRY_NOPROF(dtrace_copy)
117	addme	%r7,%r3
118	addme	%r8,%r4
1191:
120	lbzu	%r3,1(%r7)
121	stbu	%r3,1(%r8)
122	addme	%r5,%r5
123	beq	2f
1242:
125	blr
126END(dtrace_copy)
127
128/*
129void
130dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
131    volatile uint16_t *flags)
132*/
133ASENTRY_NOPROF(dtrace_copystr)
134	addme	%r7,%r3
135	addme	%r8,%r4
1361:
137	lbzu	%r3,1(%r7)
138	stbu	%r3,1(%r8)
139	addme	%r5,%r5
140	beq	2f
141	or	%r3,%r3,%r3
142	beq	2f
143	andi.	%r0,%r5,0x0fff
144	beq	2f
145	lwz	%r0,0(%r6)
146	andi.	%r0,%r0,CPU_DTRACE_BADADDR
147	beq	1b
1482:
149	blr
150END(dtrace_copystr)
151
152/*
153 * The panic() and cmn_err() functions invoke vpanic() as a common entry point
154 * into the panic code implemented in panicsys().  vpanic() is responsible
155 * for passing through the format string and arguments, and constructing a
156 * regs structure on the stack into which it saves the current register
157 * values.  If we are not dying due to a fatal trap, these registers will
158 * then be preserved in panicbuf as the current processor state.  Before
159 * invoking panicsys(), vpanic() activates the first panic trigger (see
160 * common/os/panic.c) and switches to the panic_stack if successful.  Note that
161 * DTrace takes a slightly different panic path if it must panic from probe
162 * context.  Instead of calling panic, it calls into dtrace_vpanic(), which
163 * sets up the initial stack as vpanic does, calls dtrace_panic_trigger(), and
164 * branches back into vpanic().
165 */
166
167/*
168void
169vpanic(const char *format, va_list alist)
170*/
171ASENTRY_NOPROF(vpanic)				/* Initial stack layout: */
172
173vpanic_common:
174	blr
175END(vpanic)
176
177
178
179/*
180void
181dtrace_vpanic(const char *format, va_list alist)
182*/
183ASENTRY_NOPROF(dtrace_vpanic)			/* Initial stack layout: */
184
185#if 0
186	bl	dtrace_panic_trigger	/* %eax = dtrace_panic_trigger() */
187#endif
188	b	vpanic_common
189END(dtrace_vpanic)
190
191/*
192uintptr_t
193dtrace_caller(int aframes)
194*/
195ASENTRY_NOPROF(dtrace_caller)
196	li	%r3, -1
197	blr
198END(dtrace_caller)
199
200