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"
37 #include <fcode/private.h>
38 #include <fcode/log.h>
40 #include <fcdriver/fcdriver.h>
43 create_node(fcode_env_t
*env
, device_t
*d
)
48 char *service
= FC_NEW_DEVICE
;
49 private_data_t
*pd
, *ppd
;
52 pd
= (private_data_t
*)d
->private;
53 ppd
= (private_data_t
*)d
->parent
->private;
56 MYSELF
= open_instance_chain(env
, d
, 0);
57 p
= lookup_package_property(env
, "name", d
);
59 forth_abort(env
, "create_node: '%s' name prop not found\n",
63 debug_msg(DEBUG_UPLOAD
, "Create Node: %p\n", pd
->node
);
64 debug_msg(DEBUG_UPLOAD
, " Device Name: '%s'\n", p
->data
);
65 debug_msg(DEBUG_UPLOAD
, " Parent : %p\n", ppd
->node
);
68 (void) call_my_parent(env
, "encode-unit");
69 unit_str
= pop_a_duped_string(env
, NULL
);
70 if (unit_str
== NULL
) {
71 unit_str
= STRDUP("");
74 debug_msg(DEBUG_UPLOAD
, " Unit Addr : '%s'\n", unit_str
);
76 error
= fc_run_priv(pd
->common
, FC_NEW_DEVICE
, 4, 0,
77 fc_phandle2cell(pd
->node
), fc_phandle2cell(ppd
->node
),
78 fc_ptr2cell(unit_str
), fc_ptr2cell(p
->data
));
81 close_instance_chain(env
, MYSELF
, 0);
85 log_message(MSG_ERROR
, "%s: parent: '%s' new: '%s'\n", service
,
86 get_path(env
, d
->parent
), p
->data
);
90 finish_node(fcode_env_t
*env
, device_t
*d
)
95 pd
= (private_data_t
*)d
->private;
97 debug_msg(DEBUG_UPLOAD
, "Finish Node: %p\n", pd
->node
);
99 error
= fc_run_priv(pd
->common
, FC_FINISH_DEVICE
, 1, 0,
100 fc_phandle2cell(pd
->node
));
102 log_message(MSG_ERROR
, "%s: failed\n", FC_FINISH_DEVICE
);
106 upload_properties(fcode_env_t
*env
, device_t
*d
)
112 pd
= (private_data_t
*)d
->private;
113 debug_msg(DEBUG_UPLOAD
, "Upload Properties: node %p upload: %d\n",
114 pd
->node
, pd
->upload
);
119 for (p
= d
->properties
; p
; p
= p
->next
) {
120 DEBUGF(UPLOAD
, print_property(env
, p
, " Upload: "));
122 error
= fc_run_priv(pd
->common
, FC_CREATE_PROPERTY
, 4, 0,
123 fc_phandle2cell(pd
->node
), fc_int2cell(p
->size
),
124 fc_ptr2cell(p
->data
), fc_ptr2cell(p
->name
));
127 log_message(MSG_ERROR
, "%s: '%s' failed\n",
128 FC_CREATE_PROPERTY
, p
->name
);
133 upload_node(fcode_env_t
*env
, device_t
*d
)
135 private_data_t
*pd
= (private_data_t
*)d
->private;
138 debug_msg(DEBUG_UPLOAD
, "Upload Node: dev: %p node: %p"
139 " upload: %d\n", d
, pd
->node
, pd
->upload
);
142 upload_properties(env
, d
);
146 debug_msg(DEBUG_UPLOAD
, "Upload Node: dev: %p NULL private\n",
151 upload_nodes(fcode_env_t
*env
)
153 debug_msg(DEBUG_UPLOAD
, "Upload Nodes: Recursing Tree\n");
154 recurse_tree(env
, env
->root_node
, upload_node
);
158 validate_nodes(fcode_env_t
*env
)
161 common_data_t
*cdp
= env
->private;
163 error
= ioctl(cdp
->fcode_fd
, FC_VALIDATE
);
171 fcode_env_t
*env
= initial_env
;
176 FORTH(0, "upload-nodes", upload_nodes
);
177 FORTH(0, "validate-nodes", validate_nodes
);