Changeset 3113d47 in mainline
- Timestamp:
- 2012-03-02T16:17:11Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0499235
- Parents:
- 196c253
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/ofw/ofw_tree.c
r196c253 r3113d47 320 320 } 321 321 322 /** Get OpenFirmware node properties. 323 * 324 * @param item Sysinfo item (unused). 325 * @param size Size of the returned data. 326 * @param dry_run Do not get the data, just calculate the size. 327 * @param data OpenFirmware node. 328 * 329 * @return Data containing a serialized dump of all node 330 * properties. If the return value is not NULL, it 331 * should be freed in the context of the sysinfo request. 332 * 333 */ 334 static void *ofw_sysinfo_properties(struct sysinfo_item *item, size_t *size, 335 bool dry_run, void *data) 336 { 337 ofw_tree_node_t *node = (ofw_tree_node_t *) data; 338 339 /* Compute serialized data size */ 340 *size = 0; 341 for (size_t i = 0; i < node->properties; i++) 342 *size += str_size(node->property[i].name) + 1 + 343 sizeof(node->property[i].size) + node->property[i].size; 344 345 if (dry_run) 346 return NULL; 347 348 void *dump = malloc(*size, FRAME_ATOMIC); 349 if (dump == NULL) { 350 *size = 0; 351 return NULL; 352 } 353 354 /* Serialize the data */ 355 size_t pos = 0; 356 for (size_t i = 0; i < node->properties; i++) { 357 /* Property name */ 358 str_cpy(dump + pos, *size - pos, node->property[i].name); 359 pos += str_size(node->property[i].name) + 1; 360 361 /* Value size */ 362 memcpy(dump + pos, &node->property[i].size, 363 sizeof(node->property[i].size)); 364 pos += sizeof(node->property[i].size); 365 366 /* Value */ 367 memcpy(dump + pos, node->property[i].value, 368 node->property[i].size); 369 pos += node->property[i].size; 370 } 371 372 return ((void *) dump); 373 } 374 322 375 /** Map OpenFirmware device subtree rooted in a node into sysinfo. 323 376 * … … 339 392 snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name); 340 393 341 sysinfo_set_item_undefined(cur_path, NULL); 394 sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties, 395 (void *) cur); 342 396 343 397 if (cur->child)
Note:
See TracChangeset
for help on using the changeset viewer.