Support -i partition:file feature for both read and write.
This is actually 2 steps:
1. support partial read, which is like partial write we already supported.
2. support <file> optional parameter for -i <image>. This is super convenient
for flashrom clients when they only need to read/write partial flash.
They no longer need to prepare the whole flash content. Just prepare
fragmented files, and specify partition names for each.
Stefan and Hungte, this is FYI. But still welcome your comments.
TEST=run the following commands on Mario:
cat > l
time flashrom -r /tmp/bios
time flashrom -l l -i LOG:log -i RO -i RO2:ro2 -i BV:bv -r /tmp/bios2
# Partial read should be much faster than whole read (around 0.7 seconds).
# File log should contain 256 bytes, and content are like "$LOG" FF FF ...
# File ro2 may contain Mario's VPD 1.0 data.
# File bv should contain boot vector of BIOS, which is 0F 09 E9 6B ... FC FF.
# File bios2 should only contain LOG, RO, RO2, and BV. Rest regions should be 0xFF.
time flashrom -l l -i RO:log -i RO2:bv -w /tmp/bios2
# Would take around 10 seconds (for 2 whole reads and 1 partial write).
time flashrom -l l -i RO:ro_ -i RO2:ro2_ -r /tmp/bios3
# Should be very quick.
# File ro_ should contain log (if RO originally is blank).
# First 16-byte of file ro2_ should contain bv. Rest are original ro2.
# File bios3 should only contain ro_ and ro2_. Rest are all 0xFF.