summaryrefslogtreecommitdiffstats
path: root/common/console_common.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-10-07 08:00:13 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-10-07 08:00:13 +0200
commit9aa6dd027012892d14aa53f9c3d6965c37afc001 (patch)
treeb97a8cb9ee8bf1c154ca52c010c9808d02b4fd85 /common/console_common.c
parent408f054247fa7250546bc041b1deb306d0b9fa98 (diff)
parent666f12e0c19a19f4431e05f6e5b37e657a62038f (diff)
downloadbarebox-9aa6dd027012892d14aa53f9c3d6965c37afc001.tar.gz
Merge branch 'for-next/login'
Conflicts: include/console.h
Diffstat (limited to 'common/console_common.c')
-rw-r--r--common/console_common.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/common/console_common.c b/common/console_common.c
index a3aca6f..5d2ccdb 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -21,9 +21,69 @@
#include <common.h>
#include <fs.h>
#include <errno.h>
+#include <console.h>
+#include <init.h>
+#include <environment.h>
+#include <globalvar.h>
+#include <magicvar.h>
+#include <password.h>
#ifndef CONFIG_CONSOLE_NONE
+static int console_input_allow;
+
+static int console_global_init(void)
+{
+ if (IS_ENABLED(CONFIG_CMD_LOGIN) && is_passwd_enable())
+ console_input_allow = 0;
+ else
+ console_input_allow = 1;
+
+ globalvar_add_simple_bool("console.input_allow", &console_input_allow);
+
+ return 0;
+}
+late_initcall(console_global_init);
+
+BAREBOX_MAGICVAR_NAMED(global_console_input_allow, global.console.input_allow, "console input allowed");
+
+bool console_is_input_allow(void)
+{
+ return console_input_allow;
+}
+
+void console_allow_input(bool val)
+{
+ console_input_allow = val;
+}
+
+int barebox_loglevel = CONFIG_DEFAULT_LOGLEVEL;
+
+int pr_print(int level, const char *fmt, ...)
+{
+ va_list args;
+ uint i;
+ char printbuffer[CFG_PBSIZE];
+
+ if (level > barebox_loglevel)
+ return 0;
+
+ va_start(args, fmt);
+ i = vsprintf(printbuffer, fmt, args);
+ va_end(args);
+
+ /* Print the string */
+ puts(printbuffer);
+
+ return i;
+}
+
+static int loglevel_init(void)
+{
+ return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d");
+}
+device_initcall(loglevel_init);
+
int printf(const char *fmt, ...)
{
va_list args;