[coreboot-gerrit] Change in coreboot[master]: libpayload: Add console driver qemu debugcon

Patrick Rudolph (Code Review) gerrit at coreboot.org
Wed Jan 17 20:15:25 CET 2018


Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/23306


Change subject: libpayload: Add console driver qemu debugcon
......................................................................

libpayload: Add console driver qemu debugcon

Change-Id: Ieba9ed38642cb0833564304dda2a317071f2b25c
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
M payloads/libpayload/Kconfig
M payloads/libpayload/drivers/Makefile.inc
A payloads/libpayload/drivers/qemu_console.c
M payloads/libpayload/include/libpayload.h
M payloads/libpayload/libc/console.c
5 files changed, 70 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/06/23306/1

diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig
index 8fd6a9c..0aca12e 100644
--- a/payloads/libpayload/Kconfig
+++ b/payloads/libpayload/Kconfig
@@ -321,6 +321,15 @@
 	  Say Y here if coreboot switched to a graphics mode and
 	  your payload wants to use it.
 
+config QEMU_CONSOLE
+	bool "QEMU debugcon console driver"
+	default y
+
+config CONSOLE_QEMU_DEBUGCON_PORT
+	hex "QEMU debugcon console port"
+	depends on QEMU_CONSOLE
+	default 0x402
+
 config FONT_SCALE_FACTOR
 	int "Scale factor for the included font"
 	depends on GEODELX_VIDEO_CONSOLE || COREBOOT_VIDEO_CONSOLE
diff --git a/payloads/libpayload/drivers/Makefile.inc b/payloads/libpayload/drivers/Makefile.inc
index 8dc6e8b..116e16b 100644
--- a/payloads/libpayload/drivers/Makefile.inc
+++ b/payloads/libpayload/drivers/Makefile.inc
@@ -41,6 +41,7 @@
 libc-$(CONFIG_LP_PC_KEYBOARD) += keyboard.c
 
 libc-$(CONFIG_LP_CBMEM_CONSOLE) += cbmem_console.c
+libc-$(CONFIG_LP_QEMU_CONSOLE) += qemu_console.c
 
 libc-$(CONFIG_LP_MOUSE_CURSOR) += mouse_cursor.c
 
diff --git a/payloads/libpayload/drivers/qemu_console.c b/payloads/libpayload/drivers/qemu_console.c
new file mode 100644
index 0000000..41632da
--- /dev/null
+++ b/payloads/libpayload/drivers/qemu_console.c
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (c) 2012 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload.h>
+#include <stdint.h>
+
+
+static void qemu_console_write(const void *buffer, size_t count)
+{
+	const unsigned char *buf = buffer;
+	for (size_t i = 0; i < count; i++)
+		outb(buf[i], CONFIG_LP_CONSOLE_QEMU_DEBUGCON_PORT);
+}
+
+static struct console_output_driver qemu_console_driver = {
+	.write = &qemu_console_write,
+};
+
+void qemu_console_init(void)
+{
+	if (inb(CONFIG_LP_CONSOLE_QEMU_DEBUGCON_PORT) == 0xe9)
+		console_add_output_driver(&qemu_console_driver);
+}
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 83658d1..e3a1670 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -247,6 +247,14 @@
 void cbmem_console_write(const void *buffer, size_t count);
 /** @} */
 
+/**
+ * @defgroup qemu_console QEMU debugcon console.
+ * @ingroup input
+ * @{
+ */
+void qemu_console_init(void);
+/** @} */
+
 /* drivers/option.c */
 struct nvram_accessor {
 	u8 (*read)(u8 reg);
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index b57fc47..32931d4 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -114,6 +114,9 @@
 #if IS_ENABLED(CONFIG_LP_CBMEM_CONSOLE)
 	cbmem_console_init();
 #endif
+#if IS_ENABLED(CONFIG_LP_QEMU_CONSOLE)
+	qemu_console_init();
+#endif
 }
 
 void console_write(const void *buffer, size_t count)

-- 
To view, visit https://review.coreboot.org/23306
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieba9ed38642cb0833564304dda2a317071f2b25c
Gerrit-Change-Number: 23306
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180117/6a3e3102/attachment-0001.html>


More information about the coreboot-gerrit mailing list