summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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>
| * ratp: fix single byte sending flagged with SOAleksander Morgado2017-06-231-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | When a single data byte is sent, it is flagged as SO and the actual data goes in the length byte within the header. Worth noting that this issue wasn't found in any barebox<->bbremote interaction because all data packets sent between them always have more than one byte (due to the barebox command specific header). Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: fix data presence checkAleksander Morgado2017-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at the "data length" and SO flag isn't enough to declare a packet with or without data, because SYN flagged packets will also use the "data length" field to define MDL. So, improve the check to match against SYN|RST|FIN flagged packets, which can never have data. This commit fixed a segfault in barebox when an unexpected SYN packet was sent in the middle of a connection; barebox thought the packet had data because the "data length" in the SYN packet was different than 0. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: completely ignore RST flagged packets in behavior GAleksander Morgado2017-06-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference says: This procedure represents the behavior of the CLOSED state of a connection. All incoming packets are discarded. If the packet had the RST flag set take no action. Otherwise it is necessary to build a RST packet. So, skip building the RST packet if the incoming one had RST set. This commit fixes an infinite loop of messages sent and received between both ends during the connection close procedure, found when testing barebox against a third party ratp implementation. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: add missing RST flag in behavior GAleksander Morgado2017-06-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference says: If the ACK flag was set then send: <SN=received AN><CTL=RST> If the ACK flag was not set then send: <SN=0><AN=received SN+1 modulo 2><CTL=RST, ACK> (i.e. in both cases RST is needed) The RST flag is set initially in the 'control' variable; so instead of completely overwriting it, make sure the additional flags are OR-ed to the current value. This fix isn't related to any failed barebox<->bbremote interaction (it really is a very rare corner case). Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: send missing RST in behavior C2Aleksander Morgado2017-06-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference says: If SYN was set we assume that the other end crashed and has attempted to open a new connection. We respond by sending a legal reset: <SN=received AN><AN=received SN+1 modulo 2><CTL=RST, ACK> Add this missing step. This issue affects the barebox<->bbremote interaction if bbremote crashes without closing the channel and restarts opening a complete new connection. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: avoid unnecessary variable initializationsAleksander Morgado2017-06-231-2/+2
| | | | | | | | | | | | | | | | This is just a cleanup; the variables are completely initialized later on so the initial values are totally discarded anyway. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: add missing transition to SYN-RECEIVED in behavior BAleksander Morgado2017-06-231-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference says: If the SYN flag was set but the ACK was not set then the other end of the connection has executed an active open also. Acknowledge the SYN, choose your MDL, and send: <SN=0><AN=received SN+1 modulo 2><CTL=SYN, ACK><LENGTH=MDL> Go to the SYN-RECEIVED state without any further processing. Add this missing step. This fix isn't related to any barebox<->bbremote interaction issue, because the case where both ends start an active connection doesn't apply in this case. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib/fonts: add 6x8 fontSven Schneider2017-06-233-1/+2589
|/ | | | | | | | | This font is derived from linux lib/fonts/font_6x10.c. Signed-off-by: Sven Schneider <s.schneider@arkona-technologies.de> [rhi: fix indentation for block /* 36 0x28 '$' */] Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "param: remove unnecessary device_d * argument"Sascha Hauer2017-06-131-22/+22
| | | | This reverts commit 0071bacb4c7cab21c9fab8540f5aa9922a270a85.
* ratp: avoid using already freed memoryAleksander Morgado2017-06-061-2/+2
| | | | | | | | If ratp_establish() fails we would be accessing the ratp_internal struct after having disposed it. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* xfuncs: fix format specifier in pr_emerg callIan Abbott2017-05-171-1/+1
| | | | | | | | `enomem_panic()` calls `pr_emerg()` using `%d` in the format specifier string to print a value of type `size_t`. Change it to `%zu`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/parameter-types'Sascha Hauer2017-05-052-130/+133
|\
| * param: remove unnecessary device_d * argumentSascha Hauer2017-04-111-22/+22
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * param: make parameter functions more consistentSascha Hauer2017-04-111-112/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch creates a consitent set of device parameter functions. With this we have: dev_add_param_<type><access> "type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask The improvement here is that we now can exactly specify the width of the int type parameters and also correctly distinguish between signed and unsigned variables which means that a variable no longer ends up with INT_MAX when it's assigned -1. "access" can be empty for regular read/write parameter, "_ro" for readonly parameters which get their value from a variable pointer in the background or "_fixed" for parameters which are set to a fixed value (without a pointer in the background). Some more exotic types are not (yet) implemented, like dev_add_param_ip_ro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * lib: implement simple_strtollSascha Hauer2017-04-111-0/+9
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * parameter: Give device parameters typesSascha Hauer2017-04-101-1/+29
| | | | | | | | | | | | | | | | This adds a variable type enum and adds this to the device parameters. This information gives the user a hint which values a parameter expects and also helps to organize the parameters better internally. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2017-05-053-44/+55
|\ \
| * | readline_simple: drop unusable u-boot legacy stuffAntony Pavlov2017-04-281-13/+0
| | | | | | | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | xfuncs: Be more informative when out of memory panic occursSascha Hauer2017-04-281-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | When one of the xfuncs panics we can be a bit more informative. We can at least print the amount of bytes we wanted to allocate and how much memory we have left. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | lib/strtox: remove unnecessary islower()Sascha Hauer2017-04-111-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | toupper() does the right thing, no need to test for islower() beforehand, so islower(*cp) ? toupper(*cp) : *cp can be simplified to: toupper(*cp) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | lib/strtox: whitespace cleanupSascha Hauer2017-04-111-22/+31
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / libgen: implement posix_basenameSascha Hauer2017-04-191-0/+23
|/ | | | | | | | | | There are two different versions of basename(): The GNU version and the POSIX version. The GNU version never modifies its argument and returns the empty string when path has a trailing slash, and in particular also when it is "/". The POSIX version modifies its argument and thus works properly with strings which have a trailing "/". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mips'Sascha Hauer2017-04-071-2/+2
|\
| * gui: bmp.c: fix "no previous prototype" warningAntony Pavlov2017-03-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch fixes these compiler's warnings: lib/gui/bmp.c:12:15: warning: no previous prototype for 'bmp_open' [-Wmissing-prototypes] struct image *bmp_open(char *inbuf, int insize) ^ lib/gui/bmp.c:33:6: warning: no previous prototype for 'bmp_close' [-Wmissing-prototypes] void bmp_close(struct image *img) ^ Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: random: add get_crypto_bytes interface and use HWRNG if posssibleOleksij Rempel2017-03-302-0/+61
|/ | | | | | | | | For crypto applications we need to use some thing else as PRNG. So provide get_crypto_bytes() and use HWRNG as main source. PRNG is allowed as fallback if user decided to configure it so. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/video'Sascha Hauer2017-03-135-3/+2596
|\
| * lib/fonts: add VGA8x8 fontBastian Stender2017-02-243-0/+2592
| | | | | | | | | | | | | | | | | | Ported from Linux v4.10. This font is ideal for displaying a framebuffer console on a small display. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * 2d-primitives: check dimensions in __illuminateBastian Stender2017-02-241-0/+3
| | | | | | | | | | | | | | | | gl_draw_circle draws outside of the screen if the resolution is too low. This lead to memory corruption. Check the dimensions before drawing. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * graphic_utils: do not allocate info in fb_openBastian Stender2017-02-241-3/+0
| | | | | | | | | | | | | | | | info was errorneously allocated, but it really is a pointer to a fb_info struct from the framebuffer. This fixes a memory leak. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * graphic_utils: implement 8 bpp color depth in gu_set_pixelBastian Stender2017-02-241-0/+1
| | | | | | | | | | Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | parameter: fix read only int supportJean-Christophe PLAGNIOL-VILLARD2017-03-101-2/+2
| | | | | | | | | | | | | | | | pass PARAM_FLAG_RO flag for read only it so we can not change them Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: xz: add support for bcj filtersYegor Yefremov2017-02-231-0/+24
|/ | | | | | | | | Add missing configuration options for various bcj filters. Without these options the lib/xz/xz_dec_bcj.c file will be compiled, but all filters will be disabled. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readkey: keys are unsigned charMichael Olbrich2017-01-241-2/+2
| | | | | | | Otherwise values > 127 will become negative and are dropped. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: libfile: Fix copying files to a non existing destinationTeresa Remmet2017-01-171-4/+5
| | | | | | | | | | | | If the destination file does not exist the stat call to check the file type fails. Extend the check of the stat return value. To allow to copy files to a new destination. Fixes commit 0ec6bd3e1be8 ("libfile: copy_file: Only open regular files with O_TRUNC") Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>