xref: /aosp_15_r20/external/coreboot/src/drivers/emulation/qemu/qemu_debugcon.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <console/qemu_debugcon.h>
5 #include <arch/io.h>
6 
7 static int qemu_debugcon_detected;
8 
qemu_debugcon_init(void)9 void qemu_debugcon_init(void)
10 {
11 	int detected = (inb(CONFIG_CONSOLE_QEMU_DEBUGCON_PORT) == 0xe9);
12 	qemu_debugcon_detected = detected;
13 	printk(BIOS_INFO, "QEMU debugcon %s [port 0x%x]\n",
14 	       detected ? "detected" : "not found",
15 	       CONFIG_CONSOLE_QEMU_DEBUGCON_PORT);
16 }
17 
qemu_debugcon_tx_byte(unsigned char data)18 void qemu_debugcon_tx_byte(unsigned char data)
19 {
20 	if (qemu_debugcon_detected != 0)
21 		outb(data, CONFIG_CONSOLE_QEMU_DEBUGCON_PORT);
22 }
23