coreboot-kgpe-d16/util/cbfstool
Daisuke Nojiri 0c2f0c1d31 cbfstool: Print compression algorithm
This patch adds a column to the print command to show the compression
algorithm used for the file.

Name                           Offset     Type           Size   Comp
fallback/romstage              0x0        stage           56236 none
ecrw                           0xf2380    raw             62162 LZMA (131072 decompressed)

BUG=b:66956286
BRANCH=none
TEST=Run 'cbfstool image.bin print'

Change-Id: I4bbb60ab467adac4ae5486ddafec86ad9682a40e
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://review.coreboot.org/22196
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2017-10-28 09:39:59 +00:00
..
console Remove extra newlines from the end of all coreboot files. 2016-07-31 18:19:33 +02:00
flashmap Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
lz4 Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
lzma cbfstool: have decompress functions provide ouput data size 2015-10-25 13:23:15 +01:00
EXAMPLE
Makefile util/cbfstool: Add cbfs-compression-tool 2017-01-12 21:40:25 +01:00
Makefile.inc util/cbfstool: Fix build with armv7-eabi cross compiler 2017-08-02 09:55:11 +00:00
ProcessorBind.h Remove extra newlines from the end of all coreboot files. 2016-07-31 18:19:33 +02:00
README.fmaptool fmaptool: Introduce the fmd ("flashmap descriptor") language and compiler 2015-05-08 19:55:42 +02:00
cbfs-mkpayload.c util/cbfstool: demote FV handling errors to debug 2017-07-07 09:01:29 +00:00
cbfs-mkstage.c util: change coreboot to lowercase 2017-06-27 18:26:01 +00:00
cbfs-payload-linux.c util/cbfstool: Fix to build with latest llvm 2017-01-04 21:37:39 +01:00
cbfs.h Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
cbfs_image.c cbfstool: Print compression algorithm 2017-10-28 09:39:59 +00:00
cbfs_image.h util/cbfstool: Add "truncate" command 2017-10-10 15:16:17 +00:00
cbfs_sections.c tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
cbfs_sections.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
cbfscomptool.c cbfscomptool: fix display of time_t 2017-05-27 01:45:17 +02:00
cbfstool.c util/cbfstool: Add "truncate" command 2017-10-10 15:16:17 +00:00
coff.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
common.c util/cbfstool: Handle error condition more carefully 2016-12-15 22:58:38 +01:00
common.h util/cbfstool: Add cbfs-compression-tool 2017-01-12 21:40:25 +01:00
compiler.h util/cbmem, util/cbfstool: resolve macro errors on FreeBSD 2017-08-11 18:54:23 +00:00
compress.c cbfs: Add LZ4 in-place decompression support for pre-RAM stages 2016-02-22 21:38:37 +01:00
default-x86.fmd console/flashsconsole: Add spi flash console for debugging 2017-06-04 18:44:56 +02:00
default.fmd console/flashsconsole: Add spi flash console for debugging 2017-06-04 18:44:56 +02:00
elf.h cbfstool: add ppc64 support 2015-12-12 01:36:51 +01:00
elfheaders.c rmodtool: Increase limit on number of symbols 2017-09-13 19:25:14 +00:00
elfparsing.h cbfstool/elfheaders: Make elf_writer_destroy NULL-safe 2016-08-08 13:01:34 +02:00
fit.c Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
fit.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
flashmap_tests.c tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
fmap_from_fmd.c tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
fmap_from_fmd.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
fmaptool.c fmaptool: Make base offsets absolute in fmap_config.h 2016-06-21 17:14:27 +02:00
fmd.c util/cbfstool: avoid memleaks and off-by-ones 2017-03-20 20:05:09 +01:00
fmd.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
fmd_parser.c_shipped cbfstool: Rename autogenerated targets 2015-05-19 17:03:54 +02:00
fmd_parser.h_shipped cbfstool: Rename autogenerated targets 2015-05-19 17:03:54 +02:00
fmd_parser.y tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
fmd_scanner.c_shipped fmaptool: Accept hex values with uppercase letters 2016-07-04 12:17:51 +02:00
fmd_scanner.h_shipped fmaptool: Accept hex values with uppercase letters 2016-07-04 12:17:51 +02:00
fmd_scanner.l fmaptool: Accept hex values with uppercase letters 2016-07-04 12:17:51 +02:00
fv.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
ifwitool.c Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
linux.h Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
linux_trampoline.S cbfstool: autocreate trampoline 2015-12-02 18:43:01 +01:00
linux_trampoline.c cbfstool: remove trampoline_start and trampoline_size 2015-12-02 18:43:23 +01:00
linux_trampoline.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
option.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
partitioned_file.c cbfstool: accept read-only files when possible 2016-01-19 18:14:44 +01:00
partitioned_file.h cbfstool: accept read-only files when possible 2016-01-19 18:14:44 +01:00
rmodtool.c tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
rmodule.c util/cbfstool: Include commonlib/helpers.h in common.h 2016-05-28 08:48:45 +02:00
rmodule.h tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00
swab.h cbfstool: Add header file for ntohl & htonl on Apple 2016-01-20 16:10:20 +01:00
xdr.c tree: drop last paragraph of GPL copyright header 2015-10-31 21:37:39 +01:00

README.fmaptool

Flashmap descriptors in coreboot
================================
Flashmap (https://code.google.com/p/flashmap) is a binary format for representing the layout of
flash chips. Since coreboot is starting to use a "partition" of this format to describe the flash
chip layout---both at runtime and when flashing a new image onto a chip---, the project needed a
reasonably expressive plaintext format for representing such sections in the source tree. Our
solution is the fmd ("flashmap descriptor") language, and the files in this directory contain a
scanner, parser, semantic analyser, and flashmap converter. Here's an informal language description:

# <line comment>
<image name>[@<memory-mapped address>] <image size> {
	<section name>[@<offset from start of image>] [<section size>] [{
		<subsection name>[@<offset from start of parent section>] [<subsection size>] [{
			# Sections can be nested as deeply as desired
			<subsubsection name>[(CBFS)][@...] [...] [{...}]
		}]
		[<subsection name>[(CBFS)][@...] [...] [{...}]]
		# There can be many subsections at each level of nesting: they will be inserted
		# sequentially, and although gaps are allowed, any provided offsets are always
		# relative to the closest parent node's and must be strictly increasing with neither
		# overlapping nor degenerate-size sections.
	}]
}

Note that the above example contains a few symbols that are actually metasyntax, and therefore have
neither meaning nor place in a real file. The <.*> s indicate placeholders for parameters:
 - The names are strings, which are provided as single-word---no whitespace---groups of
   syntactically unimportant symbols (i.e. everything except @, {, and }): they are not surrounded
   by quotes or any other form of delimiter.
 - The other fields are nonnegative integers, which may be given as decimal or hexadecimal; in
   either case, a K, M, or G may be appended---without intermediate whitespace---as a multiplier.
 - Comments consist of anything one manages to enter, provided it doesn't start a new line.
The [.*] s indicate that a portion of the file could be omitted altogether:
 - Just because something is noted as optional doesn't mean it is in every case: the answer might
   actually depend on which other information is---or isn't---provided.
 - In particular, it is only legal to place a (CBFS) annotation on a leaf section; that is, choosing
   to add child sections excludes the possibility of putting a CBFS in their parent. Such
   annotations are only used to decide where CBFS empty file headers should be created, and do not
   result in the storage of any additional metadata in the resulting FMAP section.
Additionally, it's important to note these properties of the overall file and its values:
 - Other than within would-be strings and numbers, whitespace is ignored. It goes without saying
   that such power comes with responsibility, which is why this sentence is here.
 - Although the .*section names must be globally unique, one of them may---but is not required to---
   match the image name.
 - It is a syntax error to supply a number---besides 0---that begins with the character 0, as there
   is no intention of adding octals to the mix.
 - The image's memory address should be present on---and only on---layouts for memory-mapped chips.
 - Although it may be evident from above, all .*section offsets are relative only to the immediate
   parent. There is no way to include an absolute offset (i.e. from the beginning of flash), which
   means that it is "safe" to reorder the .*section s within a particular level of nesting, as long
   as the change doesn't cause their positions and sizes to necessitate overlap or zero sizes.
 - A .*section with omitted offset is assumed to start at as low a position as possible---with no
   consideration of alignment---and one with omitted size is assumed to fill the remaining space
   until the next sibling or before the end of its parent.
 - It's fine to omit any .*section 's offset, size, or both, provided its position and size are
   still unambiguous in the context of its *sibling* sections and its parent's *size*. In
   particular, knowledge of one .*section 's children or the .*section s' common parent's siblings
   will not be used for this purpose.
 - Although .*section s are not required to have children, the flash chip as a whole must have at
   least one.
 - Though the braces after .*section s may be omitted for those that have no children, if they are
   present, they must contain at least one child.

PL people and sympathizers may wish to examine the formal abstract syntax and context-free grammar,
which are located in fmd_scanner.l and fmd_scanner.y, respectively. Those interested in the
algorithm used to infer omitted values will feel at home in fmd.c, particularly near the definition
of validate_and_complete_info().