dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / uts / intel / dtrace / dtrace_asm.s
blobfc49d65b8e27f5de3230701924a7b9b61a5f010f
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 * Copyright 2015 Joyent, Inc.
29 #include <sys/asm_linkage.h>
30 #include <sys/regset.h>
32 #include "assym.h"
35 #if defined(__amd64)
37 ENTRY_NP(dtrace_getfp)
38 movq %rbp, %rax
39 ret
40 SET_SIZE(dtrace_getfp)
42 #elif defined(__i386)
44 ENTRY_NP(dtrace_getfp)
45 movl %ebp, %eax
46 ret
47 SET_SIZE(dtrace_getfp)
49 #endif /* __i386 */
53 #if defined(__amd64)
55 ENTRY_NP(dtrace_getvmreg)
57 movq %rdi, %rdx
58 vmread %rdx, %rax
59 ret
61 SET_SIZE(dtrace_getvmreg)
63 #elif defined(__i386)
65 ENTRY_NP(dtrace_getvmreg)
66 pushl %ebp / Setup stack frame
67 movl %esp, %ebp
69 movl 12(%ebp), %eax / Load flag pointer
70 movw (%eax), %cx / Load flags
71 orw $CPU_DTRACE_ILLOP, %cx / Set ILLOP
72 movw %cx, (%eax) / Store flags
74 leave
75 ret
76 SET_SIZE(dtrace_getvmreg)
78 #endif /* __i386 */
82 #if defined(__amd64)
84 ENTRY(dtrace_cas32)
85 movl %esi, %eax
86 lock
87 cmpxchgl %edx, (%rdi)
88 ret
89 SET_SIZE(dtrace_cas32)
91 ENTRY(dtrace_casptr)
92 movq %rsi, %rax
93 lock
94 cmpxchgq %rdx, (%rdi)
95 ret
96 SET_SIZE(dtrace_casptr)
98 #elif defined(__i386)
100 ENTRY(dtrace_cas32)
101 ALTENTRY(dtrace_casptr)
102 movl 4(%esp), %edx
103 movl 8(%esp), %eax
104 movl 12(%esp), %ecx
105 lock
106 cmpxchgl %ecx, (%edx)
108 SET_SIZE(dtrace_casptr)
109 SET_SIZE(dtrace_cas32)
111 #endif /* __i386 */
114 #if defined(__amd64)
115 ENTRY(dtrace_caller)
116 movq $-1, %rax
118 SET_SIZE(dtrace_caller)
120 #elif defined(__i386)
122 ENTRY(dtrace_caller)
123 movl $-1, %eax
125 SET_SIZE(dtrace_caller)
127 #endif /* __i386 */
130 #if defined(__amd64)
132 ENTRY(dtrace_copy)
133 pushq %rbp
134 call smap_disable
135 movq %rsp, %rbp
137 xchgq %rdi, %rsi /* make %rsi source, %rdi dest */
138 movq %rdx, %rcx /* load count */
139 repz /* repeat for count ... */
140 smovb /* move from %ds:rsi to %ed:rdi */
141 call smap_enable
142 leave
144 SET_SIZE(dtrace_copy)
146 #elif defined(__i386)
148 ENTRY(dtrace_copy)
149 pushl %ebp
150 movl %esp, %ebp
151 pushl %esi
152 pushl %edi
154 movl 8(%ebp), %esi / Load source address
155 movl 12(%ebp), %edi / Load destination address
156 movl 16(%ebp), %ecx / Load count
157 repz / Repeat for count...
158 smovb / move from %ds:si to %es:di
160 popl %edi
161 popl %esi
162 movl %ebp, %esp
163 popl %ebp
165 SET_SIZE(dtrace_copy)
167 #endif /* __i386 */
170 #if defined(__amd64)
172 ENTRY(dtrace_copystr)
173 pushq %rbp
174 movq %rsp, %rbp
175 call smap_disable
177 movb (%rdi), %al /* load from source */
178 movb %al, (%rsi) /* store to destination */
179 addq $1, %rdi /* increment source pointer */
180 addq $1, %rsi /* increment destination pointer */
181 subq $1, %rdx /* decrement remaining count */
182 cmpb $0, %al
183 je 2f
184 testq $0xfff, %rdx /* test if count is 4k-aligned */
185 jnz 1f /* if not, continue with copying */
186 testq $CPU_DTRACE_BADADDR, (%rcx) /* load and test dtrace flags */
187 jnz 2f
189 cmpq $0, %rdx
190 jne 0b
192 call smap_enable
193 leave
196 SET_SIZE(dtrace_copystr)
198 #elif defined(__i386)
200 ENTRY(dtrace_copystr)
202 pushl %ebp / Setup stack frame
203 movl %esp, %ebp
204 pushl %ebx / Save registers
206 movl 8(%ebp), %ebx / Load source address
207 movl 12(%ebp), %edx / Load destination address
208 movl 16(%ebp), %ecx / Load count
211 movb (%ebx), %al / Load from source
212 movb %al, (%edx) / Store to destination
213 incl %ebx / Increment source pointer
214 incl %edx / Increment destination pointer
215 decl %ecx / Decrement remaining count
216 cmpb $0, %al
217 je 2f
218 testl $0xfff, %ecx / Check if count is 4k-aligned
219 jnz 1f
220 movl 20(%ebp), %eax / load flags pointer
221 testl $CPU_DTRACE_BADADDR, (%eax) / load and test dtrace flags
222 jnz 2f
224 cmpl $0, %ecx
225 jne 0b
228 popl %ebx
229 movl %ebp, %esp
230 popl %ebp
233 SET_SIZE(dtrace_copystr)
235 #endif /* __i386 */
237 #if defined(__amd64)
239 ENTRY(dtrace_fulword)
240 call smap_disable
241 movq (%rdi), %rax
242 call smap_enable
244 SET_SIZE(dtrace_fulword)
246 #elif defined(__i386)
248 ENTRY(dtrace_fulword)
249 movl 4(%esp), %ecx
250 xorl %eax, %eax
251 movl (%ecx), %eax
253 SET_SIZE(dtrace_fulword)
255 #endif /* __i386 */
257 #if defined(__amd64)
259 ENTRY(dtrace_fuword8_nocheck)
260 call smap_disable
261 xorq %rax, %rax
262 movb (%rdi), %al
263 call smap_enable
265 SET_SIZE(dtrace_fuword8_nocheck)
267 #elif defined(__i386)
269 ENTRY(dtrace_fuword8_nocheck)
270 movl 4(%esp), %ecx
271 xorl %eax, %eax
272 movzbl (%ecx), %eax
274 SET_SIZE(dtrace_fuword8_nocheck)
276 #endif /* __i386 */
278 #if defined(__amd64)
280 ENTRY(dtrace_fuword16_nocheck)
281 call smap_disable
282 xorq %rax, %rax
283 movw (%rdi), %ax
284 call smap_enable
286 SET_SIZE(dtrace_fuword16_nocheck)
288 #elif defined(__i386)
290 ENTRY(dtrace_fuword16_nocheck)
291 movl 4(%esp), %ecx
292 xorl %eax, %eax
293 movzwl (%ecx), %eax
295 SET_SIZE(dtrace_fuword16_nocheck)
297 #endif /* __i386 */
299 #if defined(__amd64)
301 ENTRY(dtrace_fuword32_nocheck)
302 call smap_disable
303 xorq %rax, %rax
304 movl (%rdi), %eax
305 call smap_enable
307 SET_SIZE(dtrace_fuword32_nocheck)
309 #elif defined(__i386)
311 ENTRY(dtrace_fuword32_nocheck)
312 movl 4(%esp), %ecx
313 xorl %eax, %eax
314 movl (%ecx), %eax
316 SET_SIZE(dtrace_fuword32_nocheck)
318 #endif /* __i386 */
320 #if defined(__amd64)
322 ENTRY(dtrace_fuword64_nocheck)
323 call smap_disable
324 movq (%rdi), %rax
325 call smap_enable
327 SET_SIZE(dtrace_fuword64_nocheck)
329 #elif defined(__i386)
331 ENTRY(dtrace_fuword64_nocheck)
332 movl 4(%esp), %ecx
333 xorl %eax, %eax
334 xorl %edx, %edx
335 movl (%ecx), %eax
336 movl 4(%ecx), %edx
338 SET_SIZE(dtrace_fuword64_nocheck)
340 #endif /* __i386 */
342 #if defined(__amd64)
344 ENTRY(dtrace_probe_error)
345 pushq %rbp
346 movq %rsp, %rbp
347 subq $0x8, %rsp
348 movq %r9, (%rsp)
349 movq %r8, %r9
350 movq %rcx, %r8
351 movq %rdx, %rcx
352 movq %rsi, %rdx
353 movq %rdi, %rsi
354 movl dtrace_probeid_error(%rip), %edi
355 call dtrace_probe
356 addq $0x8, %rsp
357 leave
359 SET_SIZE(dtrace_probe_error)
361 #elif defined(__i386)
363 ENTRY(dtrace_probe_error)
364 pushl %ebp
365 movl %esp, %ebp
366 pushl 0x1c(%ebp)
367 pushl 0x18(%ebp)
368 pushl 0x14(%ebp)
369 pushl 0x10(%ebp)
370 pushl 0xc(%ebp)
371 pushl 0x8(%ebp)
372 pushl dtrace_probeid_error
373 call dtrace_probe
374 movl %ebp, %esp
375 popl %ebp
377 SET_SIZE(dtrace_probe_error)
379 #endif /* __i386 */