xref: /illumos-gate/usr/src/cmd/mdb/common/kmdb/kmdb_wr_impl.h (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
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_WR_IMPL_H
28 #define	_KMDB_WR_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <kmdb/kmdb_wr.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define	WNTASK_DMOD_LOAD	0x0001		/* Load a specific dmod */
39 #define	WNTASK_DMOD_LOAD_ALL	0x0002		/* Load all dmods for kmods */
40 #define	WNTASK_DMOD_UNLOAD	0x0004		/* Unload a specific dmod */
41 #define	WNTASK_DMOD_PATH_CHANGE	0x0008		/* Change dmod search path */
42 
43 #define	WNFLAGS_NOFREE		0x0001		/* Don't free this wr on ack */
44 
45 #define	WNTASK_ACK		0x8000		/* Acknowledgement of req */
46 
47 #define	WR_ISACK(wr)		((((kmdb_wr_t *)(wr))->wn_task) & WNTASK_ACK)
48 #define	WR_ACK(wr)		(((kmdb_wr_t *)(wr))->wn_task) |= WNTASK_ACK
49 #define	WR_TASK(wr)		((((kmdb_wr_t *)(wr))->wn_task) & ~WNTASK_ACK)
50 
51 struct kmdb_wr {
52 	struct kmdb_wr		*wn_next;	/* List of work requests */
53 	struct kmdb_wr		*wn_prev;	/* List of work requests */
54 	ushort_t		wn_task;	/* Task to be performed */
55 	ushort_t		wn_flags;	/* Flags for this request */
56 	uint_t			wn_errno;	/* Status for completed reqs */
57 };
58 
59 /*
60  * Debugger-initiated loads: Debugger creates, passes to driver, driver loads
61  * the module, returns the request as an ack.  Driver-initiated loads: driver
62  * creates, loads module, passes to debugger as announcement, debugger returns
63  * as an ack.
64  */
65 typedef struct kmdb_wr_load {
66 	kmdb_wr_t		dlr_node;
67 
68 	/* Supplied by requestor */
69 	char			*dlr_fname;
70 
71 	/* Filled in by driver upon successful completion */
72 	struct modctl		*dlr_modctl;
73 
74 	/*
75 	 * Used by the driver to track outstanding driver-initiated
76 	 * notifications for leak prevention.
77 	 */
78 	struct kmdb_wr_load	*dlr_next;
79 	struct kmdb_wr_load	*dlr_prev;
80 } kmdb_wr_load_t;
81 
82 #define	dlr_errno	dlr_node.wn_errno
83 
84 /*
85  * The debugger creates a request for a module to be unloaded, and passes it
86  * to the driver.  The driver unloads the module, and returns the message to
87  * the debugger as an ack.
88  */
89 typedef struct kmdb_wr_unload {
90 	kmdb_wr_t		dur_node;
91 
92 	/* Supplied by requestor */
93 	char			*dur_modname;
94 	struct modctl		*dur_modctl;
95 } kmdb_wr_unload_t;
96 
97 #define	dur_errno	dur_node.wn_errno
98 
99 /*
100  * The debugger creates a new path-change "request" when the dmod search path
101  * changes, and sends it to the driver.  The driver hangs onto the request
102  * until either the path changes again or the debugger is unloaded.  Either way,
103  * the state change request is passed back at that time as an ack.
104  */
105 typedef struct kmdb_wr_path {
106 	kmdb_wr_t		dpth_node;
107 
108 	/* Supplied by requestor */
109 	const char		**dpth_path;
110 	size_t			dpth_pathlen;
111 } kmdb_wr_path_t;
112 
113 #define	dpth_errno	dpth_node.wn_errno
114 
115 #ifdef __cplusplus
116 }
117 #endif
118 
119 #endif /* _KMDB_WR_IMPL_H */
120