4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <sys/modctl.h>
28 #include <sys/sunddi.h>
30 /* internal global data */
31 static struct modlmisc modlmisc
= {
32 &mod_miscops
, "bootdev misc module"
35 static struct modlinkage modlinkage
= {
36 MODREV_1
, (void *)&modlmisc
, NULL
42 return (mod_install(&modlinkage
));
48 return (mod_remove(&modlinkage
));
52 _info(struct modinfo
*modinfop
)
54 return (mod_info(&modlinkage
, modinfop
));
58 * convert a prom device path to an equivalent path in /devices
59 * Does not deal with aliases. Does deal with pathnames which
60 * are not fully qualified. This routine is generalized
61 * to work across several flavors of OBP
64 i_promname_to_devname(char *prom_name
, char *ret_buf
)
66 if (prom_name
== NULL
|| ret_buf
== NULL
||
67 (strlen(prom_name
) >= MAXPATHLEN
)) {
70 if (i_ddi_prompath_to_devfspath(prom_name
, ret_buf
) != DDI_SUCCESS
)
77 * If bootstring contains a device path, we need to convert to a format
78 * the prom will understand. To do so, we convert the existing path to
79 * a prom-compatible path and return the value of new_path. If the
80 * caller specifies new_path as NULL, we allocate an appropriately
81 * sized new_path on behalf of the caller. If the caller invokes this
82 * function with new_path = NULL, they must do so from a context in
83 * which it is safe to perform a sleeping memory allocation.
85 * NOTE: Intel does not have a real PROM, so the implementation
86 * simply returns a copy of the string passed in.
89 i_convert_boot_device_name(char *cur_path
, char *new_path
, size_t *len
)
91 if (new_path
!= NULL
) {
92 (void) snprintf(new_path
, *len
, "%s", cur_path
);
95 *len
= strlen(cur_path
) + 1;
96 new_path
= kmem_alloc(*len
, KM_SLEEP
);
97 (void) snprintf(new_path
, *len
, "%s", cur_path
);