Add a -x option to extract regions from a flash image

The -i option combined with -r allows reading a particular region from
a flash image. It is sometimes convenient to be able to read out all images.
Add a -x option to do this. The resulting files are named after their region
names in the image.

BUG=chromium:256912
BRANCH=none
TEST=manual

sudo flashrom -p dummy:emulate=VARIABLE_SIZE,size=auto,image=/build/peach_pit \
/firmware/image-peach-pit.bin -x --ignore-lock

See that a collection of files appears in the currect directly.

Use:

gbb_utility --rootkey=rootkey.bin GBB

to check that the GBB looks correct.

Change-Id: I8e942c312467ae77dff04be415fb4d213b0f17c4
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60861
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
diff --git a/flash.h b/flash.h
index e4de7c0..a631e2e 100644
--- a/flash.h
+++ b/flash.h
@@ -240,7 +240,9 @@
 void print_banner(void);
 void list_programmers_linebreak(int startcol, int cols, int paren);
 int selfcheck(void);
-int doit(struct flashchip *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it, const char *diff_file);
+int doit(struct flashchip *flash, int force, const char *filename, int read_it,
+	 int write_it, int erase_it, int verify_it, int extract_it,
+	 const char *diff_file);
 int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename);
 int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filename);