symbian-qemu-0.9.1-12/dtc-trunk/tests/trees.S
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     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_STR(tree, name, str) \
       
    56 	PROPHDR(tree, name, 55f - 54f) \
       
    57 54:	\
       
    58 	.string	str		; \
       
    59 55:	\
       
    60 	.balign	4		;
       
    61 
       
    62 #define BEGIN_NODE(name) \
       
    63 	FDTLONG(FDT_BEGIN_NODE)	; \
       
    64 	.string	name		; \
       
    65 	.balign 4		;
       
    66 
       
    67 #define END_NODE \
       
    68 	FDTLONG(FDT_END_NODE)	;
       
    69 
       
    70 #define STRING(tree, name, str) \
       
    71 tree##_##name:			; \
       
    72 	.string	str		;
       
    73 
       
    74 	.data
       
    75 
       
    76 	TREE_HDR(test_tree1)
       
    77 
       
    78 	.balign	8
       
    79 test_tree1_rsvmap:
       
    80 	RSVMAP_ENTRY(TEST_ADDR_1, TEST_SIZE_1)
       
    81 	RSVMAP_ENTRY(TEST_ADDR_2, TEST_SIZE_2)
       
    82 	RSVMAP_ENTRY(0, 0)
       
    83 test_tree1_rsvmap_end:
       
    84 
       
    85 test_tree1_struct:
       
    86 	BEGIN_NODE("")
       
    87 	PROP_STR(test_tree1, compatible, "test_tree1")
       
    88 	PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
       
    89 	PROP_STR(test_tree1, prop_str, TEST_STRING_1)
       
    90 
       
    91 	BEGIN_NODE("subnode@1")
       
    92 	PROP_STR(test_tree1, compatible, "subnode1")
       
    93 	PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
       
    94 
       
    95 	BEGIN_NODE("subsubnode")
       
    96 	PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
       
    97 	PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
       
    98 	END_NODE
       
    99 	END_NODE
       
   100 
       
   101 	BEGIN_NODE("subnode@2")
       
   102 	PROP_INT(test_tree1, phandle, PHANDLE_1)
       
   103 	PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
       
   104 
       
   105 	BEGIN_NODE("subsubnode@0")
       
   106 	PROP_INT(test_tree1, phandle, PHANDLE_2)
       
   107 	PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
       
   108 	PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
       
   109 	END_NODE
       
   110 	END_NODE
       
   111 
       
   112 	END_NODE
       
   113 	FDTLONG(FDT_END)
       
   114 test_tree1_struct_end:
       
   115 
       
   116 test_tree1_strings:
       
   117 	STRING(test_tree1, compatible, "compatible")
       
   118 	STRING(test_tree1, prop_int, "prop-int")
       
   119 	STRING(test_tree1, prop_str, "prop-str")
       
   120 	STRING(test_tree1, phandle, "linux,phandle")
       
   121 test_tree1_strings_end:
       
   122 test_tree1_end:
       
   123 
       
   124 
       
   125 	TREE_HDR(truncated_property)
       
   126 	EMPTY_RSVMAP(truncated_property)
       
   127 
       
   128 truncated_property_struct:
       
   129 	BEGIN_NODE("")
       
   130 	PROPHDR(truncated_property, prop_truncated, 4)
       
   131 	/* Oops, no actual property data here */
       
   132 truncated_property_struct_end:
       
   133 
       
   134 truncated_property_strings:
       
   135 	STRING(truncated_property, prop_truncated, "truncated")
       
   136 truncated_property_strings_end:
       
   137 
       
   138 truncated_property_end:
       
   139 
       
   140 
       
   141 	TREE_HDR(bad_node_char)
       
   142 	EMPTY_RSVMAP(bad_node_char)
       
   143 
       
   144 bad_node_char_struct:
       
   145 	BEGIN_NODE("")
       
   146 	BEGIN_NODE("sub$node")
       
   147 	END_NODE
       
   148 	END_NODE
       
   149 	FDTLONG(FDT_END)
       
   150 bad_node_char_struct_end:
       
   151 
       
   152 bad_node_char_strings:
       
   153 bad_node_char_strings_end:
       
   154 bad_node_char_end:
       
   155 
       
   156 
       
   157 	TREE_HDR(bad_node_format)
       
   158 	EMPTY_RSVMAP(bad_node_format)
       
   159 
       
   160 bad_node_format_struct:
       
   161 	BEGIN_NODE("")
       
   162 	BEGIN_NODE("subnode@1@2")
       
   163 	END_NODE
       
   164 	END_NODE
       
   165 	FDTLONG(FDT_END)
       
   166 bad_node_format_struct_end:
       
   167 
       
   168 bad_node_format_strings:
       
   169 bad_node_format_strings_end:
       
   170 bad_node_format_end:
       
   171 
       
   172 
       
   173 	TREE_HDR(bad_prop_char)
       
   174 	EMPTY_RSVMAP(bad_prop_char)
       
   175 
       
   176 bad_prop_char_struct:
       
   177 	BEGIN_NODE("")
       
   178 	PROP_INT(bad_prop_char, prop, TEST_VALUE_1)
       
   179 	END_NODE
       
   180 	FDTLONG(FDT_END)
       
   181 bad_prop_char_struct_end:
       
   182 
       
   183 bad_prop_char_strings:
       
   184 	STRING(bad_prop_char, prop, "prop$erty")
       
   185 bad_prop_char_strings_end:
       
   186 bad_prop_char_end: