summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/ddi_create_minor_node.9f
blob: 5280932843ff22cac346e791106be1625f2133cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
.\" 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]
.TH DDI_CREATE_MINOR_NODE 9F "May 01, 2020"
.SH NAME
ddi_create_minor_node \- Create a minor node for this device
.SH SYNOPSIS
.nf
#include <sys/stat.h>
#include <sys/sunddi.h>



\fBint\fR \fBddi_create_minor_node\fR(\fBdev_info_t *\fR\fIdip\fR, \fBconst char *\fR\fIname\fR,
     \fBint\fR \fIspec_type\fR, \fBminor_t\fR \fIminor_num\fR, \fBconst char *\fR\fInode_type\fR,
     \fBint\fR \fIflag\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI).
.SH PARAMETERS
.ne 2
.na
\fB\fIdip\fR \fR
.ad
.RS 14n
A pointer to the device's \fBdev_info\fR structure.
.RE

.sp
.ne 2
.na
\fB\fIname\fR \fR
.ad
.RS 14n
The name of this particular minor device.
.RE

.sp
.ne 2
.na
\fB\fIspec_type\fR \fR
.ad
.RS 14n
\fBS_IFCHR\fR or \fBS_IFBLK\fR for character or block minor devices
respectively.
.RE

.sp
.ne 2
.na
\fB\fIminor_num\fR \fR
.ad
.RS 14n
The minor number for this particular minor device.
.RE

.sp
.ne 2
.na
\fB\fInode_type\fR \fR
.ad
.RS 14n
Any string literal that uniquely identifies the type of  node. The following
predefined node types are provided with this release:
.sp
.ne 2
.na
\fB\fBDDI_NT_SERIAL\fR \fR
.ad
.RS 24n
For serial ports
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_SERIAL_MB\fR \fR
.ad
.RS 24n
For on board serial ports
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_SERIAL_DO\fR \fR
.ad
.RS 24n
For dial out ports
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_SERIAL_MB_DO\fR \fR
.ad
.RS 24n
For on board dial out ports
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_BLOCK\fR \fR
.ad
.RS 24n
For hard disks
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_BLOCK_CHAN\fR \fR
.ad
.RS 24n
For hard disks with channel or target numbers
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_CD\fR \fR
.ad
.RS 24n
For CDROM drives
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_CD_CHAN\fR \fR
.ad
.RS 24n
For CDROM drives with channel or target numbers
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_FD\fR \fR
.ad
.RS 24n
For floppy disks
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_TAPE\fR \fR
.ad
.RS 24n
For tape drives
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_NET\fR \fR
.ad
.RS 24n
For DLPI style 1 or style 2 network devices
.RE

.sp
.ne 2
.na
\fB\fBDDI_NT_DISPLAY\fR \fR
.ad
.RS 24n
For display devices
.RE

.sp
.ne 2
.na
\fB\fBDDI_PSEUDO\fR \fR
.ad
.RS 24n
For pseudo devices
.RE

.RE

.sp
.ne 2
.na
\fB\fIflag\fR \fR
.ad
.RS 14n
If the device is a clone device then this flag is set to \fBCLONE_DEV\fR else
it is set to \fB0\fR.
.RE

.SH DESCRIPTION
\fBddi_create_minor_node()\fR provides the necessary information to enable the
system to create the \fB/dev\fR and \fB/devices\fR hierarchies. The \fIname\fR
is used to create the minor name of the block or character special file under
the \fB/devices\fR hierarchy. At-sign (\fB@\fR), slash (\fB/\fR), and space are
not allowed. The \fIspec_type\fR specifies whether this is a block or character
device. The \fIminor_num\fR is the minor number for the device. The
\fInode_type\fR is used to create the names in the \fB/dev\fR hierarchy that
refers to the names in the \fB/devices\fR hierarchy. See \fBdisks\fR(8),
\fBports\fR(8), \fBtapes\fR(8), \fBdevlinks\fR(8). Finally \fIflag\fR
determines if this is a clone device or not, and what device class the node
belongs to.
.SH RETURN VALUES
\fBddi_create_minor_node()\fR returns:
.sp
.ne 2
.na
\fB\fBDDI_SUCCESS\fR \fR
.ad
.RS 16n
Was able to allocate memory, create the minor data structure, and place it into
the linked list of minor devices for this driver.
.RE

.sp
.ne 2
.na
\fB\fBDDI_FAILURE\fR \fR
.ad
.RS 16n
Minor node creation failed.
.RE

.SH CONTEXT
The \fBddi_create_minor_node()\fR function can be called from user context. It
is typically called from \fBattach\fR(9E) or \fBioctl\fR(9E).
.SH EXAMPLES
\fBExample 1 \fRCreate Data Structure Describing Minor Device with Minor Number
of 0
.sp
.LP
The following example creates a data structure describing a minor device called
\fIfoo\fR which has a minor number of 0. It is of type \fBDDI_NT_BLOCK\fR (a
block device) and it is not a clone device.

.sp
.in +2
.nf
ddi_create_minor_node(dip, "foo", S_IFBLK, 0, DDI_NT_BLOCK, 0);
.fi
.in -2

.SH SEE ALSO
.BR add_drv (8),
.BR devlinks (8),
.BR disks (8),
.BR drvconfig (8),
.BR ports (8),
.BR tapes (8),
.BR attach (9E),
.BR ddi_remove_minor_node (9F)
.sp
.LP
\fIWriting Device Drivers\fR
.SH NOTES
If the driver is for a network device (\fInode_type\fR \fBDDI_NT_NET\fR), note
that the driver name will undergo the driver name constraints identified in the
NOTES section of \fBdlpi\fR(4P). Additionally, the minor name must match the
driver name for a DLPI style 2 provider. If the driver is a DLPI style 1
provider, the minor name must also match the driver name with the exception
that the ppa is appended to the minor name.
.sp
.LP
Non-\fBgld\fR(4D)-based DLPI network streams drivers are encouraged to switch
to \fBgld\fR(4D). Failing this, a driver that creates DLPI style-2   minor
nodes must specify CLONE_DEV for its style-2 \fBddi_create_minor_node()\fR
nodes and use \fBqassociate\fR(9F). A driver that supports both style-1 and
style-2 minor nodes should return DDI_FAILURE for DDI_INFO_DEVT2INSTANCE and
DDI_INFO_DEVT2DEVINFO \fBgetinfo\fR(9E) calls to style-2 minor nodes. (The
correct association is already established by \fBqassociate\fR(9F)). A driver
that only supports style-2 minor nodes can use \fBddi_no_info\fR(9F) for its
\fBgetinfo\fR(9E) implementation. For drivers that do not follow these rules,
the results of a \fBmodunload\fR(8) of the driver or a \fBcfgadm\fR(8) remove
of hardware controlled by the driver are undefined.
.SH WARNING
Drivers must remove references to GLOBAL_DEV, NODEBOUND_DEV, NODESPECIFIC_DEV,
and ENUMERATED_DEV to compile.