2006-11-27 06:21:28 +01:00
|
|
|
#include <fdt.h>
|
|
|
|
#include "testdata.h"
|
|
|
|
|
2006-12-04 02:52:45 +01:00
|
|
|
#define FDTLONG(val) \
|
|
|
|
.byte ((val) >> 24) & 0xff ; \
|
|
|
|
.byte ((val) >> 16) & 0xff ; \
|
|
|
|
.byte ((val) >> 8) & 0xff ; \
|
2007-10-18 06:14:09 +02:00
|
|
|
.byte (val) & 0xff ;
|
2006-12-04 02:52:45 +01:00
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
#define TREE_HDR(tree) \
|
2007-10-18 06:14:09 +02:00
|
|
|
.balign 8 ; \
|
2017-10-18 07:59:43 +02:00
|
|
|
.globl tree ; \
|
2006-11-27 06:21:28 +01:00
|
|
|
tree: \
|
2006-12-04 02:52:45 +01:00
|
|
|
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) ; \
|
2007-10-18 06:14:09 +02:00
|
|
|
FDTLONG(tree##_strings_end - tree##_strings) ; \
|
|
|
|
FDTLONG(tree##_struct_end - tree##_struct) ;
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2017-10-06 14:07:30 +02:00
|
|
|
#define RSVMAP_ENTRY(addrh, addrl, lenh, lenl) \
|
|
|
|
FDTLONG(addrh) ; \
|
|
|
|
FDTLONG(addrl) ; \
|
|
|
|
FDTLONG(lenh) ; \
|
|
|
|
FDTLONG(lenl)
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2007-10-10 09:12:12 +02:00
|
|
|
#define EMPTY_RSVMAP(tree) \
|
|
|
|
.balign 8 ; \
|
|
|
|
tree##_rsvmap: ; \
|
2017-10-06 14:07:30 +02:00
|
|
|
RSVMAP_ENTRY(0, 0, 0, 0) \
|
2007-10-18 06:14:09 +02:00
|
|
|
tree##_rsvmap_end: ;
|
2007-10-10 09:12:12 +02:00
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
#define PROPHDR(tree, name, len) \
|
2006-12-04 02:52:45 +01:00
|
|
|
FDTLONG(FDT_PROP) ; \
|
2007-02-23 04:40:14 +01:00
|
|
|
FDTLONG(len) ; \
|
|
|
|
FDTLONG(tree##_##name - tree##_strings) ;
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2017-11-14 12:45:56 +01:00
|
|
|
#define PROP_EMPTY(tree, name) \
|
|
|
|
PROPHDR(tree, name, 0) ;
|
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
#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>
2007-11-20 03:35:46 +01:00
|
|
|
FDTLONG(val) ;
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2017-10-06 14:07:30 +02:00
|
|
|
#define PROP_INT64(tree, name, valh, vall) \
|
2012-06-01 06:12:37 +02:00
|
|
|
PROPHDR(tree, name, 8) \
|
2017-10-06 14:07:30 +02:00
|
|
|
FDTLONG(valh) ; \
|
|
|
|
FDTLONG(vall) ;
|
2012-06-01 06:12:37 +02:00
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
#define PROP_STR(tree, name, str) \
|
|
|
|
PROPHDR(tree, name, 55f - 54f) \
|
|
|
|
54: \
|
|
|
|
.string str ; \
|
|
|
|
55: \
|
2007-10-18 06:14:09 +02:00
|
|
|
.balign 4 ;
|
2006-11-27 06:21:28 +01:00
|
|
|
|
|
|
|
#define BEGIN_NODE(name) \
|
2006-12-04 02:52:45 +01:00
|
|
|
FDTLONG(FDT_BEGIN_NODE) ; \
|
2006-11-27 06:21:28 +01:00
|
|
|
.string name ; \
|
2007-10-18 06:14:09 +02:00
|
|
|
.balign 4 ;
|
2006-11-27 06:21:28 +01:00
|
|
|
|
|
|
|
#define END_NODE \
|
2006-12-04 02:52:45 +01:00
|
|
|
FDTLONG(FDT_END_NODE) ;
|
2006-11-27 06:21:28 +01:00
|
|
|
|
|
|
|
#define STRING(tree, name, str) \
|
2007-10-18 06:14:09 +02:00
|
|
|
tree##_##name: ; \
|
|
|
|
.string str ;
|
2007-09-18 03:44:04 +02:00
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
.data
|
|
|
|
|
|
|
|
TREE_HDR(test_tree1)
|
|
|
|
|
2007-10-10 09:12:12 +02:00
|
|
|
.balign 8
|
2006-11-27 06:21:28 +01:00
|
|
|
test_tree1_rsvmap:
|
2017-10-06 14:07:30 +02:00
|
|
|
RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L)
|
|
|
|
RSVMAP_ENTRY(TEST_ADDR_2H, TEST_ADDR_2L, TEST_SIZE_2H, TEST_SIZE_2L)
|
|
|
|
RSVMAP_ENTRY(0, 0, 0, 0)
|
2007-10-18 06:14:09 +02:00
|
|
|
test_tree1_rsvmap_end:
|
2006-11-27 06:21:28 +01:00
|
|
|
|
|
|
|
test_tree1_struct:
|
|
|
|
BEGIN_NODE("")
|
2007-10-16 05:58:25 +02:00
|
|
|
PROP_STR(test_tree1, compatible, "test_tree1")
|
2006-11-27 06:21:28 +01:00
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
|
2017-10-06 14:07:30 +02:00
|
|
|
PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1H, TEST_VALUE64_1L)
|
2006-11-27 06:21:28 +01:00
|
|
|
PROP_STR(test_tree1, prop_str, TEST_STRING_1)
|
2013-09-19 14:15:13 +02:00
|
|
|
PROP_INT(test_tree1, address_cells, 1)
|
|
|
|
PROP_INT(test_tree1, size_cells, 0)
|
2007-09-18 03:44:04 +02:00
|
|
|
|
2007-09-28 07:51:04 +02:00
|
|
|
BEGIN_NODE("subnode@1")
|
2007-10-16 05:58:25 +02:00
|
|
|
PROP_STR(test_tree1, compatible, "subnode1")
|
2013-09-19 14:15:13 +02:00
|
|
|
PROP_INT(test_tree1, reg, 1)
|
2006-11-27 06:21:28 +01:00
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
|
|
|
|
|
|
|
|
BEGIN_NODE("subsubnode")
|
2007-10-16 05:58:25 +02:00
|
|
|
PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
|
2017-04-01 17:31:41 +02:00
|
|
|
PROP_STR(test_tree1, placeholder, "this is a placeholder string\0string2")
|
2006-11-27 06:21:28 +01:00
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
|
|
|
|
END_NODE
|
2008-10-30 03:41:08 +01:00
|
|
|
|
|
|
|
BEGIN_NODE("ss1")
|
|
|
|
END_NODE
|
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
END_NODE
|
|
|
|
|
2007-09-28 07:51:04 +02:00
|
|
|
BEGIN_NODE("subnode@2")
|
2013-09-19 14:15:13 +02:00
|
|
|
PROP_INT(test_tree1, reg, 2)
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
PROP_INT(test_tree1, linux_phandle, PHANDLE_1)
|
2006-11-27 06:21:28 +01:00
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
|
2013-09-19 14:15:13 +02:00
|
|
|
PROP_INT(test_tree1, address_cells, 1)
|
|
|
|
PROP_INT(test_tree1, size_cells, 0)
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2007-09-28 07:51:04 +02:00
|
|
|
BEGIN_NODE("subsubnode@0")
|
2013-09-19 14:15:13 +02:00
|
|
|
PROP_INT(test_tree1, reg, 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>
2007-11-20 03:35:46 +01:00
|
|
|
PROP_INT(test_tree1, phandle, PHANDLE_2)
|
2007-10-16 05:58:25 +02:00
|
|
|
PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
|
2006-11-27 06:21:28 +01:00
|
|
|
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
|
|
|
|
END_NODE
|
2008-10-30 03:41:08 +01:00
|
|
|
|
|
|
|
BEGIN_NODE("ss2")
|
|
|
|
END_NODE
|
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
END_NODE
|
|
|
|
|
|
|
|
END_NODE
|
2006-12-04 02:52:45 +01:00
|
|
|
FDTLONG(FDT_END)
|
2007-10-18 06:14:09 +02:00
|
|
|
test_tree1_struct_end:
|
2006-11-27 06:21:28 +01:00
|
|
|
|
|
|
|
test_tree1_strings:
|
2007-10-16 05:58:25 +02:00
|
|
|
STRING(test_tree1, compatible, "compatible")
|
2006-11-27 06:21:28 +01:00
|
|
|
STRING(test_tree1, prop_int, "prop-int")
|
2012-06-01 06:12:37 +02:00
|
|
|
STRING(test_tree1, prop_int64, "prop-int64")
|
2006-11-27 06:21:28 +01:00
|
|
|
STRING(test_tree1, prop_str, "prop-str")
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
STRING(test_tree1, linux_phandle, "linux,phandle")
|
|
|
|
STRING(test_tree1, phandle, "phandle")
|
2013-09-19 14:15:13 +02:00
|
|
|
STRING(test_tree1, reg, "reg")
|
2017-04-01 17:31:41 +02:00
|
|
|
STRING(test_tree1, placeholder, "placeholder")
|
2013-09-19 14:15:13 +02:00
|
|
|
STRING(test_tree1, address_cells, "#address-cells")
|
|
|
|
STRING(test_tree1, size_cells, "#size-cells")
|
2007-10-18 06:14:09 +02:00
|
|
|
test_tree1_strings_end:
|
2006-11-27 06:21:28 +01:00
|
|
|
test_tree1_end:
|
2006-12-14 05:29:25 +01:00
|
|
|
|
2007-10-18 06:14:09 +02:00
|
|
|
|
2006-12-14 05:29:25 +01:00
|
|
|
TREE_HDR(truncated_property)
|
2007-10-10 09:12:12 +02:00
|
|
|
EMPTY_RSVMAP(truncated_property)
|
2006-12-14 05:29:25 +01:00
|
|
|
|
|
|
|
truncated_property_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
PROPHDR(truncated_property, prop_truncated, 4)
|
|
|
|
/* Oops, no actual property data here */
|
2007-10-18 06:14:09 +02:00
|
|
|
truncated_property_struct_end:
|
2007-09-18 03:44:04 +02:00
|
|
|
|
2006-12-14 05:29:25 +01:00
|
|
|
truncated_property_strings:
|
|
|
|
STRING(truncated_property, prop_truncated, "truncated")
|
2007-10-18 06:14:09 +02:00
|
|
|
truncated_property_strings_end:
|
|
|
|
|
2006-12-14 05:29:25 +01:00
|
|
|
truncated_property_end:
|
2008-02-27 03:45:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
TREE_HDR(bad_node_char)
|
|
|
|
EMPTY_RSVMAP(bad_node_char)
|
|
|
|
|
|
|
|
bad_node_char_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
BEGIN_NODE("sub$node")
|
|
|
|
END_NODE
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
bad_node_char_struct_end:
|
|
|
|
|
|
|
|
bad_node_char_strings:
|
|
|
|
bad_node_char_strings_end:
|
|
|
|
bad_node_char_end:
|
|
|
|
|
|
|
|
|
|
|
|
TREE_HDR(bad_node_format)
|
|
|
|
EMPTY_RSVMAP(bad_node_format)
|
|
|
|
|
|
|
|
bad_node_format_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
BEGIN_NODE("subnode@1@2")
|
|
|
|
END_NODE
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
bad_node_format_struct_end:
|
|
|
|
|
|
|
|
bad_node_format_strings:
|
|
|
|
bad_node_format_strings_end:
|
|
|
|
bad_node_format_end:
|
|
|
|
|
|
|
|
|
|
|
|
TREE_HDR(bad_prop_char)
|
|
|
|
EMPTY_RSVMAP(bad_prop_char)
|
|
|
|
|
|
|
|
bad_prop_char_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
PROP_INT(bad_prop_char, prop, TEST_VALUE_1)
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
bad_prop_char_struct_end:
|
|
|
|
|
|
|
|
bad_prop_char_strings:
|
|
|
|
STRING(bad_prop_char, prop, "prop$erty")
|
|
|
|
bad_prop_char_strings_end:
|
|
|
|
bad_prop_char_end:
|
2016-01-02 22:43:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* overflow_size_strings */
|
|
|
|
.balign 8
|
2017-10-18 07:59:43 +02:00
|
|
|
.globl ovf_size_strings
|
2016-01-02 22:43:35 +01:00
|
|
|
ovf_size_strings:
|
|
|
|
FDTLONG(FDT_MAGIC)
|
|
|
|
FDTLONG(ovf_size_strings_end - ovf_size_strings)
|
|
|
|
FDTLONG(ovf_size_strings_struct - ovf_size_strings)
|
|
|
|
FDTLONG(ovf_size_strings_strings - ovf_size_strings)
|
|
|
|
FDTLONG(ovf_size_strings_rsvmap - ovf_size_strings)
|
|
|
|
FDTLONG(0x11)
|
|
|
|
FDTLONG(0x10)
|
|
|
|
FDTLONG(0)
|
|
|
|
FDTLONG(0xffffffff)
|
|
|
|
FDTLONG(ovf_size_strings_struct_end - ovf_size_strings_struct)
|
|
|
|
EMPTY_RSVMAP(ovf_size_strings)
|
|
|
|
|
|
|
|
ovf_size_strings_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
PROP_INT(ovf_size_strings, bad_string, 0)
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
ovf_size_strings_struct_end:
|
|
|
|
|
|
|
|
ovf_size_strings_strings:
|
|
|
|
STRING(ovf_size_strings, x, "x")
|
|
|
|
ovf_size_strings_bad_string = ovf_size_strings_strings + 0x10000000
|
|
|
|
ovf_size_strings_strings_end:
|
|
|
|
ovf_size_strings_end:
|
2017-11-14 12:45:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* truncated_string */
|
|
|
|
TREE_HDR(truncated_string)
|
|
|
|
EMPTY_RSVMAP(truncated_string)
|
|
|
|
|
|
|
|
truncated_string_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
PROP_EMPTY(truncated_string, good_string)
|
|
|
|
PROP_EMPTY(truncated_string, bad_string)
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
truncated_string_struct_end:
|
|
|
|
|
|
|
|
truncated_string_strings:
|
|
|
|
STRING(truncated_string, good_string, "good")
|
|
|
|
truncated_string_bad_string:
|
|
|
|
.byte 'b'
|
|
|
|
.byte 'a'
|
|
|
|
.byte 'd'
|
|
|
|
/* NOTE: terminating \0 deliberately missing */
|
|
|
|
truncated_string_strings_end:
|
|
|
|
truncated_string_end:
|
2018-03-09 13:28:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* truncated_memrsv */
|
|
|
|
TREE_HDR(truncated_memrsv)
|
|
|
|
|
|
|
|
truncated_memrsv_struct:
|
|
|
|
BEGIN_NODE("")
|
|
|
|
END_NODE
|
|
|
|
FDTLONG(FDT_END)
|
|
|
|
truncated_memrsv_struct_end:
|
|
|
|
|
|
|
|
truncated_memrsv_strings:
|
|
|
|
truncated_memrsv_strings_end:
|
|
|
|
|
|
|
|
.balign 8
|
|
|
|
truncated_memrsv_rsvmap:
|
|
|
|
RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L)
|
|
|
|
truncated_memrsv_rsvmap_end:
|
|
|
|
|
|
|
|
truncated_memrsv_end:
|