Changeset 8ea0308 in mainline
- Timestamp:
- 2009-01-16T16:32:59Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d4668392
- Parents:
- 0832b4d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/ofw_tree.c
r0832b4d r8ea0308 43 43 static ofw_tree_property_t *ofw_tree_properties_alloc(unsigned count) 44 44 { 45 return balloc(count * sizeof(ofw_tree_property_t), sizeof(ofw_tree_property_t)); 46 } 47 48 static void * ofw_tree_space_alloc(size_t size) 45 return balloc(count * sizeof(ofw_tree_property_t), 46 sizeof(ofw_tree_property_t)); 47 } 48 49 static void *ofw_tree_space_alloc(size_t size) 49 50 { 50 51 char *addr; … … 66 67 } 67 68 68 /** Transfer information from one OpenFirmware node into its memory representation. 69 * 70 * Transfer entire information from the OpenFirmware device tree 'current' node to 71 * its memory representation in 'current_node'. This function recursively processes 72 * all node's children. Node's peers are processed iteratively in order to prevent 73 * stack from overflowing. 74 * 75 * @param current_node Pointer to uninitialized ofw_tree_node structure that will 76 * become the memory represenation of 'current'. 77 * @param parent_node Parent ofw_tree_node structure or NULL in case of root node. 69 /** Transfer information from one OpenFirmware node into its memory 70 * representation. 71 * 72 * Transfer entire information from the OpenFirmware device tree 'current' node 73 * to its memory representation in 'current_node'. This function recursively 74 * processes all node's children. Node's peers are processed iteratively in 75 * order to prevent stack from overflowing. 76 * 77 * @param current_node Pointer to uninitialized ofw_tree_node structure that 78 * will become the memory represenation of 'current'. 79 * @param parent_node Parent ofw_tree_node structure or NULL in case of root 80 * node. 78 81 * @param current OpenFirmware phandle to the current device tree node. 79 82 */ 80 83 static void ofw_tree_node_process(ofw_tree_node_t *current_node, 81 82 { 83 static char path[MAX_PATH_LEN +1];84 ofw_tree_node_t *parent_node, phandle current) 85 { 86 static char path[MAX_PATH_LEN + 1]; 84 87 static char name[OFW_TREE_PROPERTY_MAX_NAMELEN]; 85 88 static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN]; … … 132 135 child_node = ofw_tree_node_alloc(); 133 136 if (child_node) { 134 ofw_tree_node_process(child_node, current_node, child); 137 ofw_tree_node_process(child_node, current_node, 138 child); 135 139 current_node->child = child_node; 136 140 } … … 152 156 * Copy properties. 153 157 */ 154 current_node->property = ofw_tree_properties_alloc(current_node->properties); 158 current_node->property = 159 ofw_tree_properties_alloc(current_node->properties); 155 160 if (!current_node->property) 156 161 return; … … 165 170 memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN); 166 171 memcpy(current_node->property[i].name, name, 167 OFW_TREE_PROPERTY_MAX_NAMELEN); 168 current_node->property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0'; 172 OFW_TREE_PROPERTY_MAX_NAMELEN); 173 current_node->property[i].name[ 174 OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0'; 169 175 170 176 size = ofw_get_proplen(current, name); … … 178 184 * Copy property value to memory node. 179 185 */ 180 (void) ofw_get_property(current, name, buf, size); 186 (void) ofw_get_property(current, name, 187 buf, size); 181 188 } 182 189 } else { … … 185 192 } 186 193 187 current_node->properties = i; /* Just in case we ran out of memory. */ 194 /* Just in case we ran out of memory. */ 195 current_node->properties = i; 188 196 189 197 /* … … 218 226 /** Construct memory representation of OpenFirmware device tree. 219 227 * 220 * @return 228 * @return NULL on failure or pointer to the root node. 221 229 */ 222 230 ofw_tree_node_t *ofw_tree_build(void) … … 239 247 ssm = ofw_tree_node_alloc(); 240 248 if (ssm) { 241 ofw_tree_node_process( 242 ssm, root,ofw_find_device("/ssm@0,0"));249 ofw_tree_node_process(ssm, root, 250 ofw_find_device("/ssm@0,0")); 243 251 ssm->peer = root->child; 244 252 root->child = ssm;
Note:
See TracChangeset
for help on using the changeset viewer.