summaryrefslogtreecommitdiff
path: root/convert-dtsv0-lexer.l
Commit message (Collapse)AuthorAgeFilesLines
* util: add common ARRAY_SIZE defineMike Frysinger2013-05-241-2/+0
| | | | | | | | I want to use this in more places, so put it in util.h rather than copying & pasting it into another file. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* util: drop "long" from usage helpersMike Frysinger2013-05-241-1/+1
| | | | | | | | Now that all utils have converted to the new usage framework, we can rename to just plain "usage()" and avoid naming conflicts. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc/fdt{get, put}/convert-dtsv0-lexer: convert to new usage helpersMike Frysinger2013-05-241-6/+16
| | | | | | | | | | This helps standardize the flag processing and the usage screens. Only lightly tested; would be great if someone who uses these utils could double check. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add -Wredundant-decls (resend)David Gibson2010-04-301-1/+1
| | | | | | | | | | We are almost clean already with the -Wredundant-decls warning. The only exception is a declaration for isatty() inside the flex-generated code. This can be removed by using flex's "never-interactive" option, which we probably should be using anyway, since we never parse interactively in the sense that this option implies. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Simpler interface to source file managementDavid Gibson2010-01-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | This patch cleans up our handling of input files, particularly dts source files, but also (to an extent) other input files such as those used by /incbin/ and those used in -I dtb and -I fs modes. We eliminate the current clunky mechanism which combines search paths (which we don't actually use at present) with the open relative to current source file behaviour, which we do. Instead there's a single srcfile_relative_open() entry point for callers which opens a new input file relative to the current source file (which the srcpos code tracks internally). It doesn't currently do search paths, but we can add that later without messing with the callers, by drawing the search path from a global (which makes sense anyway, rather than shuffling it around the rest of the processing code). That suffices for non-dts input files. For the actual dts files, srcfile_push() and srcfile_pop() wrappers open the file while also keeping track of it as the current source file for future opens. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Move some functions to util.[ch]David Gibson2009-01-071-20/+0
| | | | | | | | | | | Now that we have a util.[ch] file shared between dtc and convert-dtsv0, move some functions which are currently duplicated in the two to util files. Specifically we move the die(), xmalloc() and xrealloc() functions. While we're at it, add standard double-include protection to util.h Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Use noinput flex option for convert-dtsv0 to remove warningDavid Gibson2008-11-171-1/+1
| | | | | | | | | The convert-dtsv0 lexer doesn't use lex's input() macro/function. This can result in "defined but not used" warnings. This patch uses flex's noinput option to prevent this warning (as we already do for dtc-lexer.l). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Implement and use an xstrdup() functionJon Loeliger2008-10-031-1/+2
| | | | | | | | | | | | | | | | Many places in dtc use strdup(), but none of them actually check the return value to see if the implied allocation succeeded. This is a potential bug, which we fix in the patch below by replacing strdup() with an xstrdup() which in analogy to xmalloc() will quit with a fatal error if the allocation fails. I felt the introduciton of util.[ch] was a better choice for utility oriented code than directly using srcpos.c for the new string function. This patch is a re-factoring of Dave Gibson's similar patch. Signed-off-by: Jon Loeliger <jdl@freescale.com>
* dtc: Clean up lexing of include filesDavid Gibson2008-07-141-16/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we scan the /include/ directive as two tokens, the "/include/" keyword itself, then the string giving the file name to include. We use a special scanner state to keep the two linked together, and use the scanner state stack to keep track of the original state while we're parsing the two /include/ tokens. This does mean that we need to enable the 'stack' option in flex, which results in a not-easily-suppressed warning from the flex boilerplate code. This is mildly irritating. However, this two-token scanning of the /include/ directive also has some extremely strange edge cases, because there are a variety of tokens recognized in all scanner states, including INCLUDE. For example the following strange dts file: /include/ /dts-v1/; / { /* ... */ }; Will be processed successfully with the /include/ being effectively ignored: the '/dts-v1/' and ';' are recognized even in INCLUDE state, then the ';' transitions us to PROPNODENAME state, throwing away INCLUDE, and the previous state is never popped off the stack. Or for another example this construct: foo /include/ = "somefile.dts" will be parsed as though it were: foo = /include/ "somefile.dts" Again, the '=' is scanned without leaving INCLUDE state, then the next string triggers the include logic. And finally, we use a different regexp for the string with the included filename than the normal string regexpt, which is also potentially weird. This patch, therefore, cleans up the lexical handling of the /include/ directive. Instead of the INCLUDE state, we instead scan the whole include directive, both keyword and filename as a single token. This does mean a bit more complexity in extracting the filename out of yytext, but I think it's worth it to avoid the strageness described above. It also means it's no longer possible to put a comment between the /include/ and the filename, but I'm really not very worried about breaking files using such a strange construct.
* dtc: Address an assortment of portability problemsDavid Gibson2008-07-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've recently worked with a FreeBSD developer, getting dtc and libfdt working on FreeBSD. This showed up a number of portability problems in the dtc package which this patch addresses. Changes are as follows: - the parent_offset and supernode_atdepth_offset testcases used the glibc extension functions strchrnul() and strndupa(). Those are removed, using slightly longer coding with standard C functions instead. - some other testcases had a #define _GNU_SOURCE for no particular reason. This is removed. - run_tests.sh has bash specific constructs removed, and the interpreter changed to /bin/sh. This apparently now runs fine on FreeBSD's /bin/sh, and I've also tested it with both ash and dash. - convert-dtsv0-lexer.l has some extra #includes added. These must have been included indirectly with Linux and glibc, but aren't on FreeBSD. - the endian handling functions in libfdt_env.h, based on endian.h and byteswap.h are replaced with some portable open-coded versions. Unfortunately, these result in fairly crappy code when compiled, but as far as I can determine there doesn't seem to be any POSIX, SUS or de facto standard way of determining endianness at compile time, nor standard names for byteswapping functions. - some more endian handling, from testdata.h using the problematic endian.h is simply removed, since it wasn't actually being used anyway. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add program to convert dts files from v0 to v1David Gibson2008-05-191-0/+260
This patch adds a new utility program, convert-dtsv0, to the dtc sources. This program will convert dts files from v0 to v1, preserving comments and spacing. It also includes some heuristics to guess an appropriate base to use in the v1 output (so it will use hex for the contents of reg properties and decimal for clock-frequency properties, for example). They're limited and imperfect, but not terrible. The guts of the converter program is a modified version of the lexer from dtc itself. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>