vga.c 2.6 KB

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