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. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 15 | * Foundation, Inc. |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #ifndef __CONSOLE_EARLY_PRINT_H_ |
| 19 | #define __CONSOLE_EARLY_PRINT_H_ |
| 20 | |
Stefan Reinauer | 408ebe6 | 2015-02-11 01:56:38 +0100 | [diff] [blame] | 21 | #if !defined(__ROMCC__) |
| 22 | #error "Don't include early_print.h" |
| 23 | #endif |
| 24 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 25 | #include <console/console.h> |
| 26 | #include <console/streams.h> |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame^] | 27 | #include <commonlib/loglevel.h> |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 28 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 29 | /* While in romstage, console loglevel is built-time constant. |
| 30 | * With ROMCC we inline this test with help from preprocessor. |
| 31 | */ |
| 32 | #define console_log_level(msg_level) (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= msg_level) |
| 33 | |
| 34 | #define CALL_CONSOLE_TX(loglevel, tx_func, x) \ |
| 35 | do { \ |
| 36 | if (console_log_level(loglevel)) { \ |
| 37 | tx_func(x); \ |
| 38 | console_tx_flush(); \ |
| 39 | } \ |
| 40 | } while (0) |
| 41 | |
| 42 | #define __console_tx_char(level, x) CALL_CONSOLE_TX(level, console_tx_byte, x) |
| 43 | #define __console_tx_hex8(level, x) CALL_CONSOLE_TX(level, console_tx_hex8, x) |
| 44 | #define __console_tx_hex16(level, x) CALL_CONSOLE_TX(level, console_tx_hex16, x) |
| 45 | #define __console_tx_hex32(level, x) CALL_CONSOLE_TX(level, console_tx_hex32, x) |
| 46 | #define __console_tx_string(level, x) CALL_CONSOLE_TX(level, console_tx_string, x) |
| 47 | |
| 48 | #define print_emerg(STR) __console_tx_string(BIOS_EMERG, STR) |
| 49 | #define print_alert(STR) __console_tx_string(BIOS_ALERT, STR) |
| 50 | #define print_crit(STR) __console_tx_string(BIOS_CRIT, STR) |
| 51 | #define print_err(STR) __console_tx_string(BIOS_ERR, STR) |
| 52 | #define print_warning(STR) __console_tx_string(BIOS_WARNING, STR) |
| 53 | #define print_notice(STR) __console_tx_string(BIOS_NOTICE, STR) |
| 54 | #define print_info(STR) __console_tx_string(BIOS_INFO, STR) |
| 55 | #define print_debug(STR) __console_tx_string(BIOS_DEBUG, STR) |
| 56 | #define print_spew(STR) __console_tx_string(BIOS_SPEW, STR) |
| 57 | |
| 58 | #define print_emerg_char(CH) __console_tx_char(BIOS_EMERG, CH) |
| 59 | #define print_alert_char(CH) __console_tx_char(BIOS_ALERT, CH) |
| 60 | #define print_crit_char(CH) __console_tx_char(BIOS_CRIT, CH) |
| 61 | #define print_err_char(CH) __console_tx_char(BIOS_ERR, CH) |
| 62 | #define print_warning_char(CH) __console_tx_char(BIOS_WARNING, CH) |
| 63 | #define print_notice_char(CH) __console_tx_char(BIOS_NOTICE, CH) |
| 64 | #define print_info_char(CH) __console_tx_char(BIOS_INFO, CH) |
| 65 | #define print_debug_char(CH) __console_tx_char(BIOS_DEBUG, CH) |
| 66 | #define print_spew_char(CH) __console_tx_char(BIOS_SPEW, CH) |
| 67 | |
| 68 | #define print_emerg_hex8(HEX) __console_tx_hex8(BIOS_EMERG, HEX) |
| 69 | #define print_alert_hex8(HEX) __console_tx_hex8(BIOS_ALERT, HEX) |
| 70 | #define print_crit_hex8(HEX) __console_tx_hex8(BIOS_CRIT, HEX) |
| 71 | #define print_err_hex8(HEX) __console_tx_hex8(BIOS_ERR, HEX) |
| 72 | #define print_warning_hex8(HEX) __console_tx_hex8(BIOS_WARNING, HEX) |
| 73 | #define print_notice_hex8(HEX) __console_tx_hex8(BIOS_NOTICE, HEX) |
| 74 | #define print_info_hex8(HEX) __console_tx_hex8(BIOS_INFO, HEX) |
| 75 | #define print_debug_hex8(HEX) __console_tx_hex8(BIOS_DEBUG, HEX) |
| 76 | #define print_spew_hex8(HEX) __console_tx_hex8(BIOS_SPEW, HEX) |
| 77 | |
| 78 | #define print_emerg_hex16(HEX) __console_tx_hex16(BIOS_EMERG, HEX) |
| 79 | #define print_alert_hex16(HEX) __console_tx_hex16(BIOS_ALERT, HEX) |
| 80 | #define print_crit_hex16(HEX) __console_tx_hex16(BIOS_CRIT, HEX) |
| 81 | #define print_err_hex16(HEX) __console_tx_hex16(BIOS_ERR, HEX) |
| 82 | #define print_warning_hex16(HEX) __console_tx_hex16(BIOS_WARNING, HEX) |
| 83 | #define print_notice_hex16(HEX) __console_tx_hex16(BIOS_NOTICE, HEX) |
| 84 | #define print_info_hex16(HEX) __console_tx_hex16(BIOS_INFO, HEX) |
| 85 | #define print_debug_hex16(HEX) __console_tx_hex16(BIOS_DEBUG, HEX) |
| 86 | #define print_spew_hex16(HEX) __console_tx_hex16(BIOS_SPEW, HEX) |
| 87 | |
| 88 | #define print_emerg_hex32(HEX) __console_tx_hex32(BIOS_EMERG, HEX) |
| 89 | #define print_alert_hex32(HEX) __console_tx_hex32(BIOS_ALERT, HEX) |
| 90 | #define print_crit_hex32(HEX) __console_tx_hex32(BIOS_CRIT, HEX) |
| 91 | #define print_err_hex32(HEX) __console_tx_hex32(BIOS_ERR, HEX) |
| 92 | #define print_warning_hex32(HEX) __console_tx_hex32(BIOS_WARNING, HEX) |
| 93 | #define print_notice_hex32(HEX) __console_tx_hex32(BIOS_NOTICE, HEX) |
| 94 | #define print_info_hex32(HEX) __console_tx_hex32(BIOS_INFO, HEX) |
| 95 | #define print_debug_hex32(HEX) __console_tx_hex32(BIOS_DEBUG, HEX) |
| 96 | #define print_spew_hex32(HEX) __console_tx_hex32(BIOS_SPEW, HEX) |
| 97 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 98 | #endif /* __CONSOLE_EARLY_PRINT_H_ */ |