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 PROP_INT(test_tree1, address_cells, 1) 96 PROP_INT(test_tree1, size_cells, 0) 97 98 BEGIN_NODE("subnode@1") 99 PROP_STR(test_tree1, compatible, "subnode1") 100 PROP_INT(test_tree1, reg, 1) 101 PROP_INT(test_tree1, prop_int, TEST_VALUE_1) 102 103 BEGIN_NODE("subsubnode") 104 PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode") 105 PROP_STR(test_tree1, placeholder, "this is a placeholder string\0string2") 106 PROP_INT(test_tree1, prop_int, TEST_VALUE_1) 107 END_NODE 108 109 BEGIN_NODE("ss1") 110 END_NODE 111 112 END_NODE 113 114 BEGIN_NODE("subnode@2") 115 PROP_INT(test_tree1, reg, 2) 116 PROP_INT(test_tree1, linux_phandle, PHANDLE_1) 117 PROP_INT(test_tree1, prop_int, TEST_VALUE_2) 118 PROP_INT(test_tree1, address_cells, 1) 119 PROP_INT(test_tree1, size_cells, 0) 120 121 BEGIN_NODE("subsubnode@0") 122 PROP_INT(test_tree1, reg, 0) 123 PROP_INT(test_tree1, phandle, PHANDLE_2) 124 PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode") 125 PROP_INT(test_tree1, prop_int, TEST_VALUE_2) 126 END_NODE 127 128 BEGIN_NODE("ss2") 129 END_NODE 130 131 END_NODE 132 133 END_NODE 134 FDTLONG(FDT_END) 135 test_tree1_struct_end: 136 137 test_tree1_strings: 138 STRING(test_tree1, compatible, "compatible") 139 STRING(test_tree1, prop_int, "prop-int") 140 STRING(test_tree1, prop_int64, "prop-int64") 141 STRING(test_tree1, prop_str, "prop-str") 142 STRING(test_tree1, linux_phandle, "linux,phandle") 143 STRING(test_tree1, phandle, "phandle") 144 STRING(test_tree1, reg, "reg") 145 STRING(test_tree1, placeholder, "placeholder") 146 STRING(test_tree1, address_cells, "#address-cells") 147 STRING(test_tree1, size_cells, "#size-cells") 148 test_tree1_strings_end: 149 test_tree1_end: 150 151 152 TREE_HDR(truncated_property) 153 EMPTY_RSVMAP(truncated_property) 154 155 truncated_property_struct: 156 BEGIN_NODE("") 157 PROPHDR(truncated_property, prop_truncated, 4) 158 /* Oops, no actual property data here */ 159 truncated_property_struct_end: 160 161 truncated_property_strings: 162 STRING(truncated_property, prop_truncated, "truncated") 163 truncated_property_strings_end: 164 165 truncated_property_end: 166 167 168 TREE_HDR(bad_node_char) 169 EMPTY_RSVMAP(bad_node_char) 170 171 bad_node_char_struct: 172 BEGIN_NODE("") 173 BEGIN_NODE("sub$node") 174 END_NODE 175 END_NODE 176 FDTLONG(FDT_END) 177 bad_node_char_struct_end: 178 179 bad_node_char_strings: 180 bad_node_char_strings_end: 181 bad_node_char_end: 182 183 184 TREE_HDR(bad_node_format) 185 EMPTY_RSVMAP(bad_node_format) 186 187 bad_node_format_struct: 188 BEGIN_NODE("") 189 BEGIN_NODE("subnode@1@2") 190 END_NODE 191 END_NODE 192 FDTLONG(FDT_END) 193 bad_node_format_struct_end: 194 195 bad_node_format_strings: 196 bad_node_format_strings_end: 197 bad_node_format_end: 198 199 200 TREE_HDR(bad_prop_char) 201 EMPTY_RSVMAP(bad_prop_char) 202 203 bad_prop_char_struct: 204 BEGIN_NODE("") 205 PROP_INT(bad_prop_char, prop, TEST_VALUE_1) 206 END_NODE 207 FDTLONG(FDT_END) 208 bad_prop_char_struct_end: 209 210 bad_prop_char_strings: 211 STRING(bad_prop_char, prop, "prop$erty") 212 bad_prop_char_strings_end: 213 bad_prop_char_end: 214 215 216 /* overflow_size_strings */ 217 .balign 8 218 .globl _ovf_size_strings 219 _ovf_size_strings: 220 ovf_size_strings: 221 FDTLONG(FDT_MAGIC) 222 FDTLONG(ovf_size_strings_end - ovf_size_strings) 223 FDTLONG(ovf_size_strings_struct - ovf_size_strings) 224 FDTLONG(ovf_size_strings_strings - ovf_size_strings) 225 FDTLONG(ovf_size_strings_rsvmap - ovf_size_strings) 226 FDTLONG(0x11) 227 FDTLONG(0x10) 228 FDTLONG(0) 229 FDTLONG(0xffffffff) 230 FDTLONG(ovf_size_strings_struct_end - ovf_size_strings_struct) 231 EMPTY_RSVMAP(ovf_size_strings) 232 233 ovf_size_strings_struct: 234 BEGIN_NODE("") 235 PROP_INT(ovf_size_strings, bad_string, 0) 236 END_NODE 237 FDTLONG(FDT_END) 238 ovf_size_strings_struct_end: 239 240 ovf_size_strings_strings: 241 STRING(ovf_size_strings, x, "x") 242 ovf_size_strings_bad_string = ovf_size_strings_strings + 0x10000000 243 ovf_size_strings_strings_end: 244 ovf_size_strings_end: 245