This source file includes following definitions.
- prom_getchild
- prom_getsibling
- prom_getproplen
- prom_getproperty
- prom_getint
- prom_getintdefault
- prom_getbool
- prom_getstring
- prom_nodematch
- prom_searchsiblings
- prom_firstprop
- prom_nextprop
- prom_node_has_property
- prom_setprop
1
2
3
4
5
6
7
8 #include <linux/config.h>
9 #include <linux/string.h>
10
11 #include <asm/openprom.h>
12 #include <asm/oplib.h>
13
14 static char promlib_buf[128];
15
16
17
18
19 int
20 prom_getchild(int node)
21 {
22 int cnode;
23
24 #if CONFIG_AP1000
25 printk("prom_getchild -> 0\n");
26 return 0;
27 #endif
28 if(node == -1) return 0;
29 cnode = prom_nodeops->no_child(node);
30 if((cnode == 0) || (cnode == -1)) return 0;
31 return cnode;
32 }
33
34
35
36
37 int
38 prom_getsibling(int node)
39 {
40 int sibnode;
41
42 #if CONFIG_AP1000
43 printk("prom_getsibling -> 0\n");
44 return 0;
45 #endif
46 if(node == -1) return 0;
47 sibnode = prom_nodeops->no_nextnode(node);
48 if((sibnode == 0) || (sibnode == -1)) return 0;
49 return sibnode;
50 }
51
52
53
54
55 int
56 prom_getproplen(int node, char *prop)
57 {
58 #if CONFIG_AP1000
59 printk("prom_getproplen(%s) -> -1\n",prop);
60 return -1;
61 #endif
62 if((!node) || (!prop)) return -1;
63 return prom_nodeops->no_proplen(node, prop);
64 }
65
66
67
68
69
70 int
71 prom_getproperty(int node, char *prop, char *buffer, int bufsize)
72 {
73 int plen;
74
75 #if CONFIG_AP1000
76 printk("prom_getproperty(%s) -> -1\n",prop);
77 return -1;
78 #endif
79 plen = prom_getproplen(node, prop);
80 if((plen > bufsize) || (plen == 0) || (plen == -1)) return -1;
81
82
83 return prom_nodeops->no_getprop(node, prop, buffer);
84 }
85
86
87
88
89 int
90 prom_getint(int node, char *prop)
91 {
92 static int intprop;
93
94 #if CONFIG_AP1000
95 printk("prom_getint(%s) -> -1\n",prop);
96 return -1;
97 #endif
98 if(prom_getproperty(node, prop, (char *) &intprop, sizeof(int)) != -1)
99 return intprop;
100
101 return -1;
102 }
103
104
105
106
107
108 int
109 prom_getintdefault(int node, char *property, int deflt)
110 {
111 int retval;
112
113 #if CONFIG_AP1000
114 printk("prom_getintdefault(%s) -> 0\n",property);
115 return 0;
116 #endif
117 retval = prom_getint(node, property);
118 if(retval == -1) return deflt;
119
120 return retval;
121 }
122
123
124 int
125 prom_getbool(int node, char *prop)
126 {
127 int retval;
128
129 #if CONFIG_AP1000
130 printk("prom_getbool(%s) -> 0\n",prop);
131 return 0;
132 #endif
133 retval = prom_getproplen(node, prop);
134 if(retval == -1) return 0;
135 return 1;
136 }
137
138
139
140
141
142 void
143 prom_getstring(int node, char *prop, char *user_buf, int ubuf_size)
144 {
145 int len;
146
147 #if CONFIG_AP1000
148 printk("prom_getstring(%s) -> .\n",prop);
149 return;
150 #endif
151 len = prom_getproperty(node, prop, user_buf, ubuf_size);
152 if(len != -1) return;
153 user_buf[0] = 0;
154 return;
155 }
156
157
158
159
160
161 int
162 prom_nodematch(int node, char *name)
163 {
164 static char namebuf[128];
165 prom_getproperty(node, "name", namebuf, sizeof(namebuf));
166 if(strcmp(namebuf, name) == 0) return 1;
167 return 0;
168 }
169
170
171
172
173 int
174 prom_searchsiblings(int node_start, char *nodename)
175 {
176 int thisnode, error;
177
178 for(thisnode = node_start; thisnode;
179 thisnode=prom_getsibling(thisnode)) {
180 error = prom_getproperty(thisnode, "name", promlib_buf,
181 sizeof(promlib_buf));
182
183 if(error == -1) continue;
184 if(strcmp(nodename, promlib_buf)==0) return thisnode;
185 }
186
187 return 0;
188 }
189
190
191
192 char *
193 prom_firstprop(int node)
194 {
195 if(node == -1) return "";
196 return prom_nodeops->no_nextprop(node, (char *) 0x0);
197 }
198
199
200
201
202
203 char *
204 prom_nextprop(int node, char *oprop)
205 {
206 if(node == -1) return "";
207 return prom_nodeops->no_nextprop(node, oprop);
208 }
209
210 int
211 prom_node_has_property(int node, char *prop)
212 {
213 char *current_property = "";
214
215 do {
216 current_property = prom_nextprop(node, current_property);
217 if(!strcmp(current_property, prop))
218 return 1;
219 } while (*current_property);
220 return 0;
221 }
222
223
224
225
226 int
227 prom_setprop(int node, char *pname, char *value, int size)
228 {
229 if(size == 0) return 0;
230 if((pname == 0) || (value == 0)) return 0;
231 return prom_nodeops->no_setprop(node, pname, value, size);
232 }