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