Allow them to take a prefix argument giving the general type of error,
which will be useful in future.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
The srcpos_verror() and srcpos_error() functions declare the format
string as 'char const *' instead of 'const char *'. Fix it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
We already use the C99 bool type from stdbool.h in a few places. However
there are many other places we represent boolean values as plain ints.
This patch changes that.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Line control directives of the following formats are supported:
#line LINE "FILE"
# LINE "FILE" [FLAGS]
This allows dtc to consume the output of pre-processors, and to provide
error messages that refer to the original filename, including taking
into account any #include directives that the pre-processor may have
performed.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
It is often inconvenient to place device tree files in the same directory
as their includes, or to specify the full path to include files.
An example of this is in U-Boot where we have a .dtsi file for each SOC
type, and this is included by the board .dts file. We need to either use
a mechanism like:
/include/ ARCH_CPU_DTS
with sed or cpp to perform the replacement with the correct path, or
we must specify the full path in the file:
/include/ "../../arch/arm/dts/tegra20.dtsi"
The first option is not desirable since it requires anyone compiling the
file to first pre-process it. The second is not desirable since it
introduces a path which is project-specific into a file which is supposed
to be a hardware description. For example Linux and U-Boot are unlikely to
put these include files in the same place.
It is much more convenient to specify the search patch on the command line
as is done with C pre-processors, for example.
Introduce a -i option to add to the list of search paths used to find
source and include files.
We cannot use -I as it is already in use. Other suggestions welcome.
Signed-off-by: Simon Glass <sjg@chromium.org>
This will allow callers to rebuild .dtb files when any of the /include/d
.dtsi files are modified, not just the top-level .dts file.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
yyerror is meant to be called by the parser internal code, and it's interface
is limited. Instead create and call a new error message routine that allows
formatted strings to be used.
yyerror uses the new routine so error formatting remains consistent.
Signed-of-by: John Bonesio <bones@secretlab.ca>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
This patch makes some small cleanups to the declaration of YYLTYPE,
YYLLOC_DEFAULT and related things.
- We used to use undocumented magic #defines for bison,
YYLTYPE_IS_DECLARED and YYLTYPE_IS_TRIVIAL. This may not be
portable across bison versions. Instead define YYLTYPE as a
macro in terms of struct srcpos, as the info pages suggest.
- Our kernel-derived coding style discourages typedefed
structures. So use 'struct srcpos' instead of 'srcpos'
throughout'.
- Indent the YYLLOC_DEFAULT macro according to our coding
style (it was in GNU indent style, since it was taken from
the example in the bison info).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Our YYLTYPE current carries around first and last line and first and
last column information. However, of these, on the first line
information is actually filled in properly.
Furthermore, filling in the line number information from yylineno is
kind of clunky: we have to copy its value to the srcfile stack and
back to handle include file positioning correctly.
This patch cleans this up. We turn off flex's yylineno option and
instead track the line and column number ourselves from
YY_USER_ACTION. The line and column number are stored directly inside
the srcfile_state structure, so it's automatically a per-file
quantity. We now also fill in all the yylloc from YY_USER_ACTION.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
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>
Implemented some print and copy routines.
Made empty srcpos objects that will be used later.
Protected .h file from multiple #include's.
Added srcpos_error() and srcpos_warn().
Signed-off-by: Jon Loeliger <jdl@freescale.com>
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>
Error reporting in push_input_file() is a mess. One error results in
a message and exit(1), others result in a message and return 0 - which
is turned into an exit(1) at one callsite. The other callsite doesn't
check errors, but probably should. One of the error conditions gives
a message, but can only be the result of an internal programming
error, not a user error.
So. Clean that up by making push_input_file() a void function, using
die() to report errors and quit.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Looking in the diretory dtc is invoked from is not very useful behavior.
As part of the code reorganization to implement this, I removed the
uniquifying of name storage -- it seemed a rather dubious optimization
given likely usage, and some aspects of it would have been mildly awkward
to integrate with the new code.
Signed-off-by: Scott Wood <scottwood@freescale.com>
- Change include syntax to: /include/ "filename"
- Move private functions directly into dtc-lexer.l
- Define YYID for some older parser templates
Also fix a #include ordering problem around YYLTPE.
Signed-off-by; Jon Loeliger <jdl@freescale.com>
Acked-by: Haiying Wang <Haiying.Wang@freescale.com>
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>