• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#include <fdt.h>
2#include "testdata.h"
3
4#define FDTLONG(val) \
5	.byte	((val) >> 24) & 0xff ; \
6	.byte	((val) >> 16) & 0xff ; \
7	.byte	((val) >> 8) & 0xff ; \
8	.byte	(val) & 0xff	;
9
10#define TREE_HDR(tree) \
11	.balign	8		; \
12	.globl	tree		; \
13tree:	\
14	FDTLONG(FDT_MAGIC)	; \
15	FDTLONG(tree##_end - tree) ; \
16	FDTLONG(tree##_struct - tree) ; \
17	FDTLONG(tree##_strings - tree) ; \
18	FDTLONG(tree##_rsvmap - tree) ; \
19	FDTLONG(0x11)		; \
20	FDTLONG(0x10)		; \
21	FDTLONG(0)		; \
22	FDTLONG(tree##_strings_end - tree##_strings) ; \
23	FDTLONG(tree##_struct_end - tree##_struct) ;
24
25#define RSVMAP_ENTRY(addrh, addrl, lenh, lenl) \
26	FDTLONG(addrh)		; \
27	FDTLONG(addrl)		; \
28	FDTLONG(lenh)		; \
29	FDTLONG(lenl)
30
31#define EMPTY_RSVMAP(tree) \
32	.balign	8		; \
33tree##_rsvmap:			; \
34	RSVMAP_ENTRY(0, 0, 0, 0) \
35tree##_rsvmap_end:		;
36
37#define PROPHDR(tree, name, len) \
38	FDTLONG(FDT_PROP)	; \
39	FDTLONG(len)		; \
40	FDTLONG(tree##_##name - tree##_strings) ;
41
42#define PROP_EMPTY(tree, name) \
43	PROPHDR(tree, name, 0)	;
44
45#define PROP_INT(tree, name, val) \
46	PROPHDR(tree, name, 4) \
47	FDTLONG(val)		;
48
49#define PROP_INT64(tree, name, valh, vall) \
50	PROPHDR(tree, name, 8) \
51	FDTLONG(valh)		; \
52	FDTLONG(vall)		;
53
54#define PROP_STR(tree, name, str) \
55	PROPHDR(tree, name, 55f - 54f) \
5654:	\
57	.string	str		; \
5855:	\
59	.balign	4		;
60
61#define BEGIN_NODE(name) \
62	FDTLONG(FDT_BEGIN_NODE)	; \
63	.string	name		; \
64	.balign 4		;
65
66#define END_NODE \
67	FDTLONG(FDT_END_NODE)	;
68
69#define STRING(tree, name, str) \
70tree##_##name:			; \
71	.string	str		;
72
73	.data
74
75	TREE_HDR(test_tree1)
76
77	.balign	8
78test_tree1_rsvmap:
79	RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L)
80	RSVMAP_ENTRY(TEST_ADDR_2H, TEST_ADDR_2L, TEST_SIZE_2H, TEST_SIZE_2L)
81	RSVMAP_ENTRY(0, 0, 0, 0)
82test_tree1_rsvmap_end:
83
84test_tree1_struct:
85	BEGIN_NODE("")
86	PROP_STR(test_tree1, compatible, "test_tree1")
87	PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
88	PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1H, TEST_VALUE64_1L)
89	PROP_STR(test_tree1, prop_str, TEST_STRING_1)
90	PROP_INT(test_tree1, address_cells, 1)
91	PROP_INT(test_tree1, size_cells, 0)
92
93	BEGIN_NODE("subnode@1")
94	PROP_STR(test_tree1, compatible, "subnode1")
95	PROP_INT(test_tree1, reg, 1)
96	PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
97
98	BEGIN_NODE("subsubnode")
99	PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
100	PROP_STR(test_tree1, placeholder, "this is a placeholder string\0string2")
101	PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
102	END_NODE
103
104	BEGIN_NODE("ss1")
105	END_NODE
106
107	END_NODE
108
109	BEGIN_NODE("subnode@2")
110	PROP_INT(test_tree1, reg, 2)
111	PROP_INT(test_tree1, linux_phandle, PHANDLE_1)
112	PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
113	PROP_INT(test_tree1, address_cells, 1)
114	PROP_INT(test_tree1, size_cells, 0)
115
116	BEGIN_NODE("subsubnode@0")
117	PROP_INT(test_tree1, reg, 0)
118	PROP_INT(test_tree1, phandle, PHANDLE_2)
119	PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
120	PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
121	END_NODE
122
123	BEGIN_NODE("ss2")
124	END_NODE
125
126	END_NODE
127
128	END_NODE
129	FDTLONG(FDT_END)
130test_tree1_struct_end:
131
132test_tree1_strings:
133	STRING(test_tree1, compatible, "compatible")
134	STRING(test_tree1, prop_int, "prop-int")
135	STRING(test_tree1, prop_int64, "prop-int64")
136	STRING(test_tree1, prop_str, "prop-str")
137	STRING(test_tree1, linux_phandle, "linux,phandle")
138	STRING(test_tree1, phandle, "phandle")
139	STRING(test_tree1, reg, "reg")
140	STRING(test_tree1, placeholder, "placeholder")
141	STRING(test_tree1, address_cells, "#address-cells")
142	STRING(test_tree1, size_cells, "#size-cells")
143test_tree1_strings_end:
144test_tree1_end:
145
146
147	TREE_HDR(truncated_property)
148	EMPTY_RSVMAP(truncated_property)
149
150truncated_property_struct:
151	BEGIN_NODE("")
152	PROPHDR(truncated_property, prop_truncated, 4)
153	/* Oops, no actual property data here */
154truncated_property_struct_end:
155
156truncated_property_strings:
157	STRING(truncated_property, prop_truncated, "truncated")
158truncated_property_strings_end:
159
160truncated_property_end:
161
162
163	TREE_HDR(bad_node_char)
164	EMPTY_RSVMAP(bad_node_char)
165
166bad_node_char_struct:
167	BEGIN_NODE("")
168	BEGIN_NODE("sub$node")
169	END_NODE
170	END_NODE
171	FDTLONG(FDT_END)
172bad_node_char_struct_end:
173
174bad_node_char_strings:
175bad_node_char_strings_end:
176bad_node_char_end:
177
178
179	TREE_HDR(bad_node_format)
180	EMPTY_RSVMAP(bad_node_format)
181
182bad_node_format_struct:
183	BEGIN_NODE("")
184	BEGIN_NODE("subnode@1@2")
185	END_NODE
186	END_NODE
187	FDTLONG(FDT_END)
188bad_node_format_struct_end:
189
190bad_node_format_strings:
191bad_node_format_strings_end:
192bad_node_format_end:
193
194
195	TREE_HDR(bad_prop_char)
196	EMPTY_RSVMAP(bad_prop_char)
197
198bad_prop_char_struct:
199	BEGIN_NODE("")
200	PROP_INT(bad_prop_char, prop, TEST_VALUE_1)
201	END_NODE
202	FDTLONG(FDT_END)
203bad_prop_char_struct_end:
204
205bad_prop_char_strings:
206	STRING(bad_prop_char, prop, "prop$erty")
207bad_prop_char_strings_end:
208bad_prop_char_end:
209
210
211	/* overflow_size_strings */
212	.balign	8
213	.globl	ovf_size_strings
214ovf_size_strings:
215	FDTLONG(FDT_MAGIC)
216	FDTLONG(ovf_size_strings_end - ovf_size_strings)
217	FDTLONG(ovf_size_strings_struct - ovf_size_strings)
218	FDTLONG(ovf_size_strings_strings - ovf_size_strings)
219	FDTLONG(ovf_size_strings_rsvmap - ovf_size_strings)
220	FDTLONG(0x11)
221	FDTLONG(0x10)
222	FDTLONG(0)
223	FDTLONG(0xffffffff)
224	FDTLONG(ovf_size_strings_struct_end - ovf_size_strings_struct)
225	EMPTY_RSVMAP(ovf_size_strings)
226
227ovf_size_strings_struct:
228	BEGIN_NODE("")
229	PROP_INT(ovf_size_strings, bad_string, 0)
230	END_NODE
231	FDTLONG(FDT_END)
232ovf_size_strings_struct_end:
233
234ovf_size_strings_strings:
235	STRING(ovf_size_strings, x, "x")
236	ovf_size_strings_bad_string = ovf_size_strings_strings + 0x10000000
237ovf_size_strings_strings_end:
238ovf_size_strings_end:
239
240
241	/* truncated_string */
242	TREE_HDR(truncated_string)
243	EMPTY_RSVMAP(truncated_string)
244
245truncated_string_struct:
246	BEGIN_NODE("")
247	PROP_EMPTY(truncated_string, good_string)
248	PROP_EMPTY(truncated_string, bad_string)
249	END_NODE
250	FDTLONG(FDT_END)
251truncated_string_struct_end:
252
253truncated_string_strings:
254	STRING(truncated_string, good_string, "good")
255truncated_string_bad_string:
256	.byte	'b'
257	.byte	'a'
258	.byte	'd'
259	/* NOTE: terminating \0 deliberately missing */
260truncated_string_strings_end:
261truncated_string_end:
262
263
264	/* truncated_memrsv */
265	TREE_HDR(truncated_memrsv)
266
267truncated_memrsv_struct:
268	BEGIN_NODE("")
269	END_NODE
270	FDTLONG(FDT_END)
271truncated_memrsv_struct_end:
272
273truncated_memrsv_strings:
274truncated_memrsv_strings_end:
275
276	.balign	8
277truncated_memrsv_rsvmap:
278	RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L)
279truncated_memrsv_rsvmap_end:
280
281truncated_memrsv_end:
282