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