vga.c 2.6 KB

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