Add qemu 2.4.0
[kvmfornfv.git] / qemu / dtc / tests / trees.S
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 FDTQUAD(val) \
11         .byte   ((val) >> 56) & 0xff ; \
12         .byte   ((val) >> 48) & 0xff ; \
13         .byte   ((val) >> 40) & 0xff ; \
14         .byte   ((val) >> 32) & 0xff ; \
15         .byte   ((val) >> 24) & 0xff ; \
16         .byte   ((val) >> 16) & 0xff ; \
17         .byte   ((val) >> 8) & 0xff ; \
18         .byte   (val) & 0xff    ;
19
20 #define TREE_HDR(tree) \
21         .balign 8               ; \
22         .globl  _##tree         ; \
23 _##tree:        \
24 tree:   \
25         FDTLONG(FDT_MAGIC)      ; \
26         FDTLONG(tree##_end - tree) ; \
27         FDTLONG(tree##_struct - tree) ; \
28         FDTLONG(tree##_strings - tree) ; \
29         FDTLONG(tree##_rsvmap - tree) ; \
30         FDTLONG(0x11)           ; \
31         FDTLONG(0x10)           ; \
32         FDTLONG(0)              ; \
33         FDTLONG(tree##_strings_end - tree##_strings) ; \
34         FDTLONG(tree##_struct_end - tree##_struct) ;
35
36 #define RSVMAP_ENTRY(addr, len) \
37         FDTQUAD(addr)           ; \
38         FDTQUAD(len)            ; \
39
40 #define EMPTY_RSVMAP(tree) \
41         .balign 8               ; \
42 tree##_rsvmap:                  ; \
43         RSVMAP_ENTRY(0, 0) \
44 tree##_rsvmap_end:              ;
45
46 #define PROPHDR(tree, name, len) \
47         FDTLONG(FDT_PROP)       ; \
48         FDTLONG(len)            ; \
49         FDTLONG(tree##_##name - tree##_strings) ;
50
51 #define PROP_INT(tree, name, val) \
52         PROPHDR(tree, name, 4) \
53         FDTLONG(val)            ;
54
55 #define PROP_INT64(tree, name, val) \
56         PROPHDR(tree, name, 8) \
57         FDTQUAD(val)            ;
58
59 #define PROP_STR(tree, name, str) \
60         PROPHDR(tree, name, 55f - 54f) \
61 54:     \
62         .string str             ; \
63 55:     \
64         .balign 4               ;
65
66 #define BEGIN_NODE(name) \
67         FDTLONG(FDT_BEGIN_NODE) ; \
68         .string name            ; \
69         .balign 4               ;
70
71 #define END_NODE \
72         FDTLONG(FDT_END_NODE)   ;
73
74 #define STRING(tree, name, str) \
75 tree##_##name:                  ; \
76         .string str             ;
77
78         .data
79
80         TREE_HDR(test_tree1)
81
82         .balign 8
83 test_tree1_rsvmap:
84         RSVMAP_ENTRY(TEST_ADDR_1, TEST_SIZE_1)
85         RSVMAP_ENTRY(TEST_ADDR_2, TEST_SIZE_2)
86         RSVMAP_ENTRY(0, 0)
87 test_tree1_rsvmap_end:
88
89 test_tree1_struct:
90         BEGIN_NODE("")
91         PROP_STR(test_tree1, compatible, "test_tree1")
92         PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
93         PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1)
94         PROP_STR(test_tree1, prop_str, TEST_STRING_1)
95
96         BEGIN_NODE("subnode@1")
97         PROP_STR(test_tree1, compatible, "subnode1")
98         PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
99
100         BEGIN_NODE("subsubnode")
101         PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
102         PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
103         END_NODE
104
105         BEGIN_NODE("ss1")
106         END_NODE
107
108         END_NODE
109
110         BEGIN_NODE("subnode@2")
111         PROP_INT(test_tree1, linux_phandle, PHANDLE_1)
112         PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
113
114         BEGIN_NODE("subsubnode@0")
115         PROP_INT(test_tree1, phandle, PHANDLE_2)
116         PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
117         PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
118         END_NODE
119
120         BEGIN_NODE("ss2")
121         END_NODE
122
123         END_NODE
124
125         END_NODE
126         FDTLONG(FDT_END)
127 test_tree1_struct_end:
128
129 test_tree1_strings:
130         STRING(test_tree1, compatible, "compatible")
131         STRING(test_tree1, prop_int, "prop-int")
132         STRING(test_tree1, prop_int64, "prop-int64")
133         STRING(test_tree1, prop_str, "prop-str")
134         STRING(test_tree1, linux_phandle, "linux,phandle")
135         STRING(test_tree1, phandle, "phandle")
136 test_tree1_strings_end:
137 test_tree1_end:
138
139
140         TREE_HDR(truncated_property)
141         EMPTY_RSVMAP(truncated_property)
142
143 truncated_property_struct:
144         BEGIN_NODE("")
145         PROPHDR(truncated_property, prop_truncated, 4)
146         /* Oops, no actual property data here */
147 truncated_property_struct_end:
148
149 truncated_property_strings:
150         STRING(truncated_property, prop_truncated, "truncated")
151 truncated_property_strings_end:
152
153 truncated_property_end:
154
155
156         TREE_HDR(bad_node_char)
157         EMPTY_RSVMAP(bad_node_char)
158
159 bad_node_char_struct:
160         BEGIN_NODE("")
161         BEGIN_NODE("sub$node")
162         END_NODE
163         END_NODE
164         FDTLONG(FDT_END)
165 bad_node_char_struct_end:
166
167 bad_node_char_strings:
168 bad_node_char_strings_end:
169 bad_node_char_end:
170
171
172         TREE_HDR(bad_node_format)
173         EMPTY_RSVMAP(bad_node_format)
174
175 bad_node_format_struct:
176         BEGIN_NODE("")
177         BEGIN_NODE("subnode@1@2")
178         END_NODE
179         END_NODE
180         FDTLONG(FDT_END)
181 bad_node_format_struct_end:
182
183 bad_node_format_strings:
184 bad_node_format_strings_end:
185 bad_node_format_end:
186
187
188         TREE_HDR(bad_prop_char)
189         EMPTY_RSVMAP(bad_prop_char)
190
191 bad_prop_char_struct:
192         BEGIN_NODE("")
193         PROP_INT(bad_prop_char, prop, TEST_VALUE_1)
194         END_NODE
195         FDTLONG(FDT_END)
196 bad_prop_char_struct_end:
197
198 bad_prop_char_strings:
199         STRING(bad_prop_char, prop, "prop$erty")
200 bad_prop_char_strings_end:
201 bad_prop_char_end: