aboutsummaryrefslogtreecommitdiff
path: root/external/ffspart
AgeCommit message (Collapse)AuthorFilesLines
2020-08-28external/ffspart: define $(sbindir) for MakefileDan Horák1-0/+3
Right now the $(sbindir) variable isn't defined, so the binary gets installed directly into $(DESTDIR). Signed-off-by: Dan Horák <dan@danny.cz> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2020-06-11external/ffspart: Use read() rather than mmap()Oliver O'Halloran1-8/+34
The various ffspart test cases use /dev/zero as an input which doesn't behave like a normal file. The stat.st_size field for char devs is generally zero so the subsequent attempt to mmap() the file fails because we requested a zero size mapping. Previously we didn't notice this, but it sort of worked since the partitions in the test script that used /dev/zero as an input were also had those partitions marked as ECC. This resulted in the partition contents being re-generated (using a buffer libflash allocates) and the source data pointer being ignored since we said it was zero length. Fix all this by dropping mmap() entirely and inhale the input file into a buffer we malloc() instead. This works for any file, including /dev/urandom, which can't be mmap()ed. Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2020-03-12Re-license IBM written files as Apache 2.0 OR GPLv2+Stewart Smith4-4/+4
SPDX makes it a simpler diff. I have audited the commit history of each file to ensure that they are exclusively authored by IBM and thus we have the right to relicense. The motivation behind this is twofold: 1) We want to enable experiments with coreboot, which is GPLv2 licensed 2) An upcoming firmware component wants to incorporate code from skiboot and code from the Linux kernel, which is GPLv2 licensed. I have gone through the IBM internal way of gaining approval for this. The following files are not exclusively authored by IBM, so are *not* included in this update (I will be seeking approval from contributors): core/direct-controls.c core/flash.c core/pcie-slot.c external/common/arch_flash_unknown.c external/common/rules.mk external/gard/Makefile external/gard/rules.mk external/opal-prd/Makefile external/pflash/Makefile external/xscom-utils/Makefile hdata/vpd.c hw/dts.c hw/ipmi/ipmi-watchdog.c hw/phb4.c include/cpu.h include/phb4.h include/platform.h libflash/libffs.c libstb/mbedtls/sha512.c libstb/mbedtls/sha512.h platforms/astbmc/barreleye.c platforms/astbmc/garrison.c platforms/astbmc/mihawk.c platforms/astbmc/nicole.c platforms/astbmc/p8dnu.c platforms/astbmc/p8dtu.c platforms/astbmc/p9dsu.c platforms/astbmc/vesnin.c platforms/rhesus/ec/config.h platforms/rhesus/ec/gpio.h platforms/rhesus/gpio.c platforms/rhesus/rhesus.c platforms/astbmc/talos.c platforms/astbmc/romulus.c Signed-off-by: Stewart Smith <stewart@linux.ibm.com> [oliver: fixed up the drift] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2019-07-26SPDX-ify all skiboot codeStewart Smith4-14/+12
Use Software Package Data Exchange (SPDX) to indicate license for each file that is unique to skiboot. At the same time, ensure the (C) who and years are correct. See https://spdx.org/ Signed-off-by: Stewart Smith <stewart@linux.ibm.com> [oliver: Added a few missing files] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2019-02-21ffspart, libflash: Fix stack size warningsAndrew Jeffery1-1/+3
libflash/file.c: In function 'file_erase': libflash/file.c:134:1: error: the frame size of 4128 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] } ^ and ffspart.c: In function ‘main’: ffspart.c:529:1: error: the frame size of 4864 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] } ^ In both cases, mark the local variables as static to avoid the stack. The static approach is valid for file.c as the buffer is always filled with `~0`. Given it's now going to be in .bss due to static we have to still perform the memset(), but racing memset()s in this fashion won't be harmful, just wasteful. For ffspart.c's main(), there are bigger problems if that needs to be re-entrant. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-12-11ffspart: Support flashing already ECC protected imagesStewart Smith5-5/+17
We do this by assuming filenames with '.ecc' in them are already ECC protected. This solves a practical problem in transitioning op-build to use ffspart for pnor assembly rather than three perl scripts and a lot of XML. We also update the ffspart tests to take into account ECC requirements. Signed-off-by: Stewart Smith <stewart@linux.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-12-11ffspart: Increase MAX_LINE to above PATH_MAXStewart Smith1-1/+1
Otherwise we saw failures in CI and the ~221 character paths Jankins likes to have. Signed-off-by: Stewart Smith <stewart@linux.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-11-28ffspart: Add test for eraseblock sizeJoel Stanley2-0/+47
This test checks that the partitions are correctly laid out when the eraseblock size is greater than the start of the first partition. Currently ffspart fails to create a valid image in this case. There are two tests. The second is expected to fail but it is marked as passing for now. This test requires pflash to work. Currently we leave that as an exercise for the user. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-11-28ffspart: Add toc testJoel Stanley3-0/+20
This test specifies a toc in the configuration file. There are no tests or documentation for the toc syntax, so this exists to describe how specify a toc. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-06-01ffspart: Don't require user to create blank partitions manuallySamuel Mendoza-Jonas7-11/+64
Add '--allow-empty' which allows the filename for a given partition to be blank. If set ffspart will set that part of the PNOR file 'blank' and set ECC bits if required. Without this option behaviour is unchanged and ffspart will return an error if it can not find the partition file. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09external/ffspart: Improve error outputCyril Bur1-2/+2
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09external/ffspart: Use new interfaceCyril Bur52-370/+452
This also updated the pflash tests which use ffspart to generate pnors Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-09libflash/libffs: Allow caller to specifiy header partitionCyril Bur1-1/+1
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-1/+1
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 Bur10-10/+0
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 the 'sides' from the FFS TOC generation codeCyril Bur1-1/+1
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-09external/ffspart: Remove side, order and backup optionsCyril Bur6-90/+24
These options are currently flakey in libflash/libffs so there isn't much point to being able to use them in ffspart. Future reworks planned for libflash/libffs will render these options redundant anyway. 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 Bur4-5/+5
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>
2018-04-09external/ffspart: Allow # comments in input fileCyril Bur1-0/+4
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/+3
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/+3
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-01external: Consolidate Makefile.check for external toolsCyril Bur1-20/+0
The reason for this is that check targets for one tool will start to depend on other tools. For example, future pflash tests will rely on ffspart to generate pnors. The current method is too racey and results in races cleaning/building ffspart for its tests and for pflash tests. 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-08-01libflash/libffs: Don't require 'part' size to be known by callersCyril Bur10-22/+15
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-08-01external/ffspart: Add .gitignoreCyril Bur1-0/+7
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-24external/ffspart: Add testsCyril Bur66-0/+440
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-24external/ffspart: Simple C program to be able to make an FFS partitionCyril Bur4-0/+527
A typical input file to generate something that current op-build would create: HBI,0x00010000,0x05a0000,EV,./bins/HBI.bin MVPD,0x05b0000,0x0090000,EF,./bins/MVPD.bin CVPD,0x0640000,0x0048000,EF,./bins/CVPD.bin DJVPD,0x688000,0x0048000,EF,./bins/DJVPD.bin HBD,0x006d0000,0x0060000,E,./bins/HBD.bin SBEC,0x0730000,0x0090000,EI,./bins/SBEC.bin SBE,0x007c0000,0x0048000,EI,./bins/SBE.bin ATTR_TMP,0x808000,0x8000,F,./bins/ATTR_TMP.bin ATTR_PERM,0x810000,0x8000,EF,./bins/ATTR_PERM.bin WINK,0x00818000,0x0120000,EV,./bins/WINK.bin GUARD,0x00938000,0x005000,EPF,./bins/GUARD.bin HBEL,0x0093d000,0x0024000,EF,./bins/HBEL.bin PAYLOAD,0x961000,0x100000,,./bins/skiboot.lid BOOTKERNEL,0xa61000,0xf00000,,./bins/petitboot.zImage NVRAM,0x01961000,0x90000,EPF,./bins/NVRAM.bin HBRT,0x019f1000,0x360000,EV,./bins/HBRT.bin OCC,0x001d51000,0x120000,E,./bins/OCC.bin FIRDATA,0x1e71000,0x3000,EF,./bins/FIRDATA.bin CAPP,0x001e74000,0x24000,E,./bins/CAPP.bin HBB,0x0001f67000,0x90000,EV,./bins/HBB.bin VERSION,0x1ff7000,0x1000,,./bins/VERSION2.bin Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>