Commit graph

2 commits

Author SHA1 Message Date
Martin Roth
73f4be7dcc UPSTREAM: util/blobtool: Update blobtool.y
- Refactor the spec & setter file reads into a separate function.
- Make sure files can actually be opened before reading from them.
- Check all malloced variables.
- Set functions with no declatations as static.
- Update blobtool.tab.c_shipped to the latest version.

BUG=none
BRANCH=none
TEST=none

Change-Id: Idd95683db15a82debb705f1b722ac94fcb57ee8e
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 6338189d0e
Original-Change-Id: Ie97fff84493a06f48d8673d388c3882028d048ca
Original-Signed-off-by: Martin Roth <martinroth@google.com>
Original-Reviewed-on: https://review.coreboot.org/19231
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/486743
2017-04-26 07:17:30 -07:00
Damien Zammit
4f27904291 UPSTREAM: util/blobtool: Add new tool for compiling/decompiling data blobs
Given a specification of bitfields defined e.g. as follows:

        specfile:
                {
                        "field1" : 8,
                        "field2" : 4,
                        "field3" : 4
                }
and a set of values for setting defaults:
        setterfile:
                {
                        "field1" = 0xff,
                        "field2" = 0xf,
                        "field3" = 0xf
                }

You can generate a binary packed blob as follows:
        ./blobtool specfile setterfile binaryoutput
        binaryoutput:   ff ff

The reverse is also possible, i.e. you can regenerate the setter:
        ./blobtool -d specfile binaryoutput setterorig
        setterorig:
                # AUTOGENERATED SETTER BY BLOBTOOL
                {
                        "field1" = 0xff,
                        "field2" = 0xf,
                        "field3" = 0xf
                }

This tool comes with spec/set files for X200 flash descriptor
and ICH9M GbE region, and can be extended or used to decompile
other data blobs with known specs.

BUG=none
BRANCH=none
TEST=none

Change-Id: Ie8421c67f404631376d83e26f18301b34881cb5a
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 0685322f4a
Original-Change-Id: I744d6b421003feb4fc460133603af7e6bd80b1d6
Original-Signed-off-by: Damien Zammit <damien@zamaudio.com>
Original-Reviewed-on: https://review.coreboot.org/17445
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Jonathan Neuschfer <j.neuschaefer@gmx.net>
Original-Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://chromium-review.googlesource.com/438059
2017-02-06 10:37:43 -08:00