xref: /linux/arch/x86/xen/vga.c (revision b2441318)
1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2c2419b4aSJeremy Fitzhardinge #include <linux/screen_info.h>
3c2419b4aSJeremy Fitzhardinge #include <linux/init.h>
4c2419b4aSJeremy Fitzhardinge 
5c2419b4aSJeremy Fitzhardinge #include <asm/bootparam.h>
6c2419b4aSJeremy Fitzhardinge #include <asm/setup.h>
7c2419b4aSJeremy Fitzhardinge 
8c2419b4aSJeremy Fitzhardinge #include <xen/interface/xen.h>
9c2419b4aSJeremy Fitzhardinge 
10c2419b4aSJeremy Fitzhardinge #include "xen-ops.h"
11c2419b4aSJeremy Fitzhardinge 
12c2419b4aSJeremy Fitzhardinge void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size)
13c2419b4aSJeremy Fitzhardinge {
14c2419b4aSJeremy Fitzhardinge 	struct screen_info *screen_info = &boot_params.screen_info;
15c2419b4aSJeremy Fitzhardinge 
16c2419b4aSJeremy Fitzhardinge 	/* This is drawn from a dump from vgacon:startup in
17c2419b4aSJeremy Fitzhardinge 	 * standard Linux. */
18c2419b4aSJeremy Fitzhardinge 	screen_info->orig_video_mode = 3;
19c2419b4aSJeremy Fitzhardinge 	screen_info->orig_video_isVGA = 1;
20c2419b4aSJeremy Fitzhardinge 	screen_info->orig_video_lines = 25;
21c2419b4aSJeremy Fitzhardinge 	screen_info->orig_video_cols = 80;
22c2419b4aSJeremy Fitzhardinge 	screen_info->orig_video_ega_bx = 3;
23c2419b4aSJeremy Fitzhardinge 	screen_info->orig_video_points = 16;
24c2419b4aSJeremy Fitzhardinge 	screen_info->orig_y = screen_info->orig_video_lines - 1;
25c2419b4aSJeremy Fitzhardinge 
26c2419b4aSJeremy Fitzhardinge 	switch (info->video_type) {
27c2419b4aSJeremy Fitzhardinge 	case XEN_VGATYPE_TEXT_MODE_3:
28c2419b4aSJeremy Fitzhardinge 		if (size < offsetof(struct dom0_vga_console_info, u.text_mode_3)
29c2419b4aSJeremy Fitzhardinge 		    + sizeof(info->u.text_mode_3))
30c2419b4aSJeremy Fitzhardinge 			break;
31c2419b4aSJeremy Fitzhardinge 		screen_info->orig_video_lines = info->u.text_mode_3.rows;
32c2419b4aSJeremy Fitzhardinge 		screen_info->orig_video_cols = info->u.text_mode_3.columns;
33c2419b4aSJeremy Fitzhardinge 		screen_info->orig_x = info->u.text_mode_3.cursor_x;
34c2419b4aSJeremy Fitzhardinge 		screen_info->orig_y = info->u.text_mode_3.cursor_y;
35c2419b4aSJeremy Fitzhardinge 		screen_info->orig_video_points =
36c2419b4aSJeremy Fitzhardinge 			info->u.text_mode_3.font_height;
37c2419b4aSJeremy Fitzhardinge 		break;
38c2419b4aSJeremy Fitzhardinge 
39aa387d63SJan Beulich 	case XEN_VGATYPE_EFI_LFB:
40c2419b4aSJeremy Fitzhardinge 	case XEN_VGATYPE_VESA_LFB:
41c2419b4aSJeremy Fitzhardinge 		if (size < offsetof(struct dom0_vga_console_info,
42c2419b4aSJeremy Fitzhardinge 				    u.vesa_lfb.gbl_caps))
43c2419b4aSJeremy Fitzhardinge 			break;
44c2419b4aSJeremy Fitzhardinge 		screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB;
45c2419b4aSJeremy Fitzhardinge 		screen_info->lfb_width = info->u.vesa_lfb.width;
46c2419b4aSJeremy Fitzhardinge 		screen_info->lfb_height = info->u.vesa_lfb.height;
47c2419b4aSJeremy Fitzhardinge 		screen_info->lfb_depth = info->u.vesa_lfb.bits_per_pixel;
48c2419b4aSJeremy Fitzhardinge 		screen_info->lfb_base = info->u.vesa_lfb.lfb_base;
49c2419b4aSJeremy Fitzhardinge 		screen_info->lfb_size = info->u.vesa_lfb.lfb_size;
50c2419b4aSJeremy Fitzhardinge 		screen_info->lfb_linelength = info->u.vesa_lfb.bytes_per_line;
51c2419b4aSJeremy Fitzhardinge 		screen_info->red_size = info->u.vesa_lfb.red_size;
52c2419b4aSJeremy Fitzhardinge 		screen_info->red_pos = info->u.vesa_lfb.red_pos;
53c2419b4aSJeremy Fitzhardinge 		screen_info->green_size = info->u.vesa_lfb.green_size;
54c2419b4aSJeremy Fitzhardinge 		screen_info->green_pos = info->u.vesa_lfb.green_pos;
55c2419b4aSJeremy Fitzhardinge 		screen_info->blue_size = info->u.vesa_lfb.blue_size;
56c2419b4aSJeremy Fitzhardinge 		screen_info->blue_pos = info->u.vesa_lfb.blue_pos;
57c2419b4aSJeremy Fitzhardinge 		screen_info->rsvd_size = info->u.vesa_lfb.rsvd_size;
58c2419b4aSJeremy Fitzhardinge 		screen_info->rsvd_pos = info->u.vesa_lfb.rsvd_pos;
59aa387d63SJan Beulich 
60aa387d63SJan Beulich 		if (info->video_type == XEN_VGATYPE_EFI_LFB) {
61aa387d63SJan Beulich 			screen_info->orig_video_isVGA = VIDEO_TYPE_EFI;
62aa387d63SJan Beulich 			break;
63aa387d63SJan Beulich 		}
64aa387d63SJan Beulich 
65c2419b4aSJeremy Fitzhardinge 		if (size >= offsetof(struct dom0_vga_console_info,
66c2419b4aSJeremy Fitzhardinge 				     u.vesa_lfb.gbl_caps)
67c2419b4aSJeremy Fitzhardinge 		    + sizeof(info->u.vesa_lfb.gbl_caps))
68c2419b4aSJeremy Fitzhardinge 			screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
69c2419b4aSJeremy Fitzhardinge 		if (size >= offsetof(struct dom0_vga_console_info,
70c2419b4aSJeremy Fitzhardinge 				     u.vesa_lfb.mode_attrs)
71c2419b4aSJeremy Fitzhardinge 		    + sizeof(info->u.vesa_lfb.mode_attrs))
72c2419b4aSJeremy Fitzhardinge 			screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs;
73c2419b4aSJeremy Fitzhardinge 		break;
74c2419b4aSJeremy Fitzhardinge 	}
75c2419b4aSJeremy Fitzhardinge }
76