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 /*
30  * The kmdb_auxv is the interface between the driver and the debugger portions
31  * of kmdb.  It is used for three purposes:
32  *
33  *  1) To pass system-specific configuration information to the debugger.  This
34  *     information is used by the debugger to tailor itself to the running
35  *     system.
36  *
37  *  2) To pass debugger state information to the driver.
38  *
39  *  3) To configure the DPI.
40  *
41  * We use this somewhat torturous method to initialize and configure kmdb due to
42  * the somewhat unique requirements of kmdb as a pseudo-standalone debugger.
43  * The debugger portion of kmdb is compiled as a standalone, without any
44  * external dependencies.  As a result, it cannot communicate directly to the
45  * outside world.  Any such communications must be through functions passed to
46  * it by the driver.  The auxv provides a means by which these pointers and
47  * other parameters may be passed to the debugger.
48  */
49 
50 #include <gelf.h>
51 #include <sys/machelf.h>
52 #include <sys/kdi.h>
53 #ifdef sun4v
54 #include <sys/obpdefs.h>
55 #endif
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 #ifdef sun4v
108 	uint_t		kav_domaining;		/* Domaining status */
109 	caddr_t		kav_promif_root;	/* PROM shadow tree root */
110 	ihandle_t	kav_promif_in;		/* PROM input dev instance */
111 	ihandle_t	kav_promif_out;		/* PROM output dev instance */
112 	phandle_t	kav_promif_pin;		/* PROM input dev package */
113 	phandle_t	kav_promif_pout;	/* PROM output dev package */
114 	pnode_t		kav_promif_chosennode;	/* PROM "/chosen" node */
115 	pnode_t		kav_promif_optionsnode;	/* PROM "/options" node */
116 #endif
117 #endif
118 
119 } kmdb_auxv_t;
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* _KMDB_AUXV_H */
126