Changeset de3db94a in mainline for kernel/genarch/src/ofw/ofw_tree.c


Ignore:
Timestamp:
2012-03-02T15:12:01Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
71232af
Parents:
dabbe28
Message:

map OpenFirmware device tree into sysinfo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/ofw/ofw_tree.c

    rdabbe28 rde3db94a  
    3838#include <genarch/ofw/ofw_tree.h>
    3939#include <mm/slab.h>
     40#include <sysinfo/sysinfo.h>
    4041#include <memstr.h>
    4142#include <str.h>
     
    355356}
    356357
     358/** Map OpenFirmware device subtree rooted in a node into sysinfo.
     359 *
     360 * Child nodes are processed recursively and peer nodes are processed
     361 * iteratively in order to avoid stack overflow.
     362 *
     363 * @param node Root of the subtree.
     364 * @param path Current path, NULL for the very root of the entire tree.
     365 *
     366 */
     367static void ofw_tree_node_sysinfo(ofw_tree_node_t *node, const char *path)
     368{
     369        char *cur_path = (char *) malloc(PATH_MAX_LEN, 0);
     370       
     371        for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
     372                if ((cur->parent) && (path))
     373                        snprintf(cur_path, PATH_MAX_LEN, "%s.%s", path, cur->da_name);
     374                else
     375                        snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name);
     376               
     377                sysinfo_set_item_undefined(cur_path, NULL);
     378               
     379                if (cur->child)
     380                        ofw_tree_node_sysinfo(cur->child, cur_path);
     381        }
     382       
     383        free(cur_path);
     384}
     385
     386/** Map the OpenFirmware device tree into sysinfo. */
     387void ofw_sysinfo_map(void)
     388{
     389        ofw_tree_node_sysinfo(ofw_root, NULL);
     390}
     391
    357392/** @}
    358393 */
Note: See TracChangeset for help on using the changeset viewer.