Kyösti Mälkki | 03731d7 | 2014-02-02 19:12:14 +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. |
Kyösti Mälkki | 03731d7 | 2014-02-02 19:12:14 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <console/qemu_debugcon.h> |
| 19 | #include <arch/io.h> |
| 20 | #include <arch/early_variables.h> |
| 21 | |
| 22 | static int qemu_debugcon_detected CAR_GLOBAL; |
| 23 | |
| 24 | void qemu_debugcon_init(void) |
| 25 | { |
| 26 | int detected = (inb(CONFIG_CONSOLE_QEMU_DEBUGCON_PORT) == 0xe9); |
| 27 | car_set_var(qemu_debugcon_detected, detected); |
| 28 | printk(BIOS_INFO, "QEMU debugcon %s [port 0x%x]\n", |
| 29 | detected ? "detected" : "not found", |
| 30 | CONFIG_CONSOLE_QEMU_DEBUGCON_PORT); |
| 31 | } |
| 32 | |
| 33 | void qemu_debugcon_tx_byte(unsigned char data) |
| 34 | { |
| 35 | if (car_get_var(qemu_debugcon_detected) != 0) |
| 36 | outb(data, CONFIG_CONSOLE_QEMU_DEBUGCON_PORT); |
| 37 | } |