blob: ed77237e41cf2f82c93aa42962bedf6e83363287 [file] [log] [blame]
Stefan Reinauer4885daa2011-04-26 23:47:04 +00001/*
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
24static u32 uart_bar = 0;
25
Marc Jonesfa418e32012-06-13 20:48:36 -060026void uartmem_init(void)
Stefan Reinauer4885daa2011-04-26 23:47:04 +000027{
28 uart_bar = uart_mem_init();
29}
30
Stefan Reinauerd1bc3312011-06-22 16:39:19 -070031u32 uartmem_getbaseaddr(void)
32{
33 return uart_bar;
34}
35
Stefan Reinauer4885daa2011-04-26 23:47:04 +000036static 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'Connora68555f2011-07-09 20:22:21 -040044static void uartmem_tx_flush(void)
45{
46 uart8250_mem_tx_flush(uart_bar);
47}
48
Stefan Reinauer4885daa2011-04-26 23:47:04 +000049static 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
57static 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
65static const struct console_driver uart8250mem_console __console = {
66 .init = uartmem_init,
67 .tx_byte = uartmem_tx_byte,
Kevin O'Connora68555f2011-07-09 20:22:21 -040068 .tx_flush = uartmem_tx_flush,
Stefan Reinauer4885daa2011-04-26 23:47:04 +000069 .rx_byte = uartmem_rx_byte,
70 .tst_byte = uartmem_tst_byte,
71};