summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig56
-rw-r--r--common/blspec.c73
-rw-r--r--common/bootargs.c6
-rw-r--r--common/bootm.c17
-rw-r--r--common/console.c22
-rw-r--r--common/console_common.c18
-rw-r--r--common/console_countdown.c2
-rw-r--r--common/console_simple.c6
-rw-r--r--common/env.c30
-rw-r--r--common/environment.c5
-rw-r--r--common/firmware.c2
-rw-r--r--common/globalvar.c37
-rw-r--r--common/imd.c4
-rw-r--r--common/imx-bbu-nand-fcb.c1
-rw-r--r--common/menu.c15
-rw-r--r--common/menutree.c6
-rw-r--r--common/module.c2
-rw-r--r--common/partitions.c2
-rw-r--r--common/partitions/efi.c1
-rw-r--r--common/password.c3
-rw-r--r--common/startup.c1
-rw-r--r--common/state.c5
-rw-r--r--common/tlsf.c6
-rw-r--r--common/uimage.c1
24 files changed, 200 insertions, 121 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 7c09e8c117..380193b806 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -21,10 +21,6 @@ config HAS_KALLSYMS
config HAS_MODULES
bool
-config ENV_HANDLING
- select CRC32
- bool
-
config HAS_CACHE
bool
help
@@ -78,9 +74,6 @@ config FITIMAGE_SIGNATURE
config LOGBUF
bool
-config GLOBALVAR
- bool
-
config STDDEV
bool
@@ -159,6 +152,30 @@ config MEMINFO
config ENVIRONMENT_VARIABLES
bool "environment variables support"
+config GLOBALVAR
+ bool "global environment variables support"
+ default y if !SHELL_NONE
+ help
+ Global environment variables begin with "global.". Unlike normal
+ shell variables they have the same values in all contexts. Global
+ variables are used to control several aspects of the system behaviour.
+ If unsure, say yes here.
+
+config NVVAR
+ bool "Non volatile global environment variables support"
+ default y if !SHELL_NONE
+ depends on GLOBALVAR
+ depends on ENV_HANDLING
+ help
+ Non volatile environment variables begin with "nv.". They behave like
+ global variables above, but their values are saved in the environment
+ storage with 'saveenv' and thus are persistent over restarts. nv variables
+ are coupled with global variables of the same name. Setting "nv.foo" results
+ in "global.foo" changed also (but not the other way round: setting "global.foo"
+ leaves "nv.foo" untouched). The idea is that nv variables can store defaults
+ while global variables can be changed during runtime without changing the
+ default.
+
menu "memory layout"
source "pbl/Kconfig"
@@ -536,6 +553,18 @@ config BLSPEC
on a device and it allows the Operating System to install / update
kernels.
+config FLEXIBLE_BOOTARGS
+ bool
+ prompt "flexible Linux bootargs generation"
+ depends on GLOBALVAR
+ help
+ Select this to get a more flexible bootargs generation. With this
+ option the bootargs are concatenated together from global variables
+ beginning with 'global.linux.bootargs.' and 'global.linux.mtdparts.'
+ This allows for more flexible scripting since with it it's possible
+ to replace parts of the bootargs string without reconstructing it
+ completely.
+
config IMD
bool "barebox metadata support"
@@ -640,10 +669,20 @@ config PARTITION
source common/partitions/Kconfig
+config ENV_HANDLING
+ select CRC32
+ bool "Support environment files storage"
+ default y if !SHELL_NONE
+ help
+ Enabling this option will give you environment files which can be stored
+ over reboots. The "saveenv" command will store all files under /env/ to
+ the persistent environment, the "loadenv" command (also executed during
+ startup) will bring them back. If unsure, say yes.
+
config DEFAULT_ENVIRONMENT
bool
default y
- select ENV_HANDLING
+ depends on ENV_HANDLING
prompt "Compile in default environment"
help
Enabling this option will give you a default environment when
@@ -769,7 +808,6 @@ config POLLER
config STATE
bool "generic state infrastructure"
- depends on OF_BAREBOX_DRIVERS
select ENVIRONMENT_VARIABLES
select OFTREE
select PARAMETER
diff --git a/common/blspec.c b/common/blspec.c
index 18005569ff..bf98e6b29a 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -203,16 +203,18 @@ static char *parse_nfs_url(const char *url)
if (ip == 0)
goto out;
- hostpath = asprintf("%s:%s", ip_to_string(ip), path);
+ hostpath = basprintf("%s:%s", ip_to_string(ip), path);
prevpath = nfs_find_mountpath(hostpath);
if (prevpath) {
mountpath = xstrdup(prevpath);
} else {
- mountpath = asprintf("/mnt/nfs-%s-blspec-%08x", host, rand());
+ mountpath = basprintf("/mnt/nfs-%s-blspec-%08x", host,
+ rand());
if (port)
- options = asprintf("mountport=%s,port=%s", port, port);
+ options = basprintf("mountport=%s,port=%s", port,
+ port);
ret = make_directory(mountpath);
if (ret)
@@ -278,7 +280,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
if (!strcmp(devicetree, "none"))
return true;
- filename = asprintf("%s/%s", abspath, devicetree);
+ filename = basprintf("%s/%s", abspath, devicetree);
fdt = read_file(filename, &size);
if (!fdt) {
@@ -338,7 +340,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
entry_default = read_file_line("%s/default", root);
entry_once = read_file_line("%s/once", root);
- abspath = asprintf("%s/%s", root, dirname);
+ abspath = basprintf("%s/%s", root, dirname);
dir = opendir(abspath);
if (!dir) {
@@ -356,7 +358,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
if (*d->d_name == '.')
continue;
- configname = asprintf("%s/%s", abspath, d->d_name);
+ configname = basprintf("%s/%s", abspath, d->d_name);
dot = strrchr(configname, '.');
if (!dot) {
@@ -402,7 +404,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
found++;
- name = asprintf("%s/%s", dirname, d->d_name);
+ name = basprintf("%s/%s", dirname, d->d_name);
if (entry_default && !strcmp(name, entry_default))
entry->boot_default = true;
if (entry_once && !strcmp(name, entry_once))
@@ -415,10 +417,10 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
}
- entry->me.display = asprintf("%-20s %-20s %s",
- devname ? devname : "",
- hwdevname ? hwdevname : "",
- blspec_entry_var_get(entry, "title"));
+ entry->me.display = basprintf("%-20s %-20s %s",
+ devname ? devname : "",
+ hwdevname ? hwdevname : "",
+ blspec_entry_var_get(entry, "title"));
free(devname);
free(hwdevname);
@@ -637,29 +639,6 @@ int blspec_scan_devicename(struct blspec *blspec, const char *devname)
return blspec_scan_device(blspec, dev);
}
-static int blspec_append_root(struct blspec_entry *entry)
-{
- const char *appendroot;
- char *rootarg;
-
- appendroot = blspec_entry_var_get(entry, "linux-appendroot");
- if (!appendroot || strcmp(appendroot, "true"))
- return 0;
-
- rootarg = path_get_linux_rootarg(entry->rootpath);
- if (IS_ERR(rootarg)) {
- pr_err("Getting root argument for %s failed with: %s\n",
- entry->rootpath, strerrorp(rootarg));
- return PTR_ERR(rootarg);
- }
-
- globalvar_add_simple("linux.bootargs.dyn.blspec.appendroot", rootarg);
-
- free(rootarg);
-
- return 0;
-}
-
/*
* blspec_boot - boot an entry
*
@@ -671,6 +650,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
{
int ret;
const char *abspath, *devicetree, *options, *initrd, *linuximage;
+ const char *appendroot;
struct bootm_data data = {
.initrd_address = UIMAGE_INVALID_ADDRESS,
.os_address = UIMAGE_SOME_ADDRESS,
@@ -691,7 +671,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
else
abspath = "";
- data.os_file = asprintf("%s/%s", abspath, linuximage);
+ data.os_file = basprintf("%s/%s", abspath, linuximage);
if (devicetree) {
if (!strcmp(devicetree, "none")) {
@@ -699,25 +679,34 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
if (node)
of_delete_node(node);
} else {
- data.oftree_file = asprintf("%s/%s", abspath,
- devicetree);
+ data.oftree_file = basprintf("%s/%s", abspath,
+ devicetree);
}
}
if (initrd)
- data.initrd_file = asprintf("%s/%s", abspath, initrd);
+ data.initrd_file = basprintf("%s/%s", abspath, initrd);
globalvar_add_simple("linux.bootargs.dyn.blspec", options);
- ret = blspec_append_root(entry);
- if (ret)
- goto err_out;
+ appendroot = blspec_entry_var_get(entry, "linux-appendroot");
+ if (appendroot) {
+ int val;
+
+ ret = strtobool(appendroot, &val);
+ if (ret) {
+ pr_err("Invalid value \"%s\" for appendroot option\n",
+ appendroot);
+ goto err_out;
+ }
+ data.appendroot = val;
+ }
pr_info("booting %s from %s\n", blspec_entry_var_get(entry, "title"),
entry->cdev ? dev_name(entry->cdev->dev) : "none");
if (entry->boot_once) {
- char *s = asprintf("%s/once", abspath);
+ char *s = basprintf("%s/once", abspath);
ret = unlink(s);
if (ret)
diff --git a/common/bootargs.c b/common/bootargs.c
index 803736fc94..a89f23a3f2 100644
--- a/common/bootargs.c
+++ b/common/bootargs.c
@@ -53,7 +53,8 @@ const char *linux_bootargs_get(void)
parts = globalvar_get_match("linux.mtdparts.", ";");
if (strlen(parts)) {
- bootargs = asprintf("%s mtdparts=%s", linux_bootargs, parts);
+ bootargs = basprintf("%s mtdparts=%s", linux_bootargs,
+ parts);
free(linux_bootargs);
free(parts);
linux_bootargs = bootargs;
@@ -61,7 +62,8 @@ const char *linux_bootargs_get(void)
parts = globalvar_get_match("linux.blkdevparts.", ";");
if (strlen(parts)) {
- bootargs = asprintf("%s blkdevparts=%s", linux_bootargs, parts);
+ bootargs = basprintf("%s blkdevparts=%s", linux_bootargs,
+ parts);
free(linux_bootargs);
free(parts);
linux_bootargs = bootargs;
diff --git a/common/bootm.c b/common/bootm.c
index 6d22aab289..cad8c73efe 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -48,6 +48,8 @@ static struct image_handler *bootm_find_handler(enum filetype filetype,
return NULL;
}
+static int bootm_appendroot;
+
void bootm_data_init_defaults(struct bootm_data *data)
{
data->initrd_address = UIMAGE_INVALID_ADDRESS;
@@ -58,6 +60,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
data->verify = bootm_get_verify_mode();
+ data->appendroot = bootm_appendroot;
}
static enum bootm_verify bootm_verify_mode = BOOTM_VERIFY_HASH;
@@ -576,6 +579,18 @@ int bootm_boot(struct bootm_data *bootm_data)
}
}
+ if (bootm_data->appendroot) {
+ char *rootarg;
+
+ rootarg = path_get_linux_rootarg(data->os_file);
+ if (!IS_ERR(rootarg)) {
+ printf("Adding \"%s\" to Kernel commandline\n", rootarg);
+ globalvar_add_simple("linux.bootargs.bootm.appendroot",
+ rootarg);
+ free(rootarg);
+ }
+ }
+
printf("\nLoading %s '%s'", file_type_to_string(os_type),
data->os_file);
if (os_type == filetype_uimage &&
@@ -621,6 +636,7 @@ err_out:
if (data->of_root_node && data->of_root_node != of_get_root_node())
of_delete_node(data->of_root_node);
+ globalvar_remove("linux.bootargs.bootm.appendroot");
free(data->os_file);
free(data->oftree_file);
free(data->initrd_file);
@@ -634,6 +650,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+ globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD)) {
globalvar_add_simple("bootm.initrd", NULL);
globalvar_add_simple("bootm.initrd.loadaddr", NULL);
diff --git a/common/console.c b/common/console.c
index a541892583..a67f169b42 100644
--- a/common/console.c
+++ b/common/console.c
@@ -164,7 +164,7 @@ int console_set_baudrate(struct console_device *cdev, unsigned baudrate)
if (cdev->f_active) {
mdelay(50);
do {
- c = getc();
+ c = getchar();
} while (c != '\r' && c != '\n');
}
@@ -208,8 +208,8 @@ static void console_set_stdoutpath(struct console_device *cdev)
if (id < 0)
return;
- str = asprintf("console=%s%d,%dn8", cdev->linux_console_name,
- id, cdev->baudrate);
+ str = basprintf("console=%s%d,%dn8", cdev->linux_console_name, id,
+ cdev->baudrate);
globalvar_add_simple("linux.bootargs.console", str);
@@ -345,7 +345,7 @@ static int tstc_raw(void)
return 0;
}
-int getc(void)
+int getchar(void)
{
unsigned char ch;
uint64_t start;
@@ -380,17 +380,7 @@ int getc(void)
return ch;
}
-EXPORT_SYMBOL(getc);
-
-int fgetc(int fd)
-{
- char c;
-
- if (!fd)
- return getc();
- return read(fd, &c, 1);
-}
-EXPORT_SYMBOL(fgetc);
+EXPORT_SYMBOL(getchar);
int tstc(void)
{
@@ -476,7 +466,7 @@ int ctrlc (void)
{
poller_call();
- if (tstc() && getc() == 3)
+ if (tstc() && getchar() == 3)
return 1;
return 0;
}
diff --git a/common/console_common.c b/common/console_common.c
index a9bbce9a28..2e5869fab0 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -278,7 +278,7 @@ EXPORT_SYMBOL(console_get_first_active);
#endif /* !CONFIG_CONSOLE_NONE */
-int fprintf(int file, const char *fmt, ...)
+int dprintf(int file, const char *fmt, ...)
{
va_list args;
char printbuffer[CFG_PBSIZE];
@@ -293,30 +293,30 @@ int fprintf(int file, const char *fmt, ...)
va_end(args);
/* Print the string */
- return fputs(file, printbuffer);
+ return dputs(file, printbuffer);
}
-EXPORT_SYMBOL(fprintf);
+EXPORT_SYMBOL(dprintf);
-int fputs(int fd, const char *s)
+int dputs(int fd, const char *s)
{
if (fd == 1)
return puts(s);
else if (fd == 2)
- return eputs(s);
+ return console_puts(CONSOLE_STDERR, s);
else
return write(fd, s, strlen(s));
}
-EXPORT_SYMBOL(fputs);
+EXPORT_SYMBOL(dputs);
-int fputc(int fd, char c)
+int dputc(int fd, char c)
{
if (fd == 1)
putchar(c);
else if (fd == 2)
- eputc(c);
+ console_putc(CONSOLE_STDERR, c);
else
return write(fd, &c, 1);
return 0;
}
-EXPORT_SYMBOL(fputc);
+EXPORT_SYMBOL(dputc);
diff --git a/common/console_countdown.c b/common/console_countdown.c
index ffbdb4fa2d..c0c8c95022 100644
--- a/common/console_countdown.c
+++ b/common/console_countdown.c
@@ -39,7 +39,7 @@ int console_countdown(int timeout_s, unsigned flags, char *out_key)
do {
if (tstc()) {
- key = getc();
+ key = getchar();
if (flags & CONSOLE_COUNTDOWN_ANYKEY)
goto out;
if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n')
diff --git a/common/console_simple.c b/common/console_simple.c
index 69e76593ad..9675cbb0a6 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -48,13 +48,13 @@ int tstc(void)
}
EXPORT_SYMBOL(tstc);
-int getc(void)
+int getchar(void)
{
if (!console)
return -EINVAL;
return console->getc(console);
}
-EXPORT_SYMBOL(getc);
+EXPORT_SYMBOL(getchar);
void console_flush(void)
{
@@ -67,7 +67,7 @@ EXPORT_SYMBOL(console_flush);
/* test if ctrl-c was pressed */
int ctrlc (void)
{
- if (tstc() && getc() == 3)
+ if (tstc() && getchar() == 3)
return 1;
return 0;
}
diff --git a/common/env.c b/common/env.c
index c98ed73f9b..6f736d5add 100644
--- a/common/env.c
+++ b/common/env.c
@@ -28,6 +28,7 @@
#include <xfuncs.h>
#include <errno.h>
#include <init.h>
+#include <string.h>
#include <environment.h>
static struct env_context root = {
@@ -260,7 +261,7 @@ EXPORT_SYMBOL(export);
void export_env_ull(const char *name, unsigned long long val)
{
- char *valstr = asprintf("%llu", val);
+ char *valstr = basprintf("%llu", val);
setenv(name, valstr);
export(name);
@@ -323,20 +324,25 @@ int getenv_uint(const char *var , unsigned int *val)
}
EXPORT_SYMBOL(getenv_uint);
+/**
+ * getenv_bool - get a boolean value from an environment variable
+ * @var - Variable name
+ * @val - The boolean value returned.
+ *
+ * This function treats
+ * - any positive (nonzero) number as true
+ * - "0" as false
+ * - "true" (case insensitive) as true
+ * - "false" (case insensitive) as false
+ *
+ * Returns 0 for success or negative error code if the variable does
+ * not exist or contains something this function does not recognize
+ * as true or false.
+ */
int getenv_bool(const char *var, int *val)
{
const char *valstr = getenv(var);
- if (!valstr || !*valstr)
- return -EINVAL;
-
- if (!*valstr)
- *val = false;
- else if (*valstr == '0')
- *val = false;
- else
- *val = true;
-
- return 0;
+ return strtobool(valstr, val);
}
EXPORT_SYMBOL(getenv_bool);
diff --git a/common/environment.c b/common/environment.c
index be102db3d2..c3ad25266a 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -29,6 +29,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <crc.h>
#include <fcntl.h>
#include <envfs.h>
#include <xfuncs.h>
@@ -79,7 +80,7 @@ static int do_compare_file(const char *filename, const char *base)
char *cmp;
const char *relname = filename + strlen(base) + 1;
- cmp = asprintf("%s/%s", TMPDIR, relname);
+ cmp = basprintf("%s/%s", TMPDIR, relname);
ret = compare_file(cmp, filename);
free(cmp);
@@ -193,7 +194,7 @@ static int file_remove_action(const char *filename, struct stat *statbuf,
filename += sizeof(TMPDIR) - 1;
- envname = asprintf("%s/%s", data->base, filename);
+ envname = basprintf("%s/%s", data->base, filename);
ret = stat(envname, &s);
if (ret) {
diff --git a/common/firmware.c b/common/firmware.c
index a6f75bf887..664f9107d0 100644
--- a/common/firmware.c
+++ b/common/firmware.c
@@ -202,7 +202,7 @@ out:
int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *firmware)
{
int ret;
- char *name = asprintf("/dev/%s", mgr->handler->id);
+ char *name = basprintf("/dev/%s", mgr->handler->id);
ret = copy_file(firmware, name, 0);
diff --git a/common/globalvar.c b/common/globalvar.c
index 9a793ac4a9..75e4d43afb 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -33,6 +33,16 @@ int globalvar_add(const char *name,
return 0;
}
+void globalvar_remove(const char *name)
+{
+ struct param_d *param = get_param_by_name(&global_device, name);
+
+ if (!param)
+ return;
+
+ dev_remove_param(param);
+}
+
static int nv_save(const char *name, const char *val)
{
int fd, ret;
@@ -42,7 +52,7 @@ static int nv_save(const char *name, const char *val)
if (ret)
return ret;
- fname = asprintf("/env/nv/%s", name);
+ fname = basprintf("/env/nv/%s", name);
fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC);
@@ -51,7 +61,7 @@ static int nv_save(const char *name, const char *val)
if (fd < 0)
return fd;
- fprintf(fd, "%s", val);
+ dprintf(fd, "%s", val);
close(fd);
@@ -90,6 +100,9 @@ int nvvar_add(const char *name, const char *value)
struct param_d *p, *gp;
int ret;
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return -ENOSYS;
+
gp = get_param_by_name(&nv_device, name);
if (gp) {
ret = dev_set_param(&global_device, name, value);
@@ -131,11 +144,14 @@ int nvvar_remove(const char *name)
struct param_d *p;
char *fname;
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return -ENOSYS;
+
p = get_param_by_name(&nv_device, name);
if (!p)
return -ENOENT;
- fname = asprintf("/env/nv/%s", p->name);
+ fname = basprintf("/env/nv/%s", p->name);
unlink(fname);
free(fname);
@@ -153,6 +169,9 @@ int nvvar_load(void)
DIR *dir;
struct dirent *d;
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return -ENOSYS;
+
dir = opendir("/env/nv");
if (!dir)
return -ENOENT;
@@ -185,7 +204,7 @@ static void device_param_print(struct device_d *dev)
const char *p = dev_get_param(dev, param->name);
const char *nv = NULL;
- if (dev != &nv_device)
+ if (IS_ENABLED(CONFIG_NVVAR) && dev != &nv_device)
nv = dev_get_param(&nv_device, param->name);
printf("%s%s: %s\n", nv ? "* " : " ", param->name, p);
@@ -194,6 +213,9 @@ static void device_param_print(struct device_d *dev)
void nvvar_print(void)
{
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return;
+
device_param_print(&nv_device);
}
@@ -217,7 +239,8 @@ char *globalvar_get_match(const char *match, const char *separator)
if (!strncmp(match, param->name, strlen(match))) {
const char *p = dev_get_param(&global_device, param->name);
if (val) {
- char *new = asprintf("%s%s%s", val, separator, p);
+ char *new = basprintf("%s%s%s", val,
+ separator, p);
free(val);
val = new;
} else {
@@ -264,7 +287,9 @@ int globalvar_add_simple(const char *name, const char *value)
static int globalvar_init(void)
{
register_device(&global_device);
- register_device(&nv_device);
+
+ if (IS_ENABLED(CONFIG_NVVAR))
+ register_device(&nv_device);
globalvar_add_simple("version", UTS_RELEASE);
diff --git a/common/imd.c b/common/imd.c
index 241ebbdaed..159b73a828 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -306,7 +306,7 @@ int imd_command(int argc, char *argv[])
case 't':
type = imd_name_to_type(optarg);
if (type == IMD_TYPE_INVALID) {
- fprintf(stderr, "no such type: %s\n", optarg);
+ eprintf("no such type: %s\n", optarg);
return -ENOSYS;
}
break;
@@ -325,7 +325,7 @@ int imd_command(int argc, char *argv[])
}
if (optind == argc) {
- fprintf(stderr, "No image given\n");
+ eprintf("No image given\n");
return -ENOSYS;
}
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 04c6e6050c..1ffa79d1ec 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -34,6 +34,7 @@
#include <linux/mtd/nand.h>
#include <linux/stat.h>
#include <io.h>
+#include <crc.h>
#include <mach/generic.h>
#include <mtd/mtd-peb.h>
diff --git a/common/menu.c b/common/menu.c
index 54f2c71b29..9819569f6f 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -327,6 +327,7 @@ int menu_show(struct menu *m)
}
break;
}
+ case 'k':
case BB_KEY_UP:
m->selected = list_entry(m->selected->list.prev, struct menu_entry,
list);
@@ -336,6 +337,7 @@ int menu_show(struct menu *m)
}
repaint = 1;
break;
+ case 'j':
case BB_KEY_DOWN:
m->selected = list_entry(m->selected->list.next, struct menu_entry,
list);
@@ -346,13 +348,14 @@ int menu_show(struct menu *m)
repaint = 1;
break;
case ' ':
- if (m->selected->type != MENU_ENTRY_BOX)
+ if (m->selected->type == MENU_ENTRY_BOX) {
+ m->selected->box_state = !m->selected->box_state;
+ if (m->selected->action)
+ m->selected->action(m, m->selected);
+ repaint = 1;
break;
- m->selected->box_state = !m->selected->box_state;
- if (m->selected->action)
- m->selected->action(m, m->selected);
- repaint = 1;
- break;
+ }
+ /* no break */
case BB_KEY_ENTER:
if (ch_previous == BB_KEY_RETURN)
break;
diff --git a/common/menutree.c b/common/menutree.c
index 97e628de88..eb14da0d01 100644
--- a/common/menutree.c
+++ b/common/menutree.c
@@ -12,9 +12,11 @@
#include <environment.h>
#include <libbb.h>
#include <common.h>
+#include <command.h>
#include <glob.h>
#include <menu.h>
#include <fs.h>
+#include <shell.h>
#include <libfile.h>
#include <linux/stat.h>
@@ -96,7 +98,7 @@ int menutree(const char *path, int toplevel)
menu = menu_alloc();
- globpath = asprintf("%s/*", path);
+ globpath = basprintf("%s/*", path);
ret = glob(globpath, 0, NULL, &g);
free(globpath);
if (ret == GLOB_NOMATCH) {
@@ -147,7 +149,7 @@ int menutree(const char *path, int toplevel)
mt->me.type = MENU_ENTRY_NORMAL;
- mt->action = asprintf("%s/action", g.gl_pathv[i]);
+ mt->action = basprintf("%s/action", g.gl_pathv[i]);
ret = stat(mt->action, &s);
if (ret) {
diff --git a/common/module.c b/common/module.c
index eb882bce31..829c120007 100644
--- a/common/module.c
+++ b/common/module.c
@@ -60,7 +60,7 @@ static const struct kernel_symbol *lookup_symbol(const char *name,
return NULL;
}
-static unsigned long resolve_symbol(Elf32_Shdr *sechdrs,
+static unsigned long resolve_symbol(Elf32_Shdr *sechdrs,
const char *name)
{
const struct kernel_symbol *ks;
diff --git a/common/partitions.c b/common/partitions.c
index 82ec508e64..69a2b1fefb 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -51,7 +51,7 @@ static int register_one_partition(struct block_device *blk,
uint64_t size = part->size * SECTOR_SIZE;
struct cdev *cdev;
- partition_name = asprintf("%s.%d", blk->cdev.name, no);
+ partition_name = basprintf("%s.%d", blk->cdev.name, no);
if (!partition_name)
return -ENOMEM;
dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index a9945dd9eb..88734f166b 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -17,6 +17,7 @@
#include <init.h>
#include <asm/unaligned.h>
#include <dma.h>
+#include <crc.h>
#include <linux/ctype.h>
#include "efi.h"
diff --git a/common/password.c b/common/password.c
index 5b754d943f..d52b746f0f 100644
--- a/common/password.c
+++ b/common/password.c
@@ -24,6 +24,7 @@
#include <digest.h>
#include <malloc.h>
#include <xfuncs.h>
+#include <command.h>
#include <magicvar.h>
#include <clock.h>
#include <init.h>
@@ -62,7 +63,7 @@ int password(unsigned char *passwd, size_t length, int flags, int timeout)
do {
if (tstc()) {
- ch = getc();
+ ch = getchar();
switch (ch) {
case '\r':
diff --git a/common/startup.c b/common/startup.c
index 093a23ba08..432be67cd6 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -30,6 +30,7 @@
* @brief Main entry into the C part of barebox
*/
#include <common.h>
+#include <shell.h>
#include <init.h>
#include <command.h>
#include <malloc.h>
diff --git a/common/state.c b/common/state.c
index b55b1503bd..87afff3056 100644
--- a/common/state.c
+++ b/common/state.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <fcntl.h>
#include <fs.h>
+#include <crc.h>
#include <init.h>
#include <ioctl.h>
#include <libbb.h>
@@ -703,8 +704,8 @@ static int state_convert_node_variable(struct state *state,
*indexs = 0;
/* construct full name */
- name = asprintf("%s%s%s",
- parent_name, parent_name[0] ? "." : "", short_name);
+ name = basprintf("%s%s%s", parent_name, parent_name[0] ? "." : "",
+ short_name);
free(short_name);
if ((conv == STATE_CONVERT_TO_NODE) ||
diff --git a/common/tlsf.c b/common/tlsf.c
index 984342e095..ba68a5e688 100644
--- a/common/tlsf.c
+++ b/common/tlsf.c
@@ -151,7 +151,7 @@ static const size_t block_start_offset =
** the prev_phys_block field, and no larger than the number of addressable
** bits for FL_INDEX.
*/
-static const size_t block_size_min =
+static const size_t block_size_min =
sizeof(block_header_t) - sizeof(block_header_t*);
static const size_t block_size_max = tlsf_cast(size_t, 1) << FL_INDEX_MAX;
@@ -770,7 +770,7 @@ tlsf_pool tlsf_create(void* mem, size_t bytes)
#if defined (TLSF_64BIT)
rv += (tlsf_fls_sizet(0x80000000) == 31) ? 0 : 0x100;
rv += (tlsf_fls_sizet(0x100000000) == 32) ? 0 : 0x200;
- rv += (tlsf_fls_sizet(0xffffffffffffffff) == 63) ? 0 : 0x400;
+ rv += (tlsf_fls_sizet(0xffffffffffffffff) == 63) ? 0 : 0x400;
if (rv)
{
printf("tlsf_create: %x ffs/fls tests failed!\n", rv);
@@ -785,7 +785,7 @@ tlsf_pool tlsf_create(void* mem, size_t bytes)
printf("tlsf_create: Pool size must be at least %d bytes.\n",
(unsigned int)(pool_overhead + block_size_min));
#else
- printf("tlsf_create: Pool size must be between %u and %u bytes.\n",
+ printf("tlsf_create: Pool size must be between %u and %u bytes.\n",
(unsigned int)(pool_overhead + block_size_min),
(unsigned int)(pool_overhead + block_size_max));
#endif
diff --git a/common/uimage.c b/common/uimage.c
index 59d7b65c90..34daf70dc1 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -21,6 +21,7 @@
#include <image.h>
#include <malloc.h>
#include <errno.h>
+#include <crc.h>
#include <libbb.h>
#include <libfile.h>
#include <uncompress.h>