mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
layout: Hoist get_region_range() into libflashrom API
While using the libflashrom API to read specific regions there is no currently no general way to find the offset into the read buffer of the expected region. flashrom_layout_include_region() probably should have returned the region offset and size if it was included. However to avoid a change in API signature we can instead hoist up get_region_range() into the API to be called after. BUG=b:207808292 TEST=`make` && tested in porting cbfstool use-case. Change-Id: I8cf95b5eaec943a51d0ea668f26a56bf6d6b4446 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/60881 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Sam McNally <sammc@google.com>
This commit is contained in:

committed by
Edward O'Callaghan

parent
00b8e85528
commit
f31bb81de1
35
layout.c
35
layout.c
@ -188,18 +188,6 @@ static int find_romentry(struct flashrom_layout *const l, char *name, char *file
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_region_range(struct flashrom_layout *const l, const char *name,
|
||||
unsigned int *start, unsigned int *len)
|
||||
{
|
||||
const struct romentry *const entry = _layout_entry_by_name(l, name);
|
||||
if (entry) {
|
||||
*start = entry->start;
|
||||
*len = entry->end - entry->start + 1;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* process -i arguments
|
||||
* returns 0 to indicate success, >0 to indicate failure
|
||||
*/
|
||||
@ -444,6 +432,29 @@ int flashrom_layout_include_region(struct flashrom_layout *const layout, const c
|
||||
return include_region(layout, name, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get given region's offset and length.
|
||||
*
|
||||
* @param layout The layout to alter.
|
||||
* @param name The name of the region.
|
||||
* @param start The start address to be written.
|
||||
* @param len The length of the region to be written.
|
||||
*
|
||||
* @return 0 on success,
|
||||
* 1 if the given name can't be found.
|
||||
*/
|
||||
int flashrom_layout_get_region_range(struct flashrom_layout *const l, const char *name,
|
||||
unsigned int *start, unsigned int *len)
|
||||
{
|
||||
const struct romentry *const entry = _layout_entry_by_name(l, name);
|
||||
if (entry) {
|
||||
*start = entry->start;
|
||||
*len = entry->end - entry->start + 1;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free a layout.
|
||||
*
|
||||
|
Reference in New Issue
Block a user