]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/ppc/sdt_isa.h
xnu-1504.7.4.tar.gz
[apple/xnu.git] / osfmk / mach / ppc / sdt_isa.h
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 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _MACH_PPC_SDT_ISA_H
28 #define _MACH_PPC_SDT_ISA_H
29
30 /* #pragma ident "@(#)sdt.h 1.7 05/06/08 SMI" */
31
32 /*
33 * Only define when testing. This makes the calls into actual calls to
34 * test functions.
35 */
36 /* #define DTRACE_CALL_TEST */
37
38 #define DTRACE_STRINGIFY(s) #s
39 #define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s)
40
41 #if defined(KERNEL)
42 /*
43 * For the kernel, set an explicit global label so the symbol can be located
44 */
45 #define DTRACE_LAB(p, n) \
46 "__dtrace_probe$" DTRACE_TOSTRING(__LINE__) DTRACE_STRINGIFY(_##p##___##n)
47 #define DTRACE_LABEL(p, n) \
48 ".section __DATA, __data\n\t" \
49 ".globl " DTRACE_LAB(p, n) "\n\t" \
50 DTRACE_LAB(p, n) ":" ".long 1f""\n\t" \
51 ".text" "\n\t" \
52 "1:"
53 #else /* !KERNEL */
54 #define DTRACE_LABEL(p, n) \
55 "__dtrace_probe$" DTRACE_TOSTRING(__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t"
56 #endif /* !KERNEL */
57
58 #ifdef DTRACE_CALL_TEST
59
60 #define DTRACE_CALL(p,n) \
61 DTRACE_LABEL(p,n) \
62 DTRACE_CALL_INSN(p,n)
63
64 #else /* !DTRACE_CALL_TEST */
65
66 #define DTRACE_CALL(p,n) \
67 DTRACE_LABEL(p,n) \
68 DTRACE_NOPS
69
70 #endif /* !DTRACE_CALL_TEST */
71
72 #ifdef __ppc__
73
74 #define DTRACE_NOPS \
75 "nop" "\n\t"
76
77 #define DTRACE_CALL_INSN(p,n) \
78 "bl _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
79
80 #define ARG1_EXTENT 1
81 #define ARGS2_EXTENT 2
82 #define ARGS3_EXTENT 3
83 #define ARGS4_EXTENT 4
84 #define ARGS5_EXTENT 5
85 #define ARGS6_EXTENT 6
86 #define ARGS7_EXTENT 7
87 #define ARGS8_EXTENT 8
88 #define ARGS9_EXTENT 9
89 #define ARGS10_EXTENT 10
90
91 #define DTRACE_CALL0ARGS(provider, name) \
92 asm volatile ( \
93 DTRACE_CALL(provider, name) \
94 "# eat trailing nl+tab from DTRACE_CALL" \
95 : \
96 : \
97 );
98
99 #define DTRACE_CALL1ARG(provider, name) \
100 asm volatile ("subi r1,r1,0x20" "\n\t" \
101 "lwz r3,0x0(%0)" "\n\t" \
102 DTRACE_CALL(provider, name) \
103 "addi r1,r1,0x20" \
104 : \
105 : "b" (__dtrace_args) \
106 : "memory", "r3" \
107 );
108
109 #define DTRACE_CALL2ARGS(provider, name) \
110 asm volatile ("subi r1,r1,0x20" "\n\t" \
111 "lwz r3,0x0(%0)" "\n\t" \
112 "lwz r4,0x4(%0)" "\n\t" \
113 DTRACE_CALL(provider, name) \
114 "addi r1,r1,0x20" \
115 : \
116 : "b" (__dtrace_args) \
117 : "memory", "r3", "r4" \
118 );
119
120 #define DTRACE_CALL3ARGS(provider, name) \
121 asm volatile ("subi r1,r1,0x30" "\n\t" \
122 "lwz r3,0x0(%0)" "\n\t" \
123 "lwz r4,0x4(%0)" "\n\t" \
124 "lwz r5,0x8(%0)" "\n\t" \
125 DTRACE_CALL(provider, name) \
126 "addi r1,r1,0x30" \
127 : \
128 : "b" (__dtrace_args) \
129 : "memory", "r3", "r4", "r5" \
130 );
131
132 #define DTRACE_CALL4ARGS(provider, name) \
133 asm volatile ("subi r1,r1,0x30" "\n\t" \
134 "lwz r3,0x0(%0)" "\n\t" \
135 "lwz r4,0x4(%0)" "\n\t" \
136 "lwz r5,0x8(%0)" "\n\t" \
137 "lwz r6,0xc(%0)" "\n\t" \
138 DTRACE_CALL(provider, name) \
139 "addi r1,r1,0x30" \
140 : \
141 : "b" (__dtrace_args) \
142 : "memory", "r3", "r4", "r5", "r6" \
143 );
144
145 #define DTRACE_CALL5ARGS(provider, name) \
146 asm volatile ("subi r1,r1,0x30" "\n\t" \
147 "lwz r3,0x0(%0)" "\n\t" \
148 "lwz r4,0x4(%0)" "\n\t" \
149 "lwz r5,0x8(%0)" "\n\t" \
150 "lwz r6,0xc(%0)" "\n\t" \
151 "lwz r7,0x10(%0)" "\n\t" \
152 DTRACE_CALL(provider, name) \
153 "addi r1,r1,0x30" \
154 : \
155 : "b" (__dtrace_args) \
156 : "memory", "r3", "r4", "r5", "r6", "r7" \
157 );
158
159 #define DTRACE_CALL6ARGS(provider, name) \
160 asm volatile ("subi r1,r1,0x30" "\n\t" \
161 "lwz r3,0x0(%0)" "\n\t" \
162 "lwz r4,0x4(%0)" "\n\t" \
163 "lwz r5,0x8(%0)" "\n\t" \
164 "lwz r6,0xc(%0)" "\n\t" \
165 "lwz r7,0x10(%0)" "\n\t" \
166 "lwz r8,0x14(%0)" "\n\t" \
167 DTRACE_CALL(provider, name) \
168 "addi r1,r1,0x30" \
169 : \
170 : "b" (__dtrace_args) \
171 : "memory", "r3", "r4", "r5", "r6", "r7", "r8" \
172 );
173
174 #define DTRACE_CALL7ARGS(provider, name) \
175 asm volatile ("subi r1,r1,0x40" "\n\t" \
176 "lwz r3,0x0(%0)" "\n\t" \
177 "lwz r4,0x4(%0)" "\n\t" \
178 "lwz r5,0x8(%0)" "\n\t" \
179 "lwz r6,0xc(%0)" "\n\t" \
180 "lwz r7,0x10(%0)" "\n\t" \
181 "lwz r8,0x14(%0)" "\n\t" \
182 "lwz r9,0x18(%0)" "\n\t" \
183 DTRACE_CALL(provider, name) \
184 "addi r1,r1,0x40" \
185 : \
186 : "b" (__dtrace_args) \
187 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
188 );
189
190 #define DTRACE_CALL8ARGS(provider, name) \
191 asm volatile ("subi r1,r1,0x40" "\n\t" \
192 "lwz r3,0x0(%0)" "\n\t" \
193 "lwz r4,0x4(%0)" "\n\t" \
194 "lwz r5,0x8(%0)" "\n\t" \
195 "lwz r6,0xc(%0)" "\n\t" \
196 "lwz r7,0x10(%0)" "\n\t" \
197 "lwz r8,0x14(%0)" "\n\t" \
198 "lwz r9,0x18(%0)" "\n\t" \
199 "lwz r10,0x1c(%0)" "\n\t" \
200 DTRACE_CALL(provider, name) \
201 "addi r1,r1,0x40" \
202 : \
203 : "b" (__dtrace_args) \
204 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10" \
205 );
206
207 #define DTRACE_CALL9ARGS(provider, name) \
208 asm volatile ("subi r1,r1,0x40" "\n\t" \
209 "lwz r3,0x0(%0)" "\n\t" \
210 "lwz r4,0x4(%0)" "\n\t" \
211 "lwz r5,0x8(%0)" "\n\t" \
212 "lwz r6,0xc(%0)" "\n\t" \
213 "lwz r7,0x10(%0)" "\n\t" \
214 "lwz r8,0x14(%0)" "\n\t" \
215 "lwz r9,0x18(%0)" "\n\t" \
216 "lwz r10,0x1c(%0)" "\n\t" \
217 "lwz r11,0x20(%0)" "\n\t" \
218 "stw r11,0x38(r1)" "\n\t" \
219 DTRACE_CALL(provider, name) \
220 "addi r1,r1,0x40" \
221 : \
222 : "b" (__dtrace_args) \
223 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11" \
224 );
225
226 #define DTRACE_CALL10ARGS(provider, name) \
227 asm volatile ("subi r1,r1,0x40" "\n\t" \
228 "lwz r3,0x0(%0)" "\n\t" \
229 "lwz r4,0x4(%0)" "\n\t" \
230 "lwz r5,0x8(%0)" "\n\t" \
231 "lwz r6,0xc(%0)" "\n\t" \
232 "lwz r7,0x10(%0)" "\n\t" \
233 "lwz r8,0x14(%0)" "\n\t" \
234 "lwz r9,0x18(%0)" "\n\t" \
235 "lwz r10,0x1c(%0)" "\n\t" \
236 "lwz r11,0x20(%0)" "\n\t" \
237 "lwz r12,0x24(%0)" "\n\t" \
238 "stw r11,0x38(r1)" "\n\t" \
239 "stw r12,0x3c(r1)" "\n\t" \
240 DTRACE_CALL(provider, name) \
241 "addi r1,r1,0x40" \
242 : \
243 : "b" (__dtrace_args) \
244 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" \
245 );
246
247 #endif // __ppc__
248
249 #ifdef __ppc64__
250
251 #define DTRACE_NOPS \
252 "nop" "\n\t"
253
254 #define DTRACE_CALL_INSN(p,n) \
255 "bl _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
256
257 #define ARG1_EXTENT 1
258 #define ARGS2_EXTENT 2
259 #define ARGS3_EXTENT 3
260 #define ARGS4_EXTENT 4
261 #define ARGS5_EXTENT 5
262 #define ARGS6_EXTENT 6
263 #define ARGS7_EXTENT 7
264 #define ARGS8_EXTENT 8
265 #define ARGS9_EXTENT 9
266 #define ARGS10_EXTENT 10
267
268 #define DTRACE_CALL0ARGS(provider, name) \
269 asm volatile ("subi r1,r1,0x30" "\n\t" \
270 DTRACE_CALL(provider, name) \
271 "addi r1,r1,0x30" \
272 : \
273 : \
274 : \
275 );
276
277 #define DTRACE_CALL1ARG(provider, name) \
278 asm volatile ("ld r3,0x0(%0)" "\n\t" \
279 "subi r1,r1,0x38" "\n\t" \
280 DTRACE_CALL(provider, name) \
281 "addi r1,r1,0x38" \
282 : \
283 : "b" (__dtrace_args) \
284 : "memory", "r3" \
285 );
286
287 #define DTRACE_CALL2ARGS(provider, name) \
288 asm volatile ("subi r1,r1,0x40" "\n\t" \
289 "ld r3,0x0(%0)" "\n\t" \
290 "ld r4,0x8(%0)" "\n\t" \
291 DTRACE_CALL(provider, name) \
292 "addi r1,r1,0x40" \
293 : \
294 : "b" (__dtrace_args) \
295 : "memory", "r3", "r4" \
296 );
297
298 #define DTRACE_CALL3ARGS(provider, name) \
299 asm volatile ("subi r1,r1,0x48" "\n\t" \
300 "ld r3,0x0(%0)" "\n\t" \
301 "ld r4,0x8(%0)" "\n\t" \
302 "ld r5,0x10(%0)" "\n\t" \
303 DTRACE_CALL(provider, name) \
304 "addi r1,r1,0x48" \
305 : \
306 : "b" (__dtrace_args) \
307 : "memory", "r3", "r4", "r5" \
308 );
309
310 #define DTRACE_CALL4ARGS(provider, name) \
311 asm volatile ("subi r1,r1,0x50" "\n\t" \
312 "ld r3,0x0(%0)" "\n\t" \
313 "ld r4,0x8(%0)" "\n\t" \
314 "ld r5,0x10(%0)" "\n\t" \
315 "ld r6,0x18(%0)" "\n\t" \
316 DTRACE_CALL(provider, name) \
317 "addi r1,r1,0x50" \
318 : \
319 : "b" (__dtrace_args) \
320 : "memory", "r3", "r4", "r5", "r6" \
321 );
322
323 #define DTRACE_CALL5ARGS(provider, name) \
324 asm volatile ("subi r1,r1,0x58" "\n\t" \
325 "ld r3,0x0(%0)" "\n\t" \
326 "ld r4,0x8(%0)" "\n\t" \
327 "ld r5,0x10(%0)" "\n\t" \
328 "ld r6,0x18(%0)" "\n\t" \
329 "ld r7,0x20(%0)" "\n\t" \
330 DTRACE_CALL(provider, name) \
331 "addi r1,r1,0x58" \
332 : \
333 : "b" (__dtrace_args) \
334 : "memory", "r3", "r4", "r5", "r6", "r7" \
335 );
336
337 #define DTRACE_CALL6ARGS(provider, name) \
338 asm volatile ("subi r1,r1,0x60" "\n\t" \
339 "ld r3,0x0(%0)" "\n\t" \
340 "ld r4,0x8(%0)" "\n\t" \
341 "ld r5,0x10(%0)" "\n\t" \
342 "ld r6,0x18(%0)" "\n\t" \
343 "ld r7,0x20(%0)" "\n\t" \
344 "ld r8,0x28(%0)" "\n\t" \
345 DTRACE_CALL(provider, name) \
346 "addi r1,r1,0x60" \
347 : \
348 : "b" (__dtrace_args) \
349 : "memory", "r3", "r4", "r5", "r6", "r7", "r8" \
350 );
351
352 #define DTRACE_CALL7ARGS(provider, name) \
353 asm volatile ("subi r1,r1,0x68" "\n\t" \
354 "ld r3,0x0(%0)" "\n\t" \
355 "ld r4,0x8(%0)" "\n\t" \
356 "ld r5,0x10(%0)" "\n\t" \
357 "ld r6,0x18(%0)" "\n\t" \
358 "ld r7,0x20(%0)" "\n\t" \
359 "ld r8,0x28(%0)" "\n\t" \
360 "ld r9,0x30(%0)" "\n\t" \
361 DTRACE_CALL(provider, name) \
362 "addi r1,r1,0x68" \
363 : \
364 : "b" (__dtrace_args) \
365 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
366 );
367
368 #define DTRACE_CALL8ARGS(provider, name) \
369 asm volatile ("subi r1,r1,0x70" "\n\t" \
370 "ld r3,0x0(%0)" "\n\t" \
371 "ld r4,0x8(%0)" "\n\t" \
372 "ld r5,0x10(%0)" "\n\t" \
373 "ld r6,0x18(%0)" "\n\t" \
374 "ld r7,0x20(%0)" "\n\t" \
375 "ld r8,0x28(%0)" "\n\t" \
376 "ld r9,0x30(%0)" "\n\t" \
377 "ld r10,0x38(%0)" "\n\t" \
378 DTRACE_CALL(provider, name) \
379 "addi r1,r1,0x70" \
380 : \
381 : "b" (__dtrace_args) \
382 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10" \
383 );
384
385 #define DTRACE_CALL9ARGS(provider, name) \
386 asm volatile ("subi r1,r1,0x78" "\n\t" \
387 "ld r3,0x0(%0)" "\n\t" \
388 "ld r4,0x8(%0)" "\n\t" \
389 "ld r5,0x10(%0)" "\n\t" \
390 "ld r6,0x18(%0)" "\n\t" \
391 "ld r7,0x20(%0)" "\n\t" \
392 "ld r8,0x28(%0)" "\n\t" \
393 "ld r9,0x30(%0)" "\n\t" \
394 "ld r10,0x38(%0)" "\n\t" \
395 "ld r11,0x40(%0)" "\n\t" \
396 "std r11,0x70(r1)" "\n\t" \
397 DTRACE_CALL(provider, name) \
398 "addi r1,r1,0x78" \
399 : \
400 : "b" (__dtrace_args) \
401 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11" \
402 );
403
404 #define DTRACE_CALL10ARGS(provider, name) \
405 asm volatile ("subi r1,r1,0x80" "\n\t" \
406 "ld r3,0x0(%0)" "\n\t" \
407 "ld r4,0x8(%0)" "\n\t" \
408 "ld r5,0x10(%0)" "\n\t" \
409 "ld r6,0x18(%0)" "\n\t" \
410 "ld r7,0x20(%0)" "\n\t" \
411 "ld r8,0x28(%0)" "\n\t" \
412 "ld r9,0x30(%0)" "\n\t" \
413 "ld r10,0x38(%0)" "\n\t" \
414 "ld r11,0x40(%0)" "\n\t" \
415 "ld r12,0x48(%0)" "\n\t" \
416 "std r11,0x70(r1)" "\n\t" \
417 "std r12,0x78(r1)" "\n\t" \
418 DTRACE_CALL(provider, name) \
419 "addi r1,r1,0x80" \
420 : \
421 : "b" (__dtrace_args) \
422 : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" \
423 );
424
425 #endif // __ppc64__
426
427 #endif /* _MACH_PPC_SDT_ISA_H */