]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/arm/sdt_isa.h
2 * Copyright (c) 2007 Apple Inc. All rights reserved.
7 * The contents of this file are subject to the terms of the
8 * Common Development and Distribution License, Version 1.0 only
9 * (the "License"). You may not use this file except in compliance
12 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13 * or http://www.opensolaris.org/os/licensing.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
17 * When distributing Covered Code, include this CDDL HEADER in each
18 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19 * If applicable, add the following below this CDDL HEADER, with the
20 * fields enclosed by brackets "[]" replaced with your own identifying
21 * information: Portions Copyright [yyyy] [name of copyright owner]
26 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #ifndef _MACH_ARM_SDT_ISA_H
31 #define _MACH_ARM_SDT_ISA_H
34 * Only define when testing. This makes the calls into actual calls to
37 /* #define DTRACE_CALL_TEST */
39 #define DTRACE_STRINGIFY(s) #s
40 #define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s)
44 * For the kernel, set an explicit global label so the symbol can be located
48 #define DTRACE_LABEL(p, n) \
49 ".pushsection __DATA, __sdt_cstring, cstring_literals\n\t" \
50 "1: .ascii \"" DTRACE_STRINGIFY(p##___) "\\0\"\n\t" \
51 "2: .ascii \"" DTRACE_STRINGIFY(n) "\\0\"\n\t" \
52 ".popsection" "\n\t" \
53 ".pushsection __DATA, __sdt, regular, live_support\n\t" \
59 ".popsection" "\n\t" \
63 #define DTRACE_LABEL(p, n) \
64 ".pushsection __DATA, __sdt_cstring, cstring_literals\n\t" \
65 "1: .ascii \"" DTRACE_STRINGIFY(p##___) "\\0\"\n\t" \
66 "2: .ascii \"" DTRACE_STRINGIFY(n) "\\0\"\n\t" \
67 ".popsection" "\n\t" \
68 ".pushsection __DATA, __sdt, regular, live_support\n\t" \
74 ".popsection" "\n\t" \
78 #define DTRACE_LABEL(p, n) \
79 "__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t"
82 #ifdef DTRACE_CALL_TEST
84 #define DTRACE_CALL(p, n) \
88 #else /* !DTRACE_CALL_TEST */
90 #define DTRACE_CALL(p, n) \
94 #endif /* !DTRACE_CALL_TEST */
101 #define DTRACE_CALL_INSN(p, n) \
102 "blx _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
105 #define DTRACE_ALLOC_STACK(n) \
106 "sub sp, #" #n "\n\t"
107 #define DTRACE_DEALLOC_STACK(n) \
108 "add sp, #" #n "\n\t"
110 #define DTRACE_ALLOC_STACK(n) \
111 "sub sp, sp, #" #n "\n\t"
112 #define DTRACE_DEALLOC_STACK(n) \
113 "add sp, sp, #" #n "\n\t"
116 #define ARG1_EXTENT 1
117 #define ARGS2_EXTENT 2
118 #define ARGS3_EXTENT 3
119 #define ARGS4_EXTENT 4
120 #define ARGS5_EXTENT 5
121 #define ARGS6_EXTENT 6
122 #define ARGS7_EXTENT 7
123 #define ARGS8_EXTENT 8
124 #define ARGS9_EXTENT 9
125 #define ARGS10_EXTENT 10
127 #define DTRACE_CALL0ARGS(provider, name) \
129 DTRACE_CALL(provider, name) \
130 "# eat trailing nl+tab from DTRACE_CALL" \
135 #define DTRACE_CALL1ARG(provider, name) \
136 asm volatile ("ldr r0, [%0]" "\n\t" \
137 DTRACE_CALL(provider, name) \
139 : "l" (__dtrace_args) \
143 #define DTRACE_CALL2ARGS(provider, name) \
144 asm volatile ("ldr r1, [%0, #4]" "\n\t" \
145 "ldr r0, [%0]" "\n\t" \
146 DTRACE_CALL(provider, name) \
148 : "l" (__dtrace_args) \
149 : "memory", "r0", "r1" \
152 #define DTRACE_CALL3ARGS(provider, name) \
153 asm volatile ("ldr r2, [%0, #8]" "\n\t" \
154 "ldr r1, [%0, #4]" "\n\t" \
155 "ldr r0, [%0]" "\n\t" \
156 DTRACE_CALL(provider, name) \
158 : "l" (__dtrace_args) \
159 : "memory", "r0", "r1", "r2" \
162 #define DTRACE_CALL4ARGS(provider, name) \
163 asm volatile ("ldr r3, [%0, #12]" "\n\t" \
164 "ldr r2, [%0, #8]" "\n\t" \
165 "ldr r1, [%0, #4]" "\n\t" \
166 "ldr r0, [%0]" "\n\t" \
167 DTRACE_CALL(provider, name) \
169 : "l" (__dtrace_args) \
170 : "memory", "r0", "r1", "r2", "r3" \
174 * One of our ARM32 ABIs (armv7k) mandates that the stack be aligned to 16 bytes.
175 * We currently apply this constraint to all ARM32 DTRACE_CALL macros; hence the
176 * macros below will overallocate for some ABIs.
178 #define DTRACE_CALL5ARGS(provider, name) \
180 DTRACE_ALLOC_STACK(16) \
181 "ldr r0, [%0, #16]" "\n\t" \
182 "str r0, [sp]" "\n\t" \
183 "ldr r3, [%0, #12]" "\n\t" \
184 "ldr r2, [%0, #8]" "\n\t" \
185 "ldr r1, [%0, #4]" "\n\t" \
186 "ldr r0, [%0]" "\n\t" \
187 DTRACE_CALL(provider, name) \
188 DTRACE_DEALLOC_STACK(16) \
190 : "l" (__dtrace_args) \
191 : "memory", "r0", "r1", "r2", "r3" \
194 #define DTRACE_CALL6ARGS(provider, name) \
196 DTRACE_ALLOC_STACK(16) \
197 "ldr r1, [%0, #20]" "\n\t" \
198 "ldr r0, [%0, #16]" "\n\t" \
199 "str r1, [sp, #4]" "\n\t" \
200 "str r0, [sp]" "\n\t" \
201 "ldr r3, [%0, #12]" "\n\t" \
202 "ldr r2, [%0, #8]" "\n\t" \
203 "ldr r1, [%0, #4]" "\n\t" \
204 "ldr r0, [%0]" "\n\t" \
205 DTRACE_CALL(provider, name) \
206 DTRACE_DEALLOC_STACK(16) \
208 : "l" (__dtrace_args) \
209 : "memory", "r0", "r1", "r2", "r3" \
212 #define DTRACE_CALL7ARGS(provider, name) \
214 DTRACE_ALLOC_STACK(16) \
215 "ldr r2, [%0, #24]" "\n\t" \
216 "ldr r1, [%0, #20]" "\n\t" \
217 "ldr r0, [%0, #16]" "\n\t" \
218 "str r2, [sp, #8]" "\n\t" \
219 "str r1, [sp, #4]" "\n\t" \
220 "str r0, [sp]" "\n\t" \
221 "ldr r3, [%0, #12]" "\n\t" \
222 "ldr r2, [%0, #8]" "\n\t" \
223 "ldr r1, [%0, #4]" "\n\t" \
224 "ldr r0, [%0]" "\n\t" \
225 DTRACE_CALL(provider, name) \
226 DTRACE_DEALLOC_STACK(16) \
228 : "l" (__dtrace_args) \
229 : "memory", "r0", "r1", "r2", "r3" \
232 #define DTRACE_CALL8ARGS(provider, name) \
234 DTRACE_ALLOC_STACK(16) \
235 "ldr r3, [%0, #28]" "\n\t" \
236 "ldr r2, [%0, #24]" "\n\t" \
237 "ldr r1, [%0, #20]" "\n\t" \
238 "ldr r0, [%0, #16]" "\n\t" \
239 "str r3, [sp, #12]" "\n\t" \
240 "str r2, [sp, #8]" "\n\t" \
241 "str r1, [sp, #4]" "\n\t" \
242 "str r0, [sp]" "\n\t" \
243 "ldr r3, [%0, #12]" "\n\t" \
244 "ldr r2, [%0, #8]" "\n\t" \
245 "ldr r1, [%0, #4]" "\n\t" \
246 "ldr r0, [%0]" "\n\t" \
247 DTRACE_CALL(provider, name) \
248 DTRACE_DEALLOC_STACK(16) \
250 : "l" (__dtrace_args) \
251 : "memory", "r0", "r1", "r2", "r3" \
254 #define DTRACE_CALL9ARGS(provider, name) \
256 DTRACE_ALLOC_STACK(32) \
257 "ldr r0, [%0, #32]" "\n\t" \
258 "str r0, [sp, #16]" "\n\t" \
259 "ldr r3, [%0, #28]" "\n\t" \
260 "ldr r2, [%0, #24]" "\n\t" \
261 "ldr r1, [%0, #20]" "\n\t" \
262 "ldr r0, [%0, #16]" "\n\t" \
263 "str r3, [sp, #12]" "\n\t" \
264 "str r2, [sp, #8]" "\n\t" \
265 "str r1, [sp, #4]" "\n\t" \
266 "str r0, [sp]" "\n\t" \
267 "ldr r3, [%0, #12]" "\n\t" \
268 "ldr r2, [%0, #8]" "\n\t" \
269 "ldr r1, [%0, #4]" "\n\t" \
270 "ldr r0, [%0]" "\n\t" \
271 DTRACE_CALL(provider, name) \
272 DTRACE_DEALLOC_STACK(32) \
274 : "l" (__dtrace_args) \
275 : "memory", "r0", "r1", "r2", "r3" \
278 #define DTRACE_CALL10ARGS(provider, name) \
280 DTRACE_ALLOC_STACK(32) \
281 "ldr r1, [%0, #36]" "\n\t" \
282 "ldr r0, [%0, #32]" "\n\t" \
283 "str r1, [sp, #20]" "\n\t" \
284 "str r0, [sp, #16]" "\n\t" \
285 "ldr r3, [%0, #28]" "\n\t" \
286 "ldr r2, [%0, #24]" "\n\t" \
287 "ldr r1, [%0, #20]" "\n\t" \
288 "ldr r0, [%0, #16]" "\n\t" \
289 "str r3, [sp, #12]" "\n\t" \
290 "str r2, [sp, #8]" "\n\t" \
291 "str r1, [sp, #4]" "\n\t" \
292 "str r0, [sp]" "\n\t" \
293 "ldr r3, [%0, #12]" "\n\t" \
294 "ldr r2, [%0, #8]" "\n\t" \
295 "ldr r1, [%0, #4]" "\n\t" \
296 "ldr r0, [%0]" "\n\t" \
297 DTRACE_CALL(provider, name) \
298 DTRACE_DEALLOC_STACK(32) \
300 : "l" (__dtrace_args) \
301 : "memory", "r0", "r1", "r2", "r3" \
304 #elif defined(__arm64__)
306 #define DTRACE_NOPS \
310 #define DTRACE_CALL_INSN(p, n) \
311 "bl _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
313 #define DTRACE_ALLOC_STACK(n) \
314 "sub sp, sp, #" #n "\n\t"
315 #define DTRACE_DEALLOC_STACK(n) \
316 "add sp, sp, #" #n "\n\t"
318 #define ARG1_EXTENT 1
319 #define ARGS2_EXTENT 2
320 #define ARGS3_EXTENT 3
321 #define ARGS4_EXTENT 4
322 #define ARGS5_EXTENT 5
323 #define ARGS6_EXTENT 6
324 #define ARGS7_EXTENT 7
325 #define ARGS8_EXTENT 8
326 #define ARGS9_EXTENT 9
327 #define ARGS10_EXTENT 10
329 #define DTRACE_CALL0ARGS(provider, name) \
331 DTRACE_CALL(provider, name) \
332 "# eat trailing nl+tab from DTRACE_CALL" \
337 #define DTRACE_CALL1ARG(provider, name) \
338 asm volatile ("ldr x0, [%0]" "\n\t" \
339 DTRACE_CALL(provider, name) \
341 : "r" (__dtrace_args) \
345 #define DTRACE_CALL2ARGS(provider, name) \
346 asm volatile ("ldp x0, x1, [%0]" "\n\t" \
347 DTRACE_CALL(provider, name) \
349 : "r" (__dtrace_args) \
350 : "memory", "x0", "x1" \
353 #define DTRACE_CALL3ARGS(provider, name) \
354 asm volatile ("ldr x2, [%0, #16]" "\n\t" \
355 "ldp x0, x1, [%0]" "\n\t" \
356 DTRACE_CALL(provider, name) \
358 : "r" (__dtrace_args) \
359 : "memory", "x0", "x1", "x2" \
362 #define DTRACE_CALL4ARGS(provider, name) \
363 asm volatile ("ldp x2, x3, [%0, #16]" "\n\t" \
364 "ldp x0, x1, [%0]" "\n\t" \
365 DTRACE_CALL(provider, name) \
367 : "r" (__dtrace_args) \
368 : "memory", "x0", "x1", "x2", "x3" \
371 #define DTRACE_CALL5ARGS(provider, name) \
372 asm volatile ("ldr x4, [%0, #32]" "\n\t" \
373 "ldp x2, x3, [%0, #16]" "\n\t" \
374 "ldp x0, x1, [%0]" "\n\t" \
375 DTRACE_CALL(provider, name) \
377 : "r" (__dtrace_args) \
378 : "memory", "x0", "x1", "x2", "x3", "x4" \
381 #define DTRACE_CALL6ARGS(provider, name) \
382 asm volatile ("ldp x4, x5, [%0, #32]" "\n\t" \
383 "ldp x2, x3, [%0, #16]" "\n\t" \
384 "ldp x0, x1, [%0]" "\n\t" \
385 DTRACE_CALL(provider, name) \
387 : "r" (__dtrace_args) \
388 : "memory", "x0", "x1", "x2", "x3", "x4", "x5" \
391 #define DTRACE_CALL7ARGS(provider, name) \
392 asm volatile ("ldr x6, [%0, #48]" "\n\t" \
393 "ldp x4, x5, [%0, #32]" "\n\t" \
394 "ldp x2, x3, [%0, #16]" "\n\t" \
395 "ldp x0, x1, [%0]" "\n\t" \
396 DTRACE_CALL(provider, name) \
398 : "r" (__dtrace_args) \
399 : "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6" \
402 #define DTRACE_CALL8ARGS(provider, name) \
403 asm volatile ("ldp x6, x7, [%0, #48]" "\n\t" \
404 "ldp x4, x5, [%0, #32]" "\n\t" \
405 "ldp x2, x3, [%0, #16]" "\n\t" \
406 "ldp x0, x1, [%0]" "\n\t" \
407 DTRACE_CALL(provider, name) \
409 : "r" (__dtrace_args) \
410 : "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7" \
413 /* Keep stack 16 byte aligned per ABI requirements */
414 #define DTRACE_CALL9ARGS(provider, name) \
416 DTRACE_ALLOC_STACK(16) \
417 "ldr x0, [%0, #64]" "\n\t" \
418 "str x0, [sp]" "\n\t" \
419 "ldp x6, x7, [%0, #48]" "\n\t" \
420 "ldp x4, x5, [%0, #32]" "\n\t" \
421 "ldp x2, x3, [%0, #16]" "\n\t" \
422 "ldp x0, x1, [%0]" "\n\t" \
423 DTRACE_CALL(provider, name) \
424 DTRACE_DEALLOC_STACK(16) \
426 : "r" (__dtrace_args) \
427 : "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7" \
430 #define DTRACE_CALL10ARGS(provider, name) \
432 DTRACE_ALLOC_STACK(16) \
433 "ldp x0, x1, [%0, #64]" "\n\t" \
434 "stp x0, x1, [sp]" "\n\t" \
435 "ldp x6, x7, [%0, #48]" "\n\t" \
436 "ldp x4, x5, [%0, #32]" "\n\t" \
437 "ldp x2, x3, [%0, #16]" "\n\t" \
438 "ldp x0, x1, [%0]" "\n\t" \
439 DTRACE_CALL(provider, name) \
440 DTRACE_DEALLOC_STACK(16) \
442 : "r" (__dtrace_args) \
443 : "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7" \
448 #endif /* _MACH_ARM_SDT_ISA_H */