summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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
|\ \
| * | 2d-primitives: fix missing pixel in gu_draw_line()Nikita Yushchenko2017-10-161-2/+2
| |/ | | | | | | | | | | | | | | | | When drawing line from (x1, y1) to (x2, y2), pixel at (x2, y2) should be included. Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Tested-by: Chris Healy <[1]cphealy@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / graphic_utils: Fix freeing uninitialzed pointer in fb_open()Sascha Hauer2017-10-191-3/+1
|/ | | | | | | In fb_open() when fb_create_screen() fails then sc contains an error pointer which is then freed in the failure path. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline_simple: remove obsolete documentationGaël PORTAY2017-08-151-3/+0
| | | | | | | | | | The readline function does not return timed-out anymore since the commit: be5d13bcb readline_simple: drop unusable u-boot legacy stuff Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* readline_simple: return -1 if getc failsGaël PORTAY2017-08-151-0/+2
| | | | | | | | | | The getc function may return an errno code if an error happens. This patch prevents readline from printing a non printable character and from looping to infinity and beyong. Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* Merge branch 'for-next/ratp'Sascha Hauer2017-06-301-53/+63
|\
| * ratp: user close may happen in SYN-RECEIVED stateAleksander Morgado2017-06-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference says: 5.2.3. SYN-RECEIVED ... Departures - A CLOSE request is made by the user. Create a packet with FIN set. Send it and go to the FIN-WAIT state. Add this missing step. Probably not a real usecase for barebox anyway as there is no user triggered close. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: consolidate setting the next AN or SN flagsAleksander Morgado2017-06-231-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting the next AN or SN flag was being done in two different ways throughout the code; e.g. here for AN: ratp_set_an(ratp_sn(hdr) + 1); or: ratp_set_an(!ratp_sn(hdr)); We define a pair of new ratp_set_next_sn() and ratp_set_next_an() macros that make it clear that the next value is desired, and also hide the computation of the actual flag value within the macro, so the previous example would now look like: ratp_set_next_an(ratp_sn(hdr)); Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: don't ignore data that may arrive in behaviour H1Aleksander Morgado2017-06-231-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If an input packet arrives H1 that has data in it, we need to: * track sn_received * if we have data pending, send it * if we don't have data pending, send a plain ACK This process, as noted in RFC916, is the same as the I1 procedure, so go and run it: Go to the ESTABLISHED state and execute procedure I1 to process any data which might be in this packet. This fix allows the peer to queue data in the last packet doing the connection establishment. It doesn't apply to the barebox<->bbremote interaction because bbremote won't queue data until the connection is completely established, but it allows third party ratp implementations to do that. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: send initial data in behaviour B if any pendingAleksander Morgado2017-06-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | And also, use ratp_send_ack() instead of manually constructing an ACK if no data is pending to be sent. The current barebox implementation doesn't allow any queueing of data until the connection is established, so this is probably not a case that would get run anyway. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: prefer using ratp_send_ack() in behaviour I1Aleksander Morgado2017-06-231-9/+3
| | | | | | | | | | | | | | | | Instead of manually constructing an ACK, use the ratp_send_ack() method, which already does that properly. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: consolidate ratp_sn_expected() and ratp_an_expected()Aleksander Morgado2017-06-231-1/+1
| | | | | | | | | | | | | | | | This is no code change in ratp_sn_expected(), it's just rewritten in the same way as ratp_an_expected(), which follows the RFC916 approach. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: fix sending ACKs without dataAleksander Morgado2017-06-231-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All ACKs without data must be built in the same way from the input message: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> The code was actually doing this instead: <SN=0><AN=SN><CTL=ACK> This change fixes how the retransmissions are ACK-ed by the peer, and would have affected the barebox<->bbremote interactions. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: remove bogus data checks in behavior C2Aleksander Morgado2017-06-231-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The SN validation was being completely ignored if the packet had no data (e.g. for RST, FIN or SYN or plain ACKs). This condition is now removed so that the SN check is done. The second check removed was actually never being used, as it was already being tested for not having data in the first one. These two fixes are a cleanup to follow the protocol correctly. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>