summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/malloc'Sascha Hauer2018-11-091-1/+5
|\
| * libfile: Error out if out of memory in read_file_2()Andrey Smirnov2018-10-161-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All other error cases in read_file_2() are handled gracefully, so there shouldn't be any reason not do so for the case of trying to allocate too much memory. This error path can be easily triggered with: barebox_update file-bigger-than-availible-ram.img Currently this would result in a crash which is not really desirable from user experience. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2018-11-093-0/+90
|\ \
| * | lib: Port CRC8 implementation from Linux kernelAndrey Smirnov2018-11-063-0/+90
| |/ | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / lib: Port kstrtox.c from Linux kernelAndrey Smirnov2018-10-293-0/+376
|/ | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubifs'Sascha Hauer2018-10-091-0/+15
|\
| * vsprintf: implement %pVSascha Hauer2018-10-081-0/+15
| | | | | | | | | | | | | | %pV allows to pass in a struct va_format as a pointer. UBIFS uses this for its logging functions, but it may be useful in other places aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | kfifo: roundup fifo size to next power of twoSascha Hauer2018-09-211-0/+10
|/ | | | | | | | | | | Comments in include/kfifo.h state that the FIFO size will be rounded up to the next power of two, but so far we haven't actually done this, probably because we didn't have roundup_pow_of_two() back then when kfifo support was added. Fix that now and do what the comments state. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2018-09-111-2/+4
|\
| * ratp: fix sending data that won't fit in a single RATP packetAleksander Morgado2018-08-311-2/+4
| | | | | | | | | | | | | | | | We need to advance the input buffer used to create messages when the data doesn't fit in a single RATP packet. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | libfile: Introduce pwrite_full()Andrey Smirnov2018-08-311-0/+24
|/ | | | | | | | | | Analogous to what we have with write()/write_full(), introduce a lightweight wrapper around pwrite() that guarantees the either all data is going to be written or a negative error code would be returned. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* libfile: open_and_lseek: enlarge small files enough to make lseek possibleUwe Kleine-König2018-08-101-0/+18
| | | | | | | | | | | | | | | | | This makes the following do the expected thing: barebox@barebox sandbox:/ ls -l lala -rwxrwxrwx 4 lala barebox@barebox sandbox:/ mw -d lala 72 0 Without this patch mw dies with lseek: Invalid argument memset, memcpy and probably others benefit in the same way. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* libfile: open_and_lseek: don't imply O_RDONLYUwe Kleine-König2018-08-101-1/+1
| | | | | | | | | | There are several users that pass O_RDWR or O_WRONLY in mode to open_and_lseek() and use the resulting file descriptor for writing. This is no real issue becauce O_RDONLY is 0 and so can be dropped without any side effects. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cmdlinepart: Allow empty stringSascha Hauer2018-07-091-0/+3
| | | | | | | | | | | | Currently when cmdlinepart_do_parse() is called with an empty partitions string then an unnamed partition with size 0 is created. This is wrong of course and instead no partition should be created. With this barebox no longer crashes while booting when all partitions are deleted on the commandline using "nand0.partitions=" Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: Add shared copies of some GCC library routinesAntony Pavlov2018-06-295-0/+151
| | | | | | | | | | | | | | | | | | | This commit is based on these linux kernel commits: | commit b35cd9884fa5d81c9d5e7f57c9d03264ae2bd835 | Author: Palmer Dabbelt <palmer@dabbelt.com> | Date: Tue May 23 10:28:26 2017 -0700 | | lib: Add shared copies of some GCC library routines | | commit e3d5980568fdf83c15a5a3c8ddca1590551ab7a2 | Author: Matt Redfearn <matt.redfearn@mips.com> | Date: Wed Apr 11 08:50:17 2018 +0100 | | lib: Rename compiler intrinsic selects to GENERIC_LIB_* Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mvebu'Sascha Hauer2018-06-111-0/+33
|\
| * libfile: implement new helper write_file_flash()Uwe Kleine-König2018-06-081-0/+33
| | | | | | | | | | | | | | | | Compared to write_file() this new function also calls erase() to be suitable for flash devices. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: lib64: Make string functions aware of MMU configurationAndrey Smirnov2018-06-111-6/+12
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimized version of memset() in memset.S if called as: memset(foo, 0, size) will try to explicitly zero out data cache with: dc zva, dst which will result in Alignement Exception (DABT) if MMU is not enabled. For more info see: - C4.4.8 "DC ZVA, Data Cache Zero by VA" - D5.2.8 "The effects of disabling a stage of address translation" in "ARM Architecture Reference Manual. ARMv8, for ARMv8-A architecture profile" In similar vein, using optimized version of memcpy() could lead to a unaligned 16-byte write (using 'stp'), which is not allowed for Device-nGnRnE type of memory (see D5.2.8) and would liead to Alignement Exception. To fix both problems expose non-optimized and optimzied versions of the function and created a wrapper to dispatch the call to either one based on if MMU is enabled or not. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* console: Introduce console_drain()Andrey Smirnov2018-04-171-25/+5
| | | | | | | | | | | | | | Generalize high baud rate UART polling code found in lib/xmodem.c and expose it as a generic function in console API. The usecase for this -- besides X/Y-mode data transfers where the code originated -- is command/reply type of serial exchages at high baud rates (~1Mbaud) with payloads exceeding inernal UART FIFOs in size. Such interactions are not uncommon in serdev device and this patch is done in preparation for serdev support code that will follow. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2018-04-063-0/+133
|\
| * lib: Port CRC-CCITT functions from Linux kernelAndrey Smirnov2018-04-033-0/+133
| | | | | | | | | | | | | | | | Port CRC-CCITT implemenation in order to support porting MFD driver for RAVE SP. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | glob: do not unnecessarily opendir() a directorySascha Hauer2018-04-061-7/+8
|/ | | | | | | opendir() can trigger automounts, so do not use it when the pattern we examine doesn't have any wildcards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ratp'Sascha Hauer2018-03-052-2/+2
|\
| * ratp: allow building without full console supportAleksander Morgado2018-03-012-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Make CONFIG_RATP a selectable config option, so that the user can enable RATP support without explicitly needing to enable the full console support over RATP (e.g. only for RATP FS or built-in command support). The full console can still be explicitly enabled with CONFIG_CONSOLE_RATP. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: add weak clz/ctz functionsLucas Stach2018-02-212-0/+60
|/ | | | | | | | | | | | This is a copy of the Linux kernel implementation. This adds weak functions for the clz and ctz gcc builtins. Normally GCC will map those builtins to CPU instructions directly, but for CPUs where those are unavailable, we need to provide a fallback implementation. Fixes build of the zlib decompressor on ARMv4 CPUs. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/zstd'Sascha Hauer2018-02-0816-0/+7296
|\
| * lib: Add zstd decompression modulePhilipp Zabel2018-02-0515-0/+6792
| | | | | | | | | | | | | | Based on kernel commit 73f3d1b48f50 ("lib: Add zstd modules"). Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * lib: Add xxhash modulePhilipp Zabel2018-02-053-0/+504
| | | | | | | | | | | | | | Based on kernel commit 5d2405227a9e ("lib: Add xxhash module"). Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/tftp-workaround'Sascha Hauer2018-02-081-0/+55
|\ \
| * | libfile: implement a function to cache a fileSascha Hauer2018-01-251-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the nature of TFTP which can't lseek and due to the silliness of our filesystem implementation which can't cache accesses we have to manually cache files on TFTP filesystems sometimes. Make it easier for them by providing a cache_file() function which copies the file from TFTP to RAM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | libfile: implement make_tempSascha Hauer2018-01-251-0/+27
| |/ | | | | | | | | | | | | | | | | | | Create a make_temp() function which creates a name for a temporary file. Since we do not have any concurrency in barebox we do not need to create the file right away and can leave that to the caller. Unlike unix mktemp the resulting filename is dynamically allocated and must be freed by the caller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ratp'Sascha Hauer2018-02-081-2/+2
|\ \
| * | ratp: move barebox-specific command to ratp_bb.hAleksander Morgado2018-01-301-2/+2
| |/ | | | | | | | | | | | | | | | | The ratp_run_command() is really an implementation detail of the barebox ratp 'command' operation support. Move it to the barebox specific header and rename it with the correct prefix. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2018-02-081-0/+30
|\ \
| * | fs/parseopt: Add parseopt_llu_suffixPhilipp Zabel2018-02-051-0/+30
| |/ | | | | | | | | | | | | | | Add an option parser using strtoull_suffix that can be used to parse a loop mount offset option. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / libfile: Make write_file buffer constSascha Hauer2018-01-311-1/+1
|/ | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2018-01-225-12/+177
|\
| * parseopt: introduce parseopt_u16() and parseopt_str()Antony Pavlov2018-01-171-0/+64
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * move parseopt to lib/Antony Pavlov2018-01-172-0/+61
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * lib: parse_area_spec: no extra symbols after area spec are allowed except ↵Peter Mamonov2018-01-171-5/+10
| | | | | | | | | | | | | | for spaces Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * lib: parse_area_spec: part of the area spec after -/+ should start with a digitPeter Mamonov2018-01-171-0/+6
| | | | | | | | | | Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * lib: parse_area_spec: don't modify *start value if parse failedPeter Mamonov2018-01-171-7/+11
| | | | | | | | | | Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ubiformat: Lower message printing frequencySascha Hauer2018-01-111-2/+7
| | | | | | | | | | | | | | | | | | During scanning and formatting printing the messages on a serial line has significant overhead up to the point where it takes longer to print the messages than it takes to do the work. Lower the message printing frequency to improve performance. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * string.h: Implement strndupUwe Kleine-König2018-01-051-0/+20
| | | | | | | | | | | | | | | | | | I implemented this while trying to import mmc-utils into barebox. While I didn't finish this import this function might still be useful for someone?! Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Add support for fastboot sparse imagesSascha Hauer2018-01-173-0/+253
|/ | | | | | | | This adds support for reading Android fastboot sparse images. This code is based on the corresponding U-Boot code, but has been heavily modified to provide a read-like API which better fits into barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline_simple: use len instead of CONFIG_CBSIZEGaël PORTAY2017-11-171-1/+1
| | | | | | | | It is safier to use the length given in parameter instead of using the preprocessor CONFIG_CBSIZE value. Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 2d-primitives: fix typos in function names in commentsNikita Yushchenko2017-11-031-3/+3
| | | | | | | | This fixes gl_* -> gu_* in several places. Reported-by: Chris Healy <cphealy@gmail.com> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2017-10-191-1/+1
|\
| * lib,ratp: avoid too verbose info messagesAleksander Morgado2017-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using a cli-based RATP that opens and closes the RATP channel for each command sent/received, it gets annoying to get the "Closed" message printed all the time in console after each RATP channel close operation. Just demote it to debug level. E.g.: barebox@barebox sandbox:/ ratp: Closed ratp: Closed ratp: Closed ratp: Closed ... Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/graphics'Sascha Hauer2017-10-191-2/+2
|\ \