2 * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <mach/boolean.h>
31 #include <mach/mach_types.h>
33 #include <sys/syscall.h>
34 #include <sys/types.h> /* u_int */
35 #include <sys/proc.h> /* proc_t */
36 #include <sys/systm.h> /* struct sysent */
37 #include <sys/sysproto.h>
39 #pragma mark **** kern debug ****
40 typedef void (*chudxnu_kdebug_callback_func_t
)(uint32_t debugid
, uint32_t arg0
, uint32_t arg1
, uint32_t arg2
, uint32_t arg3
, uint32_t arg4
);
41 static chudxnu_kdebug_callback_func_t kdebug_callback_fn
= NULL
;
43 kern_return_t
chudxnu_kdebug_callback_enter(chudxnu_kdebug_callback_func_t
);
44 kern_return_t
chudxnu_kdebug_callback_cancel(void);
46 extern void kdbg_control_chud(int val
, void *fn
);
47 extern unsigned int kdebug_enable
;
50 chudxnu_private_kdebug_callback(
58 chudxnu_kdebug_callback_func_t fn
= kdebug_callback_fn
;
61 (fn
)(debugid
, arg0
, arg1
, arg2
, arg3
, arg4
);
65 __private_extern__ kern_return_t
66 chudxnu_kdebug_callback_enter(chudxnu_kdebug_callback_func_t func
)
68 kdebug_callback_fn
= func
;
70 kdbg_control_chud(TRUE
, (void *)chudxnu_private_kdebug_callback
);
71 kdebug_enable
|= 0x10;
76 __private_extern__ kern_return_t
77 chudxnu_kdebug_callback_cancel(void)
79 kdebug_callback_fn
= NULL
;
80 kdbg_control_chud(FALSE
, NULL
);
81 kdebug_enable
&= ~(0x10);
86 #pragma mark **** CHUD syscall ****
87 typedef kern_return_t (*chudxnu_syscall_callback_func_t
)(uint32_t code
, uint32_t arg0
, uint32_t arg1
, uint32_t arg2
, uint32_t arg3
, uint32_t arg4
);
88 static chudxnu_syscall_callback_func_t syscall_callback_fn
= NULL
;
90 kern_return_t
chudxnu_syscall_callback_enter(chudxnu_syscall_callback_func_t func
);
91 kern_return_t
chudxnu_syscall_callback_cancel(void);
94 chud(__unused proc_t p
, struct chud_args
*uap
, register_t
*retval
)
96 chudxnu_syscall_callback_func_t fn
= syscall_callback_fn
;
102 *retval
= fn(uap
->code
, uap
->arg1
, uap
->arg2
, uap
->arg3
, uap
->arg4
, uap
->arg5
);
107 __private_extern__ kern_return_t
108 chudxnu_syscall_callback_enter(chudxnu_syscall_callback_func_t func
)
110 syscall_callback_fn
= func
;
114 __private_extern__ kern_return_t
115 chudxnu_syscall_callback_cancel(void)
117 syscall_callback_fn
= NULL
;