summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/manual.txt2
-rw-r--r--fdtget.c5
-rw-r--r--fdtput.c2
-rwxr-xr-xtests/run_tests.sh2
-rw-r--r--tests/utilfdt_test.c5
-rw-r--r--util.c4
-rw-r--r--util.h3
7 files changed, 18 insertions, 5 deletions
diff --git a/Documentation/manual.txt b/Documentation/manual.txt
index 97e53b9..cf4b253 100644
--- a/Documentation/manual.txt
+++ b/Documentation/manual.txt
@@ -712,7 +712,7 @@ The syntax of the fdtget command is:
where options are:
- <type> s=string, i=int, u=unsigned, x=hex
+ <type> s=string, i=int, u=unsigned, x=hex, r=raw
Optional modifier prefix:
hh or b=byte, h=2 byte, l=4 byte (default)
diff --git a/fdtget.c b/fdtget.c
index 54fc6a0..dd70985 100644
--- a/fdtget.c
+++ b/fdtget.c
@@ -97,6 +97,11 @@ static int show_data(struct display_info *disp, const char *data, int len)
if (len == 0)
return 0;
+ if (disp->type == 'r') {
+ fwrite(data, 1, len, stdout);
+ return 0;
+ }
+
is_string = (disp->type) == 's' ||
(!disp->type && util_is_printable_string(data, len));
if (is_string) {
diff --git a/fdtput.c b/fdtput.c
index 428745a..c2fecf4 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -433,6 +433,8 @@ int main(int argc, char *argv[])
if (utilfdt_decode_type(optarg, &disp.type,
&disp.size))
usage("Invalid type string");
+ if (disp.type == 'r')
+ usage("Unsupported raw data type");
break;
case 'v':
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index d100d5a..11068e1 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -855,6 +855,8 @@ fdtget_tests () {
run_fdtget_test 8000 -tx $dtb /cpus/PowerPC,970@1 d-cache-size
run_fdtget_test "61 62 63 0" -tbx $dtb /randomnode tricky1
run_fdtget_test "a b c d de ea ad be ef" -tbx $dtb /randomnode blob
+ run_fdtget_test "MyBoardName\0MyBoardFamilyName\0" -tr $dtb / compatible
+ run_fdtget_test "\x0a\x0b\x0c\x0d\xde\xea\xad\xbe\xef" -tr $dtb /randomnode blob
# Here the property size is not a multiple of 4 bytes, so it should fail
run_wrap_error_test $DTGET -tlx $dtb /randomnode mixed
diff --git a/tests/utilfdt_test.c b/tests/utilfdt_test.c
index c621759..ba6462f 100644
--- a/tests/utilfdt_test.c
+++ b/tests/utilfdt_test.c
@@ -73,6 +73,9 @@ static void check_sizes(char *modifier, int expected_size)
*ptr = 's';
check(fmt, 's', -1);
+
+ *ptr = 'r';
+ check(fmt, 'r', -1);
}
static void test_utilfdt_decode_type(void)
@@ -90,7 +93,7 @@ static void test_utilfdt_decode_type(void)
/* try every other character */
checkfail("");
for (ch = ' '; ch < 127; ch++) {
- if (!strchr("iuxs", ch)) {
+ if (!strchr("iuxsr", ch)) {
*fmt = ch;
fmt[1] = '\0';
checkfail(fmt);
diff --git a/util.c b/util.c
index 40274fb..14d3868 100644
--- a/util.c
+++ b/util.c
@@ -353,11 +353,11 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size)
}
/* we should now have a type */
- if ((*fmt == '\0') || !strchr("iuxs", *fmt))
+ if ((*fmt == '\0') || !strchr("iuxsr", *fmt))
return -1;
/* convert qualifier (bhL) to byte size */
- if (*fmt != 's')
+ if (*fmt != 's' && *fmt != 'r')
*size = qualifier == 'b' ? 1 :
qualifier == 'h' ? 2 :
qualifier == 'l' ? 4 : -1;
diff --git a/util.h b/util.h
index c45b2c2..7a4e910 100644
--- a/util.h
+++ b/util.h
@@ -143,6 +143,7 @@ int utilfdt_write_err(const char *filename, const void *blob);
* i signed integer
* u unsigned integer
* x hex
+ * r raw
*
* TODO: Implement ll modifier (8 bytes)
* TODO: Implement o type (octal)
@@ -160,7 +161,7 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size);
*/
#define USAGE_TYPE_MSG \
- "<type>\ts=string, i=int, u=unsigned, x=hex\n" \
+ "<type>\ts=string, i=int, u=unsigned, x=hex, r=raw\n" \
"\tOptional modifier prefix:\n" \
"\t\thh or b=byte, h=2 byte, l=4 byte (default)";