ia64/xen-unstable

view xen/drivers/video/vga.c @ 19191:a55919061d79

blktap: Fix check_gcrypt

Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 11 10:44:42 2009 +0000 (2009-02-11)
parents 2f993fde1dc6
children 507b264f0a21
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(bool_t keep);
61 #else
62 #define vesa_early_init() ((void)0)
63 #define vesa_endboot(x) ((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 ( page_is_conventional_ram(paddr_to_pfn(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 if ( !vgacon_keep )
109 vga_puts = vga_noop_puts;
111 switch ( vga_console_info.video_type )
112 {
113 case XEN_VGATYPE_TEXT_MODE_3:
114 if ( !vgacon_keep )
115 memset(video, 0, columns * lines * 2);
116 break;
117 case XEN_VGATYPE_VESA_LFB:
118 vesa_endboot(vgacon_keep);
119 break;
120 default:
121 BUG();
122 }
123 }
125 static void vga_text_puts(const char *s)
126 {
127 char c;
129 while ( (c = *s++) != '\0' )
130 {
131 if ( (c == '\n') || (xpos >= columns) )
132 {
133 if ( ++ypos >= lines )
134 {
135 ypos = lines - 1;
136 memmove(video, video + 2 * columns, ypos * 2 * columns);
137 memset(video + ypos * 2 * columns, 0, 2 * xpos);
138 }
139 xpos = 0;
140 }
142 if ( c != '\n' )
143 {
144 video[(xpos + ypos * columns) * 2] = c;
145 video[(xpos + ypos * columns) * 2 + 1] = ATTRIBUTE;
146 xpos++;
147 }
148 }
149 }
151 int __init fill_console_start_info(struct dom0_vga_console_info *ci)
152 {
153 memcpy(ci, &vga_console_info, sizeof(*ci));
154 return 1;
155 }