diff options
author | Scott Wood <scottwood@freescale.com> | 2007-03-16 13:27:54 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-03-21 07:35:21 -0400 |
commit | a07940ba00218267493798e89e3f4a86fea53125 (patch) | |
tree | 99baf6139b5f9ae214dde6c629fbe986b83786b4 /arch | |
parent | e85f008d016d2de59ee5b01dba18ea3dea41545b (diff) |
[POWERPC] bootwrapper: Add dt_ops methods.
Add get_parent, create_node, and find_node_by_prop_value to dt_ops.
Currently only implemented by flatdevtree_misc.
Also, add a _str convenience wrapper for setprop.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/boot/flatdevtree_misc.c | 42 | ||||
-rw-r--r-- | arch/powerpc/boot/ops.h | 51 |
2 files changed, 83 insertions, 10 deletions
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c index 04da38fa477f..4341e6558c1a 100644 --- a/arch/powerpc/boot/flatdevtree_misc.c +++ b/arch/powerpc/boot/flatdevtree_misc.c | |||
@@ -16,24 +16,43 @@ | |||
16 | 16 | ||
17 | static struct ft_cxt cxt; | 17 | static struct ft_cxt cxt; |
18 | 18 | ||
19 | static void *ft_finddevice(const char *name) | 19 | static void *fdtm_finddevice(const char *name) |
20 | { | 20 | { |
21 | return ft_find_device(&cxt, name); | 21 | return ft_find_device(&cxt, name); |
22 | } | 22 | } |
23 | 23 | ||
24 | static int ft_getprop(const void *phandle, const char *propname, void *buf, | 24 | static int fdtm_getprop(const void *phandle, const char *propname, |
25 | const int buflen) | 25 | void *buf, const int buflen) |
26 | { | 26 | { |
27 | return ft_get_prop(&cxt, phandle, propname, buf, buflen); | 27 | return ft_get_prop(&cxt, phandle, propname, buf, buflen); |
28 | } | 28 | } |
29 | 29 | ||
30 | static int ft_setprop(const void *phandle, const char *propname, | 30 | static int fdtm_setprop(const void *phandle, const char *propname, |
31 | const void *buf, const int buflen) | 31 | const void *buf, const int buflen) |
32 | { | 32 | { |
33 | return ft_set_prop(&cxt, phandle, propname, buf, buflen); | 33 | return ft_set_prop(&cxt, phandle, propname, buf, buflen); |
34 | } | 34 | } |
35 | 35 | ||
36 | static unsigned long ft_finalize(void) | 36 | static void *fdtm_get_parent(const void *phandle) |
37 | { | ||
38 | return ft_get_parent(&cxt, phandle); | ||
39 | } | ||
40 | |||
41 | static void *fdtm_create_node(const void *phandle, const char *name) | ||
42 | { | ||
43 | return ft_create_node(&cxt, phandle, name); | ||
44 | } | ||
45 | |||
46 | static void *fdtm_find_node_by_prop_value(const void *prev, | ||
47 | const char *propname, | ||
48 | const char *propval, | ||
49 | int proplen) | ||
50 | { | ||
51 | return ft_find_node_by_prop_value(&cxt, prev, propname, | ||
52 | propval, proplen); | ||
53 | } | ||
54 | |||
55 | static unsigned long fdtm_finalize(void) | ||
37 | { | 56 | { |
38 | ft_end_tree(&cxt); | 57 | ft_end_tree(&cxt); |
39 | return (unsigned long)cxt.bph; | 58 | return (unsigned long)cxt.bph; |
@@ -41,10 +60,13 @@ static unsigned long ft_finalize(void) | |||
41 | 60 | ||
42 | int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device) | 61 | int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device) |
43 | { | 62 | { |
44 | dt_ops.finddevice = ft_finddevice; | 63 | dt_ops.finddevice = fdtm_finddevice; |
45 | dt_ops.getprop = ft_getprop; | 64 | dt_ops.getprop = fdtm_getprop; |
46 | dt_ops.setprop = ft_setprop; | 65 | dt_ops.setprop = fdtm_setprop; |
47 | dt_ops.finalize = ft_finalize; | 66 | dt_ops.get_parent = fdtm_get_parent; |
67 | dt_ops.create_node = fdtm_create_node; | ||
68 | dt_ops.find_node_by_prop_value = fdtm_find_node_by_prop_value; | ||
69 | dt_ops.finalize = fdtm_finalize; | ||
48 | 70 | ||
49 | return ft_open(&cxt, dt_blob, max_size, max_find_device, | 71 | return ft_open(&cxt, dt_blob, max_size, max_find_device, |
50 | platform_ops.realloc); | 72 | platform_ops.realloc); |
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h index 2b569ad984bd..dae0e3b23cf5 100644 --- a/arch/powerpc/boot/ops.h +++ b/arch/powerpc/boot/ops.h | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <stddef.h> | 14 | #include <stddef.h> |
15 | #include "types.h" | 15 | #include "types.h" |
16 | #include "string.h" | ||
16 | 17 | ||
17 | #define COMMAND_LINE_SIZE 512 | 18 | #define COMMAND_LINE_SIZE 512 |
18 | #define MAX_PATH_LEN 256 | 19 | #define MAX_PATH_LEN 256 |
@@ -37,6 +38,12 @@ struct dt_ops { | |||
37 | const int buflen); | 38 | const int buflen); |
38 | int (*setprop)(const void *phandle, const char *name, | 39 | int (*setprop)(const void *phandle, const char *name, |
39 | const void *buf, const int buflen); | 40 | const void *buf, const int buflen); |
41 | void *(*get_parent)(const void *phandle); | ||
42 | /* The node must not already exist. */ | ||
43 | void *(*create_node)(const void *parent, const char *name); | ||
44 | void *(*find_node_by_prop_value)(const void *prev, | ||
45 | const char *propname, | ||
46 | const char *propval, int proplen); | ||
40 | unsigned long (*finalize)(void); | 47 | unsigned long (*finalize)(void); |
41 | }; | 48 | }; |
42 | extern struct dt_ops dt_ops; | 49 | extern struct dt_ops dt_ops; |
@@ -89,6 +96,50 @@ static inline int setprop(void *devp, const char *name, void *buf, int buflen) | |||
89 | return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1; | 96 | return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1; |
90 | } | 97 | } |
91 | 98 | ||
99 | static inline int setprop_str(void *devp, const char *name, const char *buf) | ||
100 | { | ||
101 | if (dt_ops.setprop) | ||
102 | return dt_ops.setprop(devp, name, buf, strlen(buf) + 1); | ||
103 | |||
104 | return -1; | ||
105 | } | ||
106 | |||
107 | static inline void *get_parent(const char *devp) | ||
108 | { | ||
109 | return dt_ops.get_parent ? dt_ops.get_parent(devp) : NULL; | ||
110 | } | ||
111 | |||
112 | static inline void *create_node(const void *parent, const char *name) | ||
113 | { | ||
114 | return dt_ops.create_node ? dt_ops.create_node(parent, name) : NULL; | ||
115 | } | ||
116 | |||
117 | |||
118 | static inline void *find_node_by_prop_value(const void *prev, | ||
119 | const char *propname, | ||
120 | const char *propval, int proplen) | ||
121 | { | ||
122 | if (dt_ops.find_node_by_prop_value) | ||
123 | return dt_ops.find_node_by_prop_value(prev, propname, | ||
124 | propval, proplen); | ||
125 | |||
126 | return NULL; | ||
127 | } | ||
128 | |||
129 | static inline void *find_node_by_prop_value_str(const void *prev, | ||
130 | const char *propname, | ||
131 | const char *propval) | ||
132 | { | ||
133 | return find_node_by_prop_value(prev, propname, propval, | ||
134 | strlen(propval) + 1); | ||
135 | } | ||
136 | |||
137 | static inline void *find_node_by_devtype(const void *prev, | ||
138 | const char *type) | ||
139 | { | ||
140 | return find_node_by_prop_value_str(prev, "device_type", type); | ||
141 | } | ||
142 | |||
92 | static inline void *malloc(u32 size) | 143 | static inline void *malloc(u32 size) |
93 | { | 144 | { |
94 | return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; | 145 | return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; |