xref: /titanic_53/usr/src/uts/common/io/options.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1990, 2002 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4 5.0 */
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
30*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
31*7c478bd9Sstevel@tonic-gate #include <sys/conf.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /*
36*7c478bd9Sstevel@tonic-gate  * Configuration information
37*7c478bd9Sstevel@tonic-gate  */
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate static int options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
40*7c478bd9Sstevel@tonic-gate 		void **result);
41*7c478bd9Sstevel@tonic-gate static int options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
42*7c478bd9Sstevel@tonic-gate static int options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
43*7c478bd9Sstevel@tonic-gate static dev_info_t *options_devi;
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate struct dev_ops	options_ops = {
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate 	DEVO_REV,		/* devo_rev, */
48*7c478bd9Sstevel@tonic-gate 	0,			/* refcnt  */
49*7c478bd9Sstevel@tonic-gate 	options_info,		/* info */
50*7c478bd9Sstevel@tonic-gate 	nulldev,		/* identify */
51*7c478bd9Sstevel@tonic-gate 	nulldev,		/* probe */
52*7c478bd9Sstevel@tonic-gate 	options_attach,		/* attach */
53*7c478bd9Sstevel@tonic-gate 	options_detach,		/* detach */
54*7c478bd9Sstevel@tonic-gate 	nodev,			/* reset */
55*7c478bd9Sstevel@tonic-gate 	(struct cb_ops *)0,	/* driver operations */
56*7c478bd9Sstevel@tonic-gate 	(struct bus_ops *)0,	/* bus operations */
57*7c478bd9Sstevel@tonic-gate 	nulldev			/* power */
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate };
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Autoload Data and Autoload Entry
63*7c478bd9Sstevel@tonic-gate  */
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops;
68*7c478bd9Sstevel@tonic-gate static struct modldrv modldrv = {
69*7c478bd9Sstevel@tonic-gate 	&mod_driverops,	/* Type of module. This one is a driver */
70*7c478bd9Sstevel@tonic-gate 	"options driver",	/* Name of the module. */
71*7c478bd9Sstevel@tonic-gate 	&options_ops,	/* driver ops */
72*7c478bd9Sstevel@tonic-gate };
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
75*7c478bd9Sstevel@tonic-gate 	MODREV_1, (void *)&modldrv
76*7c478bd9Sstevel@tonic-gate };
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /*
79*7c478bd9Sstevel@tonic-gate  * This is the driver initialization routine.
80*7c478bd9Sstevel@tonic-gate  */
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate int
83*7c478bd9Sstevel@tonic-gate _init()
84*7c478bd9Sstevel@tonic-gate {
85*7c478bd9Sstevel@tonic-gate 	return (mod_install(&modlinkage));
86*7c478bd9Sstevel@tonic-gate }
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate int
89*7c478bd9Sstevel@tonic-gate _fini()
90*7c478bd9Sstevel@tonic-gate {
91*7c478bd9Sstevel@tonic-gate 	return (EBUSY);
92*7c478bd9Sstevel@tonic-gate }
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate int
95*7c478bd9Sstevel@tonic-gate _info(modinfop)
96*7c478bd9Sstevel@tonic-gate 	struct modinfo *modinfop;
97*7c478bd9Sstevel@tonic-gate {
98*7c478bd9Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
99*7c478bd9Sstevel@tonic-gate }
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
102*7c478bd9Sstevel@tonic-gate static int
103*7c478bd9Sstevel@tonic-gate options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
104*7c478bd9Sstevel@tonic-gate {
105*7c478bd9Sstevel@tonic-gate 	register int error;
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 	switch (infocmd) {
108*7c478bd9Sstevel@tonic-gate 	case DDI_INFO_DEVT2DEVINFO:
109*7c478bd9Sstevel@tonic-gate 		if (options_devi == NULL) {
110*7c478bd9Sstevel@tonic-gate 			error = DDI_FAILURE;
111*7c478bd9Sstevel@tonic-gate 		} else {
112*7c478bd9Sstevel@tonic-gate 			*result = (void *) options_devi;
113*7c478bd9Sstevel@tonic-gate 			error = DDI_SUCCESS;
114*7c478bd9Sstevel@tonic-gate 		}
115*7c478bd9Sstevel@tonic-gate 		break;
116*7c478bd9Sstevel@tonic-gate 	case DDI_INFO_DEVT2INSTANCE:
117*7c478bd9Sstevel@tonic-gate 		*result = (void *)0;
118*7c478bd9Sstevel@tonic-gate 		error = DDI_SUCCESS;
119*7c478bd9Sstevel@tonic-gate 		break;
120*7c478bd9Sstevel@tonic-gate 	default:
121*7c478bd9Sstevel@tonic-gate 		error = DDI_FAILURE;
122*7c478bd9Sstevel@tonic-gate 	}
123*7c478bd9Sstevel@tonic-gate 	return (error);
124*7c478bd9Sstevel@tonic-gate }
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate static int
127*7c478bd9Sstevel@tonic-gate options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
128*7c478bd9Sstevel@tonic-gate {
129*7c478bd9Sstevel@tonic-gate 	switch (cmd) {
130*7c478bd9Sstevel@tonic-gate 	case DDI_ATTACH:
131*7c478bd9Sstevel@tonic-gate 		options_devi = devi;
132*7c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate 	case DDI_RESUME:
135*7c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate 	default:
138*7c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
139*7c478bd9Sstevel@tonic-gate 	}
140*7c478bd9Sstevel@tonic-gate }
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
143*7c478bd9Sstevel@tonic-gate static int
144*7c478bd9Sstevel@tonic-gate options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
145*7c478bd9Sstevel@tonic-gate {
146*7c478bd9Sstevel@tonic-gate 	switch (cmd) {
147*7c478bd9Sstevel@tonic-gate 	case DDI_SUSPEND:
148*7c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate 	case DDI_DETACH:
151*7c478bd9Sstevel@tonic-gate 	default:
152*7c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
153*7c478bd9Sstevel@tonic-gate 	}
154*7c478bd9Sstevel@tonic-gate }
155