]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/chud/chud_bsd_callback.c
cd95c4900b00c388300f25d6b9715bec314eaff4
[apple/xnu.git] / bsd / dev / ppc / chud / chud_bsd_callback.c
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #include <stdint.h>
25 #include <mach/boolean.h>
26 #include <mach/mach_types.h>
27
28 #include <sys/syscall.h>
29 #include <sys/types.h> /* u_int */
30 #include <sys/proc.h> /* struct proc */
31 #include <sys/systm.h> /* struct sysent */
32 #include <sys/sysproto.h>
33
34 #pragma mark **** kern debug ****
35 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);
36 static chudxnu_kdebug_callback_func_t kdebug_callback_fn = NULL;
37
38 extern void kdbg_control_chudxnu(int val, void *fn);
39 extern unsigned int kdebug_enable;
40
41 static void chudxnu_private_kdebug_callback(unsigned int debugid, unsigned int arg0, unsigned int arg1, unsigned int arg2, unsigned int arg3, unsigned int arg4)
42 {
43 if(kdebug_callback_fn) {
44 (kdebug_callback_fn)(debugid, arg0, arg1, arg2, arg3, arg4);
45 }
46 }
47
48 __private_extern__
49 kern_return_t chudxnu_kdebug_callback_enter(chudxnu_kdebug_callback_func_t func)
50 {
51 kdebug_callback_fn = func;
52
53 kdbg_control_chud(TRUE, (void *)chudxnu_private_kdebug_callback);
54 kdebug_enable |= 0x10;
55
56 return KERN_SUCCESS;
57 }
58
59 __private_extern__
60 kern_return_t chudxnu_kdebug_callback_cancel(void)
61 {
62 kdebug_callback_fn = NULL;
63 kdbg_control_chud(FALSE, NULL);
64 kdebug_enable &= ~(0x10);
65
66 return KERN_SUCCESS;
67 }