Gerd Hoffmann | 038aa29 | 2013-05-29 13:06:22 +0200 | [diff] [blame] | 1 | /* |
| 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 Hoffmann | 22f01e6 | 2013-05-30 10:33:38 +0200 | [diff] [blame] | 24 | static unsigned char readback; |
| 25 | |
Gerd Hoffmann | 038aa29 | 2013-05-29 13:06:22 +0200 | [diff] [blame] | 26 | static void debugcon_init(void) |
| 27 | { |
Gerd Hoffmann | 22f01e6 | 2013-05-30 10:33:38 +0200 | [diff] [blame] | 28 | readback = inb(CONFIG_CONSOLE_QEMU_DEBUGCON_PORT); |
Gerd Hoffmann | 4321d60 | 2013-05-30 13:23:38 +0200 | [diff] [blame] | 29 | printk(BIOS_INFO, "QEMU debugcon %s [port 0x%x]\n", |
| 30 | (readback == 0xe9) ? "detected" : "not found", |
| 31 | CONFIG_CONSOLE_QEMU_DEBUGCON_PORT); |
Gerd Hoffmann | 038aa29 | 2013-05-29 13:06:22 +0200 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static void debugcon_tx_byte(unsigned char data) |
| 35 | { |
Gerd Hoffmann | 22f01e6 | 2013-05-30 10:33:38 +0200 | [diff] [blame] | 36 | if (readback == 0xe9) { |
| 37 | outb(data, CONFIG_CONSOLE_QEMU_DEBUGCON_PORT); |
| 38 | } |
Gerd Hoffmann | 038aa29 | 2013-05-29 13:06:22 +0200 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static void debugcon_tx_flush(void) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | static unsigned char debugcon_rx_byte(void) |
| 46 | { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static int debugcon_tst_byte(void) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static 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 | }; |