blob: 14ea32e734d59315c5aa70e1ba484be3468a5550 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Jeremy Fitzhardingec2419b42011-05-31 10:50:10 -04002#include <linux/screen_info.h>
3#include <linux/init.h>
4
5#include <asm/bootparam.h>
6#include <asm/setup.h>
7
8#include <xen/interface/xen.h>
9
10#include "xen-ops.h"
11
12void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size)
13{
14 struct screen_info *screen_info = &boot_params.screen_info;
15
16 /* This is drawn from a dump from vgacon:startup in
17 * standard Linux. */
18 screen_info->orig_video_mode = 3;
19 screen_info->orig_video_isVGA = 1;
20 screen_info->orig_video_lines = 25;
21 screen_info->orig_video_cols = 80;
22 screen_info->orig_video_ega_bx = 3;
23 screen_info->orig_video_points = 16;
24 screen_info->orig_y = screen_info->orig_video_lines - 1;
25
26 switch (info->video_type) {
27 case XEN_VGATYPE_TEXT_MODE_3:
28 if (size < offsetof(struct dom0_vga_console_info, u.text_mode_3)
29 + sizeof(info->u.text_mode_3))
30 break;
31 screen_info->orig_video_lines = info->u.text_mode_3.rows;
32 screen_info->orig_video_cols = info->u.text_mode_3.columns;
33 screen_info->orig_x = info->u.text_mode_3.cursor_x;
34 screen_info->orig_y = info->u.text_mode_3.cursor_y;
35 screen_info->orig_video_points =
36 info->u.text_mode_3.font_height;
37 break;
38
Jan Beulichaa387d632012-02-09 11:33:51 +080039 case XEN_VGATYPE_EFI_LFB:
Jeremy Fitzhardingec2419b42011-05-31 10:50:10 -040040 case XEN_VGATYPE_VESA_LFB:
41 if (size < offsetof(struct dom0_vga_console_info,
42 u.vesa_lfb.gbl_caps))
43 break;
44 screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB;
45 screen_info->lfb_width = info->u.vesa_lfb.width;
46 screen_info->lfb_height = info->u.vesa_lfb.height;
47 screen_info->lfb_depth = info->u.vesa_lfb.bits_per_pixel;
48 screen_info->lfb_base = info->u.vesa_lfb.lfb_base;
49 screen_info->lfb_size = info->u.vesa_lfb.lfb_size;
50 screen_info->lfb_linelength = info->u.vesa_lfb.bytes_per_line;
51 screen_info->red_size = info->u.vesa_lfb.red_size;
52 screen_info->red_pos = info->u.vesa_lfb.red_pos;
53 screen_info->green_size = info->u.vesa_lfb.green_size;
54 screen_info->green_pos = info->u.vesa_lfb.green_pos;
55 screen_info->blue_size = info->u.vesa_lfb.blue_size;
56 screen_info->blue_pos = info->u.vesa_lfb.blue_pos;
57 screen_info->rsvd_size = info->u.vesa_lfb.rsvd_size;
58 screen_info->rsvd_pos = info->u.vesa_lfb.rsvd_pos;
Jan Beulichaa387d632012-02-09 11:33:51 +080059
Jan Beulichf34c4f22022-02-07 08:41:03 +010060 if (size >= offsetof(struct dom0_vga_console_info,
61 u.vesa_lfb.ext_lfb_base)
62 + sizeof(info->u.vesa_lfb.ext_lfb_base)
63 && info->u.vesa_lfb.ext_lfb_base) {
64 screen_info->ext_lfb_base = info->u.vesa_lfb.ext_lfb_base;
65 screen_info->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
66 }
67
Jan Beulichaa387d632012-02-09 11:33:51 +080068 if (info->video_type == XEN_VGATYPE_EFI_LFB) {
69 screen_info->orig_video_isVGA = VIDEO_TYPE_EFI;
70 break;
71 }
72
Jeremy Fitzhardingec2419b42011-05-31 10:50:10 -040073 if (size >= offsetof(struct dom0_vga_console_info,
Jeremy Fitzhardingec2419b42011-05-31 10:50:10 -040074 u.vesa_lfb.mode_attrs)
75 + sizeof(info->u.vesa_lfb.mode_attrs))
76 screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs;
Jeremy Fitzhardingec2419b42011-05-31 10:50:10 -040077 break;
78 }
79}