|
|
|
#include <fdt.h>
|
|
|
|
#include "testdata.h"
|
|
|
|
|
|
|
|
#define FDTLONG(val) \
|
|
|
|
.byte ((val) >> 24) & 0xff ; \
|
|
|
|
.byte ((val) >> 16) & 0xff ; \
|
|
|
|
.byte ((val) >> 8) & 0xff ; \
|
|
|
|
.byte (val) & 0xff ;
|
|
|
|
|
|
|
|
#define FDTQUAD(val) \
|
|
|
|
.byte ((val) >> 56) & 0xff ; \
|
|
|
|
.byte ((val) >> 48) & 0xff ; \
|
|
|
|
.byte ((val) >> 40) & 0xff ; \
|
|
|
|
.byte ((val) >> 32) & 0xff ; \
|
|
|
|
.byte ((val) >> 24) & 0xff ; \
|
|
|
|
.byte ((val) >> 16) & 0xff ; \
|
|
|
|
.byte ((val) >> 8) & 0xff ; \
|
|
|
|
.byte (val) & 0xff ;
|
|
|
|
|
|
|
|
#define TREE_HDR(tree) \
|
|
|
|
.balign 8 ; \
|
|
|
|
.globl _##tree ; \
|
|
|
|
_##tree: \
|
|
|
|
tree: \
|
|
|
|
FDTLONG(FDT_MAGIC) ; \
|
|
|
|
FDTLONG(tree##_end - tree) ; \
|
|
|
|
FDTLONG(tree##_struct - tree) ; \
|
|
|
|
FDTLONG(tree##_strings - tree) ; \
|
|
|
|
FDTLONG(tree##_rsvmap - tree) ; \
|
|
|
|
FDTLONG(0x11) ; \
|
|
|
|
FDTLONG(0x10) ; \
|
|
|
|
FDTLONG(0) ; \
|
|
|
|
FDTLONG(tree##_strings_end - tree##_strings) ; \
|
|
|
|
FDTLONG(tree##_struct_end - tree##_struct) ;
|
|
|
|
|
|
|
|
#define RSVMAP_ENTRY(addr, len) \
|
|
|
|
FDTQUAD(addr) ; \
|
|
|
|
FDTQUAD(len) ; \
|
|
|
|
|
|
|
|
#define EMPTY_RSVMAP(tree) \
|
|
|
|
.balign 8 ; \
|
|
|
|
tree##_rsvmap: ; \
|
|
|
|
RSVMAP_ENTRY(0, 0) \
|
|
|
|
tree##_rsvmap_end: ;
|
|
|
|
|
|
|
|
#define PROPHDR(tree, name, len) \
|
|
|
|
FDTLONG(FDT_PROP) ; \
|
|
|
|
FDTLONG(len) ; \
|
|
|
|
FDTLONG(tree##_##name - tree##_strings) ;
|
|
|
|
|
|
|
|
#define PROP_INT(tree, name, val) \
|
|
|
|
PROPHDR(tree, name, 4) \
|
libfdt: Abolish _typed() variants, add _cell() variants
In a number of places through libfdt and its tests, we have *_typed()
macro variants on functions which use gcc's typeof and statement
expression extensions to allow passing literals where the underlying
function takes a buffer and size.
These seemed like a good idea at the time, but in fact they have some
problems. They use typeof and statement expressions, extensions I'd
prefer to avoid for portability. Plus, they have potential gotchas -
although they'll deal with the size of the thing passed, they won't
deal with other representation issues (like endianness) and results
could be very strange if the type of the expression passed isn't what
you think it is.
In fact, the only users of these _typed() macros were when the value
passed is a single cell (32-bit integer). Therefore, this patch
removes all these _typed() macros and replaces them with explicit
_cell() variants which handle a single 32-bit integer, and which also
perform endian convesions as appropriate.
With this in place, it now becomes easy to use standardized big-endian
representation for integer valued properties in the testcases,
regardless of the platform we're running on. We therefore do that,
which has the additional advantage that all the example trees created
during a test run are now byte-for-byte identical regardless of
platform.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
17 years ago
|
|
|
FDTLONG(val) ;
|
|
|
|
|
|
|
|
#define PROP_STR(tree, name, str) \
|
|
|
|
PROPHDR(tree, name, 55f - 54f) \
|
|
|
|
54: \
|
|
|
|
.string str ; \
|
|
|
|
55: \
|
|
|
|
.balign 4 ;
|
|
|
|
|
|
|
|
#define BEGIN_NODE(name) \
|
|
|
|
FDTLONG(FDT_BEGIN_NODE) ; \
|
|
|
|
.string name ; \
|
|
|
|
.balign 4 ;
|
|
|
|
|
|
|
|
#define END_NODE \
|
|
|
|
FDTLONG(FDT_END_NODE) ;
|
|
|
|
|
|
|
|
#define STRING(tree, name, str) \
|
|
|
|
tree##_##name: ; \
|
|
|
|
.string str ;
|
|
|
|
|
|
|
|
.data
|
|
|
|
|
|
|
|
TREE_HDR(test_tree1)
|
|
|
|
|
|
|
|
.balign 8
|
|
|
|
test_tree1_rsvmap:
|
|
|
|
RSVMAP_ENTRY(TEST_ADDR_1, TEST_SIZE_1)
|
|
|
|
RSVMAP_ENTRY(TEST_ADDR_2, TEST_SIZE_2)
|
|
|
|
RSVMAP_ENTRY(0, 0)
|
|
|
|
test_tree1_rsvmap_end:
|
|
|
|
|
|
|
|
test_tree1_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
PROP_STR(test_tree1, compatible, "test_tree1")
|
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
|
|
|
|
PROP_STR(test_tree1, prop_str, TEST_STRING_1)
|
|
|
|
|
|
|
|
BEGIN_NODE("subnode@1")
|
|
|
|
PROP_STR(test_tree1, compatible, "subnode1")
|
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
|
|
|
|
|
|
|
|
BEGIN_NODE("subsubnode")
|
|
|
|
PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
|
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
|
|
|
|
END_NODE
|
|
|
|
END_NODE
|
|
|
|
|
|
|
|
BEGIN_NODE("subnode@2")
|
libfdt: Abolish _typed() variants, add _cell() variants
In a number of places through libfdt and its tests, we have *_typed()
macro variants on functions which use gcc's typeof and statement
expression extensions to allow passing literals where the underlying
function takes a buffer and size.
These seemed like a good idea at the time, but in fact they have some
problems. They use typeof and statement expressions, extensions I'd
prefer to avoid for portability. Plus, they have potential gotchas -
although they'll deal with the size of the thing passed, they won't
deal with other representation issues (like endianness) and results
could be very strange if the type of the expression passed isn't what
you think it is.
In fact, the only users of these _typed() macros were when the value
passed is a single cell (32-bit integer). Therefore, this patch
removes all these _typed() macros and replaces them with explicit
_cell() variants which handle a single 32-bit integer, and which also
perform endian convesions as appropriate.
With this in place, it now becomes easy to use standardized big-endian
representation for integer valued properties in the testcases,
regardless of the platform we're running on. We therefore do that,
which has the additional advantage that all the example trees created
during a test run are now byte-for-byte identical regardless of
platform.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
17 years ago
|
|
|
PROP_INT(test_tree1, phandle, PHANDLE_1)
|
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
|
|
|
|
|
|
|
|
BEGIN_NODE("subsubnode@0")
|
libfdt: Abolish _typed() variants, add _cell() variants
In a number of places through libfdt and its tests, we have *_typed()
macro variants on functions which use gcc's typeof and statement
expression extensions to allow passing literals where the underlying
function takes a buffer and size.
These seemed like a good idea at the time, but in fact they have some
problems. They use typeof and statement expressions, extensions I'd
prefer to avoid for portability. Plus, they have potential gotchas -
although they'll deal with the size of the thing passed, they won't
deal with other representation issues (like endianness) and results
could be very strange if the type of the expression passed isn't what
you think it is.
In fact, the only users of these _typed() macros were when the value
passed is a single cell (32-bit integer). Therefore, this patch
removes all these _typed() macros and replaces them with explicit
_cell() variants which handle a single 32-bit integer, and which also
perform endian convesions as appropriate.
With this in place, it now becomes easy to use standardized big-endian
representation for integer valued properties in the testcases,
regardless of the platform we're running on. We therefore do that,
which has the additional advantage that all the example trees created
during a test run are now byte-for-byte identical regardless of
platform.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
17 years ago
|
|
|
PROP_INT(test_tree1, phandle, PHANDLE_2)
|
|
|
|
PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
|
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
|
|
|
|
END_NODE
|
|
|
|
END_NODE
|
|
|
|
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
test_tree1_struct_end:
|
|
|
|
|
|
|
|
test_tree1_strings:
|
|
|
|
STRING(test_tree1, compatible, "compatible")
|
|
|
|
STRING(test_tree1, prop_int, "prop-int")
|
|
|
|
STRING(test_tree1, prop_str, "prop-str")
|
|
|
|
STRING(test_tree1, phandle, "linux,phandle")
|
|
|
|
test_tree1_strings_end:
|
|
|
|
test_tree1_end:
|
|
|
|
|
|
|
|
|
|
|
|
TREE_HDR(truncated_property)
|
|
|
|
EMPTY_RSVMAP(truncated_property)
|
|
|
|
|
|
|
|
truncated_property_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
PROPHDR(truncated_property, prop_truncated, 4)
|
|
|
|
/* Oops, no actual property data here */
|
|
|
|
truncated_property_struct_end:
|
|
|
|
|
|
|
|
truncated_property_strings:
|
|
|
|
STRING(truncated_property, prop_truncated, "truncated")
|
|
|
|
truncated_property_strings_end:
|
|
|
|
|
|
|
|
truncated_property_end:
|