xref: /titanic_44/usr/src/cmd/mdb/common/kmdb/kmdb_auxv.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _KMDB_AUXV_H
28 #define	_KMDB_AUXV_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * The kmdb_auxv is the interface between the driver and the debugger portions
34  * of kmdb.  It is used for three purposes:
35  *
36  *  1) To pass system-specific configuration information to the debugger.  This
37  *     information is used by the debugger to tailor itself to the running
38  *     system.
39  *
40  *  2) To pass debugger state information to the driver.
41  *
42  *  3) To configure the DPI.
43  *
44  * We use this somewhat torturous method to initialize and configure kmdb due to
45  * the somewhat unique requirements of kmdb as a pseudo-standalone debugger.
46  * The debugger portion of kmdb is compiled as a standalone, without any
47  * external dependencies.  As a result, it cannot communicate directly to the
48  * outside world.  Any such communications must be through functions passed to
49  * it by the driver.  The auxv provides a means by which these pointers and
50  * other parameters may be passed to the debugger.
51  */
52 
53 #include <gelf.h>
54 #include <sys/machelf.h>
55 #include <sys/kdi.h>
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 typedef struct kmdb_auxv_nv {
62 	char kanv_name[25];
63 	char kanv_val[50];
64 } kmdb_auxv_nv_t;
65 
66 #define	KMDB_AUXV_FL_NOUNLOAD	0x1	/* don't allow debugger unload */
67 #define	KMDB_AUXV_FL_NOTRPSWTCH	0x2	/* don't switch to kmdb's TBA/IDT */
68 
69 typedef struct kmdb_auxv {
70 	caddr_t		kav_dseg;		/* Base of segdebug */
71 	size_t		kav_dseg_size;		/* Size of segdebug */
72 	size_t		kav_pagesize;		/* Base page size */
73 	int		kav_ncpu;		/* Maximum number of CPUs */
74 	kdi_t		*kav_kdi;		/* Ops vector for KDI */
75 	void		*kav_romp;		/* Opaque PROM handle */
76 
77 #ifdef __sparc
78 	int		*kav_promexitarmp;	/* PROM exit kmdb entry armer */
79 
80 	caddr_t		kav_tba_active;		/* Trap table to be used */
81 	caddr_t		kav_tba_obp;		/* OBP's trap table */
82 #ifdef	sun4v
83 	caddr_t		kav_tba_kernel;		/* Kernel's trap table */
84 #endif
85 	caddr_t		kav_tba_native;		/* kmdb's trap table */
86 	size_t		kav_tba_native_sz;	/* kmdb's trap table size */
87 #endif
88 
89 #if defined(__i386) || defined(__amd64)
90 	kmdb_auxv_nv_t	*kav_pcache;		/* Copies of common props */
91 	int		kav_nprops;		/* Size of prop cache */
92 #endif
93 
94 	uintptr_t (*kav_lookup_by_name)(char *, char *); /* Live kernel only */
95 
96 	void (*kav_wrintr_fire)(void);		/* Send softint to driver */
97 
98 	const char	*kav_config;		/* State string from MDB */
99 	const char	**kav_argv;		/* Args from boot line */
100 	uint_t		kav_flags;		/* KMDB_AUXV_FL_* */
101 
102 	const char	*kav_modpath;		/* kernel module_path */
103 
104 #ifdef __sparc
105 	void (*kav_ktrap_install)(int, void (*)(void)); /* Add to krnl trptbl */
106 	void (*kav_ktrap_restore)(void);	/* Restore krnl trap hdlrs */
107 #endif
108 
109 } kmdb_auxv_t;
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* _KMDB_AUXV_H */
116