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 |
| 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | */ |
| 17 | |
| 18 | #ifndef __CONSOLE_EARLY_PRINT_H_ |
| 19 | #define __CONSOLE_EARLY_PRINT_H_ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <console/streams.h> |
| 23 | #include <console/loglevel.h> |
| 24 | |
| 25 | #if defined(__ROMCC__) |
| 26 | /* While in romstage, console loglevel is built-time constant. |
| 27 | * With ROMCC we inline this test with help from preprocessor. |
| 28 | */ |
| 29 | #define console_log_level(msg_level) (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= msg_level) |
| 30 | |
| 31 | #define CALL_CONSOLE_TX(loglevel, tx_func, x) \ |
| 32 | do { \ |
| 33 | if (console_log_level(loglevel)) { \ |
| 34 | tx_func(x); \ |
| 35 | console_tx_flush(); \ |
| 36 | } \ |
| 37 | } while (0) |
| 38 | |
| 39 | #define __console_tx_char(level, x) CALL_CONSOLE_TX(level, console_tx_byte, x) |
| 40 | #define __console_tx_hex8(level, x) CALL_CONSOLE_TX(level, console_tx_hex8, x) |
| 41 | #define __console_tx_hex16(level, x) CALL_CONSOLE_TX(level, console_tx_hex16, x) |
| 42 | #define __console_tx_hex32(level, x) CALL_CONSOLE_TX(level, console_tx_hex32, x) |
| 43 | #define __console_tx_string(level, x) CALL_CONSOLE_TX(level, console_tx_string, x) |
| 44 | |
| 45 | #define print_emerg(STR) __console_tx_string(BIOS_EMERG, STR) |
| 46 | #define print_alert(STR) __console_tx_string(BIOS_ALERT, STR) |
| 47 | #define print_crit(STR) __console_tx_string(BIOS_CRIT, STR) |
| 48 | #define print_err(STR) __console_tx_string(BIOS_ERR, STR) |
| 49 | #define print_warning(STR) __console_tx_string(BIOS_WARNING, STR) |
| 50 | #define print_notice(STR) __console_tx_string(BIOS_NOTICE, STR) |
| 51 | #define print_info(STR) __console_tx_string(BIOS_INFO, STR) |
| 52 | #define print_debug(STR) __console_tx_string(BIOS_DEBUG, STR) |
| 53 | #define print_spew(STR) __console_tx_string(BIOS_SPEW, STR) |
| 54 | |
| 55 | #define print_emerg_char(CH) __console_tx_char(BIOS_EMERG, CH) |
| 56 | #define print_alert_char(CH) __console_tx_char(BIOS_ALERT, CH) |
| 57 | #define print_crit_char(CH) __console_tx_char(BIOS_CRIT, CH) |
| 58 | #define print_err_char(CH) __console_tx_char(BIOS_ERR, CH) |
| 59 | #define print_warning_char(CH) __console_tx_char(BIOS_WARNING, CH) |
| 60 | #define print_notice_char(CH) __console_tx_char(BIOS_NOTICE, CH) |
| 61 | #define print_info_char(CH) __console_tx_char(BIOS_INFO, CH) |
| 62 | #define print_debug_char(CH) __console_tx_char(BIOS_DEBUG, CH) |
| 63 | #define print_spew_char(CH) __console_tx_char(BIOS_SPEW, CH) |
| 64 | |
| 65 | #define print_emerg_hex8(HEX) __console_tx_hex8(BIOS_EMERG, HEX) |
| 66 | #define print_alert_hex8(HEX) __console_tx_hex8(BIOS_ALERT, HEX) |
| 67 | #define print_crit_hex8(HEX) __console_tx_hex8(BIOS_CRIT, HEX) |
| 68 | #define print_err_hex8(HEX) __console_tx_hex8(BIOS_ERR, HEX) |
| 69 | #define print_warning_hex8(HEX) __console_tx_hex8(BIOS_WARNING, HEX) |
| 70 | #define print_notice_hex8(HEX) __console_tx_hex8(BIOS_NOTICE, HEX) |
| 71 | #define print_info_hex8(HEX) __console_tx_hex8(BIOS_INFO, HEX) |
| 72 | #define print_debug_hex8(HEX) __console_tx_hex8(BIOS_DEBUG, HEX) |
| 73 | #define print_spew_hex8(HEX) __console_tx_hex8(BIOS_SPEW, HEX) |
| 74 | |
| 75 | #define print_emerg_hex16(HEX) __console_tx_hex16(BIOS_EMERG, HEX) |
| 76 | #define print_alert_hex16(HEX) __console_tx_hex16(BIOS_ALERT, HEX) |
| 77 | #define print_crit_hex16(HEX) __console_tx_hex16(BIOS_CRIT, HEX) |
| 78 | #define print_err_hex16(HEX) __console_tx_hex16(BIOS_ERR, HEX) |
| 79 | #define print_warning_hex16(HEX) __console_tx_hex16(BIOS_WARNING, HEX) |
| 80 | #define print_notice_hex16(HEX) __console_tx_hex16(BIOS_NOTICE, HEX) |
| 81 | #define print_info_hex16(HEX) __console_tx_hex16(BIOS_INFO, HEX) |
| 82 | #define print_debug_hex16(HEX) __console_tx_hex16(BIOS_DEBUG, HEX) |
| 83 | #define print_spew_hex16(HEX) __console_tx_hex16(BIOS_SPEW, HEX) |
| 84 | |
| 85 | #define print_emerg_hex32(HEX) __console_tx_hex32(BIOS_EMERG, HEX) |
| 86 | #define print_alert_hex32(HEX) __console_tx_hex32(BIOS_ALERT, HEX) |
| 87 | #define print_crit_hex32(HEX) __console_tx_hex32(BIOS_CRIT, HEX) |
| 88 | #define print_err_hex32(HEX) __console_tx_hex32(BIOS_ERR, HEX) |
| 89 | #define print_warning_hex32(HEX) __console_tx_hex32(BIOS_WARNING, HEX) |
| 90 | #define print_notice_hex32(HEX) __console_tx_hex32(BIOS_NOTICE, HEX) |
| 91 | #define print_info_hex32(HEX) __console_tx_hex32(BIOS_INFO, HEX) |
| 92 | #define print_debug_hex32(HEX) __console_tx_hex32(BIOS_DEBUG, HEX) |
| 93 | #define print_spew_hex32(HEX) __console_tx_hex32(BIOS_SPEW, HEX) |
| 94 | |
| 95 | #else |
| 96 | |
| 97 | #define print_emerg(STR) printk(BIOS_EMERG, "%s", (STR)) |
| 98 | #define print_alert(STR) printk(BIOS_ALERT, "%s", (STR)) |
| 99 | #define print_crit(STR) printk(BIOS_CRIT, "%s", (STR)) |
| 100 | #define print_err(STR) printk(BIOS_ERR, "%s", (STR)) |
| 101 | #define print_warning(STR) printk(BIOS_WARNING,"%s", (STR)) |
| 102 | #define print_notice(STR) printk(BIOS_NOTICE, "%s", (STR)) |
| 103 | #define print_info(STR) printk(BIOS_INFO, "%s", (STR)) |
| 104 | #define print_debug(STR) printk(BIOS_DEBUG, "%s", (STR)) |
| 105 | #define print_spew(STR) printk(BIOS_SPEW, "%s", (STR)) |
| 106 | |
| 107 | #define print_emerg_char(CH) printk(BIOS_EMERG, "%c", (CH)) |
| 108 | #define print_alert_char(CH) printk(BIOS_ALERT, "%c", (CH)) |
| 109 | #define print_crit_char(CH) printk(BIOS_CRIT, "%c", (CH)) |
| 110 | #define print_err_char(CH) printk(BIOS_ERR, "%c", (CH)) |
| 111 | #define print_warning_char(CH) printk(BIOS_WARNING,"%c", (CH)) |
| 112 | #define print_notice_char(CH) printk(BIOS_NOTICE, "%c", (CH)) |
| 113 | #define print_info_char(CH) printk(BIOS_INFO, "%c", (CH)) |
| 114 | #define print_debug_char(CH) printk(BIOS_DEBUG, "%c", (CH)) |
| 115 | #define print_spew_char(CH) printk(BIOS_SPEW, "%c", (CH)) |
| 116 | |
| 117 | #define print_emerg_hex8(HEX) printk(BIOS_EMERG, "%02x", (HEX)) |
| 118 | #define print_alert_hex8(HEX) printk(BIOS_ALERT, "%02x", (HEX)) |
| 119 | #define print_crit_hex8(HEX) printk(BIOS_CRIT, "%02x", (HEX)) |
| 120 | #define print_err_hex8(HEX) printk(BIOS_ERR, "%02x", (HEX)) |
| 121 | #define print_warning_hex8(HEX) printk(BIOS_WARNING,"%02x", (HEX)) |
| 122 | #define print_notice_hex8(HEX) printk(BIOS_NOTICE, "%02x", (HEX)) |
| 123 | #define print_info_hex8(HEX) printk(BIOS_INFO, "%02x", (HEX)) |
| 124 | #define print_debug_hex8(HEX) printk(BIOS_DEBUG, "%02x", (HEX)) |
| 125 | #define print_spew_hex8(HEX) printk(BIOS_SPEW, "%02x", (HEX)) |
| 126 | |
| 127 | #define print_emerg_hex16(HEX) printk(BIOS_EMERG, "%04x", (HEX)) |
| 128 | #define print_alert_hex16(HEX) printk(BIOS_ALERT, "%04x", (HEX)) |
| 129 | #define print_crit_hex16(HEX) printk(BIOS_CRIT, "%04x", (HEX)) |
| 130 | #define print_err_hex16(HEX) printk(BIOS_ERR, "%04x", (HEX)) |
| 131 | #define print_warning_hex16(HEX) printk(BIOS_WARNING,"%04x", (HEX)) |
| 132 | #define print_notice_hex16(HEX) printk(BIOS_NOTICE, "%04x", (HEX)) |
| 133 | #define print_info_hex16(HEX) printk(BIOS_INFO, "%04x", (HEX)) |
| 134 | #define print_debug_hex16(HEX) printk(BIOS_DEBUG, "%04x", (HEX)) |
| 135 | #define print_spew_hex16(HEX) printk(BIOS_SPEW, "%04x", (HEX)) |
| 136 | |
| 137 | #define print_emerg_hex32(HEX) printk(BIOS_EMERG, "%08x", (HEX)) |
| 138 | #define print_alert_hex32(HEX) printk(BIOS_ALERT, "%08x", (HEX)) |
| 139 | #define print_crit_hex32(HEX) printk(BIOS_CRIT, "%08x", (HEX)) |
| 140 | #define print_err_hex32(HEX) printk(BIOS_ERR, "%08x", (HEX)) |
| 141 | #define print_warning_hex32(HEX) printk(BIOS_WARNING,"%08x", (HEX)) |
| 142 | #define print_notice_hex32(HEX) printk(BIOS_NOTICE, "%08x", (HEX)) |
| 143 | #define print_info_hex32(HEX) printk(BIOS_INFO, "%08x", (HEX)) |
| 144 | #define print_debug_hex32(HEX) printk(BIOS_DEBUG, "%08x", (HEX)) |
| 145 | #define print_spew_hex32(HEX) printk(BIOS_SPEW, "%08x", (HEX)) |
| 146 | |
| 147 | #endif |
| 148 | |
| 149 | #endif /* __CONSOLE_EARLY_PRINT_H_ */ |