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 (c) 2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <fcode/private.h>
35 #include <fcode/log.h>
37 #include <fcdriver/fcdriver.h>
40 static char *prop_buf
;
43 getproplen(common_data_t
*cdp
, fc_phandle_t node
, char *propname
, int inherit
)
49 service
= inherit
? FC_GET_IN_PROPLEN
: FC_GET_PKG_PROPLEN
;
51 error
= fc_run_priv(cdp
, service
, 2, 1, fc_phandle2cell(node
),
52 fc_ptr2cell(propname
), &len
);
56 return (fc_cell2int(len
));
60 getprop(common_data_t
*cdp
, fc_phandle_t node
, char *propname
, char *buf
,
67 service
= inherit
? FC_GET_IN_PROP
: FC_GET_PKG_PROP
;
69 error
= fc_run_priv(cdp
, service
, 3, 1, fc_phandle2cell(node
),
70 fc_ptr2cell(buf
), fc_ptr2cell(propname
), &len
);
74 return (fc_cell2int(len
));
78 os_get_prop_common(common_data_t
*cdp
, fc_phandle_t node
, char *name
,
79 int inherit
, char **buf
, int *len
)
84 i
= getproplen(cdp
, node
, name
, inherit
);
87 * OK for properties to be undefined, suppress error message
88 * unless some debug is on.
90 if (get_interpreter_debug_level())
91 log_message(MSG_ERROR
, "os_get_prop_common:"
92 " getproplen(%s) returned %d\n", name
, i
);
97 j
= getprop(cdp
, node
, name
, bp
, inherit
);
100 * It's an error if getproplen succeeded but getprop didn't
101 * return a matching length.
103 log_message(MSG_ERROR
, "os_get_prop_common: getprop(%s)"
104 " return %d, getproplen returned %d\n", name
, j
, i
);
108 memcpy(prop_buf
, bp
, i
);
116 os_get_prop(fcode_env_t
*env
, int inherit
, device_t
*dev
)
129 name
= pop_a_string(env
, &len
);
133 log_message(MSG_ERROR
, "os_get_prop: NULL node: %s\n",
136 } else if (os_get_prop_common(pd
->common
, node
, name
, inherit
, &prop
,
140 PUSH(DS
, (fstack_t
)prop
);
147 os_get_package_prop(fcode_env_t
*env
)
151 CONVERT_PHANDLE(env
, dev
, POP(DS
));
152 os_get_prop(env
, 0, dev
);
156 os_get_inherited_prop(fcode_env_t
*env
)
158 os_get_prop(env
, 1, env
->attachment_pt
);
162 install_property_vectors(fcode_env_t
*env
, device_t
*d
)
164 d
->vectors
.get_package_prop
= os_get_package_prop
;
165 d
->vectors
.get_inherited_prop
= os_get_inherited_prop
;
173 fcode_env_t
*env
= initial_env
;
178 prop_buf
= MALLOC(4096);