Furquan Shaikh | 2af76f4 | 2014-04-28 16:39:40 -0700 | [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 |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; version 2 of |
| 7 | * the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 17 | * MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <console/console.h> |
| 21 | #include <console/vtxprintf.h> |
| 22 | |
| 23 | /* FIXME: need to make console driver more generic */ |
| 24 | void console_tx_byte(unsigned char byte) |
| 25 | { |
| 26 | if (byte == '\n') |
| 27 | console_tx_byte('\r'); |
| 28 | |
| 29 | #if CONFIG_CONSOLE_SERIAL8250MEM |
| 30 | if (oxford_oxpcie_present) { |
| 31 | uart8250_mem_tx_byte( |
| 32 | CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000, byte); |
| 33 | } |
| 34 | #endif |
| 35 | #if CONFIG_CONSOLE_SERIAL_UART |
| 36 | uart_tx_byte(byte); |
| 37 | #endif |
| 38 | #if CONFIG_USBDEBUG |
| 39 | usbdebug_tx_byte(0, byte); |
| 40 | #endif |
| 41 | #if CONFIG_CONSOLE_CBMEM && !defined(__BOOT_BLOCK__) |
| 42 | cbmemc_tx_byte(byte); |
| 43 | #endif |
| 44 | } |
| 45 | |
| 46 | void console_tx_flush(void) |
| 47 | { |
| 48 | #if CONFIG_CONSOLE_SERIAL8250MEM |
| 49 | uart8250_mem_tx_flush(CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000); |
| 50 | #endif |
| 51 | #if CONFIG_CONSOLE_SERIAL_UART |
| 52 | uart_tx_flush(); |
| 53 | #endif |
| 54 | #if CONFIG_USBDEBUG |
| 55 | usbdebug_tx_flush(0); |
| 56 | #endif |
| 57 | } |
| 58 | |
| 59 | int do_printk(int msg_level, const char *fmt, ...) |
| 60 | { |
| 61 | va_list args; |
| 62 | int i; |
| 63 | |
| 64 | if (msg_level > console_loglevel) { |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | va_start(args, fmt); |
| 69 | i = vtxprintf(console_tx_byte, fmt, args); |
| 70 | va_end(args); |
| 71 | |
| 72 | console_tx_flush(); |
| 73 | |
| 74 | return i; |
| 75 | } |