summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-05-09 08:49:43 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-05-09 08:49:43 +0200
commit4cb8e17aa3972e27f4b34e5bb2df9e7007824ac2 (patch)
tree942b24dcd275407d76f6b3ef85f6db9af1160163 /common
parent854df603da65bc56fe72218b402903f26155b0f0 (diff)
parent79fdb84a6b46f7c129225b57007b63e765747d52 (diff)
downloadbarebox-4cb8e17aa3972e27f4b34e5bb2df9e7007824ac2.tar.gz
barebox-4cb8e17aa3972e27f4b34e5bb2df9e7007824ac2.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig44
-rw-r--r--common/globalvar.c18
-rw-r--r--common/menu.c15
-rw-r--r--common/module.c2
-rw-r--r--common/tlsf.c6
5 files changed, 64 insertions, 21 deletions
diff --git a/common/Kconfig b/common/Kconfig
index d00ca6b0fb..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"
@@ -652,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
@@ -781,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/globalvar.c b/common/globalvar.c
index 5dad4f6a45..75e4d43afb 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -100,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);
@@ -141,6 +144,9 @@ 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;
@@ -163,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;
@@ -195,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);
@@ -204,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);
}
@@ -275,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/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/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/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