67a0a864be
These new-style firmware images use the FMAP of the root of knowledge about their layout, which allows them to have sections containing raw data whose offset and size can easily be determined at runtime or when modifying or flashing the image. Furthermore, they can even have multiple CBFSes, each of which occupies a different FMAP region. It is assumed that the first entry of each CBFS, including the primary one, will be located right at the start of its region. This means that the bootblock needs to be moved into its own FMAP region, but makes the CBFS master header obsolete because, with the exception of the version and alignment, all its fields are redundant once its CBFS has an entry in the FMAP. The version code will be addressed in a future commit before the new format comes into use, while the alignment will just be defined to 64 bytes in both cbfstool and coreboot itself, since there's almost no reason to ever change it in practice. The version code field and all necessary coreboot changes will come separately. BUG=chromium:470407 TEST=Build panther and nyan_big coreboot.rom and image.bin images with and without this patch, diff their hexdumps, and note that no locations differ except for those that do between subsequent builds of the same codebase. Try working with new-style images: use fmaptool to produce an FMAP section from an fmd file having raw sections and multiple CBFSes, pass the resulting file to cbfstool create -M -F, then try printing its layout and CBFSes' contents, add and remove CBFS files, and read and write raw sections. BRANCH=None Change-Id: I7dd2578d2143d0cedd652fdba5b22221fcc2184a Signed-off-by: Sol Boucher <solb@chromium.org> Original-Commit-Id: 8a670322297f83135b929a5b20ff2bd0e7d2abd3 Original-Change-Id: Ib86fb50edc66632f4e6f717909bbe4efb6c874e5 Original-Signed-off-by: Sol Boucher <solb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/265863 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/10135 Tested-by: build bot (Jenkins) |
||
---|---|---|
.. | ||
flashmap | ||
lzma | ||
cbfs-mkpayload.c | ||
cbfs-mkstage.c | ||
cbfs-payload-linux.c | ||
cbfs.h | ||
cbfs_image.c | ||
cbfs_image.h | ||
cbfs_sections.c | ||
cbfs_sections.h | ||
cbfstool.c | ||
coff.h | ||
common.c | ||
common.h | ||
compress.c | ||
elf.h | ||
elfheaders.c | ||
elfparsing.h | ||
EXAMPLE | ||
fit.c | ||
fit.h | ||
flashmap_tests.c | ||
fmap_from_fmd.c | ||
fmap_from_fmd.h | ||
fmaptool.c | ||
fmd.c | ||
fmd.h | ||
fmd_parser.c | ||
fmd_parser.h | ||
fmd_parser.y | ||
fmd_scanner.c | ||
fmd_scanner.h | ||
fmd_scanner.l | ||
fv.h | ||
linux.h | ||
linux_trampoline.c | ||
linux_trampoline.h | ||
Makefile | ||
Makefile.inc | ||
option.h | ||
partitioned_file.c | ||
partitioned_file.h | ||
README.fmaptool | ||
rmodtool.c | ||
rmodule.c | ||
rmodule.h | ||
swab.h | ||
xdr.c |
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().