[Skiboot] [RFC] Surgery on libflash/libffs

Cyril Bur cyril.bur at au1.ibm.com
Wed Apr 8 11:19:06 AEST 2015


The uses of libflash and libffs have outgrown what they currently are capable
of providing which has lead to a number of hacky workarounds.

Libffs' should simply be to parse ffs partition information within 'data'. It
does this well but as it is coupled so tightly with libflash it becomes
difficult if this data is elsewhere than somewhere libflash is comfortable
reading.

Libflash was designed provide read/write/erase accessors to a variety of flash
hardware and it works fine. Unfortunately there have been some modifications
done to libflash simply so libffs can be used on the data, none if these
solutions are ultimately great.

What Alistair and I propose are some highlevel operations. The accessing of
the data can be abstracted away and a consistent interface can be presented
regardless of where it really is.

Instead of having the current:
+-----------------+    +------------------+
| Libflash/libffs | -> | ?flash?  backend |-> ?data?
+-----------------+    +------------------+

Where we change the libflash backend and massage different things into an
interface designed to as flash hardware ops.

We can do something like:
+--------+    +--------------+    +----------+    +---------+
| libffs | -> | highlevel op | -> | libflash | -> | backend | -> flash hardware
+--------+    +--------------+    +----------+    +---------+

and with a bit of work to the current file_flash.c
+--------+    +--------------+    +-----------+    +------+
| libffs | -> | highlevel op | -> | ?libfile? | -> | libc | -> file.bin
+--------+    +--------------+    +-----------+    +------+

These highlevel ops aren't tied to libffs, they can be used for any access to
the data.

Intermediary accessors will provide a nice way of having a software
fallback for things that may be dealt with in hardware. Examples of this
include ECC and write protection.

I have specifically left out moving the ECC code out of libflash for this
patch to avoid growing this patch too much, but subsequent work would move ECC
out of there so that it wouldn't need to be duplicated for each provider of
highevel ops.

This patch is rough and will likely need more work but comments would be
greatly appreciated.

Cyril Bur (1):
  libflash/libffs: decouple libflash and libffs.

 core/flash.c                 | 34 ++++++++++--------
 external/pflash/Makefile     |  2 +-
 external/pflash/ast.h        |  1 +
 external/pflash/pflash.c     | 33 +++++++++---------
 libflash/highlevel.c         | 51 +++++++++++++++++++++++++++
 libflash/highlevel.h         | 38 ++++++++++++++++++++
 libflash/libffs.c            | 51 +++++++++++----------------
 libflash/libffs.h            |  7 ++--
 libflash/libflash.c          | 83 +++++++++++++++++++++++++++-----------------
 libflash/libflash.h          | 25 +++++--------
 libflash/test/Makefile.check |  1 +
 libflash/test/test-flash.c   | 20 +++++------
 platforms/astbmc/pnor.c      | 12 ++++---
 platforms/rhesus/rhesus.c    | 10 +++---
 14 files changed, 235 insertions(+), 133 deletions(-)
 create mode 100644 libflash/highlevel.c
 create mode 100644 libflash/highlevel.h

-- 
1.9.1



More information about the Skiboot mailing list