2020-04-02 23:48:27 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2010-09-27 20:49:46 +02:00
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
#ifndef CONSOLE_CONSOLE_H_
|
|
|
|
#define CONSOLE_CONSOLE_H_
|
|
|
|
|
2021-07-17 01:39:28 +02:00
|
|
|
#include <commonlib/console/post_codes.h>
|
2020-01-04 15:15:50 +01:00
|
|
|
#include <console/vtxprintf.h>
|
2021-07-17 01:39:28 +02:00
|
|
|
#include <stdint.h>
|
2019-02-05 08:48:59 +01:00
|
|
|
|
|
|
|
/* console.h is supposed to provide the log levels defined in here: */
|
2015-09-08 20:34:43 +02:00
|
|
|
#include <commonlib/loglevel.h>
|
2011-05-10 19:46:41 +02:00
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
#define RAM_DEBUG (CONFIG(DEBUG_RAM_SETUP) ? BIOS_DEBUG : BIOS_NEVER)
|
|
|
|
#define RAM_SPEW (CONFIG(DEBUG_RAM_SETUP) ? BIOS_SPEW : BIOS_NEVER)
|
2017-04-17 00:53:10 +02:00
|
|
|
|
2010-04-03 00:11:20 +02:00
|
|
|
void post_code(u8 value);
|
2020-01-04 15:15:50 +01:00
|
|
|
void mainboard_post(u8 value);
|
2020-01-04 10:58:50 +01:00
|
|
|
void arch_post_code(u8 value);
|
2020-01-04 14:55:16 +01:00
|
|
|
|
console: Make die() and friends variadic
die() currently only accepts a fixed message string, which is rather
inconvenient when there is extra information that would be helpful to
print in the error message. This currently requires an extra call to
printk(), which is somewhat awkward:
printk(BIOS_EMERG, "Bad table, opcode %d at %d", id, i);
die(""); // what do I say here?
die() already has a printk() inside it to print the error message, so
let's just make it variadic to combine the two.
die("Bad table, opcode %d at %d", id, i); // much better
Forwarding variadic arguments from one function to another is rather
tricky, so die_with_post_code() is redefined as a variadic macro
instead.
Change-Id: I28b9eac32899a1aa89e086e0d3889b75459581aa
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33153
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
2019-05-31 20:53:54 +02:00
|
|
|
void __noreturn die(const char *fmt, ...);
|
|
|
|
#define die_with_post_code(value, fmt, ...) \
|
|
|
|
do { post_code(value); die(fmt, ##__VA_ARGS__); } while (0)
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2017-05-17 19:08:32 +02:00
|
|
|
/*
|
|
|
|
* This function is weak and can be overridden to provide additional
|
|
|
|
* feedback to the user. Possible use case: Play a beep.
|
|
|
|
*/
|
|
|
|
void die_notify(void);
|
|
|
|
|
2021-01-28 18:35:12 +01:00
|
|
|
#if CONFIG(CONSOLE_OVERRIDE_LOGLEVEL)
|
|
|
|
/*
|
|
|
|
* This function should be implemented at mainboard level.
|
|
|
|
* The returned value will _replace_ the loglevel value;
|
|
|
|
*/
|
|
|
|
int get_console_loglevel(void);
|
|
|
|
#else
|
|
|
|
static inline int get_console_loglevel(void)
|
|
|
|
{
|
|
|
|
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-26 14:19:04 +01:00
|
|
|
#define __CONSOLE_ENABLE__ \
|
2019-03-06 01:53:33 +01:00
|
|
|
((ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \
|
2020-04-22 01:03:53 +02:00
|
|
|
(ENV_POSTCAR && CONFIG(POSTCAR_CONSOLE)) || \
|
|
|
|
ENV_SEPARATE_VERSTAGE || ENV_ROMSTAGE || ENV_RAMSTAGE || \
|
|
|
|
ENV_LIBAGESA || (ENV_SMM && CONFIG(DEBUG_SMI)))
|
2014-02-04 18:03:57 +01:00
|
|
|
|
2014-02-26 14:19:04 +01:00
|
|
|
#if __CONSOLE_ENABLE__
|
2021-09-11 00:29:23 +02:00
|
|
|
void console_init(void);
|
2014-02-26 14:19:04 +01:00
|
|
|
int console_log_level(int msg_level);
|
2021-03-27 20:03:02 +01:00
|
|
|
|
|
|
|
int printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
|
|
|
int vprintk(int msg_level, const char *fmt, va_list args);
|
|
|
|
|
2014-02-04 18:03:57 +01:00
|
|
|
void do_putchar(unsigned char byte);
|
2013-02-06 14:51:15 +01:00
|
|
|
|
2019-11-02 13:12:18 +01:00
|
|
|
/* Return number of microseconds elapsed from start of stage or the previous
|
|
|
|
get_and_reset() call. */
|
|
|
|
long console_time_get_and_reset(void);
|
|
|
|
void console_time_report(void);
|
|
|
|
|
2019-02-12 13:16:21 +01:00
|
|
|
enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL };
|
2014-02-26 14:19:04 +01:00
|
|
|
#else
|
|
|
|
static inline void console_init(void) {}
|
|
|
|
static inline int console_log_level(int msg_level) { return 0; }
|
2021-03-27 20:03:02 +01:00
|
|
|
static inline int
|
2021-04-10 19:23:57 +02:00
|
|
|
__attribute__((format(printf, 2, 3)))
|
2021-03-27 20:03:02 +01:00
|
|
|
printk(int LEVEL, const char *fmt, ...) { return 0; }
|
|
|
|
static inline int vprintk(int LEVEL, const char *fmt, va_list args) { return 0; }
|
2014-02-26 14:19:04 +01:00
|
|
|
static inline void do_putchar(unsigned char byte) {}
|
2019-11-02 13:12:18 +01:00
|
|
|
static inline long console_time_get_and_reset(void) { return 0; }
|
|
|
|
static inline void console_time_report(void) {}
|
2014-02-04 18:03:57 +01:00
|
|
|
#endif
|
2013-02-06 14:51:15 +01:00
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
#endif /* CONSOLE_CONSOLE_H_ */
|