[coreboot-gerrit] Change in coreboot[master]: console: Introduce a way for mainboard to override the loglevel

Julien Viard de Galbert (Code Review) gerrit at coreboot.org
Mon Feb 12 15:01:57 CET 2018


Julien Viard de Galbert has uploaded this change for review. ( https://review.coreboot.org/23712


Change subject: console: Introduce a way for mainboard to override the loglevel
......................................................................

console: Introduce a way for mainboard to override the loglevel

This change add a weak function to allow mainboard to override the
default console loglevel.
This allows a mainboard to sample a GPIO to switch the loglevel
value between different environments (qualification vs production)
without re-flashing.

Change-Id: Id6cc72b8fe5c4c50a6f83ce80e6440b078eec6e2
Signed-off-by: Julien Viard de Galbert <jviarddegalbert at online.net>
---
M src/console/init.c
M src/include/console/console.h
2 files changed, 17 insertions(+), 1 deletion(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/23712/1

diff --git a/src/console/init.c b/src/console/init.c
index 422315a..b14dc3d 100644
--- a/src/console/init.c
+++ b/src/console/init.c
@@ -29,12 +29,20 @@
 #define CONSOLE_LEVEL_CONST 0
 #endif
 
+__attribute__((weak)) const int mainboard_get_default_console_loglevel(void)
+{
+	return -1;
+}
+
 static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
 
 static inline int get_log_level(void)
 {
-	if (CONSOLE_LEVEL_CONST)
+	if (CONSOLE_LEVEL_CONST) {
+		int lvl = mainboard_get_default_console_loglevel();
+		if (lvl >= 0) return lvl;
 		return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
+	}
 
 	return console_loglevel;
 }
@@ -54,6 +62,9 @@
 	if (CONSOLE_LEVEL_CONST)
 		return;
 
+	int lvl = mainboard_get_default_console_loglevel();
+	if (lvl >= 0) debug_level = lvl;
+
 	get_option(&debug_level, "debug_level");
 
 	set_log_level(debug_level);
diff --git a/src/include/console/console.h b/src/include/console/console.h
index aa935e4..d21b3c4 100644
--- a/src/include/console/console.h
+++ b/src/include/console/console.h
@@ -64,6 +64,11 @@
 #define printk(LEVEL, fmt, args...) \
 	do { do_printk(LEVEL, fmt, ##args); } while (0)
 
+/*
+ * this function is weak and can be overridden by a mainboard function.
+ * return -1 to not override the configuration default.
+ */
+const int mainboard_get_default_console_loglevel(void);
 #else
 static inline void console_init(void) {}
 static inline int console_log_level(int msg_level) { return 0; }

-- 
To view, visit https://review.coreboot.org/23712
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6cc72b8fe5c4c50a6f83ce80e6440b078eec6e2
Gerrit-Change-Number: 23712
Gerrit-PatchSet: 1
Gerrit-Owner: Julien Viard de Galbert <jviarddegalbert at online.net>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180212/77f40240/attachment-0001.html>


More information about the coreboot-gerrit mailing list