]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/cddl/dev/dtrace/powerpc/dtrace_asm.S
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / cddl / dev / dtrace / powerpc / dtrace_asm.S
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$
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 /*
50 void dtrace_membar_producer(void)
51 */
52 ASENTRY_NOPROF(dtrace_membar_producer)
53         sync
54         blr
55 END(dtrace_membar_producer)
56
57 /*
58 void dtrace_membar_consumer(void)
59 */
60 ASENTRY_NOPROF(dtrace_membar_consumer)
61         isync
62         blr
63 END(dtrace_membar_consumer)
64
65 /*
66 dtrace_icookie_t dtrace_interrupt_disable(void)
67 */
68 ASENTRY_NOPROF(dtrace_interrupt_disable)
69         mfmsr   %r3
70         andi.   %r0,%r3,~PSL_EE@l
71         mtmsr   %r0
72         blr
73 END(dtrace_interrupt_disable)
74
75 /*
76 void dtrace_interrupt_enable(dtrace_icookie_t cookie)
77 */
78 ASENTRY_NOPROF(dtrace_interrupt_enable)
79         mtmsr   %r3
80         blr
81 END(dtrace_interrupt_enable)
82
83 /*
84 uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
85 */
86 ASENTRY_NOPROF(dtrace_cas32)
87 1:
88         lwarx   %r0,0,%r3
89         cmpw    %r4,%r0
90         bne     2f
91         stwcx.  %r5,0,%r3
92         bne     1b
93 2:      mr      %r3,%r0
94         blr
95 END(dtrace_cas32)
96
97 /*
98 void *
99 dtrace_casptr(void *target, void *cmp, void *new)
100 */
101 ASENTRY_NOPROF(dtrace_casptr)
102 #ifdef __powerpc64__
103 1:
104         ldarx   %r0,0,%r3
105         cmpd    %r4,%r0
106         bne     2f
107         stdcx.  %r5,0,%r3
108         bne     1b
109 #else
110 1:
111         lwarx   %r0,0,%r3
112         cmpw    %r4,%r0
113         bne     2f
114         stwcx.  %r5,0,%r3
115         bne     1b
116 #endif
117 2:      mr      %r3,%r0
118         blr
119 END(dtrace_casptr)
120
121
122 /*
123 XXX: unoptimized
124 void
125 dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
126 */
127 ASENTRY_NOPROF(dtrace_copy)
128         subi    %r7,%r3,1
129         subi    %r8,%r4,1
130         mtctr   %r5
131 1:
132         lbzu    %r3,1(%r7)
133         stbu    %r3,1(%r8)
134         bdnz    1b
135 2:
136         blr
137 END(dtrace_copy)
138
139 /*
140 void
141 dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
142     volatile uint16_t *flags)
143 */
144 ASENTRY_NOPROF(dtrace_copystr)
145         addme   %r7,%r3
146         addme   %r8,%r4
147 1:
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
159 2:
160         blr
161 END(dtrace_copystr)
162
163 /*
164  * The panic() and cmn_err() functions invoke vpanic() as a common entry point
165  * into the panic code implemented in panicsys().  vpanic() is responsible
166  * for passing through the format string and arguments, and constructing a
167  * regs structure on the stack into which it saves the current register
168  * values.  If we are not dying due to a fatal trap, these registers will
169  * then be preserved in panicbuf as the current processor state.  Before
170  * invoking panicsys(), vpanic() activates the first panic trigger (see
171  * common/os/panic.c) and switches to the panic_stack if successful.  Note that
172  * DTrace takes a slightly different panic path if it must panic from probe
173  * context.  Instead of calling panic, it calls into dtrace_vpanic(), which
174  * sets up the initial stack as vpanic does, calls dtrace_panic_trigger(), and
175  * branches back into vpanic().
176  */
177
178 /*
179 void
180 vpanic(const char *format, va_list alist)
181 */
182 ASENTRY_NOPROF(vpanic)                          /* Initial stack layout: */
183         
184 vpanic_common:
185         blr
186 END(vpanic)
187
188
189
190 /*
191 void
192 dtrace_vpanic(const char *format, va_list alist)
193 */
194 ASENTRY_NOPROF(dtrace_vpanic)                   /* Initial stack layout: */
195
196 #if 0
197         bl      dtrace_panic_trigger    /* %eax = dtrace_panic_trigger() */
198 #endif
199         b       vpanic_common
200 END(dtrace_vpanic)
201
202 /*
203 uintptr_t
204 dtrace_caller(int aframes)
205 */
206 ASENTRY_NOPROF(dtrace_caller)
207         li      %r3, -1
208         blr
209 END(dtrace_caller)
210