diff --git a/dtc-lexer.l b/dtc-lexer.l index 487953c..d142de5 100644 --- a/dtc-lexer.l +++ b/dtc-lexer.l @@ -52,15 +52,10 @@ LINECOMMENT "//".*\n #define DPRINT(fmt, ...) do { } while (0) #endif -static int dts_version; /* = 0 */ +static int dts_version = 1; -#define BEGIN_DEFAULT() if (dts_version == 0) { \ - DPRINT("\n"); \ - BEGIN(INITIAL); \ - } else { \ - DPRINT("\n"); \ +#define BEGIN_DEFAULT() DPRINT("\n"); \ BEGIN(V1); \ - } static void push_input_file(const char *filename); static int pop_input_file(void); @@ -106,25 +101,6 @@ static int pop_input_file(void); return DT_LABEL; } -[bodh]# { - if (*yytext == 'b') - yylval.cbase = 2; - else if (*yytext == 'o') - yylval.cbase = 8; - else if (*yytext == 'd') - yylval.cbase = 10; - else - yylval.cbase = 16; - DPRINT("Base: %d\n", yylval.cbase); - return DT_BASE; - } - -[0-9a-fA-F]+ { - yylval.literal = xstrdup(yytext); - DPRINT("Literal: '%s'\n", yylval.literal); - return DT_LEGACYLITERAL; - } - [0-9]+|0[xX][0-9a-fA-F]+ { yylval.literal = xstrdup(yytext); DPRINT("Literal: '%s'\n", yylval.literal); @@ -144,12 +120,6 @@ static int pop_input_file(void); return DT_REF; } -"&/"{PATHCHAR}+ { /* old-style path reference */ - DPRINT("Ref: %s\n", yytext+1); - yylval.labelref = xstrdup(yytext+1); - return DT_REF; - } - [0-9a-fA-F]{2} { yylval.byte = strtol(yytext, NULL, 16); DPRINT("Byte: %02x\n", (int)yylval.byte); diff --git a/dtc-parser.y b/dtc-parser.y index ae6f3c4..4b69c7a 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -56,7 +56,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits); %token DT_MEMRESERVE %token DT_PROPNODENAME %token DT_LITERAL -%token DT_LEGACYLITERAL %token DT_BASE %token DT_BYTE %token DT_STRING @@ -68,11 +67,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits); %type propdataprefix %type memreserve %type memreserves -%type v0_memreserve -%type v0_memreserves %type addr %type celllist -%type cellbase %type cellval %type bytestring %type propdef @@ -91,10 +87,6 @@ sourcefile: { the_boot_info = build_boot_info($3, $4, 0); } - | v0_memreserves devicetree - { - the_boot_info = build_boot_info($1, $2, 0); - } ; memreserves: @@ -115,37 +107,11 @@ memreserve: } ; -v0_memreserves: - /* empty */ - { - $$ = NULL; - } - | v0_memreserve v0_memreserves - { - $$ = chain_reserve_entry($1, $2); - }; - ; - -v0_memreserve: - memreserve - { - $$ = $1; - } - | label DT_MEMRESERVE addr '-' addr ';' - { - $$ = build_reserve_entry($3, $5 - $3 + 1, $1); - } - ; - addr: DT_LITERAL { $$ = eval_literal($1, 0, 64); } - | DT_LEGACYLITERAL - { - $$ = eval_literal($1, 16, 64); - } ; devicetree: @@ -272,23 +238,11 @@ celllist: } ; -cellbase: - /* empty */ - { - $$ = 16; - } - | DT_BASE - ; - cellval: DT_LITERAL { $$ = eval_literal($1, 0, 32); } - | cellbase DT_LEGACYLITERAL - { - $$ = eval_literal($2, $1, 32); - } ; bytestring: diff --git a/tests/base01.dts b/tests/base01.dts index f84bc49..97a5dd5 100644 --- a/tests/base01.dts +++ b/tests/base01.dts @@ -1,3 +1,5 @@ +/dts-v1/; + / { model = "SomeModel"; compatible = "Nothing"; @@ -6,26 +8,26 @@ memory@0 { device_type = "memory"; - reg = <00000000 00000000 00000000 20000000>; + reg = <0x00000000 0x00000000 0x00000000 0x20000000>; }; cpus { #address-cells = <1>; #size-cells = <0>; - d10 = ; // hex: 0xa - d23 = ; // hex: 0x17 - b101 = ; // hex: 0x5 - o17 = ; // hex: 0xf - hd00d = ; // hex: 0xd00d + d10 = < 10>; // hex: 0xa + d23 = < 23>; // hex: 0x17 + b101 = < 0x5>; // hex: 0x5 + o17 = < 017>; // hex: 0xf + hd00d = < 0xd00d>; // hex: 0xd00d // hex: 0x4d2 0x163e 0x2334 0xd80 - stuff = ; + stuff = < 1234 5678 9012 3456>; - bad-d-1 = ; // Hrm. 0 - bad-d-2 = ; - bad-o-1 = ; - bad-o-2 = ; + bad-d-1 = < 0>; // Hrm. 0 + bad-d-2 = < 123456789012345>; + bad-o-1 = < 00>; + bad-o-2 = < 0123456123456>; }; }; diff --git a/tests/empty.dts b/tests/empty.dts index 336d7a2..e160dad 100644 --- a/tests/empty.dts +++ b/tests/empty.dts @@ -1,2 +1,4 @@ +/dts-v1/; + / { }; diff --git a/tests/escapes.dts b/tests/escapes.dts index f1b8dbc..e05ab46 100644 --- a/tests/escapes.dts +++ b/tests/escapes.dts @@ -1,3 +1,5 @@ +/dts-v1/; + / { compatible = "test_string_escapes"; escape-str = "nastystring: \a\b\t\n\v\f\r\\\""; diff --git a/tests/label01.dts b/tests/label01.dts index 372b17a..a895803 100644 --- a/tests/label01.dts +++ b/tests/label01.dts @@ -1,6 +1,8 @@ -/memreserve/ 1000000000000000 0000000002000000; -memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff; -/memreserve/ 0-13; +/dts-v1/; + +/memreserve/ 0x1000000000000000 0x0000000002000000; +memrsv2: /memreserve/ 0x2000000000000000 0x0100000000000000; +/memreserve/ 0x0000000000000000 0x0000000000000014; / { model = "MyBoardName"; @@ -9,28 +11,28 @@ memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff; #size-cells = <2>; cpus { - linux,phandle = <1>; + linux,phandle = <0x1>; #address-cells = <1>; #size-cells = <0>; PowerPC,970@0 { name = "PowerPC,970"; device_type = "cpu"; - reg = <0>; - clock-frequency = <5f5e1000>; - timebase-frequency = <1FCA055>; + reg = <0x00000000>; + clock-frequency = <1600000000>; + timebase-frequency = <33333333>; linux,boot-cpu; - i-cache-size = <10000>; - d-cache-size = <8000>; + i-cache-size = <65536>; + d-cache-size = <32768>; }; PowerPC,970@1 { name = "PowerPC,970"; device_type = "cpu"; - reg = <1>; - clock-frequency = <5f5e1000>; - timebase-frequency = <1FCA055>; - i-cache-size = <10000>; - d-cache-size = <8000>; + reg = <0x00000001>; + clock-frequency = <1600000000>; + timebase-frequency = <33333333>; + i-cache-size = <65536>; + d-cache-size = <32768>; }; }; @@ -38,8 +40,8 @@ memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff; node: randomnode { prop: string = str: "foo", str_mid: "stuffstuff\t\t\t\n\n\n" str_end: ; blob = [byte: 0a 0b 0c 0d byte_mid: de ea ad be ef byte_end: ]; - ref = < cell: &/memory@0 0 cell_mid: ffffffff cell_end: >; - mixed = "abc", pre: [1234] post: , gap: < aligned: a b c>; + ref = < cell: &{/memory@0} 0x0 cell_mid: 0xffffffff cell_end: >; + mixed = "abc", pre: [1234] post: , gap: < aligned: 0xa 0xb 0xc>; tricky1 = [61 lt1: 62 63 00]; subnode: child { }; @@ -49,12 +51,12 @@ memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff; memory@0 { device_type = "memory"; - memreg: reg = <00000000 00000000 00000000 20000000>; + memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>; }; chosen { bootargs = "root=/dev/sda2"; - linux,platform = <00000600>; + linux,platform = <0x600>; }; }; diff --git a/tests/references_dts0.dts b/tests/references_dts0.dts index df82c23..36b6f51 100644 --- a/tests/references_dts0.dts +++ b/tests/references_dts0.dts @@ -1,19 +1,21 @@ +/dts-v1/; + / { /* Explicit phandles */ n1: node1 { - linux,phandle = <2000>; - ref = <&/node2>; /* reference precedes target */ + linux,phandle = <0x2000>; + ref = <&{/node2}>; /* reference precedes target */ lref = <&n2>; }; n2: node2 { - linux,phandle = <1>; - ref = <&/node1>; /* reference after target */ + linux,phandle = <0x1>; + ref = <&{/node1}>; /* reference after target */ lref = <&n1>; }; /* Implicit phandles */ n3: node3 { - ref = <&/node4>; + ref = <&{/node4}>; lref = <&n4>; }; n4: node4 { diff --git a/tests/run_tests.sh b/tests/run_tests.sh index b424664..c6ac48e 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -71,13 +71,6 @@ run_dtc_test () { base_run_test wrap_test $VALGRIND $DTC "$@" } -CONVERT=../convert-dtsv0 - -run_convert_test () { - echo -n "convert-dtsv0 $@: " - base_run_test wrap_test $VALGRIND $CONVERT "$@" -} - tree1_tests () { TREE=$1 @@ -288,21 +281,6 @@ dtc_tests () { run_sh_test dtc-fatal.sh -I fs -O dtb nosuchfile } -convert_tests () { - V0_DTS="test_tree1_dts0.dts references_dts0.dts empty.dts escapes.dts \ - test01.dts label01.dts" - for dts in $V0_DTS; do - run_dtc_test -I dts -O dtb -o cvtraw_$dts.test.dtb $dts - run_dtc_test -I dts -O dts -o cvtdtc_$dts.test.dts $dts - run_dtc_test -I dts -O dtb -o cvtdtc_$dts.test.dtb cvtdtc_$dts.test.dts - run_convert_test $dts - run_dtc_test -I dts -O dtb -o cvtcvt_$dts.test.dtb ${dts}v1 - - run_wrap_test cmp cvtraw_$dts.test.dtb cvtdtc_$dts.test.dtb - run_wrap_test cmp cvtraw_$dts.test.dtb cvtcvt_$dts.test.dtb - done -} - while getopts "vt:m" ARG ; do case $ARG in "v") @@ -318,7 +296,7 @@ while getopts "vt:m" ARG ; do done if [ -z "$TESTSETS" ]; then - TESTSETS="libfdt dtc convert" + TESTSETS="libfdt dtc" fi # Make sure we don't have stale blobs lying around @@ -332,9 +310,6 @@ for set in $TESTSETS; do "dtc") dtc_tests ;; - "convert") - convert_tests - ;; esac done diff --git a/tests/test01.dts b/tests/test01.dts index ed2b178..f9fd165 100644 --- a/tests/test01.dts +++ b/tests/test01.dts @@ -1,6 +1,8 @@ -/memreserve/ 1000000000000000 0000000002000000; -/memreserve/ 2000000000000000-20ffffffffffffff; -/memreserve/ 0-13; +/dts-v1/; + +/memreserve/ 0x1000000000000000 0x0000000002000000; +/memreserve/ 0x2000000000000000 0x0100000000000000; +/memreserve/ 0x0000000000000000 0x0000000000000014; / { model = "MyBoardName"; @@ -9,28 +11,28 @@ #size-cells = <2>; cpus { - linux,phandle = <1>; + linux,phandle = <0x1>; #address-cells = <1>; #size-cells = <0>; PowerPC,970@0 { name = "PowerPC,970"; device_type = "cpu"; - reg = <0>; - clock-frequency = <5f5e1000>; - timebase-frequency = <1FCA055>; + reg = <0x00000000>; + clock-frequency = <1600000000>; + timebase-frequency = <33333333>; linux,boot-cpu; - i-cache-size = <10000>; - d-cache-size = <8000>; + i-cache-size = <65536>; + d-cache-size = <32768>; }; PowerPC,970@1 { name = "PowerPC,970"; device_type = "cpu"; - reg = <1>; - clock-frequency = <5f5e1000>; - timebase-frequency = <1FCA055>; - i-cache-size = <10000>; - d-cache-size = <8000>; + reg = <0x00000001>; + clock-frequency = <1600000000>; + timebase-frequency = <33333333>; + i-cache-size = <65536>; + d-cache-size = <32768>; }; }; @@ -38,18 +40,18 @@ randomnode { string = "\xff\0stuffstuff\t\t\t\n\n\n"; blob = [0a 0b 0c 0d de ea ad be ef]; - ref = < &/memory@0 >; - mixed = "abc", [1234], ; + ref = < &{/memory@0} >; + mixed = "abc", [1234], <0xa 0xb 0xc>; }; memory@0 { device_type = "memory"; - memreg: reg = <00000000 00000000 00000000 20000000>; + memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>; }; chosen { bootargs = "root=/dev/sda2"; - linux,platform = <00000600>; + linux,platform = <0x600>; }; }; diff --git a/tests/test_tree1_dts0.dts b/tests/test_tree1_dts0.dts index bc65819..6b40cf5 100644 --- a/tests/test_tree1_dts0.dts +++ b/tests/test_tree1_dts0.dts @@ -1,9 +1,11 @@ -/memreserve/ deadbeef00000000-deadbeef000fffff; -/memreserve/ 75bcd15 1000; +/dts-v1/; + +/memreserve/ 0xdeadbeef00000000 0x0000000000100000; +/memreserve/ 0x00000000075bcd15 0x0000000000001000; / { compatible = "test_tree1"; - prop-int = ; + prop-int = <0xdeadbeef>; prop-str = "hello world"; subnode@1 { @@ -12,18 +14,18 @@ subsubnode { compatible = "subsubnode1", "subsubnode"; - prop-int = ; + prop-int = < 0xdeadbeef>; }; }; subnode@2 { - linux,phandle = <2000>; - prop-int = ; + linux,phandle = <0x2000>; + prop-int = < 123456789>; subsubnode@0 { - linux,phandle = <2001>; + linux,phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; - prop-int = ; + prop-int = < 0726746425>; }; }; };