[coreboot-gerrit] New patch to review for coreboot: cbfstool: provide printk() to cbfstool code

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Thu Oct 1 22:58:36 CET 2015


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11774

-gerrit

commit a084e3715ce5848f13cd90aea7ef47340bda9627
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Thu Oct 1 14:25:19 2015 -0500

    cbfstool: provide printk() to cbfstool code
    
    For shared compilation units between coreboot proper
    and cbfstool that means one needs to provide printk
    logging. Therefore, provide printk() at <console/console.h>
    to mimic coreboot's environment.
    
    BUG=chrome-os-partner:44827
    BRANCH=None
    TEST=Built cbfstool with code that includes and uses
         <console/console.h>.
    
    Change-Id: I8e54d403526a397e4fd117738a367a0a7bb71637
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 util/cbfstool/common.h          | 10 ++-------
 util/cbfstool/console/console.h | 49 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 86ae484..b638653 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -26,17 +26,11 @@
 #include <string.h>
 #include <assert.h>
 
+#include <console/console.h>
+
 /* Endianess */
 #include "swab.h"
 
-/* Message output */
-extern int verbose;
-#define ERROR(...) { fprintf(stderr, "E: " __VA_ARGS__); }
-#define WARN(...) { fprintf(stderr, "W: " __VA_ARGS__); }
-#define LOG(...) { fprintf(stderr, __VA_ARGS__); }
-#define INFO(...) { if (verbose > 0) fprintf(stderr, "INFO: " __VA_ARGS__); }
-#define DEBUG(...) { if (verbose > 1) fprintf(stderr, "DEBUG: " __VA_ARGS__); }
-
 /* Helpers */
 #define ARRAY_SIZE(a) (int)(sizeof(a) / sizeof((a)[0]))
 #define ALIGN(val, by) (((val) + (by)-1)&~((by)-1))
diff --git a/util/cbfstool/console/console.h b/util/cbfstool/console/console.h
new file mode 100644
index 0000000..c51ab0a
--- /dev/null
+++ b/util/cbfstool/console/console.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#ifndef _CBFSTOOL_CONSOLE_H_
+#define _CBFSTOOL_CONSOLE_H_
+
+#include <stdio.h>
+#include <commonlib/loglevel.h>
+
+/* Message output */
+extern int verbose;
+#define ERROR(...) { fprintf(stderr, "E: " __VA_ARGS__); }
+#define WARN(...) { fprintf(stderr, "W: " __VA_ARGS__); }
+#define LOG(...) { fprintf(stderr, __VA_ARGS__); }
+#define INFO(...) { if (verbose > 0) fprintf(stderr, "INFO: " __VA_ARGS__); }
+#define DEBUG(...) { if (verbose > 1) fprintf(stderr, "DEBUG: " __VA_ARGS__); }
+
+
+#define printk(lvl, ...) \
+	{						\
+		if ((lvl) <= BIOS_ERR) {		\
+			ERROR(__VA_ARGS__);		\
+		} else if ((lvl) <= BIOS_NOTICE) {	\
+			WARN(__VA_ARGS__);		\
+		} else if ((lvl) <= BIOS_INFO) {	\
+			INFO(__VA_ARGS__);		\
+		} else if ((lvl) <= BIOS_DEBUG) {	\
+			DEBUG(__VA_ARGS__);		\
+		}					\
+	}
+
+#endif
+



More information about the coreboot-gerrit mailing list