xref: /illumos-gate/usr/src/uts/sun4v/os/kldc.c (revision 51396a8ee7fb52fe0ab33bfe7b4f495ad431904a)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/param.h>
27 
28 /*
29  * In-Kernel Logical Domain Channel (LDC) Functionality
30  *
31  * Provides a mechanism for LDC channels to be reset when entering
32  * the prom or kmdb by invoking a callback before entry.
33  */
34 
35 /*
36  * Setting this to zero disables debug_enter/debug_exit callbacks
37  * which may be useful when debugging LDC related issues.
38  */
39 static int kldc_callback_enabled = 1;
40 
41 /*
42  * Callback function pointer.
43  */
44 static void (*kldc_debug_enter_cb)(void);
45 
46 void
47 kldc_set_debug_cb(void (*debug_enter_cb)(void))
48 {
49 	kldc_debug_enter_cb = debug_enter_cb;
50 }
51 
52 /*
53  * Called just before entering the prom or kmdb but after all other CPUs
54  * have entered the idle loop.
55  */
56 void
57 kldc_debug_enter(void)
58 {
59 	if (kldc_callback_enabled != 0 && kldc_debug_enter_cb != NULL) {
60 		(*kldc_debug_enter_cb)();
61 	}
62 }
63