Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #ifndef __CONSOLE_EARLY_PRINT_H_ |
| 15 | #define __CONSOLE_EARLY_PRINT_H_ |
| 16 | |
Stefan Reinauer | 408ebe6 | 2015-02-11 01:56:38 +0100 | [diff] [blame] | 17 | #if !defined(__ROMCC__) |
| 18 | #error "Don't include early_print.h" |
| 19 | #endif |
| 20 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 21 | #include <console/console.h> |
| 22 | #include <console/streams.h> |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame] | 23 | #include <commonlib/loglevel.h> |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 24 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 25 | /* While in romstage, console loglevel is built-time constant. |
| 26 | * With ROMCC we inline this test with help from preprocessor. |
| 27 | */ |
| 28 | #define console_log_level(msg_level) (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= msg_level) |
| 29 | |
| 30 | #define CALL_CONSOLE_TX(loglevel, tx_func, x) \ |
| 31 | do { \ |
| 32 | if (console_log_level(loglevel)) { \ |
| 33 | tx_func(x); \ |
| 34 | console_tx_flush(); \ |
| 35 | } \ |
| 36 | } while (0) |
| 37 | |
| 38 | #define __console_tx_char(level, x) CALL_CONSOLE_TX(level, console_tx_byte, x) |
| 39 | #define __console_tx_hex8(level, x) CALL_CONSOLE_TX(level, console_tx_hex8, x) |
| 40 | #define __console_tx_hex16(level, x) CALL_CONSOLE_TX(level, console_tx_hex16, x) |
| 41 | #define __console_tx_hex32(level, x) CALL_CONSOLE_TX(level, console_tx_hex32, x) |
| 42 | #define __console_tx_string(level, x) CALL_CONSOLE_TX(level, console_tx_string, x) |
| 43 | |
| 44 | #define print_emerg(STR) __console_tx_string(BIOS_EMERG, STR) |
| 45 | #define print_alert(STR) __console_tx_string(BIOS_ALERT, STR) |
| 46 | #define print_crit(STR) __console_tx_string(BIOS_CRIT, STR) |
| 47 | #define print_err(STR) __console_tx_string(BIOS_ERR, STR) |
| 48 | #define print_warning(STR) __console_tx_string(BIOS_WARNING, STR) |
| 49 | #define print_notice(STR) __console_tx_string(BIOS_NOTICE, STR) |
| 50 | #define print_info(STR) __console_tx_string(BIOS_INFO, STR) |
| 51 | #define print_debug(STR) __console_tx_string(BIOS_DEBUG, STR) |
| 52 | #define print_spew(STR) __console_tx_string(BIOS_SPEW, STR) |
| 53 | |
| 54 | #define print_emerg_char(CH) __console_tx_char(BIOS_EMERG, CH) |
| 55 | #define print_alert_char(CH) __console_tx_char(BIOS_ALERT, CH) |
| 56 | #define print_crit_char(CH) __console_tx_char(BIOS_CRIT, CH) |
| 57 | #define print_err_char(CH) __console_tx_char(BIOS_ERR, CH) |
| 58 | #define print_warning_char(CH) __console_tx_char(BIOS_WARNING, CH) |
| 59 | #define print_notice_char(CH) __console_tx_char(BIOS_NOTICE, CH) |
| 60 | #define print_info_char(CH) __console_tx_char(BIOS_INFO, CH) |
| 61 | #define print_debug_char(CH) __console_tx_char(BIOS_DEBUG, CH) |
| 62 | #define print_spew_char(CH) __console_tx_char(BIOS_SPEW, CH) |
| 63 | |
| 64 | #define print_emerg_hex8(HEX) __console_tx_hex8(BIOS_EMERG, HEX) |
| 65 | #define print_alert_hex8(HEX) __console_tx_hex8(BIOS_ALERT, HEX) |
| 66 | #define print_crit_hex8(HEX) __console_tx_hex8(BIOS_CRIT, HEX) |
| 67 | #define print_err_hex8(HEX) __console_tx_hex8(BIOS_ERR, HEX) |
| 68 | #define print_warning_hex8(HEX) __console_tx_hex8(BIOS_WARNING, HEX) |
| 69 | #define print_notice_hex8(HEX) __console_tx_hex8(BIOS_NOTICE, HEX) |
| 70 | #define print_info_hex8(HEX) __console_tx_hex8(BIOS_INFO, HEX) |
| 71 | #define print_debug_hex8(HEX) __console_tx_hex8(BIOS_DEBUG, HEX) |
| 72 | #define print_spew_hex8(HEX) __console_tx_hex8(BIOS_SPEW, HEX) |
| 73 | |
| 74 | #define print_emerg_hex16(HEX) __console_tx_hex16(BIOS_EMERG, HEX) |
| 75 | #define print_alert_hex16(HEX) __console_tx_hex16(BIOS_ALERT, HEX) |
| 76 | #define print_crit_hex16(HEX) __console_tx_hex16(BIOS_CRIT, HEX) |
| 77 | #define print_err_hex16(HEX) __console_tx_hex16(BIOS_ERR, HEX) |
| 78 | #define print_warning_hex16(HEX) __console_tx_hex16(BIOS_WARNING, HEX) |
| 79 | #define print_notice_hex16(HEX) __console_tx_hex16(BIOS_NOTICE, HEX) |
| 80 | #define print_info_hex16(HEX) __console_tx_hex16(BIOS_INFO, HEX) |
| 81 | #define print_debug_hex16(HEX) __console_tx_hex16(BIOS_DEBUG, HEX) |
| 82 | #define print_spew_hex16(HEX) __console_tx_hex16(BIOS_SPEW, HEX) |
| 83 | |
| 84 | #define print_emerg_hex32(HEX) __console_tx_hex32(BIOS_EMERG, HEX) |
| 85 | #define print_alert_hex32(HEX) __console_tx_hex32(BIOS_ALERT, HEX) |
| 86 | #define print_crit_hex32(HEX) __console_tx_hex32(BIOS_CRIT, HEX) |
| 87 | #define print_err_hex32(HEX) __console_tx_hex32(BIOS_ERR, HEX) |
| 88 | #define print_warning_hex32(HEX) __console_tx_hex32(BIOS_WARNING, HEX) |
| 89 | #define print_notice_hex32(HEX) __console_tx_hex32(BIOS_NOTICE, HEX) |
| 90 | #define print_info_hex32(HEX) __console_tx_hex32(BIOS_INFO, HEX) |
| 91 | #define print_debug_hex32(HEX) __console_tx_hex32(BIOS_DEBUG, HEX) |
| 92 | #define print_spew_hex32(HEX) __console_tx_hex32(BIOS_SPEW, HEX) |
| 93 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 94 | #endif /* __CONSOLE_EARLY_PRINT_H_ */ |