summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfstool.c
AgeCommit message (Collapse)Author
2017-01-18cbfstool: Don't use le32toh(), it's non-standardNico Huber
It's a BSD function, also, we missed to include `endian.h`. Just including `endian.h` doesn't fix the problem for everyone. Instead of digging deeper, just use our own endian-conversion from `commonlib`. Change-Id: Ia781b2258cafb0bcbe8408752a133cd28a888786 Reported-by: Werner Zeh <werner.zeh@siemens.com> Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/18157 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
2017-01-13util/cbfstool: Enable adding precompressed files to cbfsPatrick Georgi
cbfstool ... add ... -c precompression assumes the input file to be created by cbfs-compression-tool's compress command and uses that to add the file with correct metadata. When adding the locale_*.bin files to Chrome OS images, this provides a nice speedup (since we can parallelize the precompression and avoid compressing everything twice) while creating a bit-identical file. Change-Id: Iadd106672c505909528b55e2cd43c914b95b6c6d Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/18102 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber <nico.h@gmx.de>
2017-01-02util/cbfstool: Don't print region information on stderr by defaultPatrick Georgi
It's usually not too interesting, so hide it behind -v. Change-Id: Icffb5ea4d70300ab06dfa0c9134d265433260368 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/17899 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-15util/cbfstool: check that buffer_create workedPatrick Georgi
We might not care much about this buffer, but we really use it later on... Change-Id: Ia16270f836d05d8b454e77de7b5babeb6bb05d6d Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Found-by: Coverity Scan #1294797 Reviewed-on: https://review.coreboot.org/17860 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins)
2016-12-13util/cbfstool: Enable filling fmap regions with a given valuePatrick Georgi
So far, cbfstool write, when used with the -u/-d options (to "fill upwards/downwards") left the parts of the region alone for which there was no new data to write. When adding -i [0..255], these parts are overwritten with the given value. BUG=chromium:595715 BRANCH=none TEST=cbfstool write -u -i 0 ... does the right thing (fill the unused space with zeroes) Change-Id: I1b1c0eeed2862bc9fe5f66caae93b08fe21f465c Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: baf378c5f2afdae9946600ef6ff07408a3668fe0 Original-Change-Id: I3752f731f8e6592b1a390ab565aa56e6b7de6765 Original-Signed-off-by: Patrick Georgi <pgeorgi@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/417319 Original-Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Original-Tested-by: Patrick Georgi <pgeorgi@chromium.org> Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: https://review.coreboot.org/17787 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
2016-12-13util/cbfstool: require -i argument for cbfstool add-intPatrick Georgi
We never specified what value add-int should write by default. Change-Id: I240be4842fc374690c4a718fc4d8f0a03d63003c Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/17796 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2016-10-17cbfstool: Fix typo in help textPatrick Georgi
Change-Id: Ic5a3be1128f2f9a53d21e0a2c577192962260df6 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/17018 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2016-10-17util/cbfstool: Allow overwriting CBFS regions with raw data on requestPatrick Georgi
Add a --force/-F option and enable it for cbfstool write, where it has the effect of not testing if the fmap region contains a CBFS or if the data to write is a CBFS image. Change-Id: I02f72841a20db3d86d1b67ccf371bd40bb9a4d51 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/16998 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com>
2016-08-03cbfstool: Check for excessive argumentsNico Huber
Change-Id: I66de6a33b43c284198c0a0a97c5c6a10f9b96e02 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/16019 Tested-by: build bot (Jenkins) Reviewed-by: Omar Pakker Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-08-03cbfstool: Check arguments to strtoul() where appropriateNico Huber
The interface to strtoul() is a weird mess. It may or may not set errno if no conversion is done. So check for empty strings and trailing characters. Change-Id: I82373d2a0102fc89144bd12376b5ea3b10c70153 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/16012 Tested-by: build bot (Jenkins) Reviewed-by: Idwer Vollering <vidwer@gmail.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-05-18util/cbfstool: allow option to honor FSP modules' linked addressAaron Durbin
If '-b' isn't passed when adding an FSP file type to CBFS allow the currently linked address to be used. i.e. don't relocate the FSP module and just add it to CBFS. Change-Id: I61fefd962ca9cf8aff7a4ca2bea52341ab41d67b Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/14839 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
2016-05-11cbfstool/fsp: Rename fsp1_1_relocateFurquan Shaikh
FSP 2.0 uses the same relocate logic as FSP 1.1. Thus, rename fsp1_1_relocate to more generic fsp_component_relocate that can be used by cbfstool to relocate either FSP 1.1 or FSP 2.0 components. Allow FSP1.1 driver to still call fsp1_1_relocate which acts as a wrapper for fsp_component_relocate. Change-Id: I14a6efde4d86a340663422aff5ee82175362d1b0 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/14749 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
2016-05-11util/cbfstool: Allow xip/non-xip relocation for FSP componentFurquan Shaikh
Currently, convert_fsp assumes that the component is always XIP. This is no longer true with FSP 2.0 and Apollolake platform. Thus, add the option -y|--xip for FSP which will allow the caller to mention whether the FSP component being added is XIP or not. Add this option to Makefiles of current FSP drivers (fsp1_0 and fsp1_1). Change-Id: I1e41d0902bb32afaf116bb457dd9265a5bcd8779 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/14748 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
2016-05-06util/cbfstool: fix x86 execute-in-place semantics for all fmd regionsAaron Durbin
A previous patch [1] to make top-aligned addresses work within per fmap regions caused a significant regression in the semantics of adding programs that need to be execute-in-place (XIP) on x86 systems. Correct the regression by providing new function, convert_to_from_absolute_top_aligned(), which top aligns against the entire boot media. [1] 9731119b cbfstool: make top-aligned address work per-region Change-Id: I3b685abadcfc76dab8846eec21e9114a23577578 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/14608 Tested-by: build bot (Jenkins) Reviewed-by: Duncan Laurie <dlaurie@google.com> Reviewed-by: Furquan Shaikh <furquan@google.com>
2016-04-07Revert "cbfstool: Add 'hashcbfs' command to compute hash of CBFS region."Aaron Durbin
This reverts commit 272a1f05b943d781acb8c04c01874bde9df3b774. In Chrome OS this command's usage was dropped in favor of another solution. As it's not used drop the support for it. Change-Id: I58b51446d3a8b5fed7fc391025225fbe38ffc007 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/14261 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-01-28util/cbfstool: add 'compact' commandAaron Durbin
While assembling CBFS images within the RW slots on Chrome OS machines the current approach is to 'cbfstool copy' from the RO CBFS to each RW CBFS. Additional fixups are required such as removing unneeded files from the RW CBFS (e.g. verstage) as well as removing and adding back files with the proper arguments (FSP relocation as well as romstage XIP relocation). This ends up leaving holes in the RW CBFS. To speed up RW CBFS slot hashing it's beneficial to pack all non-empty files together at the beginning of the CBFS. Therefore, provide the 'compact' command which bubbles all the empty entries to the end of the CBFS. Change-Id: I8311172d71a2ccfccab384f8286cf9f21a17dec9 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/13479 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-01-28util/cbfstool: add machine parseable printAaron Durbin
In order to more easily process the output of 'cbfstool print' with other tools provide a -k option which spits out the tab-separated header and fields: Name Offset Type Metadata Size Data Size Total Size ALIGN_UP(Offset + Total Size, 64) would be the start of the next entry. Also, one can analzye the overhead and offsets of each file more easily. Example output (note: tabs aren't in here): $ ./coreboot-builds/sharedutils/cbfstool/cbfstool test.serial.bin print -r FW_MAIN_A -k Performing operation on 'FW_MAIN_A' region... Name Offset Type Metadata Size Data Size Total Size cmos_layout.bin 0x0 cmos_layout 0x38 0x48c 0x4c4 dmic-2ch-48khz-16b.bin 0x500 raw 0x48 0xb68 0xbb0 dmic-2ch-48khz-32b.bin 0x10c0 raw 0x48 0xb68 0xbb0 nau88l25-2ch-48khz-24b.bin 0x1c80 raw 0x48 0x54 0x9c ssm4567-render-2ch-48khz-24b.bin 0x1d40 raw 0x58 0x54 0xac ssm4567-capture-4ch-48khz-32b.bin 0x1e00 raw 0x58 0x54 0xac vbt.bin 0x1ec0 optionrom 0x38 0x1000 0x1038 spd.bin 0x2f00 spd 0x38 0x600 0x638 config 0x3540 raw 0x38 0x1ab7 0x1aef revision 0x5040 raw 0x38 0x25e 0x296 font.bin 0x5300 raw 0x38 0x77f 0x7b7 vbgfx.bin 0x5ac0 raw 0x38 0x32f8 0x3330 locales 0x8e00 raw 0x28 0x2 0x2a locale_en.bin 0x8e40 raw 0x38 0x29f6 0x2a2e u-boot.dtb 0xb880 mrc_cache 0x38 0xff1 0x1029 (empty) 0xc8c0 null 0x64 0xadf4 0xae58 fallback/ramstage 0x17740 stage 0x38 0x15238 0x15270 (empty) 0x2c9c0 null 0x64 0xd2c4 0xd328 fallback/payload 0x39d00 payload 0x38 0x12245 0x1227d cpu_microcode_blob.bin 0x4bf80 microcode 0x60 0x17000 0x17060 (empty) 0x63000 null 0x28 0x37cf98 0x37cfc0 Change-Id: I1c5f8c1b5f2f980033d6c954c9840299c6268431 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/13475 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-01-23cbfstool: Fix potential error when using hash attributeWerner Zeh
There can be an error when a cbfs file is added aligned or as xip-stage and hashing of this file is enabled. This commit resolves this error. Though adding a file to a fixed position while hashing is used can still lead to errors. Change-Id: Icd98d970891410538909db2830666bf159553133 Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/13136 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-01-22cbfstool: Add attributes for position and alignment constraints.Werner Zeh
Add functionality to cbfstool to generate file attributes for position and alignment constraints. This new feature can be activated with the -g option and will generate, once the option has been enabled, additional attributes for the files where position, xip or alignment was specified. Change-Id: I3db9bd2c20d26b168bc7f320362ed41be349ae3a Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/12967 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
2016-01-21cbfstool: don't rewrite param.baseaddress in cbfs_addPatrick Georgi
cbfs_add calculated a base address out of the alignment specification and stored it in param.baseaddress. This worked when every cbfstool invocation only added a single file, but with -r REGION1,REGION2,... multiple additions can happen. In that case, the second (and later) additions would have both alignment and baseaddress set, which isn't allowed, aborting the process. Change-Id: I8c5a512dbe3c97e08c5bcd92b5541b58f65c63b3 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/13063 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-19cbfstool: accept read-only files when possibleVadim Bendebury
cbfstool tries opening the input file for write access even if the command does not require modifying the file. Let's not request write access unless it is necessary, this way one can examine write protected files without sudo. BRANCH=none BUG=none TEST=running cbfstool /build/<board>/firmware/image.bin print in chroot does not require root access any more. Change-Id: Ic4e4cc389b160da190e44a676808f5c4e6625567 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: ef6a8e25d9e257d7de4cc6b94e510234fe20a56d Original-Change-Id: I871f32f0662221ffbdb13bf0482cb285ec184d07 Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/317300 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12931 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
2016-01-14cbfstool: reorder help textPatrick Georgi
hashcbfs was spliced in a line early, mixing up 'extract' and 'cbfshash' help texts. Change-Id: I86d4edb9eec0685a290b2dd4c2dc45d3611eba9a Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/12922 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-01-13cbfstool: Remove duplicate code lineWerner Zeh
Remove duplicate line which sets baseaddress parameter. Change-Id: Idfbb0297e413344be892fa1ecc676a64d20352bf Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/12904 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2016-01-06cbfstool: correct add-master-header logic to match runtime expectationsAaron Durbin
The cbfs master header's offset and romsize fields are absolute values within the boot media proper. Therefore, when adding a master header provide the offset of the CBFS region one is operating on as well as the absolute end offset (romsize) to match expectations. Built with and without CBFS_SIZE != ROM_SIZE on x86 and ARM device. Manually inspected the master headers within the images to confirm proper caclulations. Change-Id: Id0623fd713ee7a481ce3326f4770c81beda20f64 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12825 Tested-by: build bot (Jenkins) Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com> Reviewed-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
2016-01-06cbfstool: Add 'hashcbfs' command to compute hash of CBFS region.Aaron Durbin
For the purposes of maintaining integrity of a CBFS allow one to hash a CBFS over a given region. The hash consists of all file metadata and non-empty file data. The resulting digest is saved to the requested destination region. BUG=chrome-os-partner:48412 BUG=chromium:445938 BRANCH=None TEST=Integrated with glados chrome os build. vboot verification works using the same code to generate the hash in the tooling as well as at runtime on the board in question. Change-Id: Ib0d6bf668ffd6618f5f73e1217bdef404074dbfc Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12790 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-01-06cbfstool: Adapt "cbfstool copy" to only use fmap regions.Patrick Georgi
These need to go together, so the commit became a bit larger than typial. - Add an option -R for the copy source fmap region. Use: cbfstool copy -r target-region -R source-region. - Don't generate a CBFS master header because for fmap regions, we assume that the region starts with a file header. Use cbfstool add-master-header to add it afterwards, if necessary. - Don't copy files of type "cbfs master header" (which are what cbfstool add-master-header creates) - Leave room for the master header pointer - Remove -D command line option as it's no longer used. BUG=chromium:445938 BRANCH=none TEST=Manual test on image and integration test w/ bundle_firmware changes. CQ-DEPEND=CL:313770,CL:313771 Change-Id: I2a11cda42caee96aa763f162b5f3bc11bb7992f9 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12788 Tested-by: build bot (Jenkins)
2016-01-06cbfstool: Use buffer over offset/size pair for cbfs_copy_instancePatrick Georgi
This allows adding support for FMAP based cbfstool copy more easily. BUG=chromium:445938 Change-Id: I72e7bc4da7d27853e324400f76f86136e3d8726e Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/12787 Tested-by: build bot (Jenkins)
2015-12-09cbfstool: make top-aligned address work per-regionPatrick Georgi
The former interpretation sprung from the x86 way of doing things (assuming top-alignment to 4GB). Extend the mechanism to work with CBFS regions residing elsewhere. It's compatible with x86 because the default region there resides at the old location, so things fall in place. It also makes more complex layouts and non-x86 layouts work with negative base addresses. Change-Id: Ibcde973d85bad5d1195d657559f527695478f46c Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/12683 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
2015-12-06cbfstool: Re-align help textMartin Roth
The help text had gotten kind of sloppy. There was a missing newline in the add-stage command, some of the lines were too long, etc. Change-Id: If7bdc519ae062fb4ac6fc67e6b55af1e80eabe33 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12646 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Alexander Couzens <lynxis@fe80.eu>
2015-10-31tree: drop last paragraph of GPL copyright headerPatrick Georgi
It encourages users from writing to the FSF without giving an address. Linux also prefers to drop that and their checkpatch.pl (that we imported) looks out for that. This is the result of util/scripts/no-fsf-addresses.sh with no further editing. Change-Id: Ie96faea295fe001911d77dbc51e9a6789558fbd6 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11888 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2015-10-29cbfstool: add optional -m ARCH to extractAaron Durbin
In order to prepare allowing for one to extract a stage into an ELF file provide an optional -m ARCH option. This allows one to indicate to cbfstool what architecture type the ELF file should be in. Longer term each stage and payload will have an attribute associated with it which indicates the attributes of the executable. Change-Id: Id190c9719908afa85d5a3b2404ff818009eabb4c Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/12217 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2015-10-23cbfstool: Fix tolower() calls on CygwinStefan Reinauer
Cygwin complains: cbfstool.c: 1075:5 error: array subscript has type 'char' [-Werror=char-subscripts] so add an explicit cast. Change-Id: Ie89153518d6af2bacce3f48fc7952fee17a688dd Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-on: http://review.coreboot.org/11666 Tested-by: build bot (Jenkins) Reviewed-by: Zheng Bao <zheng.bao@amd.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2015-10-19cbfstool: Fix typo in error messagePatrick Georgi
Change-Id: Iaee7e2c74fe9f63d4d4878278bd445af393942f4 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: http://review.coreboot.org/11920 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2015-10-02cbfstool: relocate FSP blobs on cbfstool addAaron Durbin
When adding an FSP blob relocate it to its final destination. This allows FSP to not be hard coded in the cbfs. In order for the include paths to work correctly w/ the edk 2 headers we need to supply a neutered ProcessorBind.h to match up with the tool environment such that one can get the UEFI Platform Initialization type definitions. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built glados and booted. Also added FSP with -b and manually adjusted location in fsp cache-as-ram. Booted as well. Change-Id: I830d93578fdf745a51195109cf18d94a83ee8cd3 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11778 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-10-01cbfstool: Add support for hashes as file metadataPatrick Georgi
They allow optimizing a verification of a whole CBFS image by only dealing with the headers (assuming you choose to trust the hash algorithm(s)). The format allows for multiple hashes for a single file, and cbfstool can handle them, but right now it can't generate such headers. Loosely based on Sol's work in http://review.coreboot.org/#/c/10147/, but using the compatible file attribute format. vboot is now a hard dependency of the build process, but we import it into the tree for quite a while now. Change-Id: I9f14f30537d676ce209ad612e7327c6f4810b313 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11767 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-09-28cbfstool: prefer fmap data over cbfs master header if it existsPatrick Georgi
Up to now, if both fmap and a master header existed, the master header was used. Now, use the master header only if no fmap is found. Change-Id: Iafbf2c9dc325597e23a9780b495549b5d912e9ad Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11629 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-09-28cbfstool: have update-fit always work from CBFSPatrick Georgi
On x86, the bootblock can (and will) become part of the regular file system, so there's no distinct fixed-size region for the bootblock there. Change-Id: Ie139215b73e01027bc0586701361e9a0afa9150e Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11691 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-09-21cbfstool: don't use endian to fix BSD hostsAaron Durbin
endian.h lives in under sys on the BSDs. Replace htole32() with swab32(htonl(..)) as a proxy for little endian operations. Change-Id: I84a88f6882b6c8f14fb089e4b629e916386afe4d Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11695 Tested-by: build bot (Jenkins) Reviewed-by: Idwer Vollering <vidwer@gmail.com> Reviewed-by: Jonathan A. Kollasch <jakllsch@kollasch.net>
2015-09-21cbfstool: add new add-master-header commandPatrick Georgi
The command adds a new cbfs file, fills in the CBFS meta data in cbfs master header format, then points the master header pointer (which resides at the last 4 bytes of the CBFS region) to the data area of the new file. This can leak some space in CBFS if an old-style CBFS with native master header gets the treatment, because a new header is created and pointed at. flashmap based images have no such header, and the attempt to create a second file with the (hardcoded) name will fail. Change-Id: I5bc7fbcb5962b35a95261f30f0c93008e760680d Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11628 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-09-16cbfstool: remove locate commandAaron Durbin
The locate command was previously being used for x86 romstage linking as well as alignment handling of files. The add command already supports alignment so there's no more users of the locate command. Remove the command as well as the '-T' (top-aligned) option. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built rambi. Noted microcode being directly added. Change-Id: I3b6647bd4cac04a113ab3592f345281fbcd681af Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11671 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-16cbfstool: add --xip support to add-stage for x86Aaron Durbin
Instead of going through the locate then add-stage dance while linking romstage twice allow for adding romstage with --xip flags to perform the relocation while adding it into CBFS. The -P (page-size) and -a (alignment) parameters were added as well so one could specify the necessary parameters for x86 romstage. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built and booted on glados. Change-Id: I585619886f257e35f00961a1574009a51c28ff2b Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11669 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-16cbfstool: provide metadata size to cbfs_locate_entry()Aaron Durbin
The cbfs_locate_entry() function had a hack in there which assumed a struct cbfs_stage data was being added in addition to the struct cbfs_file and name. Move that logic out to the callers while still maintaining the logic for consistency. The only impacted commands cbfs_add and cbfs_locate, but those are using the default 'always adding struct cbfs_stage' in addition to cbfs_file + name. Eventually those should be removed when cbfs_locate is removed as cbfs_add has no smarts related to the cbfs file type provided. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built rambi. Change-Id: I2771116ea1ff439ea53b8886e1f33e0e637a79d4 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11668 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-07cbfstool: Allow adding file with specific alignment requirementAlexandru Gagniuc
Whenever we want to add a file to CBFS with a specific alignment, we have to do two cbfstool invocations: one to find a place for the file, and another to actually add the file to CBFS. Get rid of this nonsense and allow this to be done in one step. Change-Id: I526483296b494363f15dc169f163d93a6fc71bb0 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/11525 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-01cbfstool: allow compression at file header levelDaisuke Nojiri
Currently, compression is only allowed at subheader level (e.g. cbfs_stage, cbfs_payload_segment). This change adds compression field to each file's header so that any cbfs file can be compressed. With the necessary additions in coreboot and libpayload, the following sample code can load a compressed file: const char *name = "foo.bmp"; struct cbfs_file *file = cbfs_get_file(media, name); void *dst = malloc(ntohl(file->uncompressed_size)); dst = cbfs_get_file_content(media, name, type, file, dst); cbfs_stage and cbfs_payload_segment continue to support compression at subheader level because stages and payloads have to be decompressed to the load address, which is stored in the subheader. For these, file level compression should be turned off. Change-Id: I9a00ec99dfc68ffb2771bb4a3cc5ba6ba8a326f4 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/10935 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-27cbfstool: update help textPatrick Georgi
cbfstool create doesn't accept alignment configuration anymore. Change-Id: Idbf7662c605aa78e3d3413a21bfcbc1387f28701 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11358 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-27cbfstool: don't pass header_size as separate argument (part 2)Patrick Georgi
It's already present inside struct cbfs_file Change-Id: Ic9682e93c3d208e2ed458940e4a9f9f5a64b6e98 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11333 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-27cbfstool: passing a header is now mandatory for convertersPatrick Georgi
Change-Id: Iea5377af735b06bcaefb999547a8896b1c70763a Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11330 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-27cbfstool: cbfs_add_entry() doesn't need to know filename or typePatrick Georgi
They're passed as part of the header now. Change-Id: I7cd6296adac1fa72e0708b89c7009552e272f656 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11327 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-26cbfstool: move cbfs_file header creation further up the call chainPatrick Georgi
The header is now created before the "converters" are run. Adding new capabilities (and fields to the header) will happen there, so we're close. Change-Id: I0556df724bd93816b435efff7d931293dbed918f Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11326 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-26cbfstool: pass cbfs_file header into "compress" functionsPatrick Georgi
These functions can do all kinds of things, such as converting an ELF image into SELF, or (in the future) compress or checksum entire files. This may require changing or adding fields to the header, so they need to have access to it. The header_size parameter that was provided (but never used) is equivalent to cbfs_file's offset field. Change-Id: I7c10ab15f3dff4412461103e9763a1d78b7be7bb Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11325 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>