mirror of
https://review.coreboot.org/flashrom.git
synced 2025-05-13 14:50:59 +02:00
flashrom.c:Add a function to get list of sectors that need erasing
Add a function that returns a list of sectors (as seen by the first erase function) that need erasing. Change-Id: Ic57ca1cca3d1646543f6b5939ba9c35db8d08256 Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com>
This commit is contained in:
parent
26e98f6f06
commit
bcb4f037d8
36
flashrom.c
36
flashrom.c
@ -1036,6 +1036,42 @@ void align_region(const struct erase_layout *layout, struct flashctx *const flas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void select_erase_functions(const struct erase_layout *layout, size_t function_index, size_t block_num, struct flashctx *flashctx, void *curcontents, void *newcontents, chipoff_t region_start, chipoff_t region_end);
|
||||||
|
|
||||||
|
void select_erase_functions(const struct erase_layout *layout, size_t function_index, size_t block_num, struct flashctx *flashctx, void *curcontents, void *newcontents, chipoff_t region_start, chipoff_t region_end)
|
||||||
|
{
|
||||||
|
if (function_index == 0)
|
||||||
|
{
|
||||||
|
if (layout[function_index].layout_list[block_num].start_addr >= region_start &&
|
||||||
|
layout[function_index].layout_list[block_num].end_addr <= region_end) {
|
||||||
|
chipoff_t start_addr = layout[function_index].layout_list[block_num].start_addr;
|
||||||
|
chipoff_t end_addr = layout[function_index].layout_list[block_num].end_addr;
|
||||||
|
const chipsize_t erase_len = end_addr - start_addr + 1;
|
||||||
|
const uint8_t erased_value = ERASED_VALUE(flashctx);
|
||||||
|
layout[function_index].layout_list[block_num].selected = need_erase(curcontents + start_addr, newcontents + start_addr, erase_len, flashctx->chip->gran, erased_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int count = 0;
|
||||||
|
int sub_block_start = layout[function_index].layout_list[block_num].first_sub_block_index;
|
||||||
|
int sub_block_end = layout[function_index].layout_list[block_num].last_sub_block_index;
|
||||||
|
|
||||||
|
for(int j = sub_block_start; j <= sub_block_end; j++) {
|
||||||
|
select_erase_functions(layout, function_index - 1, j, flashctx, curcontents, newcontents, region_start, region_end);
|
||||||
|
if (layout[function_index - 1].layout_list[j].selected)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (count && count > (sub_block_end - sub_block_start + 1)/2) {
|
||||||
|
if (layout[function_index].layout_list[block_num].start_addr >= region_start &&
|
||||||
|
layout[function_index].layout_list[block_num].end_addr <= region_end) {
|
||||||
|
for (int j = sub_block_start; j <= sub_block_end; j++)
|
||||||
|
layout[function_index - 1].layout_list[j].selected = false;
|
||||||
|
layout[function_index].layout_list[block_num].selected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int walk_by_layout(struct flashctx *const flashctx, struct walk_info *const info,
|
static int walk_by_layout(struct flashctx *const flashctx, struct walk_info *const info,
|
||||||
const per_blockfn_t per_blockfn)
|
const per_blockfn_t per_blockfn)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user