xref: /titanic_41/usr/src/cmd/mdb/common/kmdb/kmdb_auxv.h (revision 4ef27277d4e5e7e7a1883d95aebf0ae8710873d7)
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 #ifndef _KMDB_AUXV_H
27 #define	_KMDB_AUXV_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * The kmdb_auxv is the interface between the driver and the debugger portions
33  * of kmdb.  It is used for three purposes:
34  *
35  *  1) To pass system-specific configuration information to the debugger.  This
36  *     information is used by the debugger to tailor itself to the running
37  *     system.
38  *
39  *  2) To pass debugger state information to the driver.
40  *
41  *  3) To configure the DPI.
42  *
43  * We use this somewhat torturous method to initialize and configure kmdb due to
44  * the somewhat unique requirements of kmdb as a pseudo-standalone debugger.
45  * The debugger portion of kmdb is compiled as a standalone, without any
46  * external dependencies.  As a result, it cannot communicate directly to the
47  * outside world.  Any such communications must be through functions passed to
48  * it by the driver.  The auxv provides a means by which these pointers and
49  * other parameters may be passed to the debugger.
50  */
51 
52 #include <gelf.h>
53 #include <sys/machelf.h>
54 #include <sys/kdi.h>
55 #ifdef sun4v
56 #include <sys/obpdefs.h>
57 #endif
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 typedef struct kmdb_auxv_nv {
64 	char kanv_name[25];
65 	char kanv_val[50];
66 } kmdb_auxv_nv_t;
67 
68 #define	KMDB_AUXV_FL_NOUNLOAD	0x1	/* don't allow debugger unload */
69 #define	KMDB_AUXV_FL_NOTRPSWTCH	0x2	/* don't switch to kmdb's TBA/IDT */
70 
71 typedef struct kmdb_auxv {
72 	caddr_t		kav_dseg;		/* Base of segdebug */
73 	size_t		kav_dseg_size;		/* Size of segdebug */
74 	size_t		kav_pagesize;		/* Base page size */
75 	int		kav_ncpu;		/* Maximum number of CPUs */
76 	kdi_t		*kav_kdi;		/* Ops vector for KDI */
77 	void		*kav_romp;		/* Opaque PROM handle */
78 
79 #ifdef __sparc
80 	int		*kav_promexitarmp;	/* PROM exit kmdb entry armer */
81 
82 	caddr_t		kav_tba_active;		/* Trap table to be used */
83 	caddr_t		kav_tba_obp;		/* OBP's trap table */
84 #ifdef	sun4v
85 	caddr_t		kav_tba_kernel;		/* Kernel's trap table */
86 #endif
87 	caddr_t		kav_tba_native;		/* kmdb's trap table */
88 	size_t		kav_tba_native_sz;	/* kmdb's trap table size */
89 #endif
90 
91 #if defined(__i386) || defined(__amd64)
92 	kmdb_auxv_nv_t	*kav_pcache;		/* Copies of common props */
93 	int		kav_nprops;		/* Size of prop cache */
94 #endif
95 
96 	uintptr_t (*kav_lookup_by_name)(char *, char *); /* Live kernel only */
97 
98 	void (*kav_wrintr_fire)(void);		/* Send softint to driver */
99 
100 	const char	*kav_config;		/* State string from MDB */
101 	const char	**kav_argv;		/* Args from boot line */
102 	uint_t		kav_flags;		/* KMDB_AUXV_FL_* */
103 
104 	const char	*kav_modpath;		/* kernel module_path */
105 
106 #ifdef __sparc
107 	void (*kav_ktrap_install)(int, void (*)(void)); /* Add to krnl trptbl */
108 	void (*kav_ktrap_restore)(void);	/* Restore krnl trap hdlrs */
109 #ifdef sun4v
110 	uint_t		kav_domaining;		/* Domaining status */
111 	caddr_t		kav_promif_root;	/* PROM shadow tree root */
112 	ihandle_t	kav_promif_in;		/* PROM input dev instance */
113 	ihandle_t	kav_promif_out;		/* PROM output dev instance */
114 	phandle_t	kav_promif_pin;		/* PROM input dev package */
115 	phandle_t	kav_promif_pout;	/* PROM output dev package */
116 	pnode_t		kav_promif_chosennode;	/* PROM "/chosen" node */
117 	pnode_t		kav_promif_optionsnode;	/* PROM "/options" node */
118 #endif
119 #endif
120 
121 } kmdb_auxv_t;
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif /* _KMDB_AUXV_H */
128