]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/sdt_ppc.c
xnu-1228.0.2.tar.gz
[apple/xnu.git] / bsd / dev / ppc / sdt_ppc.c
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* #pragma ident "@(#)sdt.c 1.6 06/03/24 SMI" */
27
28 #ifdef KERNEL
29 #ifndef _KERNEL
30 #define _KERNEL /* Solaris vs. Darwin */
31 #endif
32 #endif
33
34 #define MACH__POSIX_C_SOURCE_PRIVATE 1 /* pulls in suitable savearea from mach/ppc/thread_status.h */
35 #include <kern/cpu_data.h>
36 #include <kern/thread.h>
37 #include <mach/thread_status.h>
38
39 #include <sys/dtrace.h>
40 #include <sys/dtrace_impl.h>
41
42 #include <sys/dtrace_glue.h>
43
44 #include <sys/sdt_impl.h>
45 #include <machine/cpu_capabilities.h>
46
47 extern sdt_probe_t **sdt_probetab;
48
49 /*ARGSUSED*/
50 int
51 sdt_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
52 {
53 uint64_t mask = (_cpu_capabilities & k64Bit) ? 0xffffffffffffffffULL : 0x00000000ffffffffULL;
54
55 #pragma unused(eax)
56 sdt_probe_t *sdt = sdt_probetab[SDT_ADDR2NDX(addr)];
57
58 for (; sdt != NULL; sdt = sdt->sdp_hashnext) {
59 if ((uintptr_t)sdt->sdp_patchpoint == addr) {
60 ppc_saved_state_t *regs = (ppc_saved_state_t *)stack;
61
62 dtrace_probe(sdt->sdp_id, regs->save_r3 & mask, regs->save_r4 & mask,
63 regs->save_r5 & mask, regs->save_r6 & mask, regs->save_r7 & mask);
64
65 return (DTRACE_INVOP_NOP);
66 }
67 }
68
69 return (0);
70 }
71