10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7656SSherry.Moore@Sun.COM * Common Development and Distribution License (the "License").
6*7656SSherry.Moore@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
21*7656SSherry.Moore@Sun.COM
220Sstevel@tonic-gate /*
23*7656SSherry.Moore@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/errno.h>
300Sstevel@tonic-gate #include <sys/conf.h>
310Sstevel@tonic-gate #include <sys/ddi.h>
320Sstevel@tonic-gate #include <sys/sunddi.h>
330Sstevel@tonic-gate
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate * Configuration information
360Sstevel@tonic-gate */
370Sstevel@tonic-gate
380Sstevel@tonic-gate static int options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
390Sstevel@tonic-gate void **result);
400Sstevel@tonic-gate static int options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
410Sstevel@tonic-gate static int options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
420Sstevel@tonic-gate static dev_info_t *options_devi;
430Sstevel@tonic-gate
440Sstevel@tonic-gate struct dev_ops options_ops = {
450Sstevel@tonic-gate
460Sstevel@tonic-gate DEVO_REV, /* devo_rev, */
470Sstevel@tonic-gate 0, /* refcnt */
480Sstevel@tonic-gate options_info, /* info */
490Sstevel@tonic-gate nulldev, /* identify */
500Sstevel@tonic-gate nulldev, /* probe */
510Sstevel@tonic-gate options_attach, /* attach */
520Sstevel@tonic-gate options_detach, /* detach */
530Sstevel@tonic-gate nodev, /* reset */
540Sstevel@tonic-gate (struct cb_ops *)0, /* driver operations */
550Sstevel@tonic-gate (struct bus_ops *)0, /* bus operations */
56*7656SSherry.Moore@Sun.COM nulldev, /* power */
57*7656SSherry.Moore@Sun.COM ddi_quiesce_not_needed, /* quiesce */
580Sstevel@tonic-gate
590Sstevel@tonic-gate };
600Sstevel@tonic-gate
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate * Autoload Data and Autoload Entry
630Sstevel@tonic-gate */
640Sstevel@tonic-gate
650Sstevel@tonic-gate #include <sys/modctl.h>
660Sstevel@tonic-gate
670Sstevel@tonic-gate extern struct mod_ops mod_driverops;
680Sstevel@tonic-gate static struct modldrv modldrv = {
690Sstevel@tonic-gate &mod_driverops, /* Type of module. This one is a driver */
700Sstevel@tonic-gate "options driver", /* Name of the module. */
710Sstevel@tonic-gate &options_ops, /* driver ops */
720Sstevel@tonic-gate };
730Sstevel@tonic-gate
740Sstevel@tonic-gate static struct modlinkage modlinkage = {
750Sstevel@tonic-gate MODREV_1, (void *)&modldrv
760Sstevel@tonic-gate };
770Sstevel@tonic-gate
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate * This is the driver initialization routine.
800Sstevel@tonic-gate */
810Sstevel@tonic-gate
820Sstevel@tonic-gate int
_init()830Sstevel@tonic-gate _init()
840Sstevel@tonic-gate {
850Sstevel@tonic-gate return (mod_install(&modlinkage));
860Sstevel@tonic-gate }
870Sstevel@tonic-gate
880Sstevel@tonic-gate int
_fini()890Sstevel@tonic-gate _fini()
900Sstevel@tonic-gate {
910Sstevel@tonic-gate return (EBUSY);
920Sstevel@tonic-gate }
930Sstevel@tonic-gate
940Sstevel@tonic-gate int
_info(modinfop)950Sstevel@tonic-gate _info(modinfop)
960Sstevel@tonic-gate struct modinfo *modinfop;
970Sstevel@tonic-gate {
980Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
990Sstevel@tonic-gate }
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate /* ARGSUSED */
1020Sstevel@tonic-gate static int
options_info(dev_info_t * dip,ddi_info_cmd_t infocmd,void * arg,void ** result)1030Sstevel@tonic-gate options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
1040Sstevel@tonic-gate {
1050Sstevel@tonic-gate register int error;
1060Sstevel@tonic-gate
1070Sstevel@tonic-gate switch (infocmd) {
1080Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO:
1090Sstevel@tonic-gate if (options_devi == NULL) {
1100Sstevel@tonic-gate error = DDI_FAILURE;
1110Sstevel@tonic-gate } else {
1120Sstevel@tonic-gate *result = (void *) options_devi;
1130Sstevel@tonic-gate error = DDI_SUCCESS;
1140Sstevel@tonic-gate }
1150Sstevel@tonic-gate break;
1160Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE:
1170Sstevel@tonic-gate *result = (void *)0;
1180Sstevel@tonic-gate error = DDI_SUCCESS;
1190Sstevel@tonic-gate break;
1200Sstevel@tonic-gate default:
1210Sstevel@tonic-gate error = DDI_FAILURE;
1220Sstevel@tonic-gate }
1230Sstevel@tonic-gate return (error);
1240Sstevel@tonic-gate }
1250Sstevel@tonic-gate
1260Sstevel@tonic-gate static int
options_attach(dev_info_t * devi,ddi_attach_cmd_t cmd)1270Sstevel@tonic-gate options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
1280Sstevel@tonic-gate {
1290Sstevel@tonic-gate switch (cmd) {
1300Sstevel@tonic-gate case DDI_ATTACH:
1310Sstevel@tonic-gate options_devi = devi;
1320Sstevel@tonic-gate return (DDI_SUCCESS);
1330Sstevel@tonic-gate
1340Sstevel@tonic-gate case DDI_RESUME:
1350Sstevel@tonic-gate return (DDI_SUCCESS);
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate default:
1380Sstevel@tonic-gate return (DDI_FAILURE);
1390Sstevel@tonic-gate }
1400Sstevel@tonic-gate }
1410Sstevel@tonic-gate
1420Sstevel@tonic-gate /*ARGSUSED*/
1430Sstevel@tonic-gate static int
options_detach(dev_info_t * devi,ddi_detach_cmd_t cmd)1440Sstevel@tonic-gate options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
1450Sstevel@tonic-gate {
1460Sstevel@tonic-gate switch (cmd) {
1470Sstevel@tonic-gate case DDI_SUSPEND:
1480Sstevel@tonic-gate return (DDI_SUCCESS);
1490Sstevel@tonic-gate
1500Sstevel@tonic-gate case DDI_DETACH:
1510Sstevel@tonic-gate default:
1520Sstevel@tonic-gate return (DDI_FAILURE);
1530Sstevel@tonic-gate }
1540Sstevel@tonic-gate }
155