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