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