maybe it is easier to press ctrl-l to clear the screen than type
'clear' command.
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Instead of having a fixed array of fonts register the fonts dynamically.
This allows easier adding of fonts to the tree since only one file per
font has to be added and no other files modified.
Currently we have to register the fonts very early before the first
framebuffer is registered. This is because of our limited
dev_add_param_enum() which wants to know the number of elements when
called, so we can't add elements once after we've called
dev_add_param_enum(). Maybe a dev_add_param_array() has to be created
whithout this limitation, but that's left for a future exercise.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Since dev_add_param_enum is passed a pointer containing the actual value
it can contain an invalid value. Protect against it so that we do not
access invalid array elements.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Not only the array containing the pointers should be const but
also the strings themselves, so instead of using const char **
use const char * const *.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
So far we only supported blitting the whole screen from the shadow
fb to the framebuffer. Add a function to blit areas.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The fb core now has builtin support for offscreen rendering, use
this and drop offscreen handling in the gui code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Some character devices may perform meaningful operations in their
implementation of close() -- a good example would be socfpga.c which
checks if the FPGA was programmed succesfully in it's close() method
-- so ignoring return value of this call may cause false positives in
checking exit status for success.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds the new barebox logo to the tree. This is added as svg
image which is converted to different png images during build time. The logo
can be found under /logo/barebox-logo-<width>.png in the running barebox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Allocate the screen dynamically in fb_open. This opens the way to create
a fb_create_screen function which takes a struct fb_info * instead of a
filename. This is suitable for the framebuffer console which already has
a struct fb_info *.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
get_pixel converts a 32bit trgb color into framebuffer format. This
is useful for other code aswell, so export it.
Other functions in the graphics utils code use the name get/set_pixel
aswell, but instead of converting data they get a pixel from the framebuffer
or set a pixel on the framebuffer. To separate from these rename the
function to gu_hex_to_pixel.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The MAC dev parameter functions would only be built when CONFIG_NET is
set. This was okay as long as only network devices were using MAC dev
params. This has changed with the merge of the state framework, so
always compile them in if CONFIG_PARAMETER is set.
Fixes:
common/built-in.o: In function `state_mac_create':
common/state.c:387: undefined reference to `dev_add_param_mac'
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This returns a proper error code and allows us to print a proper
error message which might not always be -ENOMEM.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This function is needed for the fixed length string feature in the state
framework.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With many parameters on the global device it becomes increasingly
annoying to find a parameter in the list. Sort it alphabetically
to make this easier.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Adding debug statements to this code path does not make much sense
since when enabled it will massively spam the console.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Bootstrap_read_devfs does not remove the devices it creates during the
course of its execution which might be considered as a resource
leak. Remedy that by adding the code to remove those devices upon
function completion.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Check for errors returned by dev_add_bb_dev() and bail if there
are any.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
In case of a failure in one of the cdev_* functions original version
of bootstrap_read_devfs would not release memory allocated for barebox
header or memory allocated for the image. This commit fixes this by
adding resource deallocation code.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Check for errors returned by devfs_add_partition() and bail if there
are any.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Original version of 'read_image_head' would not free the memory
allocated for barebox header in cases of any failure. Fix this by
adding a dedicated resourse de-allocation code path.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This corresponds to kernel commit 72cf90124e87d975d0b
This fix ensures that we never meet an integer overflow while adding
255 while parsing a variable length encoding. It works differently from
commit 206a81c ("lzo: properly check for overruns") because instead of
ensuring that we don't overrun the input, which is tricky to guarantee
due to many assumptions in the code, it simply checks that the cumulated
number of 255 read cannot overflow by bounding this number.
The MAX_255_COUNT is the maximum number of times we can add 255 to a base
count without overflowing an integer. The multiply will overflow when
multiplying 255 by more than MAXINT/255. The sum will overflow earlier
depending on the base count. Since the base count is taken from a u8
and a few bits, it is safe to assume that it will always be lower than
or equal to 2*255, thus we can always prevent any overflow by accepting
two less 255 steps.
This patch also reduces the CPU overhead and actually increases performance
by 1.1% compared to the initial code, while the previous fix costs 3.1%
(measured on x86_64).
The fix needs to be backported to all currently supported stable kernels.
Reported-by: Willem Pinckaers <willem@lekkertech.net>
Cc: "Don A. Bailey" <donb@securitymouse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This reverts barebox commit ecb1dc0b1e
This corresponds to kernel commit af958a38a60c7ca3d8
As analysed by Willem Pinckaers, this fix is still incomplete on
certain rare corner cases, and it is easier to restart from the
original code.
Reported-by: Willem Pinckaers <willem@lekkertech.net>
Cc: "Don A. Bailey" <donb@securitymouse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Taken from the Kernel, put into the same place as in the kernel,
although the hexdump.c does not actually contain hexdum functions.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds a function to parse a full cmdline partition string. The
addpart command is switched to use this function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The return size should be loff_t to support partitions bigger
than 4G. Also use const for the devname and endp.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
If strdup() fails with out-of-memory, __dev_add_param() should fail
with -ENOMEM.
(Note strdup() is always given with a non-NULL pointer. If the
argument name is given with NULL, the system would already have
crashed in the get_param_by_name() function.)
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The function dev_param_set_generic() may fail because of
out of memory. If so, return -ENOMEM.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
lib/decompress_bunzip2.c includes <common.h> and INT_MAX is already
defined there. The definition in this file is redundant.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This file originates in Linux. Linux has it under include/linux/
directory since commit dccd2304cc90.
Let's move it to the same place as well in barebox.
This commit was generated by the following commands:
find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:'
git mv include/sizes.h include/linux/
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds simple console support to the PBL which makes it
possible to print more complex messages in the PBL than just
strings or hex numbers. For now puts_ll is used to print the
messages, so it depends on CONFIG_DEBUG_LL which makes it
more a debugging option. However, this could be extended later
to get regular output from the PBL if desired.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
To be independent of the _ctype array. This makes it possible
to add printf support to the PBL without adding _ctype aswell.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
panic() is not really a printf like function, so move it to common/misc.c.
This is done because we want to have printf support in the PBL, but PBL
has it's own panic() implementation.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds xz decompression support from the kernel. Both compressing
the barebox binary with xz and decompressing xz files on the commandline
is supported.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Long time ago all ".ip" parameters have been replaced with ".ipaddr".
Signed-off-by: Rolf Evers-Fischer <embedded24@evers-fischer.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
dev_add_param creates a new parameter so it makes more sense to
return it than to return an error code. Since the return value
is hardly ever checked this is only a small patch.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Set return value correct in error case.
This prevents barebox from crashing in some conditions.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
We cannot use list_entry() on an empty list. Without history
we have to return an empty line. This fixes a crash when the
cursor up button is pressed and no command has been entered
previously. Broken since:
commit ada160a34a
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date: Tue Jul 29 11:54:26 2014 +0200
readline: reimplement history functions
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Teresa Gamez <t.gamez@phytec.de>
read_file has some limitations:
- It is not possible to check the error code since read_file returns
NULL for failure
- It is not possible to limit the buffer size to sensible limits.
This patch introduces read_file_2 which doesn't have these limitations.
read_file becomes a wrapper around read_file_2.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
We have our file helper functions in several places. Move them
all to lib/libfile.c.
With this we no longer have file helpers in fs/fs.c which contains
the core fs functions and no functions in lib/libbb.c which are
not from busybox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This reimplements the history functions in readline.
- Use regular lists instead of homegrown list implementation
- Allocate history strings dynamically instead of copying strings
to fixed buffers without checking the size
- saves us an initcall
- slightly smaller
- no longer add duplicates to the history
- when moving past the last history entry print an empty line
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>