@@ -27,9 +27,11 @@ comment "U-Boot support needs libubootenv, libz"
depends on !HAVE_LIBUBOOTENV || !HAVE_ZLIB
config BOOTLOADER_NONE
- bool "None"
+ bool "Environment in RAM"
help
- No interface to a bootloader
+ This simulates the interface to a bootloader.
+ Bootloader environment is just maitained in RAM
+ and lost when SWUpdate exits.
config BOOTLOADER_GRUB
bool "GRUB"
@@ -6,24 +6,40 @@
*/
#include <unistd.h>
+#include <string.h>
#include "bootloader.h"
+#include "swupdate_dict.h"
+
+static struct dict environment;
+
int bootloader_env_set(const char __attribute__ ((__unused__)) *name,
const char __attribute__ ((__unused__)) *value)
{
+ dict_set_value(&environment, name, value);
+
return 0;
}
-int bootloader_env_unset(const char __attribute__ ((__unused__)) *name)
+int bootloader_env_unset(const char *name)
{
+ dict_remove(&environment, name);
+
return 0;
}
char *bootloader_env_get(const char __attribute__ ((__unused__)) *name)
{
- return NULL;
+ char *value = NULL, *var;
+
+ var = dict_get_value(&environment, name);
+
+ if (var)
+ value = strdup(var);
+
+ return value;
}
-int bootloader_apply_list(const char __attribute__ ((__unused__)) *filename)
+int bootloader_apply_list(const char *filename)
{
- return 0;
+ return dict_parse_script(&environment, filename);
}
Instead of doing nothing, the "none" bootloader maintains a list of environment in RAM. This allows full test when a variable is set and then read back from code. Signed-off-by: Stefano Babic <sbabic@denx.de> --- bootloader/Config.in | 6 ++++-- bootloader/none.c | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-)