xref: /titanic_41/usr/src/uts/common/io/options.c (revision 4a6822d07d6d3f9ffe6907ef5f10d11dcadd75c6)
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 1990, 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4 5.0 */
28 
29 #include <sys/types.h>
30 #include <sys/errno.h>
31 #include <sys/conf.h>
32 #include <sys/ddi.h>
33 #include <sys/sunddi.h>
34 
35 /*
36  * Configuration information
37  */
38 
39 static int options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
40 		void **result);
41 static int options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
42 static int options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
43 static dev_info_t *options_devi;
44 
45 struct dev_ops	options_ops = {
46 
47 	DEVO_REV,		/* devo_rev, */
48 	0,			/* refcnt  */
49 	options_info,		/* info */
50 	nulldev,		/* identify */
51 	nulldev,		/* probe */
52 	options_attach,		/* attach */
53 	options_detach,		/* detach */
54 	nodev,			/* reset */
55 	(struct cb_ops *)0,	/* driver operations */
56 	(struct bus_ops *)0,	/* bus operations */
57 	nulldev			/* power */
58 
59 };
60 
61 /*
62  * Autoload Data and Autoload Entry
63  */
64 
65 #include <sys/modctl.h>
66 
67 extern struct mod_ops mod_driverops;
68 static struct modldrv modldrv = {
69 	&mod_driverops,	/* Type of module. This one is a driver */
70 	"options driver",	/* Name of the module. */
71 	&options_ops,	/* driver ops */
72 };
73 
74 static struct modlinkage modlinkage = {
75 	MODREV_1, (void *)&modldrv
76 };
77 
78 /*
79  * This is the driver initialization routine.
80  */
81 
82 int
83 _init()
84 {
85 	return (mod_install(&modlinkage));
86 }
87 
88 int
89 _fini()
90 {
91 	return (EBUSY);
92 }
93 
94 int
95 _info(modinfop)
96 	struct modinfo *modinfop;
97 {
98 	return (mod_info(&modlinkage, modinfop));
99 }
100 
101 /* ARGSUSED */
102 static int
103 options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
104 {
105 	register int error;
106 
107 	switch (infocmd) {
108 	case DDI_INFO_DEVT2DEVINFO:
109 		if (options_devi == NULL) {
110 			error = DDI_FAILURE;
111 		} else {
112 			*result = (void *) options_devi;
113 			error = DDI_SUCCESS;
114 		}
115 		break;
116 	case DDI_INFO_DEVT2INSTANCE:
117 		*result = (void *)0;
118 		error = DDI_SUCCESS;
119 		break;
120 	default:
121 		error = DDI_FAILURE;
122 	}
123 	return (error);
124 }
125 
126 static int
127 options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
128 {
129 	switch (cmd) {
130 	case DDI_ATTACH:
131 		options_devi = devi;
132 		return (DDI_SUCCESS);
133 
134 	case DDI_RESUME:
135 		return (DDI_SUCCESS);
136 
137 	default:
138 		return (DDI_FAILURE);
139 	}
140 }
141 
142 /*ARGSUSED*/
143 static int
144 options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
145 {
146 	switch (cmd) {
147 	case DDI_SUSPEND:
148 		return (DDI_SUCCESS);
149 
150 	case DDI_DETACH:
151 	default:
152 		return (DDI_FAILURE);
153 	}
154 }
155