video.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* -*- linux-c -*- ------------------------------------------------------- *
  2. *
  3. * Copyright (C) 1991, 1992 Linus Torvalds
  4. * Copyright 2007 rPath, Inc. - All Rights Reserved
  5. *
  6. * This file is part of the Linux kernel, and is made available under
  7. * the terms of the GNU General Public License version 2.
  8. *
  9. * ----------------------------------------------------------------------- */
  10. /*
  11. * Header file for the real-mode video probing code
  12. */
  13. #ifndef BOOT_VIDEO_H
  14. #define BOOT_VIDEO_H
  15. #include <linux/types.h>
  16. /* Enable autodetection of SVGA adapters and modes. */
  17. #undef CONFIG_VIDEO_SVGA
  18. /* Enable autodetection of VESA modes */
  19. #define CONFIG_VIDEO_VESA
  20. /* Retain screen contents when switching modes */
  21. #define CONFIG_VIDEO_RETAIN
  22. /* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
  23. #undef CONFIG_VIDEO_400_HACK
  24. /* This code uses an extended set of video mode numbers. These include:
  25. * Aliases for standard modes
  26. * NORMAL_VGA (-1)
  27. * EXTENDED_VGA (-2)
  28. * ASK_VGA (-3)
  29. * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
  30. * of compatibility when extending the table. These are between 0x00 and 0xff.
  31. */
  32. #define VIDEO_FIRST_MENU 0x0000
  33. /* Standard BIOS video modes (BIOS number + 0x0100) */
  34. #define VIDEO_FIRST_BIOS 0x0100
  35. /* VESA BIOS video modes (VESA number + 0x0200) */
  36. #define VIDEO_FIRST_VESA 0x0200
  37. /* Video7 special modes (BIOS number + 0x0900) */
  38. #define VIDEO_FIRST_V7 0x0900
  39. /* Special video modes */
  40. #define VIDEO_FIRST_SPECIAL 0x0f00
  41. #define VIDEO_80x25 0x0f00
  42. #define VIDEO_8POINT 0x0f01
  43. #define VIDEO_80x43 0x0f02
  44. #define VIDEO_80x28 0x0f03
  45. #define VIDEO_CURRENT_MODE 0x0f04
  46. #define VIDEO_80x30 0x0f05
  47. #define VIDEO_80x34 0x0f06
  48. #define VIDEO_80x60 0x0f07
  49. #define VIDEO_GFX_HACK 0x0f08
  50. #define VIDEO_LAST_SPECIAL 0x0f09
  51. /* Video modes given by resolution */
  52. #define VIDEO_FIRST_RESOLUTION 0x1000
  53. /* The "recalculate timings" flag */
  54. #define VIDEO_RECALC 0x8000
  55. /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
  56. #ifdef CONFIG_VIDEO_RETAIN
  57. void store_screen(void);
  58. #define DO_STORE() store_screen()
  59. #else
  60. #define DO_STORE() ((void)0)
  61. #endif /* CONFIG_VIDEO_RETAIN */
  62. /*
  63. * Mode table structures
  64. */
  65. struct mode_info {
  66. u16 mode; /* Mode number (vga= style) */
  67. u16 x, y; /* Width, height */
  68. u16 depth; /* Bits per pixel, 0 for text mode */
  69. };
  70. struct card_info {
  71. const char *card_name;
  72. int (*set_mode)(struct mode_info *mode);
  73. int (*probe)(void);
  74. struct mode_info *modes;
  75. int nmodes; /* Number of probed modes so far */
  76. int unsafe; /* Probing is unsafe, only do after "scan" */
  77. u16 xmode_first; /* Unprobed modes to try to call anyway */
  78. u16 xmode_n; /* Size of unprobed mode range */
  79. };
  80. #define __videocard struct card_info __attribute__((section(".videocards")))
  81. extern struct card_info video_cards[], video_cards_end[];
  82. int mode_defined(u16 mode); /* video.c */
  83. /* Basic video information */
  84. #define ADAPTER_CGA 0 /* CGA/MDA/HGC */
  85. #define ADAPTER_EGA 1
  86. #define ADAPTER_VGA 2
  87. extern int adapter;
  88. extern u16 video_segment;
  89. extern int force_x, force_y; /* Don't query the BIOS for cols/rows */
  90. extern int do_restore; /* Restore screen contents */
  91. extern int graphic_mode; /* Graphics mode with linear frame buffer */
  92. /*
  93. * int $0x10 is notorious for touching registers it shouldn't.
  94. * gcc doesn't like %ebp being clobbered, so define it as a push/pop
  95. * sequence here.
  96. *
  97. * A number of systems, including the original PC can clobber %bp in
  98. * certain circumstances, like when scrolling. There exists at least
  99. * one Trident video card which could clobber DS under a set of
  100. * circumstances that we are unlikely to encounter (scrolling when
  101. * using an extended graphics mode of more than 800x600 pixels), but
  102. * it's cheap insurance to deal with that here.
  103. */
  104. #define INT10 "pushl %%ebp; pushw %%ds; int $0x10; popw %%ds; popl %%ebp"
  105. /* Accessing VGA indexed registers */
  106. static inline u8 in_idx(u16 port, u8 index)
  107. {
  108. outb(index, port);
  109. return inb(port+1);
  110. }
  111. static inline void out_idx(u8 v, u16 port, u8 index)
  112. {
  113. outw(index+(v << 8), port);
  114. }
  115. /* Writes a value to an indexed port and then reads the port again */
  116. static inline u8 tst_idx(u8 v, u16 port, u8 index)
  117. {
  118. out_idx(port, index, v);
  119. return in_idx(port, index);
  120. }
  121. /* Get the I/O port of the VGA CRTC */
  122. u16 vga_crtc(void); /* video-vga.c */
  123. #endif /* BOOT_VIDEO_H */