All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] change VGA yield behavior
@ 2007-02-07 17:18 Jan Beulich
  2007-02-07 18:13 ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2007-02-07 17:18 UTC (permalink / raw)
  To: xen-devel

Make the default VGA console yield behavior more debugging friendly by
allowing Xen to print to the console (by default) even after dom0
started, as long as the VGA card is not in graphics mode.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

Index: 2007-02-07/xen/drivers/video/vga.c
===================================================================
--- 2007-02-07.orig/xen/drivers/video/vga.c	2007-01-15 09:10:11.000000000 +0100
+++ 2007-02-07/xen/drivers/video/vga.c	2007-02-07 16:31:41.000000000 +0100
@@ -556,7 +556,6 @@ static int vga_load_font(const struct fo
  */
 
 static int vgacon_enabled = 0;
-static int vgacon_keep    = 0;
 static int vgacon_lines   = 50;
 static const struct font_desc *font;
 
@@ -576,13 +575,16 @@ string_param("vga", opt_vga);
 void vga_init(void)
 {
     char *p;
+    int keep = 0;
 
     for ( p = opt_vga; p != NULL; p = strchr(p, ',') )
     {
         if ( *p == ',' )
             p++;
         if ( strncmp(p, "keep", 4) == 0 )
-            vgacon_keep = 1;
+            keep = 1;
+        else if ( strncmp(p, "yield", 5) == 0 )
+            keep = -1;
         else if ( strncmp(p, "text-80x", 8) == 0 )
             vgacon_lines = simple_strtoul(p + 8, NULL, 10);
     }
@@ -621,21 +623,48 @@ void vga_init(void)
     /* Disable cursor. */
     vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, 0x20);
 
-    vgacon_enabled = 1;
+    vgacon_enabled = 3 + keep;
 }
 
 void vga_endboot(void)
 {
+    static const char *const str[] =
+    {
+        "relinquishing",
+        "auto-sensing",
+        "keeping"
+    };
+
     if ( !vgacon_enabled )
         return;
 
-    if ( !vgacon_keep )
-        vgacon_enabled = 0;
+    vgacon_enabled -= 2;
+    BUG_ON(vgacon_enabled < 0 || vgacon_enabled > 2);
         
-    printk("Xen is %s VGA console.\n",
-           vgacon_keep ? "keeping" : "relinquishing");
+    printk("Xen is %s VGA console.\n", str[vgacon_enabled]);
 }
 
+static int gfx_vga(void)
+{
+    unsigned char idx, data;
+
+    idx = vga_r(vgabase, VGA_GFX_I);
+    data = vga_rgfx(vgabase, VGA_GFX_MISC);
+    vga_w(vgabase, VGA_GFX_I, idx);
+
+    if ( data & 0x01 )
+        return 1;
+
+    /* Unfortunately many cards don't reflect their mode in the GDC
+     * miscellaneous register, bit 0 (and even fewer reflect it in the
+     * ATC mode control register, bit 0). Therefore we further check
+     * horizontal display width against our original setting. */
+    idx = vga_r(vgabase, VGA_CRT_IC);
+    data = vga_rcrt(vgabase, VGA_CRTC_H_DISP);
+    vga_w(vgabase, VGA_CRT_IC, idx);
+
+    return data != COLUMNS - 1;
+}
 
 static void put_newline(void)
 {
@@ -653,14 +682,25 @@ static void put_newline(void)
 
 void vga_putchar(int c)
 {
-    if ( !vgacon_enabled )
+    static int vga_in_gfx = -1;
+
+    switch ( vgacon_enabled )
+    {
+    case 0:
         return;
+    case 1:
+        if ( vga_in_gfx < 0 )
+            vga_in_gfx = gfx_vga();
+        break;
+    }
 
     if ( c == '\n' )
     {
-        put_newline();
+        if ( vga_in_gfx <= 0 )
+            put_newline();
+        vga_in_gfx = -1;
     }
-    else
+    else if ( vga_in_gfx <= 0 )
     {
         if ( xpos >= COLUMNS )
             put_newline();

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] change VGA yield behavior
  2007-02-07 17:18 [PATCH] change VGA yield behavior Jan Beulich
@ 2007-02-07 18:13 ` Keir Fraser
  2007-02-08  8:54   ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2007-02-07 18:13 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 7/2/07 17:18, "Jan Beulich" <jbeulich@novell.com> wrote:

> Make the default VGA console yield behavior more debugging friendly by
> allowing Xen to print to the console (by default) even after dom0
> started, as long as the VGA card is not in graphics mode.
> 
> Signed-off-by: Jan Beulich <jbeulich@novell.com>

This seems a bit iffy, at least as default. The usage scenario is to catch
crashes that take out the machine enough that 'xm dmesg' cannot be used,
where there is no serial line to catch the output, and where the bug is not
easily repro'able, right?

 -- Keir

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] change VGA yield behavior
  2007-02-07 18:13 ` Keir Fraser
@ 2007-02-08  8:54   ` Jan Beulich
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2007-02-08  8:54 UTC (permalink / raw)
  To: Keir Fraser, xen-devel

>>> Keir Fraser <Keir.Fraser@cl.cam.ac.uk> 07.02.07 19:13 >>>
>On 7/2/07 17:18, "Jan Beulich" <jbeulich@novell.com> wrote:
>
>> Make the default VGA console yield behavior more debugging friendly by
>> allowing Xen to print to the console (by default) even after dom0
>> started, as long as the VGA card is not in graphics mode.
>> 
>> Signed-off-by: Jan Beulich <jbeulich@novell.com>
>
>This seems a bit iffy, at least as default. The usage scenario is to catch

Yes, I don't like the way it's done too much, either, but didn't find a smarter
way.

>crashes that take out the machine enough that 'xm dmesg' cannot be used,
>where there is no serial line to catch the output, and where the bug is not
>easily repro'able, right?

Correct - namely dom0 crashes (perhaps preceded by some Xen messages)
and hypervisor crashes.

Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-08  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-07 17:18 [PATCH] change VGA yield behavior Jan Beulich
2007-02-07 18:13 ` Keir Fraser
2007-02-08  8:54   ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.