Browse Source
Elements of size 8, 16, 32, and 64 bits are supported. The new /bits/ syntax was selected so as to not pollute the reserved keyword space with uint8/uint16/... type names. With this patch the following property assignment: property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>; is equivalent to: property = <0x12345678 0x0000ffff>; It is now also possible to directly specify a 64 bit literal in a cell list, also known as an array using: property = /bits/ 64 <0xdeadbeef00000000>; It is an error to attempt to store a literal into an element that is too small to hold the literal, and the compiler will generate an error when it detects this. For instance: property = /bits/ 8 <256>; Will fail to compile. It is also an error to attempt to place a reference in a non 32-bit element. The documentation has been changed to reflect that the cell list is now an array of elements that can be of sizes other than the default 32-bit cell size. The sized_cells test tests the creation and access of 8, 16, 32, and 64-bit sized elements. It also tests that the creation of two properties, one with 16 bit elements and one with 32 bit elements result in the same property contents. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>main
Anton Staaf
13 years ago
committed by
Jon Loeliger
8 changed files with 177 additions and 33 deletions
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
/* |
||||
* libfdt - Flat Device Tree manipulation |
||||
* Testcase for variable sized cells in dtc |
||||
* Copyright (C) 2006 David Gibson, IBM Corporation. |
||||
* Copyright (C) 2011 The Chromium Authors. All rights reserved. |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public License |
||||
* as published by the Free Software Foundation; either version 2.1 of |
||||
* the License, or (at your option) any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, but |
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <stdint.h> |
||||
|
||||
#include <fdt.h> |
||||
#include <libfdt.h> |
||||
|
||||
#include "tests.h" |
||||
#include "testdata.h" |
||||
|
||||
static void check_compare_properties(void *fdt, |
||||
char const *name_one, |
||||
char const *name_two) |
||||
{ |
||||
const void *propval; |
||||
int proplen; |
||||
|
||||
propval = fdt_getprop(fdt, 0, name_one, &proplen); |
||||
|
||||
if (!propval) |
||||
FAIL("fdt_getprop(\"%s\"): %s", |
||||
name_one, |
||||
fdt_strerror(proplen)); |
||||
|
||||
check_getprop(fdt, 0, name_two, proplen, propval); |
||||
} |
||||
|
||||
int main(int argc, char *argv[]) |
||||
{ |
||||
void *fdt; |
||||
uint8_t expected_8[6] = {TEST_CHAR1, |
||||
TEST_CHAR2, |
||||
TEST_CHAR3, |
||||
TEST_CHAR4, |
||||
TEST_CHAR5, |
||||
TEST_VALUE_1 >> 24}; |
||||
uint16_t expected_16[6]; |
||||
uint32_t expected_32[6]; |
||||
uint64_t expected_64[6]; |
||||
int i; |
||||
|
||||
for (i = 0; i < 5; ++i) { |
||||
expected_16[i] = cpu_to_fdt16(expected_8[i]); |
||||
expected_32[i] = cpu_to_fdt32(expected_8[i]); |
||||
expected_64[i] = cpu_to_fdt64(expected_8[i]); |
||||
} |
||||
|
||||
expected_16[5] = cpu_to_fdt16(TEST_VALUE_1 >> 16); |
||||
expected_32[5] = cpu_to_fdt32(TEST_VALUE_1); |
||||
expected_64[5] = cpu_to_fdt64(TEST_ADDR_1); |
||||
|
||||
test_init(argc, argv); |
||||
fdt = load_blob_arg(argc, argv); |
||||
|
||||
check_getprop(fdt, 0, "cells-8b", sizeof(expected_8), expected_8); |
||||
check_getprop(fdt, 0, "cells-16b", sizeof(expected_16), expected_16); |
||||
check_getprop(fdt, 0, "cells-32b", sizeof(expected_32), expected_32); |
||||
check_getprop(fdt, 0, "cells-64b", sizeof(expected_64), expected_64); |
||||
|
||||
check_compare_properties(fdt, "cells-one-16b", "cells-one-32b"); |
||||
|
||||
PASS(); |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
/dts-v1/; |
||||
|
||||
/ { |
||||
cells-8b = /bits/ 8 <'\r' 'b' '\0' '\'' '\xff' 0xde>; |
||||
cells-16b = /bits/ 16 <'\r' 'b' '\0' '\'' '\xff' 0xdead>; |
||||
cells-32b = /bits/ 32 <'\r' 'b' '\0' '\'' '\xff' 0xdeadbeef>; |
||||
cells-64b = /bits/ 64 <'\r' 'b' '\0' '\'' '\xff' 0xdeadbeef00000000>; |
||||
|
||||
cells-one-16b = /bits/ 16 <0x1234 0x5678 0x0 0xffff>; |
||||
cells-one-32b = <0x12345678 0x0000ffff>; |
||||
}; |
Loading…
Reference in new issue