summaryrefslogtreecommitdiff
path: root/treesource.c
Commit message (Collapse)AuthorAgeFilesLines
* dtc: Fix zero-length input segfaultHorst Kronstorfer2012-02-161-0/+2
| | | | | | | | | | This patch fixes a segmentation fault caused by dereferencing a NULL pointer (pos->file aka yylloc.file) in srcpos_string when the input length is 0 (fe 'dtc </dev/null'.) Reason: yylloc.file is initialized with 0 and the tokenizer, which updates yylloc.file via srcpos_update doesn't get a chance to run on zero-length input. Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
* dtc: Allow multiple labels on nodes and propertiesDavid Gibson2010-02-241-6/+9
| | | | | | | | | | | | | | | | | At present, both the grammar and our internal data structures mean that there can be only one label on a node or property. This is a fairly arbitrary constraint, given that any number of value labels can appear at the same point, and that in C you can have any number of labels on the same statement. This is pretty much a non-issue now, but it may become important with some of the extensions that Grant and I have in mind. It's not that hard to change, so this patch does so, allowing an arbitrary number of labels on any given node or property. As usual a testcase is added too. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Grant Likely <grant.likely@secretlab.ca>
* dtc: Simpler interface to source file managementDavid Gibson2010-01-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix bug in -Odts with properties containing multiple terminating nullsDavid Gibson2009-11-111-14/+15
| | | | | | | | | | When in -Odts mode, dtc will not produce correct output for string-like properties which have more than one \0 character at the end of the property's bytestring. In fact, it generates output which is not syntactically correct. This patch fixes the bug, and adds a testcase for future regressions here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Make many functions 'static'David Gibson2008-08-131-1/+1
| | | | | | | | | | | | | This patch marks various functions not shared between c files 'static', as they should be. There are a couple of functions in dtc, and many in the testsuite. This is *almost* enough to enable the -Wmissing-prototypes warning. It's not quite enough, because there's a mess of junk in the flex generated code which triggers that warning which I'm not yet sure how to deal with. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Enable and fix -Wcast-qual warningsDavid Gibson2008-07-141-1/+1
| | | | | | | | | | | | Enabling -Wcast-qual warnings in dtc shows up a number of places where we are incorrectly discarding a const qualification. There are also some places where we are intentionally discarding the 'const', and we need an ugly cast through uintptr_t to suppress the warning. However, most of these are pretty well isolated with the *_w() functions. So in the interests of maximum safety with const qualifications, this patch enables the warnings and fixes the existing complaints. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Use the same endian-conversion functions as libfdtDavid Gibson2008-07-141-1/+1
| | | | | | | | | | | | | | | | Currently both libfdt and dtc define a set of endian conversion macros for accessing the device tree blob which is always big-endian. libfdt uses names like cpu_to_fdt32() and dtc uses names like cpu_to_be32 (as the Linux kernel). This patch switches dtc over to using the libfdt macros (including libfdt_env.h to supply them). This has a couple of small advantages: - Removes some code duplication - Will make conversion a bit easier if we ever need to produce little-endian device tree blobs. - dtc no longer needs to pull in netinet/in.h simply for the ntohs() and ntohl() functions Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Simplify error handling for unparseable inputDavid Gibson2008-05-191-2/+4
| | | | | | | | | | | | | | | | | | Currently, main() tests if it got a valid input tree from whichever dt_from_*() function it invoked and if not, die()s. For one thing, this test has, for no good reason, three different ways for those functions to communicate a failure to provide input (bi NULL, bi->dt NULL, or bi->error non-zero). For another, in every case save one, if the dt_from_*() functions are unable to provide input they will immediately die() (with a more specific error message) rather than proceeding to the test in main(). Therefore, this patch removes this test, making the one case that could have triggered it (in dt_from_source()) call die() directly instead. With this change, the error field in struct boot_info is now unused, so remove it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Remove ugly include stack abuseDavid Gibson2008-03-231-1/+2
| | | | | | | | | | | | | | | | | | Currently, dt_from_source() uses push_input_file() to set up the initial input file for the lexer. That sounds sensible - put the outermost input file at the bottom of the stack - until you realise that what it *actually* does is pushes the current, uninitialized, lexer input state onto the stack, then sets up the new lexer input. That necessitates an extra check in pop_input_file(), rather than signalling termination in the natural way when the include stack is empty, it has to check when it pops the bogus uninitialized state off the stack. Ick. With that fixed, push_input_file(), pop_input_file() and incl_file_stack itself become local to the lexer, so make them static. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Make -I dtb mode use fill_fullpaths()David Gibson2008-03-231-2/+0
| | | | | | | | | | | | At present -I dts and -I fs modes both use the fill_fullpaths() helper function to fill in the fullpath and basenamelen fields of struct node, which are useful in later parts of the code. -I dtb mode, however, fills these in itself. This patch simplifies flattree.c by making -I dtb mode use fill_fullpaths() like the others. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Return a non-zero exit code if an error occurs during dts parsing.Scott Wood2008-01-041-0/+3
| | | | | | | | Previously, only failure to parse caused the reading of the tree to fail; semantic errors that called yyerror() but not YYERROR only emitted a message, without signalling make to stop the build. Signed-off-by: Scott Wood <scottwood@freescale.com>
* Add yyerrorf() for formatted error messages.Scott Wood2008-01-041-1/+0
| | | | Signed-off-by: Scott Wood <scottwood@freescale.com>
* dtc: Add many const qualificationsDavid Gibson2007-12-041-3/+3
| | | | | | | | This adds 'const' qualifiers to many variables and functions. In particular it's now used for passing names to the tree accesor functions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Merge refs and labels into single "markers" list (v2)David Gibson2007-11-261-30/+32
| | | | | | | | | | | | | | | | | | | | | Currently, every 'data' object, used to represent property values, has two lists of fixup structures - one for labels and one for references. Sometimes we want to look at them separately, but other times we need to consider both types of fixup. I'm planning to implement string references, where a full path rather than a phandle is substituted into a property value. Adding yet another list of fixups for that would start to get silly. So, this patch merges the "refs" and "labels" lists into a single list of "markers", each of which has a type field indicating if it represents a label or a phandle reference. String references or any other new type of in-data marker will then just need a new type value - merging data blocks and other common manipulations will just work. While I was at it I made some cleanups to the handling of fixups which simplify things further. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: -Odts produces v1 outputDavid Gibson2007-11-121-3/+5
| | | | | | | | | This patch alters the -Odts mode output so that it uses dts-v1 format. This means that dtc -Idts -Odts used on a v0 dts file will convert that file to v1. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* dtc: Make -Idts -Odts preserve property-internal labelsDavid Gibson2007-11-081-5/+61
| | | | | | | | | | This patch changes -Odts mode output so that labels within property values in the input are preserved in the output. Applied on top of the earlier patch to preserve node and property labels in -Odts mode, this means that dtc in -Idts -Odts mode will transfer all labels in the input to the output. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Refactor printing of property values in -Odts modeDavid Gibson2007-11-081-59/+38
| | | | | | | | | | | | | | | | | Currently the main recursive tree printing function, write_tree_source_node(), calls guess_type() to apply heuristics to see how to print a property value, then calls the appropriate write_propval_*() function to print it. However, future heuristics for handling internal labels and the like don't work well this way. Therefore, this patch refactors things to have write_tree_source_node() call a new write_propval() function, which incorporates the heurstic logic from guess_type() and also calls the right function to do the actual printing. No behavioural change. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Make -Idts -Odts preserve node/property labelsDavid Gibson2007-11-051-2/+8
| | | | | | | | | | | This patch changes -Odts mode output so that labels on properties, nodes and memreserve entries in input source are preserved in the output. Preserving labels within property values is trickier - another patch coming later. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Improve -Odts outputDavid Gibson2007-10-171-27/+97
| | | | | | | | | | | | | | This patch makes improvements to the way properties are printed when in dtc is producing dts output. - Characters which need escaping are now properly handled when printing properties as strings - The heuristics for what format to use for a property are improved so that 'compatible' properties will be displayed as expected. - escapes.dts is altered to better demonstrate the changes, and the string_escapes testcase is adjusted accordingly. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Whitespace cleanupDavid Gibson2007-09-181-7/+6
| | | | | | | | | | | | This large patch removes all trailing whitespace from dtc (including libfdt, the testsuite and documentation). It also removes a handful of redundant blank lines (at the end of functions, or when there are two blank lines together for no particular reason). As well as anything else, this means that quilt won't whinge when I go to convert the whole of libfdt into a patch to apply to the kernel. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* DTC: Add support for a C-like #include "file" mechanism.Jon Loeliger2007-03-261-2/+4
| | | | | | | | | | | | Keeps track of open files in a stack, and assigns a filenum to source positions for each lexical token. Modified error reporting to show source file as well. No policy on file directory basis has been decided. Still handles stdin. Tested on all arch/powerpc/boot/dts DTS files Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Use names for output functions in the form dt_to_*() instead ofDavid Gibson2005-10-261-1/+1
| | | | write_dt_*() for consistency with the dt_from_*() input functions.
* Rework tracking of reserve entries during processing. This is initial workDavid Gibson2005-10-241-23/+4
| | | | to allow more powerful handling of reserve entries.
* Fix endian problems with handling of memreserve entries (bug pointed outDavid Gibson2005-08-291-2/+3
| | | | | by Pantelis Antoniou). The rule is that the memreserve data in struct boot_info is always stored big-endian.
* Remove an unused function, mark a bunch of other functions and variablesDavid Gibson2005-08-291-1/+1
| | | | as static. Mostly found by sparse.
* Support for specifying memreserve ranges in the source format, based onDavid Gibson2005-07-151-7/+44
| | | | | a patch by Jon Loeliger <jdl AT freescale.com>, although tweaked substantially.
* Initial commitDavid Gibson2005-06-081-0/+140