162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci#include <linux/screen_info.h> 362306a36Sopenharmony_ci#include <linux/init.h> 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <asm/bootparam.h> 662306a36Sopenharmony_ci#include <asm/setup.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <xen/interface/xen.h> 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "xen-ops.h" 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_civoid __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size, 1362306a36Sopenharmony_ci struct screen_info *screen_info) 1462306a36Sopenharmony_ci{ 1562306a36Sopenharmony_ci /* This is drawn from a dump from vgacon:startup in 1662306a36Sopenharmony_ci * standard Linux. */ 1762306a36Sopenharmony_ci screen_info->orig_video_mode = 3; 1862306a36Sopenharmony_ci screen_info->orig_video_isVGA = 1; 1962306a36Sopenharmony_ci screen_info->orig_video_lines = 25; 2062306a36Sopenharmony_ci screen_info->orig_video_cols = 80; 2162306a36Sopenharmony_ci screen_info->orig_video_ega_bx = 3; 2262306a36Sopenharmony_ci screen_info->orig_video_points = 16; 2362306a36Sopenharmony_ci screen_info->orig_y = screen_info->orig_video_lines - 1; 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci switch (info->video_type) { 2662306a36Sopenharmony_ci case XEN_VGATYPE_TEXT_MODE_3: 2762306a36Sopenharmony_ci if (size < offsetof(struct dom0_vga_console_info, u.text_mode_3) 2862306a36Sopenharmony_ci + sizeof(info->u.text_mode_3)) 2962306a36Sopenharmony_ci break; 3062306a36Sopenharmony_ci screen_info->orig_video_lines = info->u.text_mode_3.rows; 3162306a36Sopenharmony_ci screen_info->orig_video_cols = info->u.text_mode_3.columns; 3262306a36Sopenharmony_ci screen_info->orig_x = info->u.text_mode_3.cursor_x; 3362306a36Sopenharmony_ci screen_info->orig_y = info->u.text_mode_3.cursor_y; 3462306a36Sopenharmony_ci screen_info->orig_video_points = 3562306a36Sopenharmony_ci info->u.text_mode_3.font_height; 3662306a36Sopenharmony_ci break; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci case XEN_VGATYPE_EFI_LFB: 3962306a36Sopenharmony_ci case XEN_VGATYPE_VESA_LFB: 4062306a36Sopenharmony_ci if (size < offsetof(struct dom0_vga_console_info, 4162306a36Sopenharmony_ci u.vesa_lfb.gbl_caps)) 4262306a36Sopenharmony_ci break; 4362306a36Sopenharmony_ci screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB; 4462306a36Sopenharmony_ci screen_info->lfb_width = info->u.vesa_lfb.width; 4562306a36Sopenharmony_ci screen_info->lfb_height = info->u.vesa_lfb.height; 4662306a36Sopenharmony_ci screen_info->lfb_depth = info->u.vesa_lfb.bits_per_pixel; 4762306a36Sopenharmony_ci screen_info->lfb_base = info->u.vesa_lfb.lfb_base; 4862306a36Sopenharmony_ci screen_info->lfb_size = info->u.vesa_lfb.lfb_size; 4962306a36Sopenharmony_ci screen_info->lfb_linelength = info->u.vesa_lfb.bytes_per_line; 5062306a36Sopenharmony_ci screen_info->red_size = info->u.vesa_lfb.red_size; 5162306a36Sopenharmony_ci screen_info->red_pos = info->u.vesa_lfb.red_pos; 5262306a36Sopenharmony_ci screen_info->green_size = info->u.vesa_lfb.green_size; 5362306a36Sopenharmony_ci screen_info->green_pos = info->u.vesa_lfb.green_pos; 5462306a36Sopenharmony_ci screen_info->blue_size = info->u.vesa_lfb.blue_size; 5562306a36Sopenharmony_ci screen_info->blue_pos = info->u.vesa_lfb.blue_pos; 5662306a36Sopenharmony_ci screen_info->rsvd_size = info->u.vesa_lfb.rsvd_size; 5762306a36Sopenharmony_ci screen_info->rsvd_pos = info->u.vesa_lfb.rsvd_pos; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci if (size >= offsetof(struct dom0_vga_console_info, 6062306a36Sopenharmony_ci u.vesa_lfb.ext_lfb_base) 6162306a36Sopenharmony_ci + sizeof(info->u.vesa_lfb.ext_lfb_base) 6262306a36Sopenharmony_ci && info->u.vesa_lfb.ext_lfb_base) { 6362306a36Sopenharmony_ci screen_info->ext_lfb_base = info->u.vesa_lfb.ext_lfb_base; 6462306a36Sopenharmony_ci screen_info->capabilities |= VIDEO_CAPABILITY_64BIT_BASE; 6562306a36Sopenharmony_ci } 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci if (info->video_type == XEN_VGATYPE_EFI_LFB) { 6862306a36Sopenharmony_ci screen_info->orig_video_isVGA = VIDEO_TYPE_EFI; 6962306a36Sopenharmony_ci break; 7062306a36Sopenharmony_ci } 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci if (size >= offsetof(struct dom0_vga_console_info, 7362306a36Sopenharmony_ci u.vesa_lfb.mode_attrs) 7462306a36Sopenharmony_ci + sizeof(info->u.vesa_lfb.mode_attrs)) 7562306a36Sopenharmony_ci screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs; 7662306a36Sopenharmony_ci break; 7762306a36Sopenharmony_ci } 7862306a36Sopenharmony_ci} 79