17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*19397407SSherry Moore * Common Development and Distribution License (the "License"). 6*19397407SSherry Moore * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*19397407SSherry Moore 227c478bd9Sstevel@tonic-gate /* 23*19397407SSherry Moore * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/errno.h> 307c478bd9Sstevel@tonic-gate #include <sys/conf.h> 317c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 327c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * Configuration information 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate static int options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, 397c478bd9Sstevel@tonic-gate void **result); 407c478bd9Sstevel@tonic-gate static int options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd); 417c478bd9Sstevel@tonic-gate static int options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd); 427c478bd9Sstevel@tonic-gate static dev_info_t *options_devi; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate struct dev_ops options_ops = { 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 477c478bd9Sstevel@tonic-gate 0, /* refcnt */ 487c478bd9Sstevel@tonic-gate options_info, /* info */ 497c478bd9Sstevel@tonic-gate nulldev, /* identify */ 507c478bd9Sstevel@tonic-gate nulldev, /* probe */ 517c478bd9Sstevel@tonic-gate options_attach, /* attach */ 527c478bd9Sstevel@tonic-gate options_detach, /* detach */ 537c478bd9Sstevel@tonic-gate nodev, /* reset */ 547c478bd9Sstevel@tonic-gate (struct cb_ops *)0, /* driver operations */ 557c478bd9Sstevel@tonic-gate (struct bus_ops *)0, /* bus operations */ 56*19397407SSherry Moore nulldev, /* power */ 57*19397407SSherry Moore ddi_quiesce_not_needed, /* quiesce */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate }; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Autoload Data and Autoload Entry 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops; 687c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 697c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This one is a driver */ 707c478bd9Sstevel@tonic-gate "options driver", /* Name of the module. */ 717c478bd9Sstevel@tonic-gate &options_ops, /* driver ops */ 727c478bd9Sstevel@tonic-gate }; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 757c478bd9Sstevel@tonic-gate MODREV_1, (void *)&modldrv 767c478bd9Sstevel@tonic-gate }; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * This is the driver initialization routine. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate int 837c478bd9Sstevel@tonic-gate _init() 847c478bd9Sstevel@tonic-gate { 857c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate int 897c478bd9Sstevel@tonic-gate _fini() 907c478bd9Sstevel@tonic-gate { 917c478bd9Sstevel@tonic-gate return (EBUSY); 927c478bd9Sstevel@tonic-gate } 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate int 957c478bd9Sstevel@tonic-gate _info(modinfop) 967c478bd9Sstevel@tonic-gate struct modinfo *modinfop; 977c478bd9Sstevel@tonic-gate { 987c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 997c478bd9Sstevel@tonic-gate } 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1027c478bd9Sstevel@tonic-gate static int 1037c478bd9Sstevel@tonic-gate options_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 1047c478bd9Sstevel@tonic-gate { 1057c478bd9Sstevel@tonic-gate register int error; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate switch (infocmd) { 1087c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 1097c478bd9Sstevel@tonic-gate if (options_devi == NULL) { 1107c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 1117c478bd9Sstevel@tonic-gate } else { 1127c478bd9Sstevel@tonic-gate *result = (void *) options_devi; 1137c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate break; 1167c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 1177c478bd9Sstevel@tonic-gate *result = (void *)0; 1187c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 1197c478bd9Sstevel@tonic-gate break; 1207c478bd9Sstevel@tonic-gate default: 1217c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate return (error); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate static int 1277c478bd9Sstevel@tonic-gate options_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 1287c478bd9Sstevel@tonic-gate { 1297c478bd9Sstevel@tonic-gate switch (cmd) { 1307c478bd9Sstevel@tonic-gate case DDI_ATTACH: 1317c478bd9Sstevel@tonic-gate options_devi = devi; 1327c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate case DDI_RESUME: 1357c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate default: 1387c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 1397c478bd9Sstevel@tonic-gate } 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1437c478bd9Sstevel@tonic-gate static int 1447c478bd9Sstevel@tonic-gate options_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) 1457c478bd9Sstevel@tonic-gate { 1467c478bd9Sstevel@tonic-gate switch (cmd) { 1477c478bd9Sstevel@tonic-gate case DDI_SUSPEND: 1487c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate case DDI_DETACH: 1517c478bd9Sstevel@tonic-gate default: 1527c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate } 155