summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2012-06-01 14:12:37 +1000
committerJon Loeliger <jdl@jdl.com>2012-06-03 09:14:13 -0500
commitcbf1410eab4b7ce7be1b15f985ef71bfc1f5886d (patch)
tree7b91ba2d60830d89ac7de1f35a5e6130d21e0b55 /tests
parent4adbb5336b0eed99f30c852d9dcf3cd125cae921 (diff)
downloaddtc-cbf1410eab4b7ce7be1b15f985ef71bfc1f5886d.tar.gz
libfdt: Add helpers for 64-bit integer properties
In device trees in the world, properties consisting of a single 64-bit integer are not as common as those consisting of a single 32-bit, cell sized integer, but they're common enough that they're worth including convenience functions for. This patch adds helper wrappers of fdt_setprop_inplace(), fdt_setprop() and fdt_appendprop() for handling 64-bit integer quantities in properties. For better consistency with the names of these new *_u64() functions we also add *_u32() functions as alternative names for the existing *_cell() functions handling 32-bit integers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/appendprop.dts1
-rw-r--r--tests/appendprop1.c1
-rw-r--r--tests/appendprop2.c1
-rw-r--r--tests/include1.dts1
-rw-r--r--tests/include5a.dts1
-rw-r--r--tests/rw_tree1.c3
-rw-r--r--tests/setprop.c18
-rw-r--r--tests/setprop_inplace.c15
-rw-r--r--tests/sw_tree1.c3
-rw-r--r--tests/test_tree1.dts1
-rw-r--r--tests/test_tree1_merge.dts1
-rw-r--r--tests/test_tree1_merge_labelled.dts1
-rw-r--r--tests/test_tree1_merge_path.dts1
-rw-r--r--tests/testdata.h2
-rw-r--r--tests/tests.h5
-rw-r--r--tests/trees.S6
16 files changed, 59 insertions, 2 deletions
diff --git a/tests/appendprop.dts b/tests/appendprop.dts
index 6e3a3eb..f4bc730 100644
--- a/tests/appendprop.dts
+++ b/tests/appendprop.dts
@@ -2,6 +2,7 @@
/ {
prop-str = "hello world", "nastystring: \a\b\t\n\v\f\r\\\"";
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef 0xdeadbeef01abcdef>;
prop-int = <0xdeadbeef 123456789>;
prop-bytes = [00010203040001020304];
};
diff --git a/tests/appendprop1.c b/tests/appendprop1.c
index 180d296..d716f7a 100644
--- a/tests/appendprop1.c
+++ b/tests/appendprop1.c
@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
CHECK(fdt_appendprop(fdt, 0, "prop-bytes", bytes, sizeof(bytes)));
CHECK(fdt_appendprop_cell(fdt, 0, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_appendprop_u64(fdt, 0, "prop-int64", TEST_VALUE64_1));
CHECK(fdt_appendprop_string(fdt, 0, "prop-str", TEST_STRING_1));
CHECK(fdt_pack(fdt));
diff --git a/tests/appendprop2.c b/tests/appendprop2.c
index d651a89..7eb243d 100644
--- a/tests/appendprop2.c
+++ b/tests/appendprop2.c
@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
CHECK(fdt_appendprop(fdt, 0, "prop-bytes", bytes, sizeof(bytes)));
CHECK(fdt_appendprop_cell(fdt, 0, "prop-int", TEST_VALUE_2));
+ CHECK(fdt_appendprop_u64(fdt, 0, "prop-int64", TEST_VALUE64_1));
CHECK(fdt_appendprop_string(fdt, 0, "prop-str", TEST_STRING_2));
CHECK(fdt_pack(fdt));
diff --git a/tests/include1.dts b/tests/include1.dts
index 5d59d83..893aaff 100644
--- a/tests/include1.dts
+++ b/tests/include1.dts
@@ -6,6 +6,7 @@
/ {
/include/ "include4.dts"
/include/ "include5.dts" = <0xdeadbeef>;
+ prop-int64 /include/ "include5a.dts";
prop-str = /include/ "include6.dts";
/include/ "include7.dts"
diff --git a/tests/include5a.dts b/tests/include5a.dts
new file mode 100644
index 0000000..39ddba4
--- /dev/null
+++ b/tests/include5a.dts
@@ -0,0 +1 @@
+= /bits/ 64 <0xdeadbeef01abcdef> \ No newline at end of file
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c
index f0bce88..f4965ec 100644
--- a/tests/rw_tree1.c
+++ b/tests/rw_tree1.c
@@ -73,7 +73,8 @@ int main(int argc, char *argv[])
CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2));
CHECK(fdt_setprop_string(fdt, 0, "compatible", "test_tree1"));
- CHECK(fdt_setprop_cell(fdt, 0, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_u32(fdt, 0, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_u64(fdt, 0, "prop-int64", TEST_VALUE64_1));
CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1));
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1"));
diff --git a/tests/setprop.c b/tests/setprop.c
index 386b87b..9f2bc88 100644
--- a/tests/setprop.c
+++ b/tests/setprop.c
@@ -74,5 +74,23 @@ int main(int argc, char *argv[])
check_getprop(fdt, 0, "prop-str", 0, NULL);
+ err = fdt_setprop_u32(fdt, 0, "prop-u32", TEST_VALUE_2);
+ if (err)
+ FAIL("Failed to set \"prop-u32\" to 0x%08x: %s",
+ TEST_VALUE_2, fdt_strerror(err));
+ check_getprop_cell(fdt, 0, "prop-u32", TEST_VALUE_2);
+
+ err = fdt_setprop_cell(fdt, 0, "prop-cell", TEST_VALUE_2);
+ if (err)
+ FAIL("Failed to set \"prop-cell\" to 0x%08x: %s",
+ TEST_VALUE_2, fdt_strerror(err));
+ check_getprop_cell(fdt, 0, "prop-cell", TEST_VALUE_2);
+
+ err = fdt_setprop_u64(fdt, 0, "prop-u64", TEST_VALUE64_1);
+ if (err)
+ FAIL("Failed to set \"prop-u64\" to 0x%016llx: %s",
+ TEST_VALUE64_1, fdt_strerror(err));
+ check_getprop_64(fdt, 0, "prop-u64", TEST_VALUE64_1);
+
PASS();
}
diff --git a/tests/setprop_inplace.c b/tests/setprop_inplace.c
index aa0cd96..30a1cf3 100644
--- a/tests/setprop_inplace.c
+++ b/tests/setprop_inplace.c
@@ -34,6 +34,7 @@ int main(int argc, char *argv[])
{
void *fdt;
const uint32_t *intp;
+ const uint64_t *int64p;
const char *strp;
char *xstr;
int xlen, i;
@@ -55,6 +56,20 @@ int main(int argc, char *argv[])
strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
TEST_STRING_1);
+
+ int64p = check_getprop_64(fdt, 0, "prop-int64", TEST_VALUE64_1);
+
+ verbose_printf("Old int64 value was 0x%016llx\n", *int64p);
+ err = fdt_setprop_inplace_u64(fdt, 0, "prop-int64", ~TEST_VALUE64_1);
+ if (err)
+ FAIL("Failed to set \"prop-int64\" to 0x016%llx: %s",
+ ~TEST_VALUE64_1, fdt_strerror(err));
+ int64p = check_getprop_64(fdt, 0, "prop-int64", ~TEST_VALUE64_1);
+ verbose_printf("New int64 value is 0x%016llx\n", *int64p);
+
+ strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
+ TEST_STRING_1);
+
verbose_printf("Old string value was \"%s\"\n", strp);
xstr = strdup(strp);
xlen = strlen(xstr);
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index f2c430a..5c71414 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -55,7 +55,8 @@ int main(int argc, char *argv[])
CHECK(fdt_begin_node(fdt, ""));
CHECK(fdt_property_string(fdt, "compatible", "test_tree1"));
- CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_property_u32(fdt, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_property_u64(fdt, "prop-int64", TEST_VALUE64_1));
CHECK(fdt_property_string(fdt, "prop-str", TEST_STRING_1));
CHECK(fdt_begin_node(fdt, "subnode@1"));
diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts
index 4f0ce45..cf530ce 100644
--- a/tests/test_tree1.dts
+++ b/tests/test_tree1.dts
@@ -6,6 +6,7 @@
/ {
compatible = "test_tree1";
prop-int = <0xdeadbeef>;
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
prop-str = "hello world";
subnode@1 {
diff --git a/tests/test_tree1_merge.dts b/tests/test_tree1_merge.dts
index fc191fd..ded08d8 100644
--- a/tests/test_tree1_merge.dts
+++ b/tests/test_tree1_merge.dts
@@ -30,6 +30,7 @@
/ {
prop-int = <0xdeadbeef>;
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
subnode@1 {
prop-int = [deadbeef];
};
diff --git a/tests/test_tree1_merge_labelled.dts b/tests/test_tree1_merge_labelled.dts
index 46a6840..29953b0 100644
--- a/tests/test_tree1_merge_labelled.dts
+++ b/tests/test_tree1_merge_labelled.dts
@@ -6,6 +6,7 @@
/ {
compatible = "test_tree1";
prop-int = <0xdeadbeef>;
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
prop-str = "hello world";
subnode@1 {
diff --git a/tests/test_tree1_merge_path.dts b/tests/test_tree1_merge_path.dts
index d68713b..168d066 100644
--- a/tests/test_tree1_merge_path.dts
+++ b/tests/test_tree1_merge_path.dts
@@ -6,6 +6,7 @@
/ {
compatible = "test_tree1";
prop-int = <0xdeadbeef>;
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
prop-str = "hello world";
subnode@1 {
diff --git a/tests/testdata.h b/tests/testdata.h
index d4c6759..ce715e4 100644
--- a/tests/testdata.h
+++ b/tests/testdata.h
@@ -12,6 +12,8 @@
#define TEST_VALUE_1 0xdeadbeef
#define TEST_VALUE_2 123456789
+#define TEST_VALUE64_1 ASM_CONST_LL(0xdeadbeef01abcdef)
+
#define PHANDLE_1 0x2000
#define PHANDLE_2 0x2001
diff --git a/tests/tests.h b/tests/tests.h
index a51556d..56a843c 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -111,6 +111,11 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name,
uint32_t x = cpu_to_fdt32(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
})
+#define check_getprop_64(fdt, nodeoffset, name, val) \
+ ({ \
+ uint64_t x = cpu_to_fdt64(val); \
+ check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
+ })
#define check_getprop_string(fdt, nodeoffset, name, s) \
check_getprop((fdt), (nodeoffset), (name), strlen(s)+1, (s))
int nodename_eq(const char *s1, const char *s2);
diff --git a/tests/trees.S b/tests/trees.S
index 66adf3f..cae0187 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -52,6 +52,10 @@ tree##_rsvmap_end: ;
PROPHDR(tree, name, 4) \
FDTLONG(val) ;
+#define PROP_INT64(tree, name, val) \
+ PROPHDR(tree, name, 8) \
+ FDTQUAD(val) ;
+
#define PROP_STR(tree, name, str) \
PROPHDR(tree, name, 55f - 54f) \
54: \
@@ -86,6 +90,7 @@ test_tree1_struct:
BEGIN_NODE("")
PROP_STR(test_tree1, compatible, "test_tree1")
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
+ PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1)
PROP_STR(test_tree1, prop_str, TEST_STRING_1)
BEGIN_NODE("subnode@1")
@@ -124,6 +129,7 @@ test_tree1_struct_end:
test_tree1_strings:
STRING(test_tree1, compatible, "compatible")
STRING(test_tree1, prop_int, "prop-int")
+ STRING(test_tree1, prop_int64, "prop-int64")
STRING(test_tree1, prop_str, "prop-str")
STRING(test_tree1, linux_phandle, "linux,phandle")
STRING(test_tree1, phandle, "phandle")