diff options
author | Chris Horne <Chris.Horne@Sun.COM> | 2008-11-05 06:47:46 -0700 |
---|---|---|
committer | Chris Horne <Chris.Horne@Sun.COM> | 2008-11-05 06:47:46 -0700 |
commit | 62a24de03df1f2399ceda704cb3874dabc98bbbd (patch) | |
tree | a8177140d3f64d6d964fbc9bd74912a35778a048 /usr/src/uts | |
parent | 385470574fb49e32c324af06c01d697a16cc3c4b (diff) | |
download | illumos-gate-62a24de03df1f2399ceda704cb3874dabc98bbbd.tar.gz |
PSARC/2008/674 nulldriver
6767139 nulldriver
Diffstat (limited to 'usr/src/uts')
-rw-r--r-- | usr/src/uts/common/Makefile.files | 5 | ||||
-rw-r--r-- | usr/src/uts/common/io/nulldriver.c | 180 | ||||
-rw-r--r-- | usr/src/uts/common/os/autoconf.c | 2 | ||||
-rw-r--r-- | usr/src/uts/common/os/instance.c | 8 | ||||
-rw-r--r-- | usr/src/uts/common/sys/autoconf.h | 1 | ||||
-rw-r--r-- | usr/src/uts/intel/Makefile.intel.shared | 1 | ||||
-rw-r--r-- | usr/src/uts/intel/nulldriver/Makefile | 94 | ||||
-rw-r--r-- | usr/src/uts/intel/os/name_to_major | 1 | ||||
-rw-r--r-- | usr/src/uts/sparc/Makefile.sparc.shared | 1 | ||||
-rw-r--r-- | usr/src/uts/sparc/nulldriver/Makefile | 94 | ||||
-rw-r--r-- | usr/src/uts/sparc/os/name_to_major | 1 |
11 files changed, 384 insertions, 4 deletions
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index 9efa40936a..53cedce8cc 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -794,7 +794,7 @@ NSKERN_OBJS += nsc_ddi.o \ nsc_proc.o \ nsc_raw.o \ nsc_thread.o \ - nskernd.o + nskernd.o SV_OBJS += sv.o @@ -1801,3 +1801,6 @@ ISCSI_INITIATOR_OBJS = chap.o iscsi_io.o iscsi_thread.o \ # NTXN_OBJS = unm_nic_init.o unm_gem.o unm_nic_hw.o unm_ndd.o \ unm_nic_main.o unm_nic_isr.o unm_nic_ctx.o niu.o +# nulldriver module +# +NULLDRIVER_OBJS = nulldriver.o diff --git a/usr/src/uts/common/io/nulldriver.c b/usr/src/uts/common/io/nulldriver.c new file mode 100644 index 0000000000..04e8d86b22 --- /dev/null +++ b/usr/src/uts/common/io/nulldriver.c @@ -0,0 +1,180 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * nulldriver - null device driver + * + * The nulldriver is used to associate a solaris driver with a specific + * device without enabling external device access. + * + * The driver can be used to: + * + * o Prevent external access to specific devices/hardware by associating a + * high-precedence 'compatible' binding, including a path-oriented alias, + * with nulldriver. + * + * o Enable a nexus bus_config implementation to perform dynamic child + * discovery by creating a child 'probe' devinfo node, bound to + * nulldriver, at the specific child @unit-addresses associated with + * discovery. With a nulldriver bound 'probe' node, nexus driver + * bus_config discovery code can use the same devinfo node oriented + * transport services for both discovery and normal-operation: which + * is a significant simplification. While nulldriver prevents external + * device access, a nexus driver can still internally use the transport + * services. + * + * A scsi(4) example of this type of use is SCSA enumeration services + * issuing a scsi REPORT_LUN command to a lun-0 'probe' node bound to + * nulldriver in order to discover all luns supported by a target. + */ + +#include <sys/modctl.h> +#include <sys/conf.h> +#include <sys/ddi.h> +#include <sys/sunddi.h> +#include <sys/cmn_err.h> + +static int nulldriver_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); +static int nulldriver_probe(dev_info_t *); +static int nulldriver_attach(dev_info_t *, ddi_attach_cmd_t); +static int nulldriver_detach(dev_info_t *, ddi_detach_cmd_t); + +static struct cb_ops nulldriver_cb_ops = { + nodev, /* open */ + nodev, /* close */ + nodev, /* strategy */ + nodev, /* print */ + nodev, /* dump */ + nodev, /* read */ + nodev, /* write */ + nodev, /* ioctl */ + nodev, /* devmap */ + nodev, /* mmap */ + nodev, /* segmap */ + nochpoll, /* poll */ + ddi_prop_op, /* cb_prop_op */ + 0, /* streamtab */ + D_MP | D_NEW | D_HOTPLUG /* Driver compatibility flag */ +}; + +static struct dev_ops nulldriver_dev_ops = { + DEVO_REV, /* devo_rev, */ + 0, /* refcnt */ + nulldriver_getinfo, /* info */ + nodev, /* identify */ + nulldriver_probe, /* probe */ + nulldriver_attach, /* attach */ + nulldriver_detach, /* detach */ + nodev, /* reset */ + &nulldriver_cb_ops, /* driver operations */ + (struct bus_ops *)0, /* bus operations */ + NULL, /* power */ + ddi_quiesce_not_needed, /* quiesce */ +}; + +static struct modldrv modldrv = { + &mod_driverops, "nulldriver 1.1", &nulldriver_dev_ops +}; + +static struct modlinkage modlinkage = { + MODREV_1, &modldrv, NULL +}; + +int +_init(void) +{ + return (mod_install(&modlinkage)); +} + +int +_fini(void) +{ + return (mod_remove(&modlinkage)); +} + +int +_info(struct modinfo *modinfop) +{ + return (mod_info(&modlinkage, modinfop)); +} + +/*ARGSUSED*/ +static int +nulldriver_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, + void *arg, void **result) +{ + return (DDI_FAILURE); +} + +/*ARGSUSED*/ +static int +nulldriver_probe(dev_info_t *dip) +{ + /* + * We want to succeed probe so that the node gets assigned a unit + * address "@addr". + */ + if (ddi_dev_is_sid(dip) == DDI_SUCCESS) + return (DDI_PROBE_DONTCARE); + return (DDI_PROBE_DONTCARE); +} + +/* + * nulldriver_attach() + * attach(9e) entrypoint. + */ +/* ARGSUSED */ +static int +nulldriver_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) +{ + switch (cmd) { + case DDI_ATTACH: + case DDI_RESUME: + return (DDI_SUCCESS); + + case DDI_PM_RESUME: + default: + return (DDI_FAILURE); + } +} + +/* + * nulldriver_detach() + * detach(9E) entrypoint + */ +/* ARGSUSED */ +static int +nulldriver_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) +{ + switch (cmd) { + case DDI_DETACH: + case DDI_SUSPEND: + return (DDI_SUCCESS); + + case DDI_PM_SUSPEND: + default: + return (DDI_FAILURE); + } +} diff --git a/usr/src/uts/common/os/autoconf.c b/usr/src/uts/common/os/autoconf.c index 9e114a599f..2a9d6d6787 100644 --- a/usr/src/uts/common/os/autoconf.c +++ b/usr/src/uts/common/os/autoconf.c @@ -62,6 +62,7 @@ static char *rootname; /* node name of top_devinfo */ kmutex_t global_vhci_lock; major_t mm_major; +major_t nulldriver_major; /* * Forward declarations @@ -469,6 +470,7 @@ i_ddi_init_root() clone_dip = i_ddi_attach_pseudo_node("clone"); clone_major = ddi_driver_major(clone_dip); mm_major = ddi_name_to_major("mm"); + nulldriver_major = ddi_name_to_major("nulldriver"); /* * Attach scsi_vhci for MPXIO, this registers scsi vhci class diff --git a/usr/src/uts/common/os/instance.c b/usr/src/uts/common/os/instance.c index 1e58309d8d..6d4bc8de3f 100644 --- a/usr/src/uts/common/os/instance.c +++ b/usr/src/uts/common/os/instance.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Instance number assignment code */ @@ -317,7 +315,7 @@ in_set_instance(dev_info_t *dip, in_drv_t *dp, major_t major) * Return 1 if instance block was assigned for the path. * * For multi-port NIC cards, sequential instance assignment across all - * ports on a card is highly deseriable since the ppa is typically the + * ports on a card is highly desirable since the ppa is typically the * same as the instance number, and the ppa is used in the NIC's public * /dev name. This sequential assignment typically occurs as a result * of in_preassign_instance() after initial install, or by @@ -760,6 +758,10 @@ e_ddi_keep_instance(dev_info_t *dip) in_node_t *np, *ap; in_drv_t *dp; + /* Don't make nulldriver instance assignments permanent */ + if (ddi_driver_major(dip) == nulldriver_major) + return; + /* * Allow implementation override */ diff --git a/usr/src/uts/common/sys/autoconf.h b/usr/src/uts/common/sys/autoconf.h index 2748ae594b..dcff2318de 100644 --- a/usr/src/uts/common/sys/autoconf.h +++ b/usr/src/uts/common/sys/autoconf.h @@ -196,6 +196,7 @@ extern dev_info_t *pseudo_dip; extern dev_info_t *clone_dip; extern major_t clone_major; extern major_t mm_major; +extern major_t nulldriver_major; extern struct devnames *devnamesp; extern struct devnames orphanlist; diff --git a/usr/src/uts/intel/Makefile.intel.shared b/usr/src/uts/intel/Makefile.intel.shared index 2912878e93..84808ad5aa 100644 --- a/usr/src/uts/intel/Makefile.intel.shared +++ b/usr/src/uts/intel/Makefile.intel.shared @@ -261,6 +261,7 @@ DRV_KMODS_32 += mscsi DRV_KMODS_32 += msm DRV_KMODS += nca DRV_KMODS += nsmb +DRV_KMODS += nulldriver DRV_KMODS += nv_sata DRV_KMODS += nxge DRV_KMODS += openeepr diff --git a/usr/src/uts/intel/nulldriver/Makefile b/usr/src/uts/intel/nulldriver/Makefile new file mode 100644 index 0000000000..96ca163261 --- /dev/null +++ b/usr/src/uts/intel/nulldriver/Makefile @@ -0,0 +1,94 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# uts/intel/nulldriver/Makefile +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# This makefile drives the production of nulldriver kernel module. +# +# i86pc architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = nulldriver +OBJECTS = $(NULLDRIVER_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(NULLDRIVER_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) + +# +# Include common rules. +# +include $(UTSBASE)/Makefile.uts +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +# +# header file directories +# +INC_PATH += -I$(ROOT)/usr/include + +# +# Overrides +# +LDFLAGS += -dy + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +warlock: + @echo warlock is not supported + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/intel/os/name_to_major b/usr/src/uts/intel/os/name_to_major index 30e03cc231..c30f70c0b8 100644 --- a/usr/src/uts/intel/os/name_to_major +++ b/usr/src/uts/intel/os/name_to_major @@ -152,3 +152,4 @@ nsmb 256 fm 257 amd_iommu 258 xpvtap 259 +nulldriver 260 diff --git a/usr/src/uts/sparc/Makefile.sparc.shared b/usr/src/uts/sparc/Makefile.sparc.shared index 0141a71a81..eae5cf44a6 100644 --- a/usr/src/uts/sparc/Makefile.sparc.shared +++ b/usr/src/uts/sparc/Makefile.sparc.shared @@ -224,6 +224,7 @@ DRV_KMODS += smbsrv DRV_KMODS += vscan DRV_KMODS += nsmb DRV_KMODS += fm +DRV_KMODS += nulldriver # # Don't build some of these for OpenSolaris, since they will be diff --git a/usr/src/uts/sparc/nulldriver/Makefile b/usr/src/uts/sparc/nulldriver/Makefile new file mode 100644 index 0000000000..8377da2f73 --- /dev/null +++ b/usr/src/uts/sparc/nulldriver/Makefile @@ -0,0 +1,94 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# uts/sparc/nulldriver/Makefile +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# This makefile drives the production of nulldriver kernel module. +# +# sparc architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = nulldriver +OBJECTS = $(NULLDRIVER_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(NULLDRIVER_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) + +# +# Include common rules. +# +include $(UTSBASE)/Makefile.uts +include $(UTSBASE)/sparc/Makefile.sparc + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +# +# header file directories +# +INC_PATH += -I$(ROOT)/usr/include + +# +# Overrides +# +LDFLAGS += -dy + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +warlock: + @echo warlock is not supported + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/sparc/Makefile.targ diff --git a/usr/src/uts/sparc/os/name_to_major b/usr/src/uts/sparc/os/name_to_major index 1ab97aa3b6..37821178ea 100644 --- a/usr/src/uts/sparc/os/name_to_major +++ b/usr/src/uts/sparc/os/name_to_major @@ -225,3 +225,4 @@ nsmb 276 mem_cache 277 bmc 278 fm 279 +nulldriver 280 |