From df307e0eecf119a26be838428311199f23e43c69 Mon Sep 17 00:00:00 2001 From: Cyril Bur Date: Tue, 23 Jun 2015 13:22:14 +1000 Subject: libffs: init with ecc protection at blocklevel level Passing a flag on libffs init will register all regions of the flash with ecc (as per the libffs partition information) as being ecc protected (or not). This saves the consumer needing to know or care about the presence of ecc. Reviewed-By: Alistair Popple Signed-off-by: Cyril Bur Signed-off-by: Stewart Smith --- libflash/libffs.c | 14 ++++++++++++-- libflash/libffs.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'libflash') diff --git a/libflash/libffs.c b/libflash/libffs.c index c03c56a..f4aafd8 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -73,12 +73,12 @@ static int ffs_check_convert_header(struct ffs_hdr *dst, struct ffs_hdr *src) } int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl, - struct ffs_handle **ffs) + struct ffs_handle **ffs, int mark_ecc) { struct ffs_hdr hdr; struct ffs_handle *f; uint32_t total_size; - int rc; + int rc, i; if (!ffs || !bl) return FLASH_ERR_PARM_ERROR; @@ -140,6 +140,16 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl, goto out; } + if (mark_ecc) { + uint32_t start, total_size; + bool ecc; + for (i = 0; i < f->hdr.entry_count; i++) { + ffs_part_info(f, i, NULL, &start, &total_size, NULL, &ecc); + if (ecc) + blocklevel_ecc_protect(bl, start, total_size); + } + } + out: if (rc == 0) *ffs = f; diff --git a/libflash/libffs.h b/libflash/libffs.h index a0040e9..ddf3793 100644 --- a/libflash/libffs.h +++ b/libflash/libffs.h @@ -38,7 +38,7 @@ struct ffs_handle; /* Init */ int ffs_init(uint32_t offset, uint32_t max_size, - struct blocklevel_device *bl, struct ffs_handle **ffs); + struct blocklevel_device *bl, struct ffs_handle **ffs, int mark_ecc); /* ffs_open_image is Linux only as it uses lseek, which skiboot does not * implement */ -- cgit v1.1