Introduce action_descriptor to aid in speeding up operations
The vast majority of the modern flash chips are logically organized as
unions of arrays of blocks of several different sizes. Each size is a
flash erase granularity, controlled by the command given to the chip.
Erase operation takes a fairly long time, and the smaller the block,
the slower the operation is when expressed by amount of flash erased
per unit of time.
This is why from the operation duration point of view it is beneficial
to erase a larger block if a certain amount of smaller blocks in the
same address range need to be erased, even if some extra write would
be required to restore smaller blocks which did not have to be erased.
This patch introduces a module which compares old (existing) and new
(required) flash contents and based on the differences creates an
array of actions to be taken to bring the flash chip to new contents.
Actions are processing units of the following structure:
struct processing_unit {
size_t block_size; /* Block size granularity of this unit. */
size_t offset; /* Offset of the first block into the flash. */
size_t num_blocks; /* Number of consecutive blocks. */
int block_eraser_index; /* Index into 'block_erasers'. */
int block_region_index; /* Index into 'eraseblocks'. */
};
This unit references the flash erase operation which needs to be used
for erasing of blocks of this size. When processing the description,
the program would iterate over the array of units, erasing and
programming blocks as required.
A test is also being added, along with a target in the Makefile, this
could be extended further and executed during build.
BRANCH=none
BUG=b:79492818
TEST=verified programming and erasing when combined with the rest of
flashrom utility changes.
Also verified that ./falshrom-test succeeds:
# make test
[...]
./flashrom-test
test_one_erase test 1...passed
test_one_erase test 2...passed
test_one_erase test 3...passed
test_one_erase test 4...passed
test_one_erase test 5...passed
test_one_erase test 6...passed
Test assorted sizes...passed
Success!
Change-Id: I61fdca7be282c81461e7eb2adea67226a54c4502
Signed-off-by: Vadim Bendebury <[email protected]>
Reviewed-on: https://chromium-review.googlesource.com/1060121
5 files changed