xref: /illumos-gate/usr/src/uts/common/sys/dacf.h (revision d0b3c59ba652f183eeec1414dd9fbdc56bf05cc8)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_DACF_H
27 #define	_DACF_H
28 
29 /*
30  * Device autoconfiguration framework (dacf)
31  */
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include <sys/types.h>
38 
39 #define	DACF_MODREV_1		1	/* interface version # */
40 
41 typedef void* dacf_arghdl_t;
42 typedef void* dacf_infohdl_t;
43 
44 typedef enum {
45 	DACF_OPID_ERROR = -1,
46 	DACF_OPID_END = 0,		/* mark end of array of dacf_op's */
47 	DACF_OPID_POSTATTACH = 1,	/* operate after a driver attaches */
48 	DACF_OPID_PREDETACH = 2		/* operate before a driver detaches */
49 } dacf_opid_t;
50 
51 #define	DACF_NUM_OPIDS 2
52 
53 typedef struct dacf_op {
54 	dacf_opid_t op_id;		/* operation id */
55 	int (*op_func)(dacf_infohdl_t, dacf_arghdl_t, int);
56 } dacf_op_t;
57 
58 typedef struct dacf_opset {
59 	char *opset_name;		/* name of this op-set */
60 	dacf_op_t *opset_ops;		/* null-terminated array of ops */
61 } dacf_opset_t;
62 
63 struct dacfsw {
64 	int		dacf_rev;	/* dacf interface revision #	*/
65 	dacf_opset_t	*dacf_opsets;	/* op-sets in this module	*/
66 };
67 
68 extern struct dacfsw kmod_dacfsw;	/* kernel provided module */
69 
70 /*
71  * DACF client interface
72  */
73 
74 const char *dacf_minor_name(dacf_infohdl_t);
75 minor_t dacf_minor_number(dacf_infohdl_t);
76 dev_t dacf_get_dev(dacf_infohdl_t);
77 const char *dacf_driver_name(dacf_infohdl_t);
78 dev_info_t *dacf_devinfo_node(dacf_infohdl_t);
79 const char *dacf_get_arg(dacf_arghdl_t, char *);
80 
81 void dacf_store_info(dacf_infohdl_t, void *);
82 void *dacf_retrieve_info(dacf_infohdl_t);
83 
84 struct vnode *dacf_makevp(dacf_infohdl_t);
85 
86 /*
87  * Error codes for configuration operations
88  */
89 #define	DACF_SUCCESS		0
90 #define	DACF_FAILURE		-1
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* _DACF_H */
97