diff options
author | Michael Tritz <mtritz@us.ibm.com> | 2017-07-12 15:31:49 -0500 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-07-19 15:49:39 +1000 |
commit | f2c87a3d2f6df0886124636239d9950ef0abcab0 (patch) | |
tree | f696ffe06dc199d5f339f9a0e14ba034002a27f9 /libflash | |
parent | eae86789c72e61288514eace206588d9d1633a25 (diff) | |
download | skiboot-f2c87a3d2f6df0886124636239d9950ef0abcab0.zip skiboot-f2c87a3d2f6df0886124636239d9950ef0abcab0.tar.gz skiboot-f2c87a3d2f6df0886124636239d9950ef0abcab0.tar.bz2 |
pflash option to retrieve PNOR partition flags
This commit extends pflash with an option to retrieve and print
information for a particular partition, including the content from
"pflash -i" and a verbose list of set miscellaneous flags. -i option
is also updated to print a short list of flags in addition to the
ECC flag, with one character per flag. A test of the new option is
included in libflash/test.
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
[stewart@linux.vnet.ibm.com: various test fixes, enable gcov]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash')
-rw-r--r-- | libflash/libffs.c | 11 | ||||
-rw-r--r-- | libflash/libffs.h | 4 | ||||
-rw-r--r-- | libflash/test/Makefile.check | 7 | ||||
-rw-r--r-- | libflash/test/test-miscprint.pnor | bin | 0 -> 3072 bytes | |||
-rwxr-xr-x | libflash/test/test-miscprint.sh | 27 |
5 files changed, 44 insertions, 5 deletions
diff --git a/libflash/libffs.c b/libflash/libffs.c index 9b940ec..754245f 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -188,7 +188,12 @@ static int ffs_entry_to_cpu(struct ffs_hdr *hdr, return rc; } -static struct ffs_entry *ffs_get_part(struct ffs_handle *ffs, uint32_t index) +bool has_flag(struct ffs_entry *ent, uint16_t flag) +{ + return ((ent->user.miscflags & flag) != 0); +} + +struct ffs_entry *ffs_entry_get(struct ffs_handle *ffs, uint32_t index) { int i = 0; struct ffs_entry *ent = NULL; @@ -379,7 +384,7 @@ int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx, struct ffs_entry *ent; char *n; - ent = ffs_get_part(ffs, part_idx); + ent = ffs_entry_get(ffs, part_idx); if (!ent) return FFS_ERR_PART_NOT_FOUND; @@ -794,7 +799,7 @@ int ffs_update_act_size(struct ffs_handle *ffs, uint32_t part_idx, uint32_t offset; int rc; - ent = ffs_get_part(ffs, part_idx); + ent = ffs_entry_get(ffs, part_idx); if (!ent) { FL_DBG("FFS: Entry not found\n"); return FFS_ERR_PART_NOT_FOUND; diff --git a/libflash/libffs.h b/libflash/libffs.h index 2c1fbd8..a86c698 100644 --- a/libflash/libffs.h +++ b/libflash/libffs.h @@ -92,6 +92,8 @@ struct ffs_entry_user { bool has_ecc(struct ffs_entry *ent); +bool has_flag(struct ffs_entry *ent, uint16_t flag); + /* Init */ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl, @@ -126,6 +128,8 @@ int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx, char **name, uint32_t *start, uint32_t *total_size, uint32_t *act_size, bool *ecc); +struct ffs_entry *ffs_entry_get(struct ffs_handle *ffs, uint32_t index); + int ffs_update_act_size(struct ffs_handle *ffs, uint32_t part_idx, uint32_t act_size); diff --git a/libflash/test/Makefile.check b/libflash/test/Makefile.check index 1f92b9d..344cad0 100644 --- a/libflash/test/Makefile.check +++ b/libflash/test/Makefile.check @@ -4,8 +4,8 @@ LIBFLASH_TEST := libflash/test/test-flash libflash/test/test-ecc libflash/test/t LCOV_EXCLUDE += $(LIBFLASH_TEST:%=%.c) .PHONY : libflash-check libc-coverage -libflash-check: $(LIBFLASH_TEST:%=%-check) $(CORE_TEST:%=%-gcov-run) -libflash-coverage: $(LIBFLASH_TEST:%=%-gcov-run) +libflash-check: $(LIBFLASH_TEST:%=%-check) libflash/test/test-miscprint $(CORE_TEST:%=%-gcov-run) +libflash-coverage: $(LIBFLASH_TEST:%=%-gcov-run) libflash/test/test-miscprint check: libflash-check libc-coverage coverage: libflash-coverage @@ -16,6 +16,9 @@ $(LIBFLASH_TEST:%=%-gcov-run) : %-run: % $(LIBFLASH_TEST:%=%-check) : %-check: % $(call QTEST, RUN-TEST ,$(VALGRIND) $<, $<) +libflash/test/test-miscprint: pflash + $(call Q, RUN-TEST , ./libflash/test/test-miscprint.sh, $@) + libflash/test/stubs.o: libflash/test/stubs.c $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -g -c -o $@ $<, $<) diff --git a/libflash/test/test-miscprint.pnor b/libflash/test/test-miscprint.pnor Binary files differnew file mode 100644 index 0000000..8a84eba --- /dev/null +++ b/libflash/test/test-miscprint.pnor diff --git a/libflash/test/test-miscprint.sh b/libflash/test/test-miscprint.sh new file mode 100755 index 0000000..b84a6cf --- /dev/null +++ b/libflash/test/test-miscprint.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# test-miscprint.pnor is constructed as follows: +# PRESERVED,0x00000300,0x00000100,P,/dev/zero +# READONLY,0x00000400,0x00000100,R,/dev/zero +# REPROVISION,0x00000500,0x00000100,F,/dev/zero +# BACKUP,0x00000600,0x00000100,B,/dev/zero + +wd="libflash/test" +pflash="./external/pflash/pflash" + +pnor="$wd/test-miscprint.pnor" + +output1=$(${pflash} --detail=1 -F "$pnor" | grep "\[P\]") +output2=$(${pflash} --detail=2 -F "$pnor" | grep "\[R\]") +output3=$(${pflash} --detail=3 -F "$pnor" | grep "\[F\]") +output4=$(${pflash} --detail=4 -F "$pnor" | grep "\[B\]") + +if [[ $output1 == "PRESERVED [P]" && $output2 == "READONLY [R]" && + $output3 == "REPROVISION [F]" && $output4 == "BACKUP [B]" ]]; then + echo "Test passed!" + exit 0; +else + echo "Test failed!" + exit 1; +fi + |