mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
layout: Factor out flash_region structure from romentry
The romentry structure is the container ADT with some annotated meta-data such as 'included' or 'file' however the substantive substructure is a 'flash_region'. Therefore factor this out. That is to say, the link list node 'romentry' is obscured by the implementation details of its use-case of 'flash_region' that we clear up here. BUG=b:260440773 BRANCH=none TEST=flashrom_tester Change-Id: I768742b73db901df5b5208fcbcb8a324a06014c2 CoAuthored-by: Nikolai Artemiev <nartemiev@google.com> Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/69196 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
77fe266307
commit
66655b7423
22
flashrom.c
22
flashrom.c
@ -1029,8 +1029,9 @@ static int read_by_layout(struct flashctx *const flashctx, uint8_t *const buffer
|
||||
const struct romentry *entry = NULL;
|
||||
|
||||
while ((entry = layout_next_included(layout, entry))) {
|
||||
const chipoff_t region_start = entry->start;
|
||||
const chipsize_t region_len = entry->end - entry->start + 1;
|
||||
const struct flash_region *region = &entry->region;
|
||||
const chipoff_t region_start = region->start;
|
||||
const chipsize_t region_len = region->end - region->start + 1;
|
||||
|
||||
if (read_flash(flashctx, buffer + region_start, region_start, region_len))
|
||||
return 1;
|
||||
@ -1191,8 +1192,9 @@ static int walk_by_layout(struct flashctx *const flashctx, struct walk_info *con
|
||||
msg_cinfo("Erasing and writing flash chip... ");
|
||||
|
||||
while ((entry = layout_next_included(layout, entry))) {
|
||||
info->region_start = entry->start;
|
||||
info->region_end = entry->end;
|
||||
const struct flash_region *region = &entry->region;
|
||||
info->region_start = region->start;
|
||||
info->region_end = region->end;
|
||||
|
||||
size_t j;
|
||||
int error = 1; /* retry as long as it's 1 */
|
||||
@ -1467,8 +1469,9 @@ static int verify_by_layout(
|
||||
const struct romentry *entry = NULL;
|
||||
|
||||
while ((entry = layout_next_included(layout, entry))) {
|
||||
const chipoff_t region_start = entry->start;
|
||||
const chipsize_t region_len = entry->end - entry->start + 1;
|
||||
const struct flash_region *region = &entry->region;
|
||||
const chipoff_t region_start = region->start;
|
||||
const chipsize_t region_len = region->end - region->start + 1;
|
||||
|
||||
if (read_flash(flashctx, curcontents + region_start, region_start, region_len))
|
||||
return 1;
|
||||
@ -1807,12 +1810,13 @@ static void combine_image_by_layout(const struct flashctx *const flashctx,
|
||||
chipoff_t start = 0;
|
||||
|
||||
while ((included = layout_next_included_region(layout, start))) {
|
||||
if (included->start > start) {
|
||||
const struct flash_region *region = &included->region;
|
||||
if (region->start > start) {
|
||||
/* copy everything up to the start of this included region */
|
||||
memcpy(newcontents + start, oldcontents + start, included->start - start);
|
||||
memcpy(newcontents + start, oldcontents + start, region->start - start);
|
||||
}
|
||||
/* skip this included region */
|
||||
start = included->end + 1;
|
||||
start = region->end + 1;
|
||||
if (start == 0)
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user