4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
32 #include <sys/mkdev.h>
33 #include <bsm/devalloc.h>
35 extern int system_labeled
;
38 static int ddi_other(di_minor_t minor
, di_node_t node
);
39 static int diskette(di_minor_t minor
, di_node_t node
);
40 static int ecpp_create(di_minor_t minor
, di_node_t node
);
41 static int mc_node(di_minor_t minor
, di_node_t node
);
42 static int starcat_sbbc_node(di_minor_t minor
, di_node_t node
);
43 static int lom(di_minor_t minor
, di_node_t node
);
44 static int ntwdt_create(di_minor_t minor
, di_node_t node
);
45 static int bmc(di_minor_t minor
, di_node_t node
);
47 static devfsadm_create_t misc_cbt
[] = {
48 { "other", "ddi_other", NULL
,
49 TYPE_EXACT
, ILEVEL_0
, ddi_other
51 { "memory-controller", "ddi_mem_ctrl", NULL
,
52 TYPE_EXACT
, ILEVEL_0
, mc_node
54 { "pseudo", "ddi_pseudo", "sbbc",
55 TYPE_EXACT
| DRV_EXACT
, ILEVEL_1
, starcat_sbbc_node
57 { "disk", "ddi_block:diskette", NULL
,
58 TYPE_EXACT
, ILEVEL_1
, diskette
60 { "printer", "ddi_printer", NULL
,
61 TYPE_EXACT
, ILEVEL_1
, ecpp_create
63 { "pseudo", "ddi_pseudo", "lw8",
64 TYPE_EXACT
| DRV_EXACT
, ILEVEL_0
, lom
66 { "pseudo", "ddi_pseudo", "ntwdt",
67 TYPE_EXACT
| DRV_EXACT
, ILEVEL_0
, ntwdt_create
69 { "pseudo", "ddi_pseudo", "bmc",
70 TYPE_EXACT
| DRV_EXACT
, ILEVEL_0
, bmc
74 DEVFSADM_CREATE_INIT_V0(misc_cbt
);
78 * Handles minor node type "ddi_other"
79 * type=ddi_other;name=SUNW,pmc pmc
80 * type=ddi_other;name=SUNW,mic mic\M0
83 ddi_other(di_minor_t minor
, di_node_t node
)
85 char path
[PATH_MAX
+ 1];
86 char *nn
= di_node_name(node
);
87 char *mn
= di_minor_name(minor
);
89 if (strcmp(nn
, "SUNW,pmc") == 0) {
90 (void) devfsadm_mklink("pcm", node
, minor
, 0);
91 } else if (strcmp(nn
, "SUNW,mic") == 0) {
92 (void) strcpy(path
, "mic");
93 (void) strcat(path
, mn
);
94 (void) devfsadm_mklink(path
, node
, minor
, 0);
97 return (DEVFSADM_CONTINUE
);
101 * This function is called for diskette nodes
104 diskette(di_minor_t minor
, di_node_t node
)
107 char *mn
= di_minor_name(minor
);
110 flags
= DA_ADD
|DA_FLOPPY
;
112 if (strcmp(mn
, "c") == 0) {
113 (void) devfsadm_mklink("diskette", node
, minor
, flags
);
114 (void) devfsadm_mklink("diskette0", node
, minor
, flags
);
116 } else if (strcmp(mn
, "c,raw") == 0) {
117 (void) devfsadm_mklink("rdiskette", node
, minor
, flags
);
118 (void) devfsadm_mklink("rdiskette0", node
, minor
, flags
);
121 return (DEVFSADM_CONTINUE
);
125 * Handles links of the form:
126 * type=ddi_printer;name=ecpp ecpp\N0
129 ecpp_create(di_minor_t minor
, di_node_t node
)
132 char path
[PATH_MAX
+ 1];
133 devfsadm_enumerate_t rules
[1] = {"^ecpp([0-9]+)$", 1, MATCH_ALL
};
135 if (strcmp(di_driver_name(node
), "ecpp") != 0) {
136 return (DEVFSADM_CONTINUE
);
139 if ((buf
= di_devfs_path(node
)) == NULL
) {
140 return (DEVFSADM_CONTINUE
);
143 (void) snprintf(path
, sizeof (path
), "%s:%s",
144 buf
, di_minor_name(minor
));
146 di_devfs_path_free(buf
);
148 if (devfsadm_enumerate_int(path
, 0, &buf
, rules
, 1)) {
149 return (DEVFSADM_CONTINUE
);
152 (void) snprintf(path
, sizeof (path
), "ecpp%s", buf
);
155 (void) devfsadm_mklink(path
, node
, minor
, 0);
156 return (DEVFSADM_CONTINUE
);
159 /* Rules for memory controller */
160 static devfsadm_enumerate_t mc_rules
[1] =
161 {"^mc$/^mc([0-9]+)$", 1, MATCH_ALL
};
165 mc_node(di_minor_t minor
, di_node_t node
)
167 char path
[PATH_MAX
], l_path
[PATH_MAX
], *buf
, *devfspath
;
170 minor_nm
= di_minor_name(minor
);
172 if (minor_nm
== NULL
) {
173 return (DEVFSADM_CONTINUE
);
176 devfspath
= di_devfs_path(node
);
178 (void) strcpy(path
, devfspath
);
179 (void) strcat(path
, ":");
180 (void) strcat(path
, minor_nm
);
181 di_devfs_path_free(devfspath
);
183 /* build the physical path from the components */
184 if (devfsadm_enumerate_int(path
, 0, &buf
, mc_rules
, 1)) {
185 return (DEVFSADM_CONTINUE
);
188 (void) strcpy(l_path
, "mc/mc");
189 (void) strcat(l_path
, buf
);
193 (void) devfsadm_mklink(l_path
, node
, minor
, 0);
194 return (DEVFSADM_CONTINUE
);
199 * Starcat sbbc node. We only really care about generating a /dev
200 * link for the lone sbbc on the SC (as opposed to the potentially
201 * numerous sbbcs on the domain), so only operate on instance 0.
204 starcat_sbbc_node(di_minor_t minor
, di_node_t node
)
208 if (di_instance(node
) == 0) {
209 mn
= di_minor_name(minor
);
210 (void) devfsadm_mklink(mn
, node
, minor
, 0);
212 return (DEVFSADM_CONTINUE
);
217 * Creates /dev/lom nodes for Platform Specific lom driver
220 lom(di_minor_t minor
, di_node_t node
)
222 (void) devfsadm_mklink("lom", node
, minor
, 0);
223 return (DEVFSADM_CONTINUE
);
227 * Creates /dev/ntwdt nodes for Platform Specific ntwdt driver
230 ntwdt_create(di_minor_t minor
, di_node_t node
)
232 (void) devfsadm_mklink("ntwdt", node
, minor
, 0);
233 return (DEVFSADM_CONTINUE
);
237 * Creates /dev/bmc node.
240 bmc(di_minor_t minor
, di_node_t node
)
242 (void) devfsadm_mklink("bmc", node
, minor
, 0);
243 return (DEVFSADM_CONTINUE
);