1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __DEVICE_TREE_H__
15#define __DEVICE_TREE_H__
16
17void *create_device_tree(int *sizep);
18void *load_device_tree(const char *filename_path, int *sizep);
19
20int qemu_devtree_setprop(void *fdt, const char *node_path,
21 const char *property, const void *val_array, int size);
22int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
23 const char *property, uint32_t val);
24int qemu_devtree_setprop_u64(void *fdt, const char *node_path,
25 const char *property, uint64_t val);
26int qemu_devtree_setprop_string(void *fdt, const char *node_path,
27 const char *property, const char *string);
28int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
29 const char *property,
30 const char *target_node_path);
31const void *qemu_devtree_getprop(void *fdt, const char *node_path,
32 const char *property, int *lenp);
33uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
34 const char *property);
35uint32_t qemu_devtree_get_phandle(void *fdt, const char *path);
36uint32_t qemu_devtree_alloc_phandle(void *fdt);
37int qemu_devtree_nop_node(void *fdt, const char *node_path);
38int qemu_devtree_add_subnode(void *fdt, const char *name);
39
40#define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \
41 do { \
42 uint32_t qdt_tmp[] = { __VA_ARGS__ }; \
43 int i; \
44 \
45 for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \
46 qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \
47 } \
48 qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \
49 sizeof(qdt_tmp)); \
50 } while (0)
51
52void qemu_devtree_dumpdtb(void *fdt, int size);
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81int qemu_devtree_setprop_sized_cells_from_array(void *fdt,
82 const char *node_path,
83 const char *property,
84 int numvalues,
85 uint64_t *values);
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104#define qemu_devtree_setprop_sized_cells(fdt, node_path, property, ...) \
105 ({ \
106 uint64_t qdt_tmp[] = { __VA_ARGS__ }; \
107 qemu_devtree_setprop_sized_cells_from_array(fdt, node_path, \
108 property, \
109 ARRAY_SIZE(qdt_tmp) / 2, \
110 qdt_tmp); \
111 })
112
113#endif
114