[OpenBIOS] [PATCH 3/3] ppc: enable basic PReP serial console
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Sun Oct 13 22:13:28 CEST 2013
This patch follows on from the previous patchsets and provides a basic PReP
serial console when launched under QEMU with -nographic. This is done by
including the PC serial driver as part of the PPC binary build and setting
up a prep_console_ops structure for use when PReP architecture is detected.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
CC: Andreas Färber <afaerber at suse.de>
CC: Hervé Poussineau <hpoussin at reactos.org>
---
openbios-devel/arch/ppc/qemu/console.c | 32 +++++++++++++++++++++++++
openbios-devel/arch/ppc/qemu/init.c | 28 ++++++++++++++++------
openbios-devel/arch/ppc/qemu/main.c | 5 +++-
openbios-devel/config/examples/ppc_config.xml | 1 +
4 files changed, 58 insertions(+), 8 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/console.c b/openbios-devel/arch/ppc/qemu/console.c
index 25b21c0..53a3215 100644
--- a/openbios-devel/arch/ppc/qemu/console.c
+++ b/openbios-devel/arch/ppc/qemu/console.c
@@ -53,4 +53,36 @@ struct _console_ops mac_console_ops = {
.getchar = mac_getchar
};
+static int prep_putchar(int c)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ uart_putchar(c & 0xff);
+#endif
+ return c;
+}
+
+static int prep_availchar(void)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ if (uart_charav(CONFIG_SERIAL_PORT))
+ return 1;
+#endif
+ return 0;
+}
+
+static int prep_getchar(void)
+{
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+ if (uart_charav(CONFIG_SERIAL_PORT))
+ return (uart_getchar(CONFIG_SERIAL_PORT));
+#endif
+ return 0;
+}
+
+struct _console_ops prep_console_ops = {
+ .putchar = prep_putchar,
+ .availchar = prep_availchar,
+ .getchar = prep_getchar
+};
+
#endif // CONFIG_DEBUG_CONSOLE
diff --git a/openbios-devel/arch/ppc/qemu/init.c b/openbios-devel/arch/ppc/qemu/init.c
index 48d39b6..4eb0f0e 100644
--- a/openbios-devel/arch/ppc/qemu/init.c
+++ b/openbios-devel/arch/ppc/qemu/init.c
@@ -163,7 +163,7 @@ static const pci_arch_t known_arch[] = {
};
unsigned long isa_io_base;
-extern struct _console_ops mac_console_ops;
+extern struct _console_ops mac_console_ops, prep_console_ops;
void
entry(void)
@@ -188,7 +188,11 @@ entry(void)
isa_io_base = arch->io_base;
#ifdef CONFIG_DEBUG_CONSOLE
- init_console(mac_console_ops);
+ if (is_apple()) {
+ init_console(mac_console_ops);
+ } else {
+ init_console(prep_console_ops);
+ }
#endif
if (temp != 1) {
@@ -658,6 +662,11 @@ arch_of_init(void)
ofmem_t *ofmem = ofmem_arch_get_private();
+ if (!is_apple()) {
+ /* Initialise PReP serial port */
+ ob_pc_serial_init("", "serial", arch->io_base, 0x3f8ULL, 0);
+ }
+
openbios_init();
modules_init();
setup_timers();
@@ -823,12 +832,17 @@ arch_of_init(void)
#endif
if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) {
- if (CONFIG_SERIAL_PORT) {
- stdin_path = "scca";
- stdout_path = "scca";
+ if (is_apple()) {
+ if (CONFIG_SERIAL_PORT) {
+ stdin_path = "scca";
+ stdout_path = "scca";
+ } else {
+ stdin_path = "sccb";
+ stdout_path = "sccb";
+ }
} else {
- stdin_path = "sccb";
- stdout_path = "sccb";
+ stdin_path = "/serial";
+ stdout_path = "/serial";
}
/* Some bootloaders force the output to the screen device, so
diff --git a/openbios-devel/arch/ppc/qemu/main.c b/openbios-devel/arch/ppc/qemu/main.c
index 30a4375..44b1666 100644
--- a/openbios-devel/arch/ppc/qemu/main.c
+++ b/openbios-devel/arch/ppc/qemu/main.c
@@ -22,6 +22,7 @@
#include "libc/diskio.h"
#include "libc/vsprintf.h"
#include "kernel.h"
+#include "drivers/drivers.h"
#include "libopenbios/ofmem.h"
#define NO_QEMU_PROTOS
#include "arch/common/fw_cfg.h"
@@ -78,5 +79,7 @@ boot( void )
check_preloaded_kernel();
}
- update_nvram();
+ if (is_apple()) {
+ update_nvram();
+ }
}
diff --git a/openbios-devel/config/examples/ppc_config.xml b/openbios-devel/config/examples/ppc_config.xml
index 5bb789f..200775d 100644
--- a/openbios-devel/config/examples/ppc_config.xml
+++ b/openbios-devel/config/examples/ppc_config.xml
@@ -8,6 +8,7 @@
<option name="CONFIG_DEBUG_INTERPRETER" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_CONSOLE" type="boolean" value="true"/>
<option name="CONFIG_DEBUG_CONSOLE_SERIAL" type="boolean" value="true"/>
+ <option name="CONFIG_DRIVER_PC_SERIAL" type="boolean" value="true"/>
<option name="CONFIG_SERIAL_PORT" type="integer" value="0"/>
<option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/>
<option name="CONFIG_DEBUG_CONSOLE_VGA" type="boolean" value="true"/>
--
1.7.10.4
More information about the OpenBIOS
mailing list