aboutsummaryrefslogtreecommitdiff
path: root/libflash/ffs.h
AgeCommit message (Collapse)AuthorFilesLines
2018-04-09libflash/libffs: Allow caller to specifiy header partitionCyril Bur1-1/+0
An FFS TOC is comprised of two parts. A small header which has a magic and very minimmal information about the TOC which will be common to all partitions, things like number of patritions, block sizes and the like. Following this small header are a series of entries. Importantly there is always an entry which encompases the TOC its self, this is usually called the 'part' partition. Currently libffs always assumes that the 'part' partition is at zero. While there is always a TOC and zero there doesn't actually have to be. PNORs may have multiple TOCs within them, therefore libffs needs to be flexible enough to allow callers to specify TOCs not at zero. The 'part' partition is otherwise a regular partition which may have flags associated with it. libffs should allow the user to set the flags for the 'part' partition. This patch achieves both by allowing the caller to specify the 'part' partition. The caller can not and libffs will provide a sensible default. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09libflash/libffs: Refcount ffs entriesCyril Bur1-0/+2
Currently consumers can add an new ffs entry to multiple headers, this is fine but freeing any of the headers will cause the entry to be freed, this causes double free problems. Even if only one header is uses, the consumer of the library still has a reference to the entry, which they may well reuse at some other point. libffs will now refcount entries and only free when there are no more references. This patch also removes the pointless return value of ffs_hdr_free() Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09libflash/libffs: Switch to storing header entries in an arrayCyril Bur1-3/+5
Since the libffs no longer needs to sort the entries as they get added it makes little sense to have the complexity of a linked list when an array will suffice. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09libflash/libffs: Remove backup partition from TOC generation codeCyril Bur1-2/+0
It turns out this code was messy and not all that reliable. Doing it at the library level adds complexity to the library and restrictions to the caller. A simpler approach can be achived with the just instantiating multiple ffs_header structures pointing to different parts of the same file. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09libflash/libffs: Remove the 'sides' from the FFS TOC generation codeCyril Bur1-2/+0
It turns out this code was messy and not all that reliable. Doing it at the library level adds complexity to the library and restrictions to the caller. A simpler approach can be achived with the just instantiating multiple ffs_header structures pointing to different parts of the same file. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09libffs: Standardise ffs partition flagsCyril Bur1-0/+1
It seems we've developed a character respresentation for ffs partition flags. Currently only pflash really prints them so it hasn't been a problem but now ffspart wants to read them in from user input. It is important that what libffs reads and what pflash prints remain consistent, we should move the code into libffs to avoid problems. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2017-12-13pflash: Support for clean_on_ecc_error flagAdriana Kobylak1-0/+1
Add the misc flag clear_on_ecc_error to libflash/pflash. This was the only missing flag. The generator of the virtual pnor image relies on libflash/pflash to provide the partition information, so all flags are needed to build an accurate virtual pnor partition table. Signed-off-by: Adriana Kobylak <anoo@linux.vnet.ibm.com> Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-11-09pflash: Support for volatile flagAdriana Kobylak1-0/+1
The volatile flag was added to the pnor image to indicate partitions that are cleared during a host power off. Display this flag from the pflash command. Signed-off-by: Adriana Kobylak <anoo@us.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-01libflash/libffs: Don't require 'part' size to be known by callersCyril Bur1-0/+1
Currently the FFS header/TOC generation code requires that consumers know the size of their TOC beforehand. While this may be advantageous in some circumstances if there are known limitations of other software. It should not be a requirement. Knowing the size of the FFS header/TOC partially breaks the abstraction since it would require consumers of the library to be aware of/have some idea of the on flash structure and size. Future work may introduce functions to force sizes but the default behaviour should be to calculate it behind the scenes. This patch also addresses an off by one issue in checking for TOC overflow. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-24libffs: Understand how to create FFS partition TOCs and entries.Cyril Bur1-0/+26
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-24libflash/libffs: Rework libffsCyril Bur1-57/+98
This patch attempts a rework of libffs to prepare it for future changes. Firstly the types are split in two: 1. Packed, big endian structures used to map exactly how the data is on flash. 2. CPU endian, sane valued, not packed structures used to manipulate FFS data. Secondly: The packed struct can use BE types so that in future tools like sparse can be run over the code to check for endian conversion bugs. Thirdly: defines of sizeof(struct ...) were removed for clarity. Finally: For ease of manipulation, the in memory FFS structures contain a linked list of entries as this will make addition and removal operations much easier. This patch should be invisible to consumers of libffs. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-23libffs: Add ffs_entry_user fieldMichael Neuling1-6/+23
This adds the correct user structure to ffs_entry as defined from hostboot. No functional changes. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-07-30libflash: Fix licence header in ffs.hBenjamin Herrenschmidt1-22/+0
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-02Initial commit of Open Source releaseBenjamin Herrenschmidt1-0/+159
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>