blob: 1d66d87c6484c0567d1b060b5a735ca43749b5d1 [file] [log] [blame]
Gerd Hoffmann038aa292013-05-29 13:06:22 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Red Hat Inc.
5 * Written by Gerd Hoffmann <kraxel@redhat.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <console/console.h>
22#include <arch/io.h>
23
Gerd Hoffmann22f01e62013-05-30 10:33:38 +020024static unsigned char readback;
25
Gerd Hoffmann038aa292013-05-29 13:06:22 +020026static void debugcon_init(void)
27{
Gerd Hoffmann22f01e62013-05-30 10:33:38 +020028 readback = inb(CONFIG_CONSOLE_QEMU_DEBUGCON_PORT);
Gerd Hoffmann4321d602013-05-30 13:23:38 +020029 printk(BIOS_INFO, "QEMU debugcon %s [port 0x%x]\n",
30 (readback == 0xe9) ? "detected" : "not found",
31 CONFIG_CONSOLE_QEMU_DEBUGCON_PORT);
Gerd Hoffmann038aa292013-05-29 13:06:22 +020032}
33
34static void debugcon_tx_byte(unsigned char data)
35{
Gerd Hoffmann22f01e62013-05-30 10:33:38 +020036 if (readback == 0xe9) {
37 outb(data, CONFIG_CONSOLE_QEMU_DEBUGCON_PORT);
38 }
Gerd Hoffmann038aa292013-05-29 13:06:22 +020039}
40
41static void debugcon_tx_flush(void)
42{
43}
44
45static unsigned char debugcon_rx_byte(void)
46{
47 return 0;
48}
49
50static int debugcon_tst_byte(void)
51{
52 return 0;
53}
54
55static const struct console_driver debugcon_console __console = {
56 .init = debugcon_init,
57 .tx_byte = debugcon_tx_byte,
58 .tx_flush = debugcon_tx_flush,
59 .rx_byte = debugcon_rx_byte,
60 .tst_byte = debugcon_tst_byte,
61};