sky2: Flow control frames recorded as dropped packets
[safe/jmp/linux-2.6] / drivers / video / console / vgacon.c
index f65bcd3..cc4bbbe 100644 (file)
@@ -112,6 +112,23 @@ static int                 vga_video_font_height;
 static int             vga_scan_lines          __read_mostly;
 static unsigned int    vga_rolled_over;
 
+int vgacon_text_mode_force = 0;
+
+bool vgacon_text_force(void)
+{
+       return vgacon_text_mode_force ? true : false;
+}
+EXPORT_SYMBOL(vgacon_text_force);
+
+static int __init text_mode(char *str)
+{
+       vgacon_text_mode_force = 1;
+       return 1;
+}
+
+/* force text mode - used by kernel modesetting */
+__setup("nomodeset", text_mode);
+
 static int __init no_scroll(char *str)
 {
        /*
@@ -163,7 +180,6 @@ static inline void vga_set_mem_top(struct vc_data *c)
 }
 
 #ifdef CONFIG_VGACON_SOFT_SCROLLBACK
-#include <linux/bootmem.h>
 /* software scrollback */
 static void *vgacon_scrollback;
 static int vgacon_scrollback_tail;
@@ -193,8 +209,7 @@ static void vgacon_scrollback_init(int pitch)
  */
 static void __init_refok vgacon_scrollback_startup(void)
 {
-       vgacon_scrollback = alloc_bootmem(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE
-                                         * 1024);
+       vgacon_scrollback = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024, GFP_NOWAIT);
        vgacon_scrollback_init(vga_video_num_columns * 2);
 }
 
@@ -239,8 +254,7 @@ static void vgacon_restore_screen(struct vc_data *c)
 
 static int vgacon_scrolldelta(struct vc_data *c, int lines)
 {
-       int start, end, count, soff, diff;
-       void *d, *s;
+       int start, end, count, soff;
 
        if (!lines) {
                c->vc_visible_origin = c->vc_origin;
@@ -287,29 +301,29 @@ static int vgacon_scrolldelta(struct vc_data *c, int lines)
        if (count > c->vc_rows)
                count = c->vc_rows;
 
-       diff = c->vc_rows - count;
+       if (count) {
+               int copysize;
 
-       d = (void *) c->vc_origin;
-       s = (void *) c->vc_screenbuf;
+               int diff = c->vc_rows - count;
+               void *d = (void *) c->vc_origin;
+               void *s = (void *) c->vc_screenbuf;
 
-       while (count--) {
-               scr_memcpyw(d, vgacon_scrollback + soff, c->vc_size_row);
-               d += c->vc_size_row;
-               soff += c->vc_size_row;
+               count *= c->vc_size_row;
+               /* how much memory to end of buffer left? */
+               copysize = min(count, vgacon_scrollback_size - soff);
+               scr_memcpyw(d, vgacon_scrollback + soff, copysize);
+               d += copysize;
+               count -= copysize;
 
-               if (soff >= vgacon_scrollback_size)
-                       soff = 0;
-       }
+               if (count) {
+                       scr_memcpyw(d, vgacon_scrollback, count);
+                       d += count;
+               }
 
-       if (diff == c->vc_rows) {
+               if (diff)
+                       scr_memcpyw(d, s, diff * c->vc_size_row);
+       } else
                vgacon_cursor(c, CM_MOVE);
-       } else {
-               while (diff--) {
-                       scr_memcpyw(d, s, c->vc_size_row);
-                       d += c->vc_size_row;
-                       s += c->vc_size_row;
-               }
-       }
 
        return 1;
 }
@@ -571,16 +585,23 @@ static void vgacon_init(struct vc_data *c, int init)
        vgacon_uni_pagedir[1]++;
        if (!vgacon_uni_pagedir[0] && p)
                con_set_default_unimap(c);
+
+       /* Only set the default if the user didn't deliberately override it */
+       if (global_cursor_default == -1)
+               global_cursor_default =
+                       !(screen_info.flags & VIDEO_FLAGS_NOCURSOR);
 }
 
 static void vgacon_deinit(struct vc_data *c)
 {
-       /* When closing the last console, reset video origin */
-       if (!--vgacon_uni_pagedir[1]) {
+       /* When closing the active console, reset video origin */
+       if (CON_IS_VISIBLE(c)) {
                c->vc_visible_origin = vga_vram_base;
                vga_set_mem_top(c);
-               con_free_unimap(c);
        }
+
+       if (!--vgacon_uni_pagedir[1])
+               con_free_unimap(c);
        c->vc_uni_pagedir_loc = &c->vc_uni_pagedir;
        con_set_default_unimap(c);
 }
@@ -1153,8 +1174,6 @@ static int vgacon_do_font_op(struct vgastate *state,char *arg,int set,int ch512)
 
        /* if 512 char mode is already enabled don't re-enable it. */
        if ((set) && (ch512 != vga_512_chars)) {
-               int i;  
-               
                /* attribute controller */
                for (i = 0; i < MAX_NR_CONSOLES; i++) {
                        struct vc_data *c = vc_cons[i].d;
@@ -1268,7 +1287,7 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font)
        font->charcount = vga_512_chars ? 512 : 256;
        if (!font->data)
                return 0;
-       return vgacon_do_font_op(&state, font->data, 0, 0);
+       return vgacon_do_font_op(&state, font->data, 0, vga_512_chars);
 }
 
 #else
@@ -1318,7 +1337,7 @@ static void vgacon_save_screen(struct vc_data *c)
                c->vc_y = screen_info.orig_y;
        }
 
-       /* We can't copy in more then the size of the video buffer,
+       /* We can't copy in more than the size of the video buffer,
         * or we'll be copying in VGA BIOS */
 
        if (!vga_is_gfx)