2 * libfdt - Flat Device Tree manipulation
3 * Testcase for variable sized cells in dtc
4 * Copyright (C) 2006 David Gibson, IBM Corporation.
5 * Copyright (C) 2011 The Chromium Authors. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 static void check_compare_properties(void *fdt,
38 propval = fdt_getprop(fdt, 0, name_one, &proplen);
41 FAIL("fdt_getprop(\"%s\"): %s",
43 fdt_strerror(proplen));
45 check_getprop(fdt, 0, name_two, proplen, propval);
48 int main(int argc, char *argv[])
51 uint8_t expected_8[6] = {TEST_CHAR1,
57 uint16_t expected_16[6];
58 uint32_t expected_32[6];
59 uint64_t expected_64[6];
62 for (i = 0; i < 5; ++i) {
63 expected_16[i] = cpu_to_fdt16(expected_8[i]);
64 expected_32[i] = cpu_to_fdt32(expected_8[i]);
65 expected_64[i] = cpu_to_fdt64(expected_8[i]);
68 expected_16[5] = cpu_to_fdt16(TEST_VALUE_1 >> 16);
69 expected_32[5] = cpu_to_fdt32(TEST_VALUE_1);
70 expected_64[5] = cpu_to_fdt64(TEST_ADDR_1);
72 test_init(argc, argv);
73 fdt = load_blob_arg(argc, argv);
75 check_getprop(fdt, 0, "cells-8b", sizeof(expected_8), expected_8);
76 check_getprop(fdt, 0, "cells-16b", sizeof(expected_16), expected_16);
77 check_getprop(fdt, 0, "cells-32b", sizeof(expected_32), expected_32);
78 check_getprop(fdt, 0, "cells-64b", sizeof(expected_64), expected_64);
80 check_compare_properties(fdt, "cells-one-16b", "cells-one-32b");