debuggers.hg

view xen/drivers/video/vga.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 46f8fc57b1a4
line source
1 /******************************************************************************
2 * vga.c
3 *
4 * VGA support routines.
5 */
7 #include <xen/config.h>
8 #include <xen/init.h>
9 #include <xen/lib.h>
10 #include <xen/mm.h>
11 #include <xen/errno.h>
12 #include <xen/console.h>
13 #include <xen/vga.h>
14 #include <asm/io.h>
16 /* Filled in by arch boot code. */
17 struct xen_vga_console_info vga_console_info;
19 static int vgacon_keep;
20 static unsigned int xpos, ypos;
21 static unsigned char *video;
23 static void vga_text_puts(const char *s);
24 static void vga_noop_puts(const char *s) {}
25 void (*vga_puts)(const char *) = vga_noop_puts;
27 /*
28 * 'vga=<mode-specifier>[,keep]' where <mode-specifier> is one of:
29 *
30 * 'vga=ask':
31 * display a vga menu of available modes
32 *
33 * 'vga=current':
34 * use the current vga mode without modification
35 *
36 * 'vga=text-80x<rows>':
37 * text mode, where <rows> is one of {25,28,30,34,43,50,60}
38 *
39 * 'vga=gfx-<width>x<height>x<depth>':
40 * graphics mode, e.g., vga=gfx-1024x768x16
41 *
42 * 'vga=mode-<mode>:
43 * specifies a mode as specified in 'vga=ask' menu
44 * (NB. menu modes are displayed in hex, so mode numbers here must
45 * be prefixed with '0x' (e.g., 'vga=mode-0x0318'))
46 *
47 * The option 'keep' causes Xen to continue to print to the VGA console even
48 * after domain 0 starts to boot. The default behaviour is to relinquish
49 * control of the console to domain 0.
50 */
51 static char opt_vga[30] = "";
52 string_param("vga", opt_vga);
54 /* VGA text-mode definitions. */
55 static unsigned int columns, lines;
56 #define ATTRIBUTE 7
58 #ifdef CONFIG_X86_64
59 void vesa_early_init(void);
60 void vesa_endboot(void);
61 #else
62 #define vesa_early_init() ((void)0)
63 #define vesa_endboot() ((void)0)
64 #endif
66 void __init vga_init(void)
67 {
68 char *p;
70 /* Look for 'keep' in comma-separated options. */
71 for ( p = opt_vga; p != NULL; p = strchr(p, ',') )
72 {
73 if ( *p == ',' )
74 p++;
75 if ( strncmp(p, "keep", 4) == 0 )
76 vgacon_keep = 1;
77 }
79 switch ( vga_console_info.video_type )
80 {
81 case XEN_VGATYPE_TEXT_MODE_3:
82 if ( memory_is_conventional_ram(0xB8000) ||
83 ((video = ioremap(0xB8000, 0x8000)) == NULL) )
84 return;
85 outw(0x200a, 0x3d4); /* disable cursor */
86 columns = vga_console_info.u.text_mode_3.columns;
87 lines = vga_console_info.u.text_mode_3.rows;
88 memset(video, 0, columns * lines * 2);
89 vga_puts = vga_text_puts;
90 break;
91 case XEN_VGATYPE_VESA_LFB:
92 vesa_early_init();
93 break;
94 default:
95 memset(&vga_console_info, 0, sizeof(vga_console_info));
96 break;
97 }
98 }
100 void __init vga_endboot(void)
101 {
102 if ( vga_puts == vga_noop_puts )
103 return;
105 printk("Xen is %s VGA console.\n",
106 vgacon_keep ? "keeping" : "relinquishing");
108 vesa_endboot();
110 if ( !vgacon_keep )
111 vga_puts = vga_noop_puts;
112 }
114 static void vga_text_puts(const char *s)
115 {
116 char c;
118 while ( (c = *s++) != '\0' )
119 {
120 if ( (c == '\n') || (xpos >= columns) )
121 {
122 if ( ++ypos >= lines )
123 {
124 ypos = lines - 1;
125 memmove(video, video + 2 * columns, ypos * 2 * columns);
126 memset(video + ypos * 2 * columns, 0, 2 * xpos);
127 }
128 xpos = 0;
129 }
131 if ( c != '\n' )
132 {
133 video[(xpos + ypos * columns) * 2] = c;
134 video[(xpos + ypos * columns) * 2 + 1] = ATTRIBUTE;
135 xpos++;
136 }
137 }
138 }
140 int __init fill_console_start_info(struct dom0_vga_console_info *ci)
141 {
142 memcpy(ci, &vga_console_info, sizeof(*ci));
143 return 1;
144 }