diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2015-05-22 15:30:17 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-01 17:25:14 +1000 |
commit | 4a590ac0f2602830a73409e714f32de0354b634d (patch) | |
tree | 909d7c1227e2bc38371f20c28314ff45945cf402 /external | |
parent | 40d4a311a6e969251076f8295fb404ae21d6b863 (diff) | |
download | skiboot-4a590ac0f2602830a73409e714f32de0354b634d.zip skiboot-4a590ac0f2602830a73409e714f32de0354b634d.tar.gz skiboot-4a590ac0f2602830a73409e714f32de0354b634d.tar.bz2 |
external/pflash: Allow the libffs TOC to operate on to be specified
On systems with multiple TOCs it may be useful to be able to specify which
one should be operated on.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-By: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/pflash/pflash.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index 6d85f93..0722bc6 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -118,7 +118,7 @@ static void print_ffs_info(uint32_t toc_offset) } -static void print_flash_info(void) +static void print_flash_info(uint32_t toc) { printf("Flash info:\n"); printf("-----------\n"); @@ -129,7 +129,7 @@ static void print_flash_info(void) if (bmc_flash) return; - print_ffs_info(0); + print_ffs_info(toc); } static int open_partition(const char *name) @@ -550,6 +550,9 @@ static void print_help(const char *pname) printf("\t\t(Implicit for all other operations)\n\n"); printf("\t-S, --side\n"); printf("\t\tSide of the flash on which to operate, 0 (default) or 1\n\n"); + printf("\t-T, --toc\n"); + printf("\t\tlibffs TOC on which to operate, defaults to 0.\n"); + printf("\t\tleading 0x is required for interpretation of a hex value\n\n"); printf("\t-i, --info\n"); printf("\t\tDisplay some information about the flash.\n\n"); printf("\t-h, --help\n"); @@ -568,6 +571,7 @@ int main(int argc, char *argv[]) bool has_sfc = false, has_ast = false; bool no_action = false, tune = false; char *write_file = NULL, *read_file = NULL, *part_name = NULL; + bool ffs_toc_seen = false; int rc; while(1) { @@ -591,10 +595,11 @@ int main(int argc, char *argv[]) {"version", no_argument, NULL, 'v'}, {"debug", no_argument, NULL, 'g'}, {"side", required_argument, NULL, 'S'}, + {"toc", required_argument, NULL, 'T'}, }; int c, oidx = 0; - c = getopt_long(argc, argv, "a:s:P:r:43Eep:fdihlvbtgS:", + c = getopt_long(argc, argv, "a:s:P:r:43Eep:fdihlvbtgS:T:", long_opts, &oidx); if (c == EOF) break; @@ -659,6 +664,10 @@ int main(int argc, char *argv[]) case 'S': flash_side = atoi(optarg); break; + case 'T': + ffs_toc_seen = true; + ffs_toc = strtoul(optarg, NULL, 0); + break; default: exit(1); } @@ -732,6 +741,11 @@ int main(int argc, char *argv[]) exit(1); } + if (ffs_toc_seen && flash_side) { + fprintf(stderr, "--toc and --side are exclusive"); + exit(1); + } + /* If file specified but not size, get size from file */ if (write_file && !write_size) { @@ -842,8 +856,14 @@ int main(int argc, char *argv[]) enable_4B_addresses(); if (disable_4B) disable_4B_addresses(); - if (info) - print_flash_info(); + if (info ) { + /* + * Don't pass through modfied TOC value if the modification was done + * because of --size, but still respect if it came from --toc (we + * assume the user knows what they're doing in that case) + */ + print_flash_info(flash_side ? 0 : ffs_toc); + } if (do_read) do_read_file(read_file, address, read_size); if (erase_all) |