summaryrefslogtreecommitdiff
path: root/data.c
Commit message (Collapse)AuthorAgeFilesLines
* dtc: Add data_append_integer functionAnton Staaf2011-10-111-7/+32
| | | | | | | | | | | | | This function deals with appending integers of various sizes (8, 16 32, and 64 bit currently). It handles endianess conversions. If the integer will not fit in the requested number of bits of storage it will have it's high bits ignored. This patch also rewrites data_append_cell and data_append_addr to use data_append_integer. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Refactor character literal parsing codeAnton Staaf2011-09-091-81/+4
| | | | | | | | | Move the parsing of hex, octal and escaped characters from data.c to util.c where it can be used for character literal parsing within strings as well as for stand alone C style character literals. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-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: Use the same endian-conversion functions as libfdtDavid Gibson2008-07-141-4/+4
| | | | | | | | | | | | | | | | 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: Use stdint.h types throughout dtcDavid Gibson2008-07-141-2/+2
| | | | | | | | | Currently, dtc defines Linux-like names for various fixed-size integer types. There's no good reason to do this; even Linux itself doesn't use these names for externally visible things any more. This patch replaces these with the C99 standardized type names from stdint.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add support for binary includes.David Gibson2008-06-191-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Wed, Jun 04, 2008 at 09:26:23AM -0500, Jon Loeliger wrote: > David Gibson wrote: > >> But as I said that can be dealt with in the future without breaking >> compatibility. Objection withdrawn. >> > > And on that note, I officially implore Scott to > re-submit his binary include patch! Scott's original patch does still have some implementation details I didn't like. So in the interests of saving time, I've addressed some of those, added a testcase, and and now resubmitting my revised version of Scott's patch. dtc: Add support for binary includes. A property's data can be populated with a file's contents as follows: node { prop = /incbin/("path/to/data"); }; A subset of a file can be included by passing start and size parameters. For example, to include bytes 8 through 23: node { prop = /incbin/("path/to/data", 8, 16); }; As with /include/, non-absolute paths are looked for in the directory of the source file that includes them. Implementation revised, and a testcase added by David Gibson Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Scott Wood <scottwood@freescale.com>
* dtc: Cleanup \nnn and \xNN string escape handlingDavid Gibson2008-03-231-13/+6
| | | | | | | | | | | | | | | Several small cleanups to the handling of octal and hex string escapes: - Use strncmp() instead dof what were essentially open-coded versions of the same, with short fixed lengths. - The call path to get_oct_char() means an empty escape is not possible. So replace the error message in this case with an assert. - Use die() instead of a non-fatal error message if get_hex_char() is given an empty escape. Change error message to close match gcc's in the same circumstance. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Abolish asize field of struct dataDavid Gibson2008-03-231-8/+0
| | | | | | | | | | | The asize field in struct data is a hangover from the early days when a struct data was sometimes allowed to refer to a static chunk of memory rather than a malloc()ed block. That's long gone, since the lifetime issues were far more trouble than it was worth, so get rid of the asize field. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Implement path referencesDavid Gibson2007-12-051-0/+15
| | | | | | | | | | | | This patch extends dtc syntax to allow references (&label, or &{/full/path}) directly within property definitions, rather than inside a cell list. Such references are expanded to the full path of the referenced node, as a string, instead of to a phandle as references within cell lists are evaluated. A testcase is also included. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add many const qualificationsDavid Gibson2007-12-041-6/+6
| | | | | | | | 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-74/+29
| | | | | | | | | | | | | | | | | | | | | 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: data.c doesn't need to include dtc-parser.tab.hDavid Gibson2007-10-221-1/+0
| | | | | | | Presumably we used this #include once, but it's certainly not necessary now. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Improve support for string escapesDavid Gibson2007-10-161-0/+12
| | | | | | | | | | | | | | | | | | | | dtc supports the use of C-style escapes (\n, \t and so forth) in string property definitions via the data_copy_escape_string() function. However, while it supports the most common escape characters, it doesn't support the full set that C does, which is a potential gotcha. Worse, a bug in the lexer means that while data_copy_escape_string() can handle the \" escape, a string with such an escape won't lex correctly. This patch fixes both problems, extending data_copy_escape_string() to support the missing escapes, and fixing the regex for strings in the lexer to handle internal escaped quotes. This also adds a testcase for string escape functionality. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Use libfdt/fdt.h instead of flat_dt.hDavid Gibson2007-09-271-2/+2
| | | | | | | | | | | | In the dtc tree, both flat_dt.h and libfdt/fdt.h have structures and constants relating to the flattened device tree format derived from asm-powerpc/prom.h in the kernel. The former is used in dtc, the latter in libfdt. libfdt/fdt.h is the more recent, revised version, so use that throughout, removing flat_dt.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Whitespace cleanupDavid Gibson2007-09-181-8/+8
| | | | | | | | | | | | 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: store labels in ascending orderMilton Miller2007-07-071-3/+9
| | | | | | | | | | | | | | | When adding a label, walk to the end of the list since the label reflects the end of the data. Since merging data buffers already preserved the order, this will cause the labels to be emitted in order when writing assembly output. It should also aid emiting labels when writing dts output should that be added in the future (data formatting would need to break at each label). Signed-off-by: Milton Miller <miltonm@bga.com>
* dtc: implement labels on property dataMilton Miller2007-07-071-10/+40
| | | | | | | | | | | | | | | | | | | | | | | Extend the parser grammer to allow labels before or after any property data (string, cell list, or byte list), and any byte or cell within the property data. Store the labels using the same linked list structure as node references, but using a parallel list. When writing assembly output emit global labels as offsets from the start of the definition of the data. Note that the alignment for a cell list is done as part of the opening < delimiter, not the = or , before it. To label a cell after a string or byte list put the label inside the cell list. For example, prop = zero: [ aa bb ], two: < four: 1234 > eight: ; will produce labels with offsets 0, 2, 4, and 8 bytes from the beginning of the data for property prop. Signed-off-by: Milton Miller <miltonm@bga.com>
* dtc: clean up grow_data_for()Milton Miller2007-07-071-2/+2
| | | | | | | | | | | | Change the grow_data_for function to copy struct data and modifiy the fields it is updating instead of storing all fields individually to a stack allocated struct. This reduces maintence for future enhancements as now all instances of struct data are created by modifying a copy of an existing struct data or directly copying empty_data. Signed-off-by: Milton Miller <miltonm@bga.com>
* Moved data_convert_cell() out of data.c to the parser.Jon Loeliger2007-02-161-20/+0
| | | | | | | It constructs a cell_t, not data objects. Renamed it to cell_from_string() as well. Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Add support for decimal, octal and binary based cell values.Jon Loeliger2007-02-151-0/+21
| | | | | | | New syntax d#, b#, o# and h# allow for an explicit prefix on cell values to specify their base. Eg: <d# 123> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Allow multipart property valuesDavid Gibson2007-02-081-0/+27
| | | | | | | | | | | | | | | | | | | | At present each property definition in a dts file must give as the value either a string ("abc..."), a bytestring ([12abcd...]) or a cell list (<1 2 3 ...>). This patch allows a property value to be given as several of these, comma-separated. The final property value is just the components appended together. So a property could have a list of cells followed by a string, or a bytestring followed by some cells. Cells are always aligned, so if cells are given following a string or bytestring which is not a multiple of 4 bytes long, zero bytes are inserted to align the following cells. The primary motivation for this feature, however, is to allow defining a property as a list of several strings. This is what's needed for defining OF 'compatible' properties, and is less ugly and fiddly than using embedded \0s in the strings. Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Remove dead code.Jon Loeliger2006-06-241-18/+0
| | | | Signed-off-by: Jon Loeliger <jdl@jdl.com>
* Rework tracking of reserve entries during processing. This is initial workDavid Gibson2005-10-241-0/+10
| | | | to allow more powerful handling of reserve entries.
* Oops avoid using case range gcc extension.David Gibson2005-10-171-1/+8
|
* Remove an unused function, mark a bunch of other functions and variablesDavid Gibson2005-08-291-16/+2
| | | | as static. Mostly found by sparse.
* Support for specifying memreserve ranges in the source format, based onDavid Gibson2005-07-151-0/+7
| | | | | a patch by Jon Loeliger <jdl AT freescale.com>, although tweaked substantially.
* Rudimentary phandle reference support.David Gibson2005-06-161-0/+34
|
* Initial commitDavid Gibson2005-06-081-0/+250