[SeaBIOS] Bug#678042: seabios - Please enable Xen support

Ian Campbell ijc at hellion.org.uk
Wed Jun 27 12:55:11 CEST 2012


On Mon, 2012-06-25 at 18:55 -0400, Kevin O'Connor wrote:
> On Wed, Jun 20, 2012 at 10:25:13AM +0100, Ian Campbell wrote:
> > On Wed, 2012-06-20 at 10:22 +0100, Ian Campbell wrote:
> > > Subject: [PATCH] enable Xen support by default.
> > 
> > In this context I thought it would also be useful to make
> > CONFIG_DEBUG_IO_PORT dynamic. However with the below I get lots of build
> > errors about xen_cpuid_base not being defined. I got similar errors
> > without the VAR16VISIBLE and GET_GLOBAL hunks. I suspect this is due to
> > the variable being used in both 32 and 16 bit mode and my not knowing
> > what I'm doing in that regard ;-)
> 
> xen_cpuid_base is defined in xen.c which is only compiled in 32bit
> mode, so you can't declare a variable as VAR16VISIBLE there.

Ah, right yes, thanks! I think I keep tripping over that...

> I wonder if it is simpler to define a "u16 DebugOutputPort
> VAR16VISIBLE = CONFIG_DEBUG_IO_PORT" in output.c and then override it
> early in the xen boot sequence though.

Yes, this makes sense. I actually went one further and nuked the Kconfig
option, since it's only real non-default use was Xen. So now I makde it
default to 0x402 and set it to 0xe9 in the Xen case.

8<-----------------------------------------------------

>From 903d84d2c320543ac07ae1298d57643575d6ffc8 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell at citrix.com>
Date: Wed, 27 Jun 2012 11:39:01 +0100
Subject: [PATCH] Xen: Autodetect debug I/O port at runtime instead of via Kconfig

This allows a common image which supports Xen to still print debug

Signed-off-by: Ian Campbell <ian.campbell at citrix.com>
---
 src/Kconfig  |    7 -------
 src/output.c |    4 +++-
 src/util.h   |    1 +
 src/xen.c    |    5 +++++
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/Kconfig b/src/Kconfig
index 8120ff7..8932c9e 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -361,11 +361,4 @@ menu "Debugging"
             information by outputing strings in a special port present in the
             IO space.
 
-    config DEBUG_IO_PORT
-        depends on DEBUG_IO
-        hex "Debug IO port address"
-        default 0x0402
-        help
-            Bochs uses the 0x0402 address by default, whereas Xen
-            makes the 0xe9 IO address available for guests use.
 endmenu
diff --git a/src/output.c b/src/output.c
index 37c4942..25300d0 100644
--- a/src/output.c
+++ b/src/output.c
@@ -23,6 +23,8 @@ struct putcinfo {
 
 #define DEBUG_TIMEOUT 100000
 
+u16 DebugOutputPort VAR16VISIBLE = 0x402;
+
 void
 debug_serial_setup(void)
 {
@@ -77,7 +79,7 @@ putc_debug(struct putcinfo *action, char c)
         return;
     if (CONFIG_DEBUG_IO)
         // Send character to debug port.
-        outb(c, CONFIG_DEBUG_IO_PORT);
+        outb(c, DebugOutputPort);
     if (c == '\n')
         debug_serial('\r');
     debug_serial(c);
diff --git a/src/util.h b/src/util.h
index dbee0e5..ef8ec7c 100644
--- a/src/util.h
+++ b/src/util.h
@@ -231,6 +231,7 @@ int wait_preempt(void);
 void check_preempt(void);
 
 // output.c
+extern u16 DebugOutputPort;
 void debug_serial_setup(void);
 void panic(const char *fmt, ...)
     __attribute__ ((format (printf, 1, 2))) __noreturn;
diff --git a/src/xen.c b/src/xen.c
index 961e316..128e6c0 100644
--- a/src/xen.c
+++ b/src/xen.c
@@ -64,6 +64,9 @@ void xen_probe(void)
         dprintf(1, "Found hypervisor signature \"%s\" at %x\n",
                 signature, base);
         if (strcmp(signature, "XenVMMXenVMM") == 0) {
+            /* Set debug_io_port first, so the following messages work. */
+            DebugOutputPort = 0xe9;
+            dprintf(1, "Found Xen hypervisor signature at %x\n", base);
             if ((eax - base) < 2)
                 panic("Insufficient Xen cpuid leaves. eax=%x at base %x\n",
                       eax, base);
@@ -71,6 +74,8 @@ void xen_probe(void)
             break;
         }
     }
+    if (!xen_cpuid_base)
+        dprintf(1, "No Xen hypervisor found.\n");
 }
 
 static int hypercall_xen_version( int cmd, void *arg)
-- 
1.7.2.5




-- 
Ian Campbell
Current Noise: Iron Monkey - Shrimp Fist

A diplomatic husband said to his wife, "How do you expect me to remember
your birthday when you never look any older?"




More information about the SeaBIOS mailing list