aboutsummaryrefslogtreecommitdiff
path: root/core/init.c
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2017-04-20 17:15:00 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-04-27 14:16:19 +1000
commitba4d46fdd9eb3543ec9841efc8f504c21a5f9a48 (patch)
tree8235f246c995d25abec1ad97a9cbadd598b72909 /core/init.c
parentb74841db759d33d6823a8f39603e07319b90103b (diff)
downloadskiboot-ba4d46fdd9eb3543ec9841efc8f504c21a5f9a48.zip
skiboot-ba4d46fdd9eb3543ec9841efc8f504c21a5f9a48.tar.gz
skiboot-ba4d46fdd9eb3543ec9841efc8f504c21a5f9a48.tar.bz2
console: Set log level from nvram
This adds two new nvram options to set the console log level for the driver/uart and in memory. These are called log-level-memory and log-level-driver. These are only set once we have nvram inited. To set them you do: nvram -p ibm,skiboot --update-config log-level-memory=9 nvram -p ibm,skiboot --update-config log-level-driver=9 You can also use the named versions of emerg, alert, crit, err, warning, notice, printf, info, debug, trace or insane. ie. nvram -p ibm,skiboot --update-config log-level-driver=insane Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/init.c')
-rw-r--r--core/init.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/core/init.c b/core/init.c
index 6b8137c..9d4d185 100644
--- a/core/init.c
+++ b/core/init.c
@@ -68,6 +68,8 @@ struct debug_descriptor debug_descriptor = {
.state_flags = 0,
.memcons_phys = (uint64_t)&memcons,
.trace_mask = 0, /* All traces disabled by default */
+ /* console log level:
+ * high 4 bits in memory, low 4 bits driver (e.g. uart). */
#ifdef DEBUG
.console_log_levels = (PR_DEBUG << 4) | PR_DEBUG,
#else
@@ -615,6 +617,61 @@ static void dt_init_misc(void)
dt_fixups();
}
+static u8 console_get_level(const char *s)
+{
+ if (strcmp(s, "emerg") == 0)
+ return PR_EMERG;
+ if (strcmp(s, "alert") == 0)
+ return PR_ALERT;
+ if (strcmp(s, "crit") == 0)
+ return PR_CRIT;
+ if (strcmp(s, "err") == 0)
+ return PR_ERR;
+ if (strcmp(s, "warning") == 0)
+ return PR_WARNING;
+ if (strcmp(s, "notice") == 0)
+ return PR_NOTICE;
+ if (strcmp(s, "printf") == 0)
+ return PR_PRINTF;
+ if (strcmp(s, "info") == 0)
+ return PR_INFO;
+ if (strcmp(s, "debug") == 0)
+ return PR_DEBUG;
+ if (strcmp(s, "trace") == 0)
+ return PR_TRACE;
+ if (strcmp(s, "insane") == 0)
+ return PR_INSANE;
+ /* Assume it's a number instead */
+ return atoi(s);
+}
+
+static void console_log_level(void)
+{
+ const char *s;
+ u8 level;
+
+ /* console log level:
+ * high 4 bits in memory, low 4 bits driver (e.g. uart). */
+ s = nvram_query("log-level-driver");
+ if (s) {
+ level = console_get_level(s);
+ debug_descriptor.console_log_levels =
+ (debug_descriptor.console_log_levels & 0xf0 ) |
+ (level & 0x0f);
+ prlog(PR_NOTICE, "console: Setting driver log level to %i\n",
+ level & 0x0f);
+ }
+ s = nvram_query("log-level-memory");
+ if (s) {
+ level = console_get_level(s);
+ debug_descriptor.console_log_levels =
+ (debug_descriptor.console_log_levels & 0x0f ) |
+ ((level & 0x0f) << 4);
+ prlog(PR_NOTICE, "console: Setting memory log level to %i\n",
+ level & 0x0f);
+ }
+}
+
typedef void (*ctorcall_t)(void);
static void __nomcount do_ctors(void)
@@ -921,6 +978,9 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
/* Read in NVRAM and set it up */
nvram_init();
+ /* Set the console level */
+ console_log_level();
+
/* Secure/Trusted Boot init. We look for /ibm,secureboot in DT */
stb_init();