2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH DDI_CREATE_MINOR_NODE 9F "Dec 14, 2004"
8 ddi_create_minor_node \- Create a minor node for this device
13 #include <sys/sunddi.h>
17 \fBint\fR \fBddi_create_minor_node\fR(\fBdev_info_t *\fR\fIdip\fR, \fBchar *\fR\fIname\fR, \fBint\fR \fIspec_type\fR,
18 \fBminor_t\fR \fIminor_num\fR, \fBchar *\fR\fInode_type\fR, \fBint\fR \fIflag\fR);
24 Solaris DDI specific (Solaris DDI).
32 A pointer to the device's \fBdev_info\fR structure.
41 The name of this particular minor device.
47 \fB\fIspec_type\fR \fR
50 \fBS_IFCHR\fR or \fBS_IFBLK\fR for character or block minor devices
57 \fB\fIminor_num\fR \fR
60 The minor number for this particular minor device.
66 \fB\fInode_type\fR \fR
69 Any string literal that uniquely identifies the type of node. The following
70 predefined node types are provided with this release:
74 \fB\fBDDI_NT_SERIAL\fR \fR
83 \fB\fBDDI_NT_SERIAL_MB\fR \fR
86 For on board serial ports
92 \fB\fBDDI_NT_SERIAL_DO\fR \fR
101 \fB\fBDDI_NT_SERIAL_MB_DO\fR \fR
104 For on board dial out ports
110 \fB\fBDDI_NT_BLOCK\fR \fR
119 \fB\fBDDI_NT_BLOCK_CHAN\fR \fR
122 For hard disks with channel or target numbers
128 \fB\fBDDI_NT_CD\fR \fR
137 \fB\fBDDI_NT_CD_CHAN\fR \fR
140 For CDROM drives with channel or target numbers
146 \fB\fBDDI_NT_FD\fR \fR
155 \fB\fBDDI_NT_TAPE\fR \fR
164 \fB\fBDDI_NT_NET\fR \fR
167 For DLPI style 1 or style 2 network devices
173 \fB\fBDDI_NT_DISPLAY\fR \fR
182 \fB\fBDDI_PSEUDO\fR \fR
196 If the device is a clone device then this flag is set to \fBCLONE_DEV\fR else
197 it is set to \fB0\fR.
203 \fBddi_create_minor_node()\fR provides the necessary information to enable the
204 system to create the \fB/dev\fR and \fB/devices\fR hierarchies. The \fIname\fR
205 is used to create the minor name of the block or character special file under
206 the \fB/devices\fR hierarchy. At-sign (\fB@\fR), slash (\fB/\fR), and space are
207 not allowed. The \fIspec_type\fR specifies whether this is a block or character
208 device. The \fIminor_num\fR is the minor number for the device. The
209 \fInode_type\fR is used to create the names in the \fB/dev\fR hierarchy that
210 refers to the names in the \fB/devices\fR hierarchy. See \fBdisks\fR(1M),
211 \fBports\fR(1M), \fBtapes\fR(1M), \fBdevlinks\fR(1M). Finally \fIflag\fR
212 determines if this is a clone device or not, and what device class the node
217 \fBddi_create_minor_node()\fR returns:
221 \fB\fBDDI_SUCCESS\fR \fR
224 Was able to allocate memory, create the minor data structure, and place it into
225 the linked list of minor devices for this driver.
231 \fB\fBDDI_FAILURE\fR \fR
234 Minor node creation failed.
240 The \fBddi_create_minor_node()\fR function can be called from user context. It
241 is typically called from \fBattach\fR(9E) or \fBioctl\fR(9E).
244 \fBExample 1 \fRCreate Data Structure Describing Minor Device with Minor Number
248 The following example creates a data structure describing a minor device called
249 \fIfoo\fR which has a minor number of 0. It is of type \fBDDI_NT_BLOCK\fR (a
250 block device) and it is not a clone device.
255 ddi_create_minor_node(dip, "foo", S_IFBLK, 0, DDI_NT_BLOCK, 0);
262 \fBadd_drv\fR(1M), \fBdevlinks\fR(1M), \fBdisks\fR(1M), \fBdrvconfig\fR(1M),
263 \fBports\fR(1M), \fBtapes\fR(1M), \fBattach\fR(9E),
264 \fBddi_remove_minor_node\fR(9F)
267 \fIWriting Device Drivers\fR
271 If the driver is for a network device (\fInode_type\fR \fBDDI_NT_NET\fR), note
272 that the driver name will undergo the driver name constraints identified in the
273 NOTES section of \fBdlpi\fR(7P). Additionally, the minor name must match the
274 driver name for a DLPI style 2 provider. If the driver is a DLPI style 1
275 provider, the minor name must also match the driver name with the exception
276 that the ppa is appended to the minor name.
279 Non-\fBgld\fR(7D)-based DLPI network streams drivers are encouraged to switch
280 to \fBgld\fR(7D). Failing this, a driver that creates DLPI style-2 minor
281 nodes must specify CLONE_DEV for its style-2 \fBddi_create_minor_node()\fR
282 nodes and use \fBqassociate\fR(9F). A driver that supports both style-1 and
283 style-2 minor nodes should return DDI_FAILURE for DDI_INFO_DEVT2INSTANCE and
284 DDI_INFO_DEVT2DEVINFO \fBgetinfo\fR(9E) calls to style-2 minor nodes. (The
285 correct association is already established by \fBqassociate\fR(9F)). A driver
286 that only supports style-2 minor nodes can use \fBddi_no_info\fR(9F) for its
287 \fBgetinfo\fR(9E) implementation. For drivers that do not follow these rules,
288 the results of a \fBmodunload\fR(1M) of the driver or a \fBcfgadm\fR(1M) remove
289 of hardware controlled by the driver are undefined.
293 Drivers must remove references to GLOBAL_DEV, NODEBOUND_DEV, NODESPECIFIC_DEV,
294 and ENUMERATED_DEV to compile under Solaris 10 and later versions.