Changeset 16529d5 in mainline for boot/genarch/ofw_tree.c


Ignore:
Timestamp:
2006-09-20T20:31:44Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
28ecadb
Parents:
61e90dd
Message:

More ofw_tree work and fixes.
Add ofw_tree_lookup().
Every ofw_tree_node now also contains a disambigued name which is essential for tree lookups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/ofw_tree.c

    r61e90dd r16529d5  
    3232#include <string.h>
    3333#include <balloc.h>
     34#include <asm.h>
     35
     36#define MAX_PATH_LEN    256
    3437
    3538static ofw_tree_node_t *ofw_tree_node_alloc(void)
     
    6265        ofw_tree_node_t *parent_node, phandle current)
    6366{
     67        static char path[MAX_PATH_LEN+1];
     68        static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
    6469        phandle peer;
    6570        phandle child;
    6671        unsigned properties = 0;
    67         char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
     72        size_t len;
     73        int i;
    6874
    6975        /*
     
    7783       
    7884        /*
     85         * Get the disambigued name.
     86         */
     87        len = ofw_package_to_path(current, path, MAX_PATH_LEN);
     88        if (len == -1)
     89                return;
     90       
     91        path[len] = '\0';
     92        for (i = len - 1; i >= 0 && path[i] != '/'; i--)
     93                ;
     94        i++;                                                            /* do not include '/' */
     95       
     96        len -= i;
     97        current_node->da_name = ofw_tree_space_alloc(len + 1);          /* add space for trailing '\0' */
     98        if (!current_node->da_name)
     99                return;
     100       
     101        memcpy(current_node->da_name, &path[i], len);
     102        current_node->da_name[len] = '\0';
     103       
     104        /*
    79105         * Recursively process the potential peer node.
    80106         */
     
    85111                peer_node = ofw_tree_node_alloc();
    86112                if (peer_node) {
    87                         ofw_tree_node_process(peer_node, current_node, peer);
     113                        ofw_tree_node_process(peer_node, parent_node, peer);
    88114                        current_node->peer = peer_node;
    89115                }
     
    121147                return;
    122148               
    123         int i = 0;
    124 
    125149        name[0] = '\0';
    126150        for (i = 0; ofw_next_property(current, name, name) == 1; i++) {
Note: See TracChangeset for help on using the changeset viewer.