Revision 5a4348d1 device_tree.c
b/device_tree.c | ||
---|---|---|
131 | 131 |
return offset; |
132 | 132 |
} |
133 | 133 |
|
134 |
int qemu_devtree_setprop(void *fdt, const char *node_path,
|
|
135 |
const char *property, const void *val_array, int size)
|
|
134 |
int qemu_fdt_setprop(void *fdt, const char *node_path,
|
|
135 |
const char *property, const void *val_array, int size) |
|
136 | 136 |
{ |
137 | 137 |
int r; |
138 | 138 |
|
... | ... | |
146 | 146 |
return r; |
147 | 147 |
} |
148 | 148 |
|
149 |
int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
|
|
150 |
const char *property, uint32_t val)
|
|
149 |
int qemu_fdt_setprop_cell(void *fdt, const char *node_path,
|
|
150 |
const char *property, uint32_t val) |
|
151 | 151 |
{ |
152 | 152 |
int r; |
153 | 153 |
|
... | ... | |
161 | 161 |
return r; |
162 | 162 |
} |
163 | 163 |
|
164 |
int qemu_devtree_setprop_u64(void *fdt, const char *node_path,
|
|
165 |
const char *property, uint64_t val)
|
|
164 |
int qemu_fdt_setprop_u64(void *fdt, const char *node_path,
|
|
165 |
const char *property, uint64_t val) |
|
166 | 166 |
{ |
167 | 167 |
val = cpu_to_be64(val); |
168 |
return qemu_devtree_setprop(fdt, node_path, property, &val, sizeof(val));
|
|
168 |
return qemu_fdt_setprop(fdt, node_path, property, &val, sizeof(val));
|
|
169 | 169 |
} |
170 | 170 |
|
171 |
int qemu_devtree_setprop_string(void *fdt, const char *node_path,
|
|
172 |
const char *property, const char *string)
|
|
171 |
int qemu_fdt_setprop_string(void *fdt, const char *node_path,
|
|
172 |
const char *property, const char *string) |
|
173 | 173 |
{ |
174 | 174 |
int r; |
175 | 175 |
|
... | ... | |
183 | 183 |
return r; |
184 | 184 |
} |
185 | 185 |
|
186 |
const void *qemu_devtree_getprop(void *fdt, const char *node_path,
|
|
187 |
const char *property, int *lenp)
|
|
186 |
const void *qemu_fdt_getprop(void *fdt, const char *node_path,
|
|
187 |
const char *property, int *lenp) |
|
188 | 188 |
{ |
189 | 189 |
int len; |
190 | 190 |
const void *r; |
... | ... | |
200 | 200 |
return r; |
201 | 201 |
} |
202 | 202 |
|
203 |
uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
|
|
204 |
const char *property)
|
|
203 |
uint32_t qemu_fdt_getprop_cell(void *fdt, const char *node_path,
|
|
204 |
const char *property) |
|
205 | 205 |
{ |
206 | 206 |
int len; |
207 |
const uint32_t *p = qemu_devtree_getprop(fdt, node_path, property, &len);
|
|
207 |
const uint32_t *p = qemu_fdt_getprop(fdt, node_path, property, &len);
|
|
208 | 208 |
if (len != 4) { |
209 | 209 |
fprintf(stderr, "%s: %s/%s not 4 bytes long (not a cell?)\n", |
210 | 210 |
__func__, node_path, property); |
... | ... | |
213 | 213 |
return be32_to_cpu(*p); |
214 | 214 |
} |
215 | 215 |
|
216 |
uint32_t qemu_devtree_get_phandle(void *fdt, const char *path)
|
|
216 |
uint32_t qemu_fdt_get_phandle(void *fdt, const char *path)
|
|
217 | 217 |
{ |
218 | 218 |
uint32_t r; |
219 | 219 |
|
... | ... | |
227 | 227 |
return r; |
228 | 228 |
} |
229 | 229 |
|
230 |
int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
|
|
231 |
const char *property,
|
|
232 |
const char *target_node_path)
|
|
230 |
int qemu_fdt_setprop_phandle(void *fdt, const char *node_path,
|
|
231 |
const char *property, |
|
232 |
const char *target_node_path) |
|
233 | 233 |
{ |
234 |
uint32_t phandle = qemu_devtree_get_phandle(fdt, target_node_path);
|
|
235 |
return qemu_devtree_setprop_cell(fdt, node_path, property, phandle);
|
|
234 |
uint32_t phandle = qemu_fdt_get_phandle(fdt, target_node_path);
|
|
235 |
return qemu_fdt_setprop_cell(fdt, node_path, property, phandle);
|
|
236 | 236 |
} |
237 | 237 |
|
238 |
uint32_t qemu_devtree_alloc_phandle(void *fdt)
|
|
238 |
uint32_t qemu_fdt_alloc_phandle(void *fdt)
|
|
239 | 239 |
{ |
240 | 240 |
static int phandle = 0x0; |
241 | 241 |
|
... | ... | |
259 | 259 |
return phandle++; |
260 | 260 |
} |
261 | 261 |
|
262 |
int qemu_devtree_nop_node(void *fdt, const char *node_path)
|
|
262 |
int qemu_fdt_nop_node(void *fdt, const char *node_path)
|
|
263 | 263 |
{ |
264 | 264 |
int r; |
265 | 265 |
|
... | ... | |
273 | 273 |
return r; |
274 | 274 |
} |
275 | 275 |
|
276 |
int qemu_devtree_add_subnode(void *fdt, const char *name)
|
|
276 |
int qemu_fdt_add_subnode(void *fdt, const char *name)
|
|
277 | 277 |
{ |
278 | 278 |
char *dupname = g_strdup(name); |
279 | 279 |
char *basename = strrchr(dupname, '/'); |
... | ... | |
303 | 303 |
return retval; |
304 | 304 |
} |
305 | 305 |
|
306 |
void qemu_devtree_dumpdtb(void *fdt, int size)
|
|
306 |
void qemu_fdt_dumpdtb(void *fdt, int size)
|
|
307 | 307 |
{ |
308 | 308 |
const char *dumpdtb = qemu_opt_get(qemu_get_machine_opts(), "dumpdtb"); |
309 | 309 |
|
... | ... | |
313 | 313 |
} |
314 | 314 |
} |
315 | 315 |
|
316 |
int qemu_devtree_setprop_sized_cells_from_array(void *fdt,
|
|
317 |
const char *node_path,
|
|
318 |
const char *property,
|
|
319 |
int numvalues,
|
|
320 |
uint64_t *values)
|
|
316 |
int qemu_fdt_setprop_sized_cells_from_array(void *fdt,
|
|
317 |
const char *node_path, |
|
318 |
const char *property, |
|
319 |
int numvalues, |
|
320 |
uint64_t *values) |
|
321 | 321 |
{ |
322 | 322 |
uint32_t *propcells; |
323 | 323 |
uint64_t value; |
... | ... | |
342 | 342 |
propcells[cellnum++] = cpu_to_be32(value); |
343 | 343 |
} |
344 | 344 |
|
345 |
return qemu_devtree_setprop(fdt, node_path, property, propcells,
|
|
346 |
cellnum * sizeof(uint32_t));
|
|
345 |
return qemu_fdt_setprop(fdt, node_path, property, propcells,
|
|
346 |
cellnum * sizeof(uint32_t)); |
|
347 | 347 |
} |
Also available in: Unified diff