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]
23 * Copyright 2008 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>
33 prom_fopen(ihandle_t fsih
, char *path
)
38 #ifdef PROM_32BIT_ADDRS
41 if ((uintptr_t)path
> (uint32_t)-1) {
43 len
= prom_strlen(opath
) + 1; /* include terminating NUL */
44 path
= promplat_alloc(len
);
47 (void) prom_strcpy(path
, opath
);
50 len
= prom_strlen(path
);
53 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
54 ci
[1] = (cell_t
)4; /* #argument cells */
55 ci
[2] = (cell_t
)3; /* #result cells */
56 ci
[3] = p1275_ptr2cell("open-file"); /* Arg1: Method name */
57 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
58 ci
[5] = p1275_uint2cell(len
); /* Arg3: Len */
59 ci
[6] = p1275_ptr2cell(path
); /* Arg4: Pathname */
61 (void) p1275_cif_handler(&ci
);
65 #ifdef PROM_32BIT_ADDRS
67 promplat_free(path
, len
+ 1);
70 if (ci
[7] != 0) /* Catch result */
73 if (ci
[8] == 0) /* Res1: failed */
76 return (p1275_cell2int(ci
[9])); /* Res2: fd */
80 prom_volopen(ihandle_t fsih
, char *path
)
85 #ifdef PROM_32BIT_ADDRS
88 if ((uintptr_t)path
> (uint32_t)-1) {
90 len
= prom_strlen(opath
) + 1; /* include terminating NUL */
91 path
= promplat_alloc(len
);
94 (void) prom_strcpy(path
, opath
);
97 len
= prom_strlen(path
);
100 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
101 ci
[1] = (cell_t
)4; /* #argument cells */
102 ci
[2] = (cell_t
)3; /* #result cells */
103 ci
[3] = p1275_ptr2cell("open-volume"); /* Arg1: Method name */
104 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
105 ci
[5] = p1275_uint2cell(len
); /* Arg3: Len */
106 ci
[6] = p1275_ptr2cell(path
); /* Arg4: Pathname */
108 (void) p1275_cif_handler(&ci
);
112 #ifdef PROM_32BIT_ADDRS
114 promplat_free(path
, len
+ 1);
117 if (ci
[7] != 0) /* Catch result */
120 if (ci
[8] == 0) /* Res1: failed */
123 return (p1275_cell2int(ci
[9])); /* Res2: fd */
127 prom_fseek(ihandle_t fsih
, int fd
, unsigned long long offset
)
131 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
132 ci
[1] = (cell_t
)4; /* #argument cells */
133 ci
[2] = (cell_t
)3; /* #result cells */
134 ci
[3] = p1275_ptr2cell("seek-file"); /* Arg1: Method name */
135 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
136 ci
[5] = p1275_int2cell(fd
); /* Arg3: file desc */
137 ci
[6] = p1275_ull2cell_low(offset
); /* Arg4: Offset */
140 (void) p1275_cif_handler(&ci
);
143 if (ci
[7] != 0) /* Catch result */
146 if (ci
[8] == 0) /* Res1: failed */
149 return (p1275_cell2int(ci
[9])); /* Res2: off */
154 prom_fread(ihandle_t fsih
, int fd
, caddr_t buf
, size_t len
)
157 #ifdef PROM_32BIT_ADDRS
160 if ((uintptr_t)buf
> (uint32_t)-1) {
162 buf
= promplat_alloc(len
);
170 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
171 ci
[1] = (cell_t
)5; /* #argument cells */
172 ci
[2] = (cell_t
)2; /* #result cells */
173 ci
[3] = p1275_ptr2cell("read-file"); /* Arg1: Method name */
174 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
175 ci
[5] = p1275_int2cell(fd
); /* Arg3: file desc */
176 ci
[6] = p1275_uint2cell(len
); /* Arg4: buffer length */
177 ci
[7] = p1275_ptr2cell(buf
); /* Arg5: buffer address */
179 (void) p1275_cif_handler(&ci
);
183 #ifdef PROM_32BIT_ADDRS
185 promplat_bcopy(buf
, obuf
, len
);
186 promplat_free(buf
, len
);
190 if (ci
[8] != 0) /* Catch result */
193 return (p1275_cell2int(ci
[9])); /* Res2: actual length */
197 prom_fsize(ihandle_t fsih
, int fd
, size_t *size
)
203 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
204 ci
[1] = (cell_t
)3; /* #argument cells */
205 ci
[2] = (cell_t
)2; /* #result cells */
206 ci
[3] = p1275_ptr2cell("size-file"); /* Arg1: Method name */
207 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
208 ci
[5] = p1275_int2cell(fd
); /* Arg3: file desc */
210 (void) p1275_cif_handler(&ci
);
214 if (ci
[6] != 0) /* Catch result */
217 *size
= p1275_cell2uint(ci
[7]); /* Res2: size */
223 prom_compinfo(ihandle_t fsih
, int fd
, int *iscmp
, size_t *fsize
, size_t *bsize
)
229 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
230 ci
[1] = (cell_t
)3; /* #argument cells */
231 ci
[2] = (cell_t
)4; /* #result cells */
232 ci
[3] = p1275_ptr2cell("cinfo-file"); /* Arg1: Method name */
233 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
234 ci
[5] = p1275_int2cell(fd
); /* Arg3: file desc */
236 (void) p1275_cif_handler(&ci
);
240 if (ci
[6] != 0) /* Catch result */
243 *iscmp
= p1275_cell2int(ci
[7]); /* Res2: iscmp */
244 *fsize
= p1275_cell2uint(ci
[8]); /* Res3: fsize */
245 *bsize
= p1275_cell2uint(ci
[9]); /* Res4: bsize */
250 prom_fclose(ihandle_t fsih
, int fd
)
254 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
255 ci
[1] = (cell_t
)3; /* #argument cells */
256 ci
[2] = (cell_t
)1; /* #result cells */
257 ci
[3] = p1275_ptr2cell("close-file"); /* Arg1: Method name */
258 ci
[4] = p1275_ihandle2cell(fsih
); /* Arg2: fs ihandle */
259 ci
[5] = p1275_int2cell(fd
); /* Arg3: file desc */
262 (void) p1275_cif_handler(&ci
);