debuggers.hg

changeset 21089:04cb0829d138

Improve graphical console performance

As it is pretty pointless to clear unused parts of a line over and
over again, keep track of how much of a line was actually written
to and avoid clearing parts of the screen that are known to already
be clear. With this, scrolling speed becomes comparable to that of
Linux' VESA console.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 17 14:10:43 2010 +0000 (2010-03-17)
parents 0d45541c0658
children 84c563da39c8
files xen/drivers/video/vesa.c
line diff
     1.1 --- a/xen/drivers/video/vesa.c	Wed Mar 17 14:09:55 2010 +0000
     1.2 +++ b/xen/drivers/video/vesa.c	Wed Mar 17 14:10:43 2010 +0000
     1.3 @@ -21,6 +21,7 @@ static void vesa_redraw_puts(const char 
     1.4  static void vesa_scroll_puts(const char *s);
     1.5  
     1.6  static unsigned char *lfb, *lbuf, *text_buf;
     1.7 +static unsigned int *__initdata line_len;
     1.8  static const struct font_desc *font;
     1.9  static bool_t vga_compat;
    1.10  static unsigned int pixel_on;
    1.11 @@ -96,6 +97,10 @@ void __init vesa_init(void)
    1.12      if ( !text_buf )
    1.13          goto fail;
    1.14  
    1.15 +    line_len = xmalloc_array(unsigned int, text_columns);
    1.16 +    if ( !line_len )
    1.17 +        goto fail;
    1.18 +
    1.19      if ( map_pages_to_xen(IOREMAP_VIRT_START,
    1.20                            vlfb_info.lfb_base >> PAGE_SHIFT,
    1.21                            vram_remap >> PAGE_SHIFT,
    1.22 @@ -104,6 +109,7 @@ void __init vesa_init(void)
    1.23  
    1.24      lfb = memset((void *)IOREMAP_VIRT_START, 0, vram_remap);
    1.25      memset(text_buf, 0, text_columns * text_rows);
    1.26 +    memset(line_len, 0, text_columns * sizeof(*line_len));
    1.27  
    1.28      vga_puts = vesa_redraw_puts;
    1.29  
    1.30 @@ -144,6 +150,7 @@ void __init vesa_init(void)
    1.31   fail:
    1.32      xfree(lbuf);
    1.33      xfree(text_buf);
    1.34 +    xfree(line_len);
    1.35  }
    1.36  
    1.37  void __init vesa_endboot(bool_t keep)
    1.38 @@ -160,6 +167,8 @@ void __init vesa_endboot(bool_t keep)
    1.39              memset(lfb + i * vlfb_info.bytes_per_line, 0,
    1.40                     vlfb_info.width * bpp);
    1.41      }
    1.42 +
    1.43 +    xfree(line_len);
    1.44  }
    1.45  
    1.46  #if defined(CONFIG_X86)
    1.47 @@ -212,7 +221,8 @@ static void lfb_flush(void)
    1.48  static void vesa_show_line(
    1.49      const unsigned char *text_line,
    1.50      unsigned char *video_line,
    1.51 -    unsigned int nr_chars)
    1.52 +    unsigned int nr_chars,
    1.53 +    unsigned int nr_cells)
    1.54  {
    1.55      unsigned int i, j, b, bpp, pixel;
    1.56  
    1.57 @@ -236,13 +246,13 @@ static void vesa_show_line(
    1.58          }
    1.59  
    1.60          memset(ptr, 0, (vlfb_info.width - nr_chars * font->width) * bpp);
    1.61 -        memcpy(video_line, lbuf, vlfb_info.width * bpp);
    1.62 +        memcpy(video_line, lbuf, nr_cells * font->width * bpp);
    1.63          video_line += vlfb_info.bytes_per_line;
    1.64      }
    1.65  }
    1.66  
    1.67  /* Fast mode which redraws all modified parts of a 2D text buffer. */
    1.68 -static void vesa_redraw_puts(const char *s)
    1.69 +static void __init vesa_redraw_puts(const char *s)
    1.70  {
    1.71      unsigned int i, min_redraw_y = ypos;
    1.72      char c;
    1.73 @@ -269,9 +279,18 @@ static void vesa_redraw_puts(const char 
    1.74  
    1.75      /* Render modified section of text buffer to VESA linear framebuffer. */
    1.76      for ( i = min_redraw_y; i <= ypos; i++ )
    1.77 -        vesa_show_line(text_buf + i * text_columns,
    1.78 +    {
    1.79 +        const unsigned char *line = text_buf + i * text_columns;
    1.80 +        unsigned int width;
    1.81 +
    1.82 +        for ( width = text_columns; width; --width )
    1.83 +            if ( line[width - 1] )
    1.84 +                 break;
    1.85 +        vesa_show_line(line,
    1.86                         lfb + i * font->height * vlfb_info.bytes_per_line,
    1.87 -                       text_columns);
    1.88 +                       width, max(line_len[i], width));
    1.89 +        line_len[i] = width;
    1.90 +    }
    1.91  
    1.92      lfb_flush();
    1.93  }
    1.94 @@ -303,7 +322,7 @@ static void vesa_scroll_puts(const char 
    1.95              vesa_show_line(
    1.96                  text_buf,
    1.97                  lfb + (text_rows-1) * font->height * vlfb_info.bytes_per_line,
    1.98 -                xpos);
    1.99 +                xpos, text_columns);
   1.100  
   1.101              xpos = 0;
   1.102          }