|
|
|
#include <endian.h>
|
|
|
|
|
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
|
|
#define cell_to_fdt(x) (x)
|
|
|
|
#else
|
|
|
|
/* We do this as a big hairy expression instead of using bswap_32()
|
|
|
|
* because we need it to work in asm as well as C. */
|
|
|
|
#define cell_to_fdt(x) ((((x) >> 24) & 0xff) | (((x) >> 8) & 0xff00) \
|
|
|
|
| (((x) << 8) & 0xff0000) | (((x) << 24) & 0xff000000))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
#define ASM_CONST_LL(x) (x)
|
|
|
|
#else
|
|
|
|
#define ASM_CONST_LL(x) (x##ULL)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TEST_ADDR_1 ASM_CONST_LL(0xdeadbeef00000000)
|
|
|
|
#define TEST_SIZE_1 ASM_CONST_LL(0x100000)
|
|
|
|
#define TEST_ADDR_2 ASM_CONST_LL(123456789)
|
|
|
|
#define TEST_SIZE_2 ASM_CONST_LL(010000)
|
|
|
|
|
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
|
|
|
#define TEST_VALUE_1 0xdeadbeef
|
|
|
|
#define TEST_VALUE_2 123456789
|
|
|
|
|
|
|
|
#define PHANDLE_1 0x2000
|
|
|
|
#define PHANDLE_2 0x2001
|
|
|
|
|
|
|
|
#define TEST_STRING_1 "hello world"
|
|
|
|
#define TEST_STRING_2 "nastystring: \a\b\t\n\v\f\r\\\""
|
|
|
|
#define TEST_STRING_3 "\xde\xad\xbe\xef"
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
extern struct fdt_header _test_tree1;
|
|
|
|
extern struct fdt_header _truncated_property;
|
|
|
|
#endif /* ! __ASSEMBLY */
|