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

Ian Campbell ijc at hellion.org.uk
Wed Jun 20 11:25:13 CEST 2012


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 ;-)


diff --git a/src/Kconfig b/src/Kconfig
index 8120ff7..4487844 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -364,8 +364,10 @@ menu "Debugging"
     config DEBUG_IO_PORT
         depends on DEBUG_IO
         hex "Debug IO port address"
-        default 0x0402
+        default 0x00
         help
             Bochs uses the 0x0402 address by default, whereas Xen
             makes the 0xe9 IO address available for guests use.
+
+            The default (0) is to autodetect which to use.
 endmenu
diff --git a/src/output.c b/src/output.c
index 37c4942..2826e00 100644
--- a/src/output.c
+++ b/src/output.c
@@ -11,6 +11,7 @@
 #include "bregs.h" // struct bregs
 #include "config.h" // CONFIG_*
 #include "biosvar.h" // GET_GLOBAL
+#include "xen.h" // usingXen
 
 struct putcinfo {
     void (*func)(struct putcinfo *info, char c);
@@ -69,6 +70,15 @@ debug_serial_flush(void)
             return;
 }
 
+static int debug_io_port(void)
+{
+    if (CONFIG_DEBUG_IO_PORT)
+	return CONFIG_DEBUG_IO_PORT;
+    if (usingXen())
+	return 0xe9;
+    return 0x402;
+}
+
 // Write a character to debug port(s).
 static void
 putc_debug(struct putcinfo *action, char c)
@@ -77,7 +87,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, debug_io_port());
     if (c == '\n')
         debug_serial('\r');
     debug_serial(c);
diff --git a/src/xen.c b/src/xen.c
index 961e316..a3e12d8 100644
--- a/src/xen.c
+++ b/src/xen.c
@@ -13,7 +13,7 @@
 
 #define INFO_PHYSICAL_ADDRESS 0x00001000
 
-u32 xen_cpuid_base = 0;
+u32 xen_cpuid_base VAR16VISIBLE = 0;
 
 struct xen_seabios_info {
     char signature[14]; /* XenHVMSeaBIOS\0 */
diff --git a/src/xen.h b/src/xen.h
index cc506a6..3eb7771 100644
--- a/src/xen.h
+++ b/src/xen.h
@@ -3,6 +3,7 @@
 
 #include "config.h" // CONFIG_*
 #include "types.h" // u32
+#include "biosvar.h" // GET_GLOBAL
 
 extern u32 xen_cpuid_base;
 
@@ -14,7 +15,7 @@ void xen_copy_biostables(void);
 static inline int usingXen(void) {
     if (!CONFIG_XEN)
         return 0;
-    return (xen_cpuid_base != 0);
+    return (GET_GLOBAL(xen_cpuid_base) != 0);
 }
 
 unsigned long xen_hypercall_page;

-- 
Ian Campbell

I used to be disgusted, now I find I'm just amused.
		-- Elvis Costello




More information about the SeaBIOS mailing list