xref: /titanic_41/usr/src/uts/common/sys/ddi_impldefs.h (revision 774ef820abb3ffe8f38adcc17dee852d45d871a0)
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 _SYS_DDI_IMPLDEFS_H
27 #define	_SYS_DDI_IMPLDEFS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <sys/t_lock.h>
34 #include <sys/ddipropdefs.h>
35 #include <sys/devops.h>
36 #include <sys/autoconf.h>
37 #include <sys/mutex.h>
38 #include <vm/page.h>
39 #include <sys/dacf_impl.h>
40 #include <sys/ndifm.h>
41 #include <sys/epm.h>
42 #include <sys/ddidmareq.h>
43 #include <sys/ddi_intr.h>
44 #include <sys/ddi_isa.h>
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 /*
51  * The device id implementation has been switched to be based on properties.
52  * For compatibility with di_devid libdevinfo interface the following
53  * must be defined:
54  */
55 #define	DEVID_COMPATIBILITY	((ddi_devid_t)-1)
56 
57 /*
58  * Definitions for node class.
59  * DDI_NC_PROM: a node with a nodeid that may be used in a promif call.
60  * DDI_NC_PSEUDO: a software created node with a software assigned nodeid.
61  */
62 typedef enum {
63 	DDI_NC_PROM = 0,
64 	DDI_NC_PSEUDO
65 } ddi_node_class_t;
66 
67 /*
68  * dev_info:	The main device information structure this is intended to be
69  *		opaque to drivers and drivers should use ddi functions to
70  *		access *all* driver accessible fields.
71  *
72  * devi_parent_data includes property lists (interrupts, registers, etc.)
73  * devi_driver_data includes whatever the driver wants to place there.
74  */
75 struct devinfo_audit;
76 
77 struct dev_info  {
78 
79 	struct dev_info *devi_parent;	/* my parent node in tree	*/
80 	struct dev_info *devi_child;	/* my child list head		*/
81 	struct dev_info *devi_sibling;	/* next element on my level	*/
82 
83 	char	*devi_binding_name;	/* name used to bind driver	*/
84 
85 	char	*devi_addr;		/* address part of name		*/
86 
87 	int	devi_nodeid;		/* device nodeid		*/
88 	int	devi_instance;		/* device instance number	*/
89 
90 	struct dev_ops *devi_ops;	/* driver operations		*/
91 
92 	void	*devi_parent_data;	/* parent private data		*/
93 	void	*devi_driver_data;	/* driver private data		*/
94 
95 	ddi_prop_t *devi_drv_prop_ptr;	/* head of driver prop list */
96 	ddi_prop_t *devi_sys_prop_ptr;	/* head of system prop list */
97 
98 	struct ddi_minor_data *devi_minor;	/* head of minor list */
99 	struct dev_info *devi_next;	/* Next instance of this device */
100 	kmutex_t devi_lock;		/* Protects per-devinfo data */
101 
102 	/* logical parents for busop primitives	 */
103 
104 	struct dev_info *devi_bus_map_fault;	/* bus_map_fault parent	 */
105 	struct dev_info *devi_bus_dma_map;	/* bus_dma_map parent	 */
106 	struct dev_info *devi_bus_dma_allochdl; /* bus_dma_newhdl parent */
107 	struct dev_info *devi_bus_dma_freehdl;  /* bus_dma_freehdl parent */
108 	struct dev_info *devi_bus_dma_bindhdl;  /* bus_dma_bindhdl parent */
109 	struct dev_info *devi_bus_dma_unbindhdl; /* bus_dma_unbindhdl parent */
110 	struct dev_info *devi_bus_dma_flush;    /* bus_dma_flush parent	 */
111 	struct dev_info *devi_bus_dma_win;	/* bus_dma_win parent	 */
112 	struct dev_info *devi_bus_dma_ctl;	/* bus_dma_ctl parent	 */
113 	struct dev_info	*devi_bus_ctl;		/* bus_ctl parent	 */
114 
115 	ddi_prop_t *devi_hw_prop_ptr;		/* head of hw prop list */
116 
117 	char	*devi_node_name;		/* The 'name' of the node */
118 	char	*devi_compat_names;		/* A list of driver names */
119 	size_t	devi_compat_length;		/* Size of compat_names */
120 
121 	int (*devi_bus_dma_bindfunc)(dev_info_t *, dev_info_t *,
122 	    ddi_dma_handle_t, struct ddi_dma_req *, ddi_dma_cookie_t *,
123 	    uint_t *);
124 	int (*devi_bus_dma_unbindfunc)(dev_info_t *, dev_info_t *,
125 	    ddi_dma_handle_t);
126 
127 #ifdef	DEVID_COMPATIBILITY
128 	ddi_devid_t	devi_devid;		/* registered device id */
129 #endif	/* DEVID_COMPATIBILITY */
130 	/*
131 	 * power management entries
132 	 * components exist even if the device is not currently power managed
133 	 */
134 	struct pm_info *devi_pm_info;		/* 0 => dev not power managed */
135 	uint_t		devi_pm_flags;		/* pm flags */
136 	int		devi_pm_num_components;	/* number of components */
137 	size_t		devi_pm_comp_size;	/* size of devi_components */
138 	struct pm_component *devi_pm_components; /* array of pm components */
139 	struct dev_info *devi_pm_ppm;		/* ppm attached to this one */
140 	void		*devi_pm_ppm_private;	/* for use by ppm driver */
141 	int		devi_pm_dev_thresh;	/* "device" threshold */
142 	uint_t		devi_pm_kidsupcnt;	/* # of kids powered up */
143 	struct pm_scan	*devi_pm_scan;		/* pm scan info */
144 	uint_t		devi_pm_noinvolpm;	/* # of descendents no-invol */
145 	uint_t		devi_pm_volpmd;		/* # of voluntarily pm'ed */
146 	kmutex_t	devi_pm_lock;		/* pm lock for state */
147 	kmutex_t	devi_pm_busy_lock;	/* for component busy count */
148 
149 	uint_t		devi_state;		/* device/bus state flags */
150 						/* see below for definitions */
151 	kcondvar_t	devi_cv;		/* cv */
152 	int		devi_ref;		/* reference count */
153 
154 	dacf_rsrvlist_t *devi_dacf_tasks;	/* dacf reservation queue */
155 
156 	ddi_node_class_t devi_node_class;	/* Node class */
157 	int		devi_node_attributes;	/* Node attributes: See below */
158 
159 	char		*devi_device_class;
160 
161 	/*
162 	 * New mpxio kernel hooks entries
163 	 */
164 	int		devi_mdi_component;	/* mpxio component type */
165 	void		*devi_mdi_client;	/* mpxio client information */
166 	void		*devi_mdi_xhci;		/* vhci/phci info */
167 
168 	ddi_prop_list_t	*devi_global_prop_list;	/* driver global properties */
169 	major_t		devi_major;		/* driver major number */
170 	ddi_node_state_t devi_node_state;	/* state of node */
171 	uint_t		devi_flags;		/* configuration flags */
172 	int		devi_circular;		/* for recursive operations */
173 	void		*devi_busy_thread;	/* thread operating on node */
174 	void		*devi_taskq;		/* hotplug taskq */
175 
176 	/* device driver statistical and audit info */
177 	struct devinfo_audit *devi_audit;		/* last state change */
178 
179 	/*
180 	 * FMA support for resource caches and error handlers
181 	 */
182 	struct i_ddi_fmhdl	*devi_fmhdl;
183 
184 	uint_t		devi_cpr_flags;
185 
186 	/* For interrupt support */
187 	devinfo_intr_t		*devi_intr_p;
188 
189 	void		*devi_nex_pm;		/* nexus PM private */
190 
191 	char		*devi_addr_buf;		/* buffer for devi_addr */
192 };
193 
194 #define	DEVI(dev_info_type)	((struct dev_info *)(dev_info_type))
195 
196 /*
197  * NB: The 'name' field, for compatibility with old code (both existing
198  * device drivers and userland code), is now defined as the name used
199  * to bind the node to a device driver, and not the device node name.
200  * If the device node name does not define a binding to a device driver,
201  * and the framework uses a different algorithm to create the binding to
202  * the driver, the node name and binding name will be different.
203  *
204  * Note that this implies that the node name plus instance number does
205  * NOT create a unique driver id; only the binding name plus instance
206  * number creates a unique driver id.
207  *
208  * New code should not use 'devi_name'; use 'devi_binding_name' or
209  * 'devi_node_name' and/or the routines that access those fields.
210  */
211 
212 #define	devi_name devi_binding_name
213 
214 /*
215  * DDI_CF1, DDI_CF2 and DDI_DRV_UNLOADED are obsolete. They are kept
216  * around to allow legacy drivers to to compile.
217  */
218 #define	DDI_CF1(devi)		(DEVI(devi)->devi_addr != NULL)
219 #define	DDI_CF2(devi)		(DEVI(devi)->devi_ops != NULL)
220 #define	DDI_DRV_UNLOADED(devi)	(DEVI(devi)->devi_ops == &mod_nodev_ops)
221 
222 /*
223  * The device state flags (devi_state) contains information regarding
224  * the state of the device (Online/Offline/Down).  For bus nexus
225  * devices, the device state also contains state information regarding
226  * the state of the bus represented by this nexus node.
227  *
228  * Device state information is stored in bits [0-7], bus state in bits
229  * [8-15].
230  *
231  * NOTE: all devi_state updates shoule be protected by devi_lock.
232  */
233 #define	DEVI_DEVICE_OFFLINE	0x00000001
234 #define	DEVI_DEVICE_DOWN	0x00000002
235 #define	DEVI_DEVICE_DEGRADED	0x00000004
236 #define	DEVI_DEVICE_REMOVED	0x00000008 /* hardware removed */
237 
238 #define	DEVI_BUS_QUIESCED	0x00000100
239 #define	DEVI_BUS_DOWN		0x00000200
240 #define	DEVI_NDI_CONFIG		0x00000400 /* perform config when attaching */
241 
242 #define	DEVI_S_ATTACHING	0x00010000
243 #define	DEVI_S_DETACHING	0x00020000
244 #define	DEVI_S_ONLINING		0x00040000
245 #define	DEVI_S_OFFLINING	0x00080000
246 
247 #define	DEVI_S_INVOKING_DACF	0x00100000 /* busy invoking a dacf task */
248 
249 #define	DEVI_S_UNBOUND		0x00200000
250 #define	DEVI_S_MD_UPDATE	0x00400000
251 #define	DEVI_S_REPORT		0x08000000 /* report status change */
252 
253 #define	DEVI_S_EVADD		0x10000000 /* state of devfs event */
254 #define	DEVI_S_EVREMOVE		0x20000000 /* state of devfs event */
255 #define	DEVI_S_NEED_RESET	0x40000000 /* devo_reset should be called */
256 
257 /*
258  * Device state macros.
259  * o All SET/CLR/DONE users must protect context with devi_lock.
260  * o DEVI_SET_DEVICE_ONLINE users must do his own DEVI_SET_REPORT.
261  * o DEVI_SET_DEVICE_{DOWN|DEGRADED|UP} should only be used when !OFFLINE.
262  * o DEVI_SET_DEVICE_UP clears DOWN and DEGRADED.
263  */
264 #define	DEVI_IS_DEVICE_OFFLINE(dip)					\
265 	((DEVI(dip)->devi_state & DEVI_DEVICE_OFFLINE) == DEVI_DEVICE_OFFLINE)
266 
267 #define	DEVI_SET_DEVICE_ONLINE(dip)	{				\
268 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
269 	/* setting ONLINE clears DOWN, DEGRADED, OFFLINE */		\
270 	DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DOWN |			\
271 	    DEVI_DEVICE_DEGRADED | DEVI_DEVICE_OFFLINE);		\
272 	}
273 
274 #define	DEVI_SET_DEVICE_OFFLINE(dip)	{				\
275 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
276 	DEVI(dip)->devi_state |= (DEVI_DEVICE_OFFLINE | DEVI_S_REPORT);	\
277 	}
278 
279 #define	DEVI_IS_DEVICE_DOWN(dip)					\
280 	((DEVI(dip)->devi_state & DEVI_DEVICE_DOWN) == DEVI_DEVICE_DOWN)
281 
282 #define	DEVI_SET_DEVICE_DOWN(dip)	{				\
283 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
284 	ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip));				\
285 	DEVI(dip)->devi_state |= (DEVI_DEVICE_DOWN | DEVI_S_REPORT);	\
286 	}
287 
288 #define	DEVI_IS_DEVICE_DEGRADED(dip)					\
289 	((DEVI(dip)->devi_state &					\
290 	    (DEVI_DEVICE_DEGRADED|DEVI_DEVICE_DOWN)) == DEVI_DEVICE_DEGRADED)
291 
292 #define	DEVI_SET_DEVICE_DEGRADED(dip)	{				\
293 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
294 	ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip));				\
295 	DEVI(dip)->devi_state |= (DEVI_DEVICE_DEGRADED | DEVI_S_REPORT); \
296 	}
297 
298 #define	DEVI_SET_DEVICE_UP(dip)		{				\
299 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
300 	ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip));				\
301 	DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DEGRADED | DEVI_DEVICE_DOWN); \
302 	DEVI(dip)->devi_state |= DEVI_S_REPORT;				\
303 	}
304 
305 /* Device removal and insertion */
306 #define	DEVI_IS_DEVICE_REMOVED(dip)					\
307 	((DEVI(dip)->devi_state & DEVI_DEVICE_REMOVED) == DEVI_DEVICE_REMOVED)
308 
309 #define	DEVI_SET_DEVICE_REMOVED(dip)	{				\
310 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
311 	DEVI(dip)->devi_state |= DEVI_DEVICE_REMOVED;			\
312 	}
313 
314 #define	DEVI_SET_DEVICE_REINSERTED(dip)	{				\
315 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
316 	DEVI(dip)->devi_state &= ~DEVI_DEVICE_REMOVED;			\
317 	}
318 
319 /* Bus state change macros */
320 #define	DEVI_IS_BUS_QUIESCED(dip)					\
321 	((DEVI(dip)->devi_state & DEVI_BUS_QUIESCED) == DEVI_BUS_QUIESCED)
322 
323 #define	DEVI_SET_BUS_ACTIVE(dip)	{				\
324 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
325 	DEVI(dip)->devi_state &= ~DEVI_BUS_QUIESCED;			\
326 	DEVI(dip)->devi_state |= DEVI_S_REPORT;				\
327 	}
328 
329 #define	DEVI_SET_BUS_QUIESCE(dip)	{				\
330 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
331 	DEVI(dip)->devi_state |= (DEVI_BUS_QUIESCED | DEVI_S_REPORT);	\
332 	}
333 
334 #define	DEVI_IS_BUS_DOWN(dip)						\
335 	((DEVI(dip)->devi_state & DEVI_BUS_DOWN) == DEVI_BUS_DOWN)
336 
337 #define	DEVI_SET_BUS_UP(dip)		{				\
338 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
339 	DEVI(dip)->devi_state &= ~DEVI_BUS_DOWN;			\
340 	DEVI(dip)->devi_state |= DEVI_S_REPORT;				\
341 	}
342 
343 #define	DEVI_SET_BUS_DOWN(dip)		{				\
344 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
345 	DEVI(dip)->devi_state |= (DEVI_BUS_DOWN | DEVI_S_REPORT);	\
346 	}
347 
348 /* Status change report needed */
349 #define	DEVI_NEED_REPORT(dip)						\
350 	((DEVI(dip)->devi_state & DEVI_S_REPORT) == DEVI_S_REPORT)
351 
352 #define	DEVI_SET_REPORT(dip)		{				\
353 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
354 	DEVI(dip)->devi_state |= DEVI_S_REPORT;				\
355 	}
356 
357 #define	DEVI_REPORT_DONE(dip)		{				\
358 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
359 	DEVI(dip)->devi_state &= ~DEVI_S_REPORT;			\
360 	}
361 
362 /* Do an NDI_CONFIG for its children */
363 #define	DEVI_NEED_NDI_CONFIG(dip)					\
364 	((DEVI(dip)->devi_state & DEVI_NDI_CONFIG) == DEVI_NDI_CONFIG)
365 
366 #define	DEVI_SET_NDI_CONFIG(dip)	{				\
367 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
368 	DEVI(dip)->devi_state |= DEVI_NDI_CONFIG;			\
369 	}
370 
371 #define	DEVI_CLR_NDI_CONFIG(dip)	{				\
372 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
373 	DEVI(dip)->devi_state &= ~DEVI_NDI_CONFIG;			\
374 	}
375 
376 /* Attaching or detaching state */
377 #define	DEVI_IS_ATTACHING(dip)						\
378 	((DEVI(dip)->devi_state & DEVI_S_ATTACHING) == DEVI_S_ATTACHING)
379 
380 #define	DEVI_SET_ATTACHING(dip)		{				\
381 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
382 	DEVI(dip)->devi_state |= DEVI_S_ATTACHING;			\
383 	}
384 
385 #define	DEVI_CLR_ATTACHING(dip)		{				\
386 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
387 	DEVI(dip)->devi_state &= ~DEVI_S_ATTACHING;			\
388 	}
389 
390 #define	DEVI_IS_DETACHING(dip)						\
391 	((DEVI(dip)->devi_state & DEVI_S_DETACHING) == DEVI_S_DETACHING)
392 
393 #define	DEVI_SET_DETACHING(dip)		{				\
394 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
395 	DEVI(dip)->devi_state |= DEVI_S_DETACHING;			\
396 	}
397 
398 #define	DEVI_CLR_DETACHING(dip)		{				\
399 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
400 	DEVI(dip)->devi_state &= ~DEVI_S_DETACHING;			\
401 	}
402 
403 /* Onlining or offlining state */
404 #define	DEVI_IS_ONLINING(dip)						\
405 	((DEVI(dip)->devi_state & DEVI_S_ONLINING) == DEVI_S_ONLINING)
406 
407 #define	DEVI_SET_ONLINING(dip)		{				\
408 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
409 	DEVI(dip)->devi_state |= DEVI_S_ONLINING;			\
410 	}
411 
412 #define	DEVI_CLR_ONLINING(dip)		{				\
413 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
414 	DEVI(dip)->devi_state &= ~DEVI_S_ONLINING;			\
415 	}
416 
417 #define	DEVI_IS_OFFLINING(dip)						\
418 	((DEVI(dip)->devi_state & DEVI_S_OFFLINING) == DEVI_S_OFFLINING)
419 
420 #define	DEVI_SET_OFFLINING(dip)		{				\
421 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
422 	DEVI(dip)->devi_state |= DEVI_S_OFFLINING;			\
423 	}
424 
425 #define	DEVI_CLR_OFFLINING(dip)		{				\
426 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
427 	DEVI(dip)->devi_state &= ~DEVI_S_OFFLINING;			\
428 	}
429 
430 #define	DEVI_IS_IN_RECONFIG(dip)					\
431 	(DEVI(dip)->devi_state & (DEVI_S_OFFLINING | DEVI_S_ONLINING))
432 
433 /* Busy invoking a dacf task against this node */
434 #define	DEVI_IS_INVOKING_DACF(dip)					\
435 	((DEVI(dip)->devi_state & DEVI_S_INVOKING_DACF) == DEVI_S_INVOKING_DACF)
436 
437 #define	DEVI_SET_INVOKING_DACF(dip)	{				\
438 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
439 	DEVI(dip)->devi_state |= DEVI_S_INVOKING_DACF;			\
440 	}
441 
442 #define	DEVI_CLR_INVOKING_DACF(dip)	{				\
443 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
444 	DEVI(dip)->devi_state &= ~DEVI_S_INVOKING_DACF;			\
445 	}
446 
447 /* Events for add/remove */
448 #define	DEVI_EVADD(dip)							\
449 	((DEVI(dip)->devi_state & DEVI_S_EVADD) == DEVI_S_EVADD)
450 
451 #define	DEVI_SET_EVADD(dip)		{				\
452 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
453 	DEVI(dip)->devi_state &= ~DEVI_S_EVREMOVE;			\
454 	DEVI(dip)->devi_state |= DEVI_S_EVADD;				\
455 	}
456 
457 #define	DEVI_EVREMOVE(dip)						\
458 	((DEVI(dip)->devi_state & DEVI_S_EVREMOVE) == DEVI_S_EVREMOVE)
459 
460 #define	DEVI_SET_EVREMOVE(dip)		{				\
461 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
462 	DEVI(dip)->devi_state &= ~DEVI_S_EVADD;				\
463 	DEVI(dip)->devi_state |= DEVI_S_EVREMOVE;			\
464 	}
465 
466 #define	DEVI_SET_EVUNINIT(dip)		{				\
467 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
468 	DEVI(dip)->devi_state &= ~(DEVI_S_EVADD | DEVI_S_EVREMOVE);	\
469 	}
470 
471 /* Need to call the devo_reset entry point for this device at shutdown */
472 #define	DEVI_NEED_RESET(dip)						\
473 	((DEVI(dip)->devi_state & DEVI_S_NEED_RESET) == DEVI_S_NEED_RESET)
474 
475 #define	DEVI_SET_NEED_RESET(dip)	{				\
476 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
477 	DEVI(dip)->devi_state |= DEVI_S_NEED_RESET;			\
478 	}
479 
480 #define	DEVI_CLR_NEED_RESET(dip)	{				\
481 	ASSERT(mutex_owned(&DEVI(dip)->devi_lock));			\
482 	DEVI(dip)->devi_state &= ~DEVI_S_NEED_RESET;			\
483 	}
484 
485 void	i_devi_enter(dev_info_t *, uint_t s_mask, uint_t w_mask, int has_lock);
486 void	i_devi_exit(dev_info_t *, uint_t c_mask, int has_lock);
487 
488 /*
489  * devi_flags bits
490  *
491  * NOTE: all devi_state updates shoule be protected by devi_lock.
492  */
493 #define	DEVI_BUSY		0x00000001 /* busy configuring children */
494 #define	DEVI_MADE_CHILDREN	0x00000002 /* children made from specs */
495 #define	DEVI_ATTACHED_CHILDREN	0x00000004 /* attached all existing children */
496 #define	DEVI_BRANCH_HELD	0x00000008 /* branch rooted at this dip held */
497 #define	DEVI_NO_BIND		0x00000010 /* prevent driver binding */
498 #define	DEVI_REGISTERED_DEVID	0x00000020 /* device registered a devid */
499 
500 #define	DEVI_BUSY_CHANGING(dip)	(DEVI(dip)->devi_flags & DEVI_BUSY)
501 #define	DEVI_BUSY_OWNED(dip)	(DEVI_BUSY_CHANGING(dip) &&	\
502 	((DEVI(dip))->devi_busy_thread == curthread))
503 
504 char	*i_ddi_devi_class(dev_info_t *);
505 int	i_ddi_set_devi_class(dev_info_t *, char *, int);
506 
507 /*
508  * This structure represents one piece of bus space occupied by a given
509  * device. It is used in an array for devices with multiple address windows.
510  */
511 struct regspec {
512 	uint_t regspec_bustype;		/* cookie for bus type it's on */
513 	uint_t regspec_addr;		/* address of reg relative to bus */
514 	uint_t regspec_size;		/* size of this register set */
515 };
516 
517 /*
518  * This structure represents one piece of nexus bus space.
519  * It is used in an array for nexi with multiple bus spaces
520  * to define the childs offsets in the parents bus space.
521  */
522 struct rangespec {
523 	uint_t rng_cbustype;		/* Child's address, hi order */
524 	uint_t rng_coffset;		/* Child's address, lo order */
525 	uint_t rng_bustype;		/* Parent's address, hi order */
526 	uint_t rng_offset;		/* Parent's address, lo order */
527 	uint_t rng_size;		/* size of space for this entry */
528 };
529 
530 #ifdef _KERNEL
531 
532 typedef enum {
533 	DDI_PRE = 0,
534 	DDI_POST = 1
535 } ddi_pre_post_t;
536 
537 /*
538  * This structure represents notification of a child attach event
539  * These could both be the same if attach/detach commands were in the
540  * same name space.
541  * Note that the target dip is passed as an arg already.
542  */
543 struct attachspec {
544 	ddi_attach_cmd_t cmd;	/* type of event */
545 	ddi_pre_post_t	when;	/* one of DDI_PRE or DDI_POST */
546 	dev_info_t	*pdip;	/* parent of attaching node */
547 	int		result;	/* result of attach op (post command only) */
548 };
549 
550 /*
551  * This structure represents notification of a child detach event
552  * Note that the target dip is passed as an arg already.
553  */
554 struct detachspec {
555 	ddi_detach_cmd_t cmd;	/* type of event */
556 	ddi_pre_post_t	when;	/* one of DDI_PRE or DDI_POST */
557 	dev_info_t	*pdip;	/* parent of detaching node */
558 	int		result;	/* result of detach op (post command only) */
559 };
560 
561 #endif /* _KERNEL */
562 
563 typedef enum {
564 	DDM_MINOR = 0,
565 	DDM_ALIAS,
566 	DDM_DEFAULT,
567 	DDM_INTERNAL_PATH
568 } ddi_minor_type;
569 
570 /* implementation flags for driver specified device access control */
571 #define	DM_NO_FSPERM	0x1
572 
573 struct devplcy;
574 
575 struct ddi_minor {
576 	char		*name;		/* name of node */
577 	dev_t		dev;		/* device number */
578 	int		spec_type;	/* block or char */
579 	int		flags;		/* access flags */
580 	char		*node_type;	/* block, byte, serial, network */
581 	struct devplcy	*node_priv;	/* privilege for this minor */
582 	mode_t		priv_mode;	/* default apparent privilege mode */
583 };
584 
585 /*
586  * devi_node_attributes contains node attributes private to the
587  * ddi implementation. As a consumer, do not use these bit definitions
588  * directly, use the ndi functions that check for the existence of the
589  * specific node attributes.
590  *
591  * DDI_PERSISTENT indicates a 'persistent' node; one that is not
592  * automatically freed by the framework if the driver is unloaded
593  * or the driver fails to attach to this node.
594  *
595  * DDI_AUTO_ASSIGNED_NODEID indicates that the nodeid was auto-assigned
596  * by the framework and should be auto-freed if the node is removed.
597  *
598  * DDI_VHCI_NODE indicates that the node type is VHCI. This flag
599  * must be set by ndi_devi_config_vhci() routine only.
600  */
601 #define	DDI_PERSISTENT			0x01
602 #define	DDI_AUTO_ASSIGNED_NODEID	0x02
603 #define	DDI_VHCI_NODE			0x04
604 
605 #define	DEVI_VHCI_NODE(dip)						\
606 	(DEVI(dip)->devi_node_attributes & DDI_VHCI_NODE)
607 
608 /*
609  * The ddi_minor_data structure gets filled in by ddi_create_minor_node.
610  * It then gets attached to the devinfo node as a property.
611  */
612 struct ddi_minor_data {
613 	struct ddi_minor_data *next;	/* next one in the chain */
614 	dev_info_t	*dip;		/* pointer to devinfo node */
615 	ddi_minor_type	type;		/* Following data type */
616 	struct ddi_minor d_minor;	/* Actual minor node data */
617 };
618 
619 #define	ddm_name	d_minor.name
620 #define	ddm_dev		d_minor.dev
621 #define	ddm_flags	d_minor.flags
622 #define	ddm_spec_type	d_minor.spec_type
623 #define	ddm_node_type	d_minor.node_type
624 #define	ddm_node_priv	d_minor.node_priv
625 #define	ddm_priv_mode	d_minor.priv_mode
626 
627 /*
628  * parent private data structure contains register, interrupt, property
629  * and range information.
630  */
631 struct ddi_parent_private_data {
632 	int par_nreg;			/* number of regs */
633 	struct regspec *par_reg;	/* array of regs */
634 	int par_nintr;			/* number of interrupts */
635 	struct intrspec *par_intr;	/* array of possible interrupts */
636 	int par_nrng;			/* number of ranges */
637 	struct rangespec *par_rng;	/* array of ranges */
638 };
639 #define	DEVI_PD(d)	\
640 	((struct ddi_parent_private_data *)DEVI((d))->devi_parent_data)
641 
642 #define	sparc_pd_getnreg(dev)		(DEVI_PD(dev)->par_nreg)
643 #define	sparc_pd_getnintr(dev)		(DEVI_PD(dev)->par_nintr)
644 #define	sparc_pd_getnrng(dev)		(DEVI_PD(dev)->par_nrng)
645 #define	sparc_pd_getreg(dev, n)		(&DEVI_PD(dev)->par_reg[(n)])
646 #define	sparc_pd_getintr(dev, n)	(&DEVI_PD(dev)->par_intr[(n)])
647 #define	sparc_pd_getrng(dev, n)		(&DEVI_PD(dev)->par_rng[(n)])
648 
649 /*
650  * This data structure is entirely private to the soft state allocator.
651  */
652 struct i_ddi_soft_state {
653 	void		**array;	/* the array of pointers */
654 	kmutex_t	lock;	/* serialize access to this struct */
655 	size_t		size;	/* how many bytes per state struct */
656 	size_t		n_items;	/* how many structs herein */
657 	struct i_ddi_soft_state *next;	/* 'dirty' elements */
658 };
659 
660 /*
661  * Solaris DDI DMA implementation structure and function definitions.
662  *
663  * Note: no callers of DDI functions must depend upon data structures
664  * declared below. They are not guaranteed to remain constant.
665  */
666 
667 /*
668  * Implementation DMA mapping structure.
669  *
670  * The publicly visible ddi_dma_req structure is filled
671  * in by a caller that wishes to map a memory object
672  * for DMA. Internal to this implementation of the public
673  * DDI DMA functions this request structure is put together
674  * with bus nexus specific functions that have additional
675  * information and constraints as to how to go about doing
676  * the requested mapping function
677  *
678  * In this implementation, some of the information from the
679  * original requester is retained throughout the lifetime
680  * of the I/O mapping being active.
681  */
682 
683 /*
684  * This is the implementation specific description
685  * of how we've mapped an object for DMA.
686  */
687 #if defined(__sparc)
688 typedef struct ddi_dma_impl {
689 	/*
690 	 * DMA mapping information
691 	 */
692 	ulong_t	dmai_mapping;	/* mapping cookie */
693 
694 	/*
695 	 * Size of the current mapping, in bytes.
696 	 *
697 	 * Note that this is distinct from the size of the object being mapped
698 	 * for DVMA. We might have only a portion of the object mapped at any
699 	 * given point in time.
700 	 */
701 	uint_t	dmai_size;
702 
703 	/*
704 	 * Offset, in bytes, into object that is currently mapped.
705 	 */
706 	off_t	dmai_offset;
707 
708 	/*
709 	 * Information gathered from the original DMA mapping
710 	 * request and saved for the lifetime of the mapping.
711 	 */
712 	uint_t		dmai_minxfer;
713 	uint_t		dmai_burstsizes;
714 	uint_t		dmai_ndvmapages;
715 	uint_t		dmai_pool;	/* cached DVMA space */
716 	uint_t		dmai_rflags;	/* requester's flags + ours */
717 	uint_t		dmai_inuse;	/* active handle? */
718 	uint_t		dmai_nwin;
719 	uint_t		dmai_winsize;
720 	caddr_t		dmai_nexus_private;
721 	void		*dmai_iopte;
722 	uint_t		*dmai_sbi;
723 	void		*dmai_minfo;	/* random mapping information */
724 	dev_info_t	*dmai_rdip;	/* original requester's dev_info_t */
725 	ddi_dma_obj_t	dmai_object;	/* requester's object */
726 	ddi_dma_attr_t	dmai_attr;	/* DMA attributes */
727 	ddi_dma_cookie_t *dmai_cookie;	/* pointer to first DMA cookie */
728 
729 	int		(*dmai_fault_check)(struct ddi_dma_impl *handle);
730 	void		(*dmai_fault_notify)(struct ddi_dma_impl *handle);
731 	int		dmai_fault;
732 	ndi_err_t	dmai_error;
733 
734 } ddi_dma_impl_t;
735 
736 #elif defined(__x86)
737 
738 /*
739  * ddi_dma_impl portion that genunix (sunddi.c) depends on. x86 rootnex
740  * implementation specific state is in dmai_private.
741  */
742 typedef struct ddi_dma_impl {
743 	ddi_dma_cookie_t *dmai_cookie; /* array of DMA cookies */
744 	void		*dmai_private;
745 
746 	/*
747 	 * Information gathered from the original dma mapping
748 	 * request and saved for the lifetime of the mapping.
749 	 */
750 	uint_t		dmai_minxfer;
751 	uint_t		dmai_burstsizes;
752 	uint_t		dmai_rflags;	/* requester's flags + ours */
753 	int		dmai_nwin;
754 	dev_info_t	*dmai_rdip;	/* original requester's dev_info_t */
755 
756 	ddi_dma_attr_t	dmai_attr;	/* DMA attributes */
757 
758 	int		(*dmai_fault_check)(struct ddi_dma_impl *handle);
759 	void		(*dmai_fault_notify)(struct ddi_dma_impl *handle);
760 	int		dmai_fault;
761 	ndi_err_t	dmai_error;
762 } ddi_dma_impl_t;
763 
764 #else
765 #error "struct ddi_dma_impl not defined for this architecture"
766 #endif  /* defined(__sparc) */
767 
768 /*
769  * For now DMA segments share state with the DMA handle
770  */
771 typedef ddi_dma_impl_t ddi_dma_seg_impl_t;
772 
773 /*
774  * These flags use reserved bits from the dma request flags.
775  *
776  * A note about the DMP_NOSYNC flags: the root nexus will
777  * set these as it sees best. If an intermediate nexus
778  * actually needs these operations, then during the unwind
779  * from the call to ddi_dma_bind, the nexus driver *must*
780  * clear the appropriate flag(s). This is because, as an
781  * optimization, ddi_dma_sync(9F) looks at these flags before
782  * deciding to spend the time going back up the tree.
783  */
784 
785 #define	_DMCM1	DDI_DMA_RDWR|DDI_DMA_REDZONE|DDI_DMA_PARTIAL
786 #define	_DMCM2	DDI_DMA_CONSISTENT|DMP_VMEREQ
787 #define	DMP_DDIFLAGS	(_DMCM1|_DMCM2)
788 #define	DMP_SHADOW	0x20
789 #define	DMP_LKIOPB	0x40
790 #define	DMP_LKSYSV	0x80
791 #define	DMP_IOCACHE	0x100
792 #define	DMP_USEHAT	0x200
793 #define	DMP_PHYSADDR	0x400
794 #define	DMP_INVALID	0x800
795 #define	DMP_NOLIMIT	0x1000
796 #define	DMP_VMEREQ	0x10000000
797 #define	DMP_BYPASSNEXUS	0x20000000
798 #define	DMP_NODEVSYNC	0x40000000
799 #define	DMP_NOCPUSYNC	0x80000000
800 #define	DMP_NOSYNC	(DMP_NODEVSYNC|DMP_NOCPUSYNC)
801 
802 /*
803  * In order to complete a device to device mapping that
804  * has percolated as high as an IU nexus (gone that high
805  * because the DMA request is a VADDR type), we define
806  * structure to use with the DDI_CTLOPS_DMAPMAPC request
807  * that re-traverses the request tree to finish the
808  * DMA 'mapping' for a device.
809  */
810 struct dma_phys_mapc {
811 	struct ddi_dma_req *dma_req;	/* original request */
812 	ddi_dma_impl_t *mp;		/* current handle, or none */
813 	int nptes;			/* number of ptes */
814 	void *ptes;			/* ptes already read */
815 };
816 
817 #define	MAXCALLBACK		20
818 
819 /*
820  * Callback definitions
821  */
822 struct ddi_callback {
823 	struct ddi_callback	*c_nfree;
824 	struct ddi_callback	*c_nlist;
825 	int			(*c_call)();
826 	int			c_count;
827 	caddr_t			c_arg;
828 	size_t			c_size;
829 };
830 
831 
832 /*
833  * Device id - Internal definition.
834  */
835 #define	DEVID_MAGIC_MSB		0x69
836 #define	DEVID_MAGIC_LSB		0x64
837 #define	DEVID_REV_MSB		0x00
838 #define	DEVID_REV_LSB		0x01
839 #define	DEVID_HINT_SIZE		4
840 
841 typedef struct impl_devid {
842 	uchar_t	did_magic_hi;			/* device id magic # (msb) */
843 	uchar_t	did_magic_lo;			/* device id magic # (lsb) */
844 	uchar_t	did_rev_hi;			/* device id revision # (msb) */
845 	uchar_t	did_rev_lo;			/* device id revision # (lsb) */
846 	uchar_t	did_type_hi;			/* device id type (msb) */
847 	uchar_t	did_type_lo;			/* device id type (lsb) */
848 	uchar_t	did_len_hi;			/* length of devid data (msb) */
849 	uchar_t	did_len_lo;			/* length of devid data (lsb) */
850 	char	did_driver[DEVID_HINT_SIZE];	/* driver name - HINT */
851 	char	did_id[1];			/* start of device id data */
852 } impl_devid_t;
853 
854 #define	DEVID_GETTYPE(devid)		((ushort_t) \
855 					    (((devid)->did_type_hi << NBBY) + \
856 					    (devid)->did_type_lo))
857 
858 #define	DEVID_FORMTYPE(devid, type)	(devid)->did_type_hi = hibyte((type)); \
859 					(devid)->did_type_lo = lobyte((type));
860 
861 #define	DEVID_GETLEN(devid)		((ushort_t) \
862 					    (((devid)->did_len_hi << NBBY) + \
863 					    (devid)->did_len_lo))
864 
865 #define	DEVID_FORMLEN(devid, len)	(devid)->did_len_hi = hibyte((len)); \
866 					(devid)->did_len_lo = lobyte((len));
867 
868 /*
869  * Per PSARC/1995/352, a binary devid contains fields for <magic number>,
870  * <revision>, <driver_hint>, <type>, <id_length>, and the <id> itself.
871  * This proposal would encode the binary devid into a string consisting
872  * of "<magic><revision>,<driver_hint>@<type><id>" as indicated below
873  * (<id_length> is rederived from the length of the string
874  * representation of the <id>):
875  *
876  *	<magic>		->"id"
877  *
878  *	<rev>		->"%d"	// "0" -> type of DEVID_NONE  "id0"
879  *				// NOTE: PSARC/1995/352 <revision> is "1".
880  *				// NOTE: support limited to 10 revisions
881  *				//	in current implementation
882  *
883  *	<driver_hint>	->"%s"	// "sd"/"ssd"
884  *				// NOTE: driver names limited to 4
885  *				//	characters for <revision> "1"
886  *
887  *	<type>		->'w' |	// DEVID_SCSI3_WWN	<hex_id>
888  *			'W' |	// DEVID_SCSI3_WWN	<ascii_id>
889  *			't' |	// DEVID_SCSI3_VPD_T10	<hex_id>
890  *			'T' |	// DEVID_SCSI3_VPD_T10	<ascii_id>
891  *			'x' |	// DEVID_SCSI3_VPD_EUI	<hex_id>
892  *			'X' |	// DEVID_SCSI3_VPD_EUI	<ascii_id>
893  *			'n' |	// DEVID_SCSI3_VPD_NAA	<hex_id>
894  *			'N' |	// DEVID_SCSI3_VPD_NAA	<ascii_id>
895  *			's' |	// DEVID_SCSI_SERIAL	<hex_id>
896  *			'S' |	// DEVID_SCSI_SERIAL	<ascii_id>
897  *			'f' |	// DEVID_FAB		<hex_id>
898  *			'F' |	// DEVID_FAB		<ascii_id>
899  *			'e' |	// DEVID_ENCAP		<hex_id>
900  *			'E' |	// DEVID_ENCAP		<ascii_id>
901  *			'a' |	// DEVID_ATA_SERIAL	<hex_id>
902  *			'A' |	// DEVID_ATA_SERIAL	<ascii_id>
903  *			'u' |	// unknown		<hex_id>
904  *			'U'	// unknown		<ascii_id>
905  *              		// NOTE: lower case -> <hex_id>
906  *				//       upper case -> <ascii_id>
907  *				// NOTE: this covers all types currently
908  *				//	defined for <revision> 1.
909  *				// NOTE: a <type> can be added
910  *				//	without changing the <revision>.
911  *
912  *	<id>		-> <ascii_id> |	// <type> is upper case
913  *			<hex_id>	// <type> is lower case
914  *
915  *	<ascii_id>	// only if all bytes of binary <id> field
916  *			// are in the set:
917  *			//	[A-Z][a-z][0-9]+-.= and space and 0x00
918  *			// the encoded form is:
919  *			//	[A-Z][a-z][0-9]+-.= and _     and ~
920  *			//          NOTE: ' ' <=> '_', 0x00 <=> '~'
921  *			// these sets are chosen to avoid shell
922  *			// and conflicts with DDI node names.
923  *
924  *	<hex_id>	// if not <ascii_id>; each byte of binary
925  *			// <id> maps a to 2 digit ascii hex
926  *			// representation in the string.
927  *
928  * This encoding provides a meaningful correlation between the /devices
929  * path and the devid string where possible.
930  *
931  *   Fibre:
932  *	sbus@6,0/SUNW,socal@d,10000/sf@1,0/ssd@w21000020370bb488,0:c,raw
933  *      id1,ssd@w20000020370bb488:c,raw
934  *
935  *   Copper:
936  *	sbus@7,0/SUNW,fas@3,8800000/sd@a,0:c
937  *      id1,sd@SIBM_____1XY210__________:c
938  */
939 /* determine if a byte of an id meets ASCII representation requirements */
940 #define	DEVID_IDBYTE_ISASCII(b)		(				\
941 	(((b) >= 'a') && ((b) <= 'z')) ||				\
942 	(((b) >= 'A') && ((b) <= 'Z')) ||				\
943 	(((b) >= '0') && ((b) <= '9')) ||				\
944 	(b == '+') || (b == '-') || (b == '.') || (b == '=') ||		\
945 	(b == ' ') || (b == 0x00))
946 
947 /* set type to lower case to indicate that the did_id field is ascii */
948 #define	DEVID_TYPE_SETASCII(c)	(c - 0x20)	/* 'a' -> 'A' */
949 
950 /* determine from type if did_id field is binary or ascii */
951 #define	DEVID_TYPE_ISASCII(c)	(((c) >= 'A') && ((c) <= 'Z'))
952 
953 /* convert type field from binary to ascii */
954 #define	DEVID_TYPE_BINTOASCII(b)	(				\
955 	((b) == DEVID_SCSI3_WWN)	? 'w' :				\
956 	((b) == DEVID_SCSI3_VPD_T10)	? 't' :				\
957 	((b) == DEVID_SCSI3_VPD_EUI)	? 'x' :				\
958 	((b) == DEVID_SCSI3_VPD_NAA)	? 'n' :				\
959 	((b) == DEVID_SCSI_SERIAL)	? 's' :				\
960 	((b) == DEVID_FAB)		? 'f' :				\
961 	((b) == DEVID_ENCAP)		? 'e' :				\
962 	((b) == DEVID_ATA_SERIAL)	? 'a' :				\
963 	'u')						/* unknown */
964 
965 /* convert type field from ascii to binary */
966 #define	DEVID_TYPE_ASCIITOBIN(c)	(				\
967 	(((c) == 'w') || ((c) == 'W'))	? DEVID_SCSI3_WWN :		\
968 	(((c) == 't') || ((c) == 'T'))	? DEVID_SCSI3_VPD_T10 :		\
969 	(((c) == 'x') || ((c) == 'X'))	? DEVID_SCSI3_VPD_EUI :		\
970 	(((c) == 'n') || ((c) == 'N'))	? DEVID_SCSI3_VPD_NAA :		\
971 	(((c) == 's') || ((c) == 'S'))	? DEVID_SCSI_SERIAL :		\
972 	(((c) == 'f') || ((c) == 'F'))	? DEVID_FAB :			\
973 	(((c) == 'e') || ((c) == 'E'))	? DEVID_ENCAP :			\
974 	(((c) == 'a') || ((c) == 'A'))	? DEVID_ATA_SERIAL :		\
975 	DEVID_MAXTYPE +1)				/* unknown */
976 
977 /* determine if the type should be forced to hex encoding (non-ascii) */
978 #define	DEVID_TYPE_BIN_FORCEHEX(b) (	\
979 	((b) == DEVID_SCSI3_WWN) ||	\
980 	((b) == DEVID_SCSI3_VPD_EUI) ||	\
981 	((b) == DEVID_SCSI3_VPD_NAA) ||	\
982 	((b) == DEVID_FAB))
983 
984 /* determine if the type is from a scsi3 vpd */
985 #define	IS_DEVID_SCSI3_VPD_TYPE(b) (	\
986 	((b) == DEVID_SCSI3_VPD_T10) ||	\
987 	((b) == DEVID_SCSI3_VPD_EUI) ||	\
988 	((b) == DEVID_SCSI3_VPD_NAA))
989 
990 /* convert rev field from binary to ascii (only supports 10 revs) */
991 #define	DEVID_REV_BINTOASCII(b) (b + '0')
992 
993 /* convert rev field from ascii to binary (only supports 10 revs) */
994 #define	DEVID_REV_ASCIITOBIN(c) (c - '0')
995 
996 /* name of devid property */
997 #define	DEVID_PROP_NAME	"devid"
998 
999 /*
1000  * prop_name used by pci_{save,restore}_config_regs()
1001  */
1002 #define	SAVED_CONFIG_REGS "pci-config-regs"
1003 #define	SAVED_CONFIG_REGS_MASK "pcie-config-regs-mask"
1004 #define	SAVED_CONFIG_REGS_CAPINFO "pci-cap-info"
1005 
1006 typedef struct pci_config_header_state {
1007 	uint16_t	chs_command;
1008 	uint8_t		chs_cache_line_size;
1009 	uint8_t		chs_latency_timer;
1010 	uint8_t		chs_header_type;
1011 	uint8_t		chs_sec_latency_timer;
1012 	uint8_t		chs_bridge_control;
1013 	uint32_t	chs_base0;
1014 	uint32_t	chs_base1;
1015 	uint32_t	chs_base2;
1016 	uint32_t	chs_base3;
1017 	uint32_t	chs_base4;
1018 	uint32_t	chs_base5;
1019 } pci_config_header_state_t;
1020 
1021 #ifdef _KERNEL
1022 
1023 typedef struct pci_cap_save_desc {
1024 	uint16_t	cap_offset;
1025 	uint16_t	cap_id;
1026 	uint32_t	cap_nregs;
1027 } pci_cap_save_desc_t;
1028 
1029 typedef struct pci_cap_entry {
1030 	uint16_t		cap_id;
1031 	uint32_t		cap_ndwords;
1032 	uint32_t (*cap_save_func)(ddi_acc_handle_t confhdl, uint16_t cap_ptr,
1033 	    uint32_t *regbuf, uint32_t ndwords);
1034 } pci_cap_entry_t;
1035 
1036 #endif /* _KERNEL */
1037 
1038 #ifdef	__cplusplus
1039 }
1040 #endif
1041 
1042 #endif	/* _SYS_DDI_IMPLDEFS_H */
1043