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 1991-1994,1998,2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
32 static int token2path(char *svc
, uint_t token
, char *buf
, uint_t len
);
35 prom_ihandle_to_path(ihandle_t instance
, char *buf
, uint_t len
)
37 return (token2path("instance-to-path", (uint_t
)instance
, buf
, len
));
41 prom_phandle_to_path(phandle_t package
, char *buf
, uint_t len
)
43 return (token2path("package-to-path", (uint_t
)package
, buf
, len
));
47 token2path(char *service
, uint_t token
, char *buf
, uint_t len
)
51 #ifdef PROM_32BIT_ADDRS
54 if ((uintptr_t)buf
> (uint32_t)-1) {
56 buf
= promplat_alloc(len
);
65 ci
[0] = p1275_ptr2cell(service
); /* Service name */
66 ci
[1] = 3; /* #argument cells */
67 ci
[2] = 1; /* #return cells */
68 ci
[3] = p1275_uint2cell(token
); /* Arg1: ihandle/phandle */
69 ci
[4] = p1275_ptr2cell(buf
); /* Arg2: Result buffer */
70 ci
[5] = p1275_uint2cell(len
); /* Arg3: Buffer len */
71 rv
= p1275_cif_handler(&ci
);
75 #ifdef PROM_32BIT_ADDRS
77 promplat_bcopy(buf
, obuf
, len
);
78 promplat_free(buf
, len
);
84 return (p1275_cell2int(ci
[6])); /* Res1: Actual length */