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