summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-10-07 08:51:11 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-10-07 08:51:11 +0200
commitab7647dbd8aa54fcb0178829ac9e5fccb053d4ef (patch)
tree907492c209e5639af4faac074df9939f78aa078d /common
parentb06ef2e54303443d21dd98a773a13289e66812fb (diff)
parent6fb511fa62efe3faa8be67800cd934c143405fca (diff)
downloadbarebox-ab7647dbd8aa54fcb0178829ac9e5fccb053d4ef.tar.gz
barebox-ab7647dbd8aa54fcb0178829ac9e5fccb053d4ef.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig36
-rw-r--r--common/console.c12
-rw-r--r--common/console_simple.c5
-rw-r--r--common/fastboot.c2
-rw-r--r--common/file-list.c16
-rw-r--r--common/hush.c23
-rw-r--r--common/startup.c5
-rw-r--r--common/state/backend_format_raw.c4
-rw-r--r--common/usbgadget.c24
9 files changed, 98 insertions, 29 deletions
diff --git a/common/Kconfig b/common/Kconfig
index a9feae2ae8..70debb9cd5 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -812,6 +812,17 @@ config CONSOLE_ALLOW_COLOR
compile time default for colored console output. After boot it
can be controlled using global.allow_color.
+config CONSOLE_DISABLE_INPUT
+ prompt "Disable input on all consoles by default (non-interactive)"
+ def_bool CONSOLE_NONE
+ help
+ If enabled, all consoles are initially configured to not accept any input,
+ making the consoles effectively non-interactive.
+ The active device parameter can be used to override this on a per-console
+ basis.
+ CAUTION: this will also disable input devices by default, since they are
+ registered as consoles.
+
config PBL_CONSOLE
depends on PBL_IMAGE
depends on !CONSOLE_NONE
@@ -842,6 +853,7 @@ config ENV_HANDLING
startup) will bring them back. If unsure, say yes.
config DEFAULT_ENVIRONMENT
+ select CRC32
bool
default y if ENV_HANDLING
prompt "Compile in default environment"
@@ -1091,6 +1103,30 @@ config SYSTEMD_OF_WATCHDOG
in the kernel device tree. If the kernel is booted without a device
tree or with one that lacks aliases, nothing is added.
+config EXTERNAL_DTS_FRAGMENTS
+ string "external dts file fragments"
+ depends on OFTREE
+ help
+ List of dts fragment files that will be appended to Barebox's device
+ tree(s) source when building the dtb file(s). If multiple files are
+ listed, they will be appended in order. Relative filenames will use
+ the dtc include search path.
+
+ A preprocessor macro based on the name of the main dts will be
+ defined, which allows the dts fragments to based on which image of a
+ multi image build they are being used in. Given the dts filename
+ used for a board is "foo-board.dts" the external dts usage can be
+ limited to that board with
+
+ #ifdef foo_board_dts
+ ...
+ #endif
+
+ It not intended that this be put into into Barebox defconfig files.
+ Instead, it's an external build system, like Yocto or buildroot, to
+ add dts fragments from outside the Barebox source tree into the
+ Barebox build.
+
menu "OP-TEE loading"
config OPTEE_SIZE
diff --git a/common/console.c b/common/console.c
index ad1a6aaab2..0368c72d0b 100644
--- a/common/console.c
+++ b/common/console.c
@@ -328,7 +328,7 @@ int console_register(struct console_device *newcdev)
return of_platform_populate(serdev_node, NULL, dev);
if (newcdev->dev && of_device_is_stdout_path(newcdev->dev, &baudrate)) {
- activate = 1;
+ activate = CONSOLE_STDIOE;
console_set_stdoutpath(newcdev, baudrate);
}
@@ -349,16 +349,18 @@ int console_register(struct console_device *newcdev)
if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) {
if (list_empty(&console_list))
- activate = 1;
+ activate = CONSOLE_STDIOE;
} else if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_ALL)) {
- activate = 1;
+ activate = CONSOLE_STDIOE;
}
list_add_tail(&newcdev->list, &console_list);
+ if (IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT))
+ activate &= ~CONSOLE_STDIN;
+
if (activate)
- console_set_active(newcdev, CONSOLE_STDIN |
- CONSOLE_STDOUT | CONSOLE_STDERR);
+ console_set_active(newcdev, activate);
/* expose console as device in fs */
newcdev->devfs.name = basprintf("%s%d", newcdev->class_dev.name,
diff --git a/common/console_simple.c b/common/console_simple.c
index 42224842c5..3b95570e5e 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -92,7 +92,10 @@ int console_register(struct console_device *newcdev)
newcdev->setbrg(newcdev, newcdev->baudrate);
}
- newcdev->f_active = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+ newcdev->f_active = CONSOLE_STDIOE;
+
+ if (IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT))
+ newcdev->f_active = ~CONSOLE_STDIN;
barebox_banner();
diff --git a/common/fastboot.c b/common/fastboot.c
index 75f6691b08..04a8573b4a 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -919,7 +919,7 @@ bool get_fastboot_bbu(void)
struct file_list *get_fastboot_partitions(void)
{
if (fastboot_partitions && *fastboot_partitions)
- return file_list_parse(fastboot_partitions);
+ return file_list_parse_null(fastboot_partitions);
if (!system_partitions_empty())
return system_partitions_get();
return NULL;
diff --git a/common/file-list.c b/common/file-list.c
index 05f44514fb..407b312833 100644
--- a/common/file-list.c
+++ b/common/file-list.c
@@ -158,6 +158,22 @@ out:
return ERR_PTR(ret);
}
+struct file_list *file_list_parse_null(const char *files)
+{
+ struct file_list *list;
+
+ if (!files)
+ return NULL;
+
+ list = file_list_parse(files);
+ if (IS_ERR(list)) {
+ pr_err("Parsing file list \"%s\" failed: %pe\n", files, list);
+ return NULL;
+ }
+
+ return list;
+}
+
void file_list_free(struct file_list *files)
{
struct file_list_entry *entry, *tmp;
diff --git a/common/hush.c b/common/hush.c
index 0475401321..d80df7a181 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -854,7 +854,7 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi)
struct pipe *rpipe;
int flag_rep = 0;
int rcode=0, flag_skip=1;
- int flag_restore = 0;
+ int flag_restore = 0, flag_conditional = 0;
int if_code=0, next_if_code=0; /* need double-buffer to handle elif */
reserved_style rmode, skip_more_in_this_rmode = RES_XXXX;
@@ -966,6 +966,20 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi)
return rcode; /* exit */
}
+ /* Conditional statements like "if", "elif", "while" and "until"
+ * return 1 if conditional is not met. This is standard behavior.
+ * However this does not mean that this value (1) should be
+ * returned as exit code, as it suggests generic error code.
+ * Catch this by raising a flag and check it later on.
+ */
+ if (rcode == 1) {
+ if (rmode == RES_IF || rmode == RES_ELIF ||
+ rmode == RES_WHILE || rmode == RES_UNTIL)
+ flag_conditional = 1;
+ else
+ flag_conditional = 0;
+ }
+
last_return_code = rcode;
if (rmode == RES_IF || rmode == RES_ELIF )
@@ -981,6 +995,13 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi)
(rcode != EXIT_SUCCESS && pi->followup == PIPE_AND) )
skip_more_in_this_rmode = rmode;
}
+
+ /* Substitute exit code in case flag_conditional is set. */
+ if (flag_conditional == 1 && last_return_code == 1) {
+ last_return_code = 0;
+ rcode = 0;
+ }
+
return rcode;
}
diff --git a/common/startup.c b/common/startup.c
index 871696968a..f72902fc53 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -241,6 +241,11 @@ enum autoboot_state do_autoboot_countdown(void)
if (autoboot_state != AUTOBOOT_UNKNOWN)
return autoboot_state;
+ if (IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT)) {
+ printf("\nNon-interactive console, booting system\n");
+ return autoboot_state = AUTOBOOT_BOOT;
+ }
+
if (global_autoboot_state != AUTOBOOT_COUNTDOWN)
return global_autoboot_state;
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index 5a71149d34..ea962606cc 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -183,6 +183,7 @@ static int backend_format_raw_unpack(struct state_backend_format *format,
const struct backend_raw_header *header;
const void *data;
struct state_backend_format_raw *backend_raw = get_format_raw(format);
+ int ret = 0;
header = (const struct backend_raw_header *)buf;
data = buf + sizeof(*header);
@@ -191,12 +192,13 @@ static int backend_format_raw_unpack(struct state_backend_format *format,
if (sv->start + sv->size > header->data_len) {
dev_err(backend_raw->dev, "State variable ends behind valid data, %s\n",
sv->name);
+ ret = -ENOSPC;
continue;
}
memcpy(sv->raw, data + sv->start, sv->size);
}
- return 0;
+ return ret;
}
static int backend_format_raw_pack(struct state_backend_format *format,
diff --git a/common/usbgadget.c b/common/usbgadget.c
index 34a685234b..e8c9f7d236 100644
--- a/common/usbgadget.c
+++ b/common/usbgadget.c
@@ -23,26 +23,10 @@ static int autostart;
static int acm;
static char *dfu_function;
-static struct file_list *parse(const char *files)
-{
- struct file_list *list;
-
- if (!files)
- return NULL;
-
- list = file_list_parse(files);
- if (IS_ERR(list)) {
- pr_err("Parsing file list \"%s\" failed: %pe\n", files, list);
- return NULL;
- }
-
- return list;
-}
-
static inline struct file_list *get_dfu_function(void)
{
if (dfu_function && *dfu_function)
- return file_list_parse(dfu_function);
+ return file_list_parse_null(dfu_function);
if (!system_partitions_empty())
return system_partitions_get();
return NULL;
@@ -59,7 +43,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs)
opts->release = usb_multi_opts_release;
if (flags & USBGADGET_DFU) {
- opts->dfu_opts.files = parse(funcs->dfu_opts);
+ opts->dfu_opts.files = file_list_parse_null(funcs->dfu_opts);
if (IS_ENABLED(CONFIG_USB_GADGET_DFU) && file_list_empty(opts->dfu_opts.files)) {
file_list_free(opts->dfu_opts.files);
opts->dfu_opts.files = get_dfu_function();
@@ -67,7 +51,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs)
}
if (flags & USBGADGET_MASS_STORAGE) {
- opts->ums_opts.files = parse(funcs->ums_opts);
+ opts->ums_opts.files = file_list_parse_null(funcs->ums_opts);
if (IS_ENABLED(CONFIG_USB_GADGET_MASS_STORAGE) && file_list_empty(opts->ums_opts.files)) {
file_list_free(opts->ums_opts.files);
opts->ums_opts.files = system_partitions_get();
@@ -75,7 +59,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs)
}
if (flags & USBGADGET_FASTBOOT) {
- opts->fastboot_opts.files = parse(funcs->fastboot_opts);
+ opts->fastboot_opts.files = file_list_parse_null(funcs->fastboot_opts);
if (IS_ENABLED(CONFIG_FASTBOOT_BASE) && file_list_empty(opts->fastboot_opts.files)) {
file_list_free(opts->fastboot_opts.files);
opts->fastboot_opts.files = get_fastboot_partitions();