Nico Huber
f1f39d682f
layout: Turn overlap debug message into warning
...
Let's assume this function is only called when overlapping, included
regions are fatal.
Change-Id: Ie969e0538d302ccd58d3fec3921265ed3621eaa5
Signed-off-by: Nico Huber <nico.huber@secunet.com >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55999
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
2021-07-06 02:26:43 +00:00
Nico Huber
c9039fc279
layout: Fix overlap-check routine
...
Fixes a regression introduced by commit 06a89d713 (layout: Introduce
layout_next()). A negation was dropped by accident which resulted in
comparisons with later, not-included regions instead of included ones.
Change-Id: I18168b9bd9a7d0fe2ba04fb091d1600f65d6dd5b
Signed-off-by: Nico Huber <nico.huber@secunet.com >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55997
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
2021-07-06 02:25:44 +00:00
Nico Huber
7dd1624a7d
layout: Tidy up the include-args API
...
Move all forward declarations into `layout.h`, use consistent naming.
Change-Id: I0e87c9d91b9bc4d78f9cee98caff6985803f7be7
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54287
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:59:44 +00:00
Nico Huber
d855351ce7
layout: Kill the global layout
...
Change-Id: Ic302e9c5faf1368e5ca244ce461e55e14f916ab8
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54286
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
2021-06-26 15:59:34 +00:00
Nico Huber
7f48053172
layout: Rework normalize_romentries() API
...
Rename it to layout_sanity_checks() as that is what it does and
let it work on the currently active layout instead of the global
layout.
Change-Id: Ifae3480d4bd68c939c291f05734544e93f00306c
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54285
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:59:00 +00:00
Nico Huber
194815a363
layout: Make struct layout_include_args private to layout.c
...
Change-Id: Icbfee68e85429fe41db1cad6b99f25e9f30cd672
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33545
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Reviewed-by: Peter Marheine <pmarheine@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:57:36 +00:00
Nico Huber
78d9c7d02c
layout: Drop count parameter of flashrom_layout_new()
...
Change-Id: I22c180c9971068b1ae101845ce88484c6842b852
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33544
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:57:21 +00:00
Nico Huber
953c5ad440
layout: Use linked list for struct romentry
...
This gets rid of the entry limit and hopefully makes future layout
handling easier. We start by making `struct flashrom_layout` private
to `layout.c`.
Change-Id: I60a0aa1007ebcd5eb401db116f835d129b3e9732
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33521
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
2021-06-26 15:57:06 +00:00
Nico Huber
a630a56413
layout: Introduce get_default_layout()
...
Containing an included, full-flash-chip sized default region.
This allows us to query the default layout specifically, also
if an additional layout is attached to the flash context.
Change-Id: Ia343e9775ec5bdc3fea5cdb6b347298515996e34
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33519
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Peter Marheine <pmarheine@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:55:39 +00:00
Nico Huber
c32c8dc8af
layout: Introduce flashrom_layout_new()
...
It initializes an empty layout. Currently the maximum number of entries
has to be specified, which will vanish once we use dynamic allocation
per entry.
We replace the two special cases `single_layout` and `ich_layout` with
dynamically allocated layouts. As a result, we have to take care to
release the `default_layout` in a flashctx once we are done with it.
Change-Id: I2ae7246493ff592e631cce924777925c7825e398
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33543
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
2021-06-26 15:54:51 +00:00
Nico Huber
f394fcec0d
layout: Introduce flashrom_layout_add_region()
...
Adds a region to an existing layout, as long as there is space.
Change-Id: I50d473d0d5d1fb38bd6f9ae3d7127e9ea66a94e1
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33517
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Peter Marheine <pmarheine@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:54:22 +00:00
Nico Huber
7ebd578100
layout: Add capacity field
...
Use it to keep track of the size of the `entries` array. An interim
solution until we have dynamic allocation.
Change-Id: Ib5f431bc0a72a79a53fa1376c3417942b19dd3a0
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33516
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Peter Marheine <pmarheine@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:53:31 +00:00
Nico Huber
06a89d7139
layout: Introduce layout_next()
...
Also, a `layout.c` internal version mutable_layout_next() that
allows to modify layout entries and a shorthand to look up an
entry by name, _layout_entry_by_name().
Use the new functions where applicable and the code is not
dropped later in this train, and also to compare the layouts
in flashrom_layout_read_from_ifd() in depth.
Change-Id: I284958471c61344d29d92c95d88475065a9ca9aa
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33542
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org >
Reviewed-by: Peter Marheine <pmarheine@chromium.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-06-26 15:53:04 +00:00
Angel Pons
3bd47524c0
treewide: Drop most cases of sizeof(struct ...)
...
Spelling out the struct type name hurts readability and introduces
opportunities for bugs to happen when the pointer variable type is
changed but the corresponding sizeof is (are) not.
TEST=`make CONFIG_EVERYTHING=yes CONFIG_JLINK_SPI=no VERSION=none -j`
with and without this patch; the flashrom executable does not change.
Change-Id: Icc0b60ca6ef9f5ece6ed2a0e03600bb6ccd7dcc6
Signed-off-by: Angel Pons <th3fanbus@gmail.com >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55266
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Nico Huber <nico.h@gmx.de >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
2021-06-09 16:03:30 +00:00
Daniel Campello
7367f77aa4
cli_classic.c: implement set_wp_region operation
...
set_wp_region allows to set the wp_range based on a layout region.
Signed-off-by: Daniel Campello <campello@chromium.org >
Change-Id: Ibad68a038ab38b9986b0d8b5f5eb6c73b20ef381
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52531
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
2021-05-04 02:18:43 +00:00
Daniel Campello
ce983bccaa
cli_classic.c: add -x option for do_extract()
...
This change introduces a new option to extract all layout regions to
files with the name of each region (or with the provided filename via
-i region:file). It is implemented by mutating the flash layout to
include all regions and backfilling the entry->file with entry->name
(replacing spaces with underscores)
Signed-off-by: Daniel Campello <campello@chromium.org >
Change-Id: I8c69223fa92cf5b50abe070f1ab9f19d3b42f6ff
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52450
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
2021-05-02 23:45:43 +00:00
Daniel Campello
45d50a101e
layout: Add -i <region>[:<file>] support
...
Add an optional sub-parameter to the -i parameter to allow building the
image to be written from multiple files. This will also allow regions to
be read from flash and written to separate image files.
This is a rebase of a patch that was ported from chromiumos. A lot of
things have changed, but the idea is the same.
Original patch by Louis Yung-Chieh Lo <yjlou@chromium.org >:
Summary: Support -i partition:file feature for both read and write.
Commit: 9c7525f
Review URL: http://codereview.chromium.org/6611015
Ported version by Stefan Tauner <stefan.tauner@student.tuwien.ac.at >
and Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net >:
Summary: [PATCH 2/6] layout: Add -i <region>[:<file>] support.
Review URL: https://mail.coreboot.org/pipermail/flashrom/2013-October/011729.html
Change-Id: Ic5465659605d8431d931053967b40290195cfd99
Signed-off-by: David Hendricks <dhendrix@chromium.org >
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at >
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net >
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz >
Signed-off-by: Nico Huber <nico.huber@secunet.com >
Signed-off-by: Edward O'Callaghan <quasisec@google.com >
Signed-off-by: Daniel Campello <campello@chromium.org >
Co-Authored-by: Edward O'Callaghan <quasisec@google.com >
Co-Authored-by: Daniel Campello <campello@chromium.org >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/23021
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Sam McNally <sammc@google.com >
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org >
2021-04-27 23:41:53 +00:00
Edward O'Callaghan
358a350e11
layout.h,c: Use 'false' over '0' for bool type
...
The field member 'included' is of type boolean and so keep to
using 'true, false' values over numerics like '0'. Get rid of
a unnecessary yet trivial tab at the end of layout.h while we
are here.
BUG=none
BRANCH=none
TEST=builds
Change-Id: Ib594de2834175482ae5e36d9dd354ef2555c53d5
Signed-off-by: Edward O'Callaghan <quasisec@google.com >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/48743
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Sam McNally <sammc@google.com >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
2020-12-20 23:10:08 +00:00
Nico Huber
519be66fc5
Fix -Wsign-compare trouble
...
Mostly by changing to `unsigned` types where applicable, sometimes
`signed` types, and casting as a last resort.
Change-Id: I08895543ffb7a48058bcf91ef6500ca113f2d305
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/30409
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca >
2019-07-31 08:26:59 +00:00
Jacob Garber
afc3ad6430
tree: Make internal variables static
...
All these variables are only used in the files they are defined in, so
they can be made static.
Change-Id: I1e55138adef540e9d3a2237aa5b289cb338c0608
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33747
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Nico Huber <nico.h@gmx.de >
2019-06-26 07:25:01 +00:00
Nico Huber
5ca5523fd8
layout: Introduce layout_next_included()
...
Change-Id: Ib01c8af06c3f84eafbd585760e74c3c287b9fa7d
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33518
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz >
2019-06-17 08:33:09 +00:00
Nico Huber
70461a9524
layout: Make romentry.name a pointer
...
This should provide more flexibility while we don't have to allocate
256B extra per layout entry.
Change-Id: Ibb903113550ec13f43cbbd0a412c8f35fe1cf454
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33515
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz >
2019-06-17 08:32:43 +00:00
Nico Huber
4f213285d7
layout: Move generic layout functions into layout.c
...
Change-Id: If1edde70fc51e88e6e1c560d79a0d51941b9627c
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33514
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz >
2019-06-17 08:31:18 +00:00
Nico Huber
2b94cdb5cb
layout: Never use global layout directly
...
And rename it to `global_layout` to free `layout` as a local variable
name. We will get rid of the global layout entirely later.
Change-Id: Ia2d7d1f4f649cd239b559ba6a40ee0977004e774
Signed-off-by: Nico Huber <nico.h@gmx.de >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33513
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Angel Pons <th3fanbus@gmail.com >
2019-06-17 08:31:07 +00:00
Arthur Heymans
b04fef91c1
layout.c: Don't use global variables for included regions
...
This removes the use of global variables for included region arguments
and also uses a linked list to store the arguments.
Change-Id: I6534cc58b8dcc6256c2730c809286d8083669a6c
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz >
Reviewed-on: https://review.coreboot.org/c/flashrom/+/31247
Tested-by: build bot (Jenkins) <no-reply@coreboot.org >
Reviewed-by: Nico Huber <nico.h@gmx.de >
2019-06-17 08:03:12 +00:00