| 1 |
|
| 2 |
|
| 3 |
#ifndef CONSOLE_CONSOLE_H_ |
| 4 |
#define CONSOLE_CONSOLE_H_ |
| 5 |
|
| 6 |
#include <commonlib/console/post_codes.h> |
| 7 |
#include <console/vtxprintf.h> |
| 8 |
#include <stdint.h> |
| 9 |
|
| 10 |
|
| 11 |
#include <commonlib/loglevel.h> |
| 12 |
|
| 13 |
#define RAM_DEBUG (CONFIG(DEBUG_RAM_SETUP) ? BIOS_DEBUG : BIOS_NEVER) |
| 14 |
#define RAM_SPEW (CONFIG(DEBUG_RAM_SETUP) ? BIOS_SPEW : BIOS_NEVER) |
| 15 |
|
| 16 |
void post_code(u8 value); |
| 17 |
void mainboard_post(u8 value); |
| 18 |
void arch_post_code(u8 value); |
| 19 |
void soc_post_code(uint8_t value); |
| 20 |
|
| 21 |
void __noreturn __printf(1, 2) die(const char *fmt, ...); |
| 22 |
#define die_with_post_code(value, fmt, ...) \ |
| 23 |
do { post_code(value); die(fmt, ##__VA_ARGS__); } while (0) |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
void die_notify(void); |
| 30 |
|
| 31 |
#if CONFIG(CONSOLE_OVERRIDE_LOGLEVEL) |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
int get_console_loglevel(void); |
| 37 |
#else |
| 38 |
static inline int get_console_loglevel(void) |
| 39 |
{ |
| 40 |
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL; |
| 41 |
} |
| 42 |
#endif |
| 43 |
|
| 44 |
#define __CONSOLE_ENABLE__ \ |
| 45 |
((ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \ |
| 46 |
(ENV_POSTCAR && CONFIG(POSTCAR_CONSOLE)) || \ |
| 47 |
ENV_SEPARATE_VERSTAGE || ENV_SEPARATE_ROMSTAGE || ENV_RAMSTAGE || \ |
| 48 |
ENV_LIBAGESA || (ENV_SMM && CONFIG(DEBUG_SMI))) |
| 49 |
|
| 50 |
#if __CONSOLE_ENABLE__ |
| 51 |
int get_log_level(void); |
| 52 |
void console_init(void); |
| 53 |
int console_log_level(int msg_level); |
| 54 |
|
| 55 |
int printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); |
| 56 |
int vprintk(int msg_level, const char *fmt, va_list args); |
| 57 |
|
| 58 |
void do_putchar(unsigned char byte); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
long console_time_get_and_reset(void); |
| 63 |
void console_time_report(void); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL }; |
| 72 |
#define HAS_ONLY_FAST_CONSOLES !(CONFIG(SPKMODEM) || CONFIG(CONSOLE_QEMU_DEBUGCON) || \ |
| 73 |
CONFIG(CONSOLE_SERIAL) || CONFIG(CONSOLE_NE2K) || CONFIG(CONSOLE_USB) || \ |
| 74 |
CONFIG(EM100PRO_SPI_CONSOLE) || CONFIG(CONSOLE_SPI_FLASH) || \ |
| 75 |
CONFIG(CONSOLE_SYSTEM76_EC) || CONFIG(CONSOLE_AMD_SIMNOW) || \ |
| 76 |
CONFIG(CONSOLE_I2C_SMBUS)) |
| 77 |
|
| 78 |
#else |
| 79 |
static inline int get_log_level(void) { return -1; } |
| 80 |
static inline void console_init(void) {} |
| 81 |
static inline int console_log_level(int msg_level) { return 0; } |
| 82 |
static inline int |
| 83 |
__attribute__((format(printf, 2, 3))) |
| 84 |
printk(int LEVEL, const char *fmt, ...) { return 0; } |
| 85 |
static inline int vprintk(int LEVEL, const char *fmt, va_list args) { return 0; } |
| 86 |
static inline void do_putchar(unsigned char byte) {} |
| 87 |
static inline long console_time_get_and_reset(void) { return 0; } |
| 88 |
static inline void console_time_report(void) {} |
| 89 |
#endif |
| 90 |
|
| 91 |
#endif |