Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2003 Eric Biederman |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <console/console.h> |
| 21 | #include <uart8250.h> |
| 22 | #include <pc80/mc146818rtc.h> |
| 23 | |
| 24 | static u32 uart_bar = 0; |
| 25 | |
Marc Jones | fa418e3 | 2012-06-13 20:48:36 -0600 | [diff] [blame] | 26 | void uartmem_init(void) |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 27 | { |
| 28 | uart_bar = uart_mem_init(); |
| 29 | } |
| 30 | |
Stefan Reinauer | d1bc331 | 2011-06-22 16:39:19 -0700 | [diff] [blame] | 31 | u32 uartmem_getbaseaddr(void) |
| 32 | { |
| 33 | return uart_bar; |
| 34 | } |
| 35 | |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 36 | static void uartmem_tx_byte(unsigned char data) |
| 37 | { |
| 38 | if (!uart_bar) |
| 39 | return; |
| 40 | |
| 41 | uart8250_mem_tx_byte(uart_bar, data); |
| 42 | } |
| 43 | |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 44 | static void uartmem_tx_flush(void) |
| 45 | { |
| 46 | uart8250_mem_tx_flush(uart_bar); |
| 47 | } |
| 48 | |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 49 | static unsigned char uartmem_rx_byte(void) |
| 50 | { |
| 51 | if (!uart_bar) |
| 52 | return 0; |
| 53 | |
| 54 | return uart8250_mem_rx_byte(uart_bar); |
| 55 | } |
| 56 | |
| 57 | static int uartmem_tst_byte(void) |
| 58 | { |
| 59 | if (!uart_bar) |
| 60 | return 0; |
| 61 | |
| 62 | return uart8250_mem_can_rx_byte(uart_bar); |
| 63 | } |
| 64 | |
| 65 | static const struct console_driver uart8250mem_console __console = { |
| 66 | .init = uartmem_init, |
| 67 | .tx_byte = uartmem_tx_byte, |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 68 | .tx_flush = uartmem_tx_flush, |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 69 | .rx_byte = uartmem_rx_byte, |
| 70 | .tst_byte = uartmem_tst_byte, |
| 71 | }; |