Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1894 → Rev 1895

/trunk/boot/genarch/ofw_tree.h
43,6 → 43,8
ofw_tree_node_t *peer;
ofw_tree_node_t *child;
 
char *da_name; /**< Disambigued name. */
 
unsigned properties; /**< Number of properties. */
ofw_tree_property_t *property;
};
/trunk/boot/genarch/ofw.h
102,7 → 102,7
 
extern void ofw_write(const char *str, const int len);
 
extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
extern int ofw_get_proplen(const phandle device, const char *name);
extern int ofw_next_property(const phandle device, char *previous, char *buf);
 
110,6 → 110,8
extern phandle ofw_get_peer_node(const phandle node);
extern phandle ofw_find_device(const char *name);
 
extern int ofw_package_to_path(const phandle device, char *buf, const int buflen);
 
extern int ofw(ofw_args_t *arg);
extern unsigned int ofw_get_address_cells(const phandle device);
extern unsigned int ofw_get_size_cells(const phandle device);
/trunk/boot/genarch/ofw_tree.c
31,7 → 31,10
#include <types.h>
#include <string.h>
#include <balloc.h>
#include <asm.h>
 
#define MAX_PATH_LEN 256
 
static ofw_tree_node_t *ofw_tree_node_alloc(void)
{
return balloc(sizeof(ofw_tree_node_t), sizeof(ofw_tree_node_t));
61,10 → 64,13
static void ofw_tree_node_process(ofw_tree_node_t *current_node,
ofw_tree_node_t *parent_node, phandle current)
{
static char path[MAX_PATH_LEN+1];
static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
phandle peer;
phandle child;
unsigned properties = 0;
char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
size_t len;
int i;
 
/*
* Initialize node.
76,6 → 82,26
current_node->property = NULL;
/*
* Get the disambigued name.
*/
len = ofw_package_to_path(current, path, MAX_PATH_LEN);
if (len == -1)
return;
path[len] = '\0';
for (i = len - 1; i >= 0 && path[i] != '/'; i--)
;
i++; /* do not include '/' */
len -= i;
current_node->da_name = ofw_tree_space_alloc(len + 1); /* add space for trailing '\0' */
if (!current_node->da_name)
return;
memcpy(current_node->da_name, &path[i], len);
current_node->da_name[len] = '\0';
/*
* Recursively process the potential peer node.
*/
peer = ofw_get_peer_node(current);
84,7 → 110,7
peer_node = ofw_tree_node_alloc();
if (peer_node) {
ofw_tree_node_process(peer_node, current_node, peer);
ofw_tree_node_process(peer_node, parent_node, peer);
current_node->peer = peer_node;
}
}
120,8 → 146,6
if (!current_node->property)
return;
int i = 0;
 
name[0] = '\0';
for (i = 0; ofw_next_property(current, name, name) == 1; i++) {
size_t size;
/trunk/boot/genarch/ofw.c
114,7 → 114,7
return ofw_call("finddevice", 1, 1, NULL, name);
}
 
int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
{
return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
}
129,6 → 129,11
return ofw_call("nextprop", 3, 1, NULL, device, previous, buf);
}
 
int ofw_package_to_path(const phandle device, char *buf, const int buflen)
{
return ofw_call("package-to-path", 3, 1, NULL, device, buf, buflen);
}
 
unsigned int ofw_get_address_cells(const phandle device)
{
unsigned int ret = 1;