mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 07:23:43 +02:00
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>
This commit is contained in:
parent
70461a9524
commit
5ca5523fd8
33
flashrom.c
33
flashrom.c
@ -1597,14 +1597,11 @@ static int check_block_eraser(const struct flashctx *flash, int k, int log)
|
|||||||
static int read_by_layout(struct flashctx *const flashctx, uint8_t *const buffer)
|
static int read_by_layout(struct flashctx *const flashctx, uint8_t *const buffer)
|
||||||
{
|
{
|
||||||
const struct flashrom_layout *const layout = get_layout(flashctx);
|
const struct flashrom_layout *const layout = get_layout(flashctx);
|
||||||
|
const struct romentry *entry = NULL;
|
||||||
|
|
||||||
size_t i;
|
while ((entry = layout_next_included(layout, entry))) {
|
||||||
for (i = 0; i < layout->num_entries; ++i) {
|
const chipoff_t region_start = entry->start;
|
||||||
if (!layout->entries[i].included)
|
const chipsize_t region_len = entry->end - entry->start + 1;
|
||||||
continue;
|
|
||||||
|
|
||||||
const chipoff_t region_start = layout->entries[i].start;
|
|
||||||
const chipsize_t region_len = layout->entries[i].end - layout->entries[i].start + 1;
|
|
||||||
|
|
||||||
if (flashctx->chip->read(flashctx, buffer + region_start, region_start, region_len))
|
if (flashctx->chip->read(flashctx, buffer + region_start, region_start, region_len))
|
||||||
return 1;
|
return 1;
|
||||||
@ -1681,17 +1678,14 @@ static int walk_by_layout(struct flashctx *const flashctx, struct walk_info *con
|
|||||||
const per_blockfn_t per_blockfn)
|
const per_blockfn_t per_blockfn)
|
||||||
{
|
{
|
||||||
const struct flashrom_layout *const layout = get_layout(flashctx);
|
const struct flashrom_layout *const layout = get_layout(flashctx);
|
||||||
|
const struct romentry *entry = NULL;
|
||||||
|
|
||||||
all_skipped = true;
|
all_skipped = true;
|
||||||
msg_cinfo("Erasing and writing flash chip... ");
|
msg_cinfo("Erasing and writing flash chip... ");
|
||||||
|
|
||||||
size_t i;
|
while ((entry = layout_next_included(layout, entry))) {
|
||||||
for (i = 0; i < layout->num_entries; ++i) {
|
info->region_start = entry->start;
|
||||||
if (!layout->entries[i].included)
|
info->region_end = entry->end;
|
||||||
continue;
|
|
||||||
|
|
||||||
info->region_start = layout->entries[i].start;
|
|
||||||
info->region_end = layout->entries[i].end;
|
|
||||||
|
|
||||||
size_t j;
|
size_t j;
|
||||||
int error = 1; /* retry as long as it's 1 */
|
int error = 1; /* retry as long as it's 1 */
|
||||||
@ -1962,14 +1956,11 @@ static int verify_by_layout(struct flashctx *const flashctx,
|
|||||||
void *const curcontents, const uint8_t *const newcontents)
|
void *const curcontents, const uint8_t *const newcontents)
|
||||||
{
|
{
|
||||||
const struct flashrom_layout *const layout = get_layout(flashctx);
|
const struct flashrom_layout *const layout = get_layout(flashctx);
|
||||||
|
const struct romentry *entry = NULL;
|
||||||
|
|
||||||
size_t i;
|
while ((entry = layout_next_included(layout, entry))) {
|
||||||
for (i = 0; i < layout->num_entries; ++i) {
|
const chipoff_t region_start = entry->start;
|
||||||
if (!layout->entries[i].included)
|
const chipsize_t region_len = entry->end - entry->start + 1;
|
||||||
continue;
|
|
||||||
|
|
||||||
const chipoff_t region_start = layout->entries[i].start;
|
|
||||||
const chipsize_t region_len = layout->entries[i].end - layout->entries[i].start + 1;
|
|
||||||
|
|
||||||
if (flashctx->chip->read(flashctx, curcontents + region_start, region_start, region_len))
|
if (flashctx->chip->read(flashctx, curcontents + region_start, region_start, region_len))
|
||||||
return 1;
|
return 1;
|
||||||
|
18
layout.c
18
layout.c
@ -252,6 +252,24 @@ const struct romentry *layout_next_included_region(
|
|||||||
return lowest;
|
return lowest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct romentry *layout_next_included(
|
||||||
|
const struct flashrom_layout *const layout, const struct romentry *iterator)
|
||||||
|
{
|
||||||
|
const struct romentry *const end = layout->entries + layout->num_entries;
|
||||||
|
|
||||||
|
if (iterator)
|
||||||
|
++iterator;
|
||||||
|
else
|
||||||
|
iterator = &layout->entries[0];
|
||||||
|
|
||||||
|
for (; iterator < end; ++iterator) {
|
||||||
|
if (!iterator->included)
|
||||||
|
continue;
|
||||||
|
return iterator;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup flashrom-layout
|
* @addtogroup flashrom-layout
|
||||||
* @{
|
* @{
|
||||||
|
1
layout.h
1
layout.h
@ -65,5 +65,6 @@ const struct flashrom_layout *get_layout(const struct flashrom_flashctx *const f
|
|||||||
|
|
||||||
int process_include_args(struct flashrom_layout *l, const struct layout_include_args *const args);
|
int process_include_args(struct flashrom_layout *l, const struct layout_include_args *const args);
|
||||||
const struct romentry *layout_next_included_region(const struct flashrom_layout *, chipoff_t);
|
const struct romentry *layout_next_included_region(const struct flashrom_layout *, chipoff_t);
|
||||||
|
const struct romentry *layout_next_included(const struct flashrom_layout *, const struct romentry *);
|
||||||
|
|
||||||
#endif /* !__LAYOUT_H__ */
|
#endif /* !__LAYOUT_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user