Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
7.9 KiB

  1. /*++
  2. Copyright (c) 1990-1997 Microsoft Corporation
  3. Module Name:
  4. vga.h
  5. Author:
  6. Erick Smith (ericks) Oct. 1997
  7. Environment:
  8. kernel mode only
  9. Revision History:
  10. --*/
  11. //
  12. // VGA register definitions
  13. //
  14. #define CRTC_ADDRESS_PORT_MONO 0x03b4 // CRT Controller Address and
  15. #define CRTC_DATA_PORT_MONO 0x03b5 // Data registers in mono mode
  16. #define FEAT_CTRL_WRITE_PORT_MONO 0x03bA // Feature Control write port
  17. // in mono mode
  18. #define INPUT_STATUS_1_MONO 0x03bA // Input Status 1 register read
  19. // port in mono mode
  20. #define ATT_INITIALIZE_PORT_MONO INPUT_STATUS_1_MONO
  21. // Register to read to reset
  22. // Attribute Controller index/data
  23. #define ATT_ADDRESS_PORT 0x03c0 // Attribute Controller Address and
  24. #define ATT_DATA_WRITE_PORT 0x03c0 // Data registers share one port
  25. // for writes, but only Address is
  26. // readable at 0x3C0
  27. #define ATT_DATA_READ_PORT 0x03c1 // Attribute Controller Data reg is
  28. // readable here
  29. #define MISC_OUTPUT_REG_WRITE_PORT 0x03c2 // Miscellaneous Output reg write
  30. // port
  31. #define INPUT_STATUS_0_PORT 0x03c2 // Input Status 0 register read
  32. // port
  33. #define VIDEO_SUBSYSTEM_ENABLE_PORT 0x03c3 // Bit 0 enables/disables the
  34. // entire VGA subsystem
  35. #define SEQ_ADDRESS_PORT 0x03c4 // Sequence Controller Address and
  36. #define SEQ_DATA_PORT 0x03c5 // Data registers
  37. #define DAC_PIXEL_MASK_PORT 0x03c6 // DAC pixel mask reg
  38. #define DAC_ADDRESS_READ_PORT 0x03c7 // DAC register read index reg,
  39. // write-only
  40. #define DAC_STATE_PORT 0x03c7 // DAC state (read/write),
  41. // read-only
  42. #define DAC_ADDRESS_WRITE_PORT 0x03c8 // DAC register write index reg
  43. #define DAC_DATA_REG_PORT 0x03c9 // DAC data transfer reg
  44. #define FEAT_CTRL_READ_PORT 0x03cA // Feature Control read port
  45. #define MISC_OUTPUT_REG_READ_PORT 0x03cC // Miscellaneous Output reg read
  46. // port
  47. #define GRAPH_ADDRESS_PORT 0x03cE // Graphics Controller Address
  48. #define GRAPH_DATA_PORT 0x03cF // and Data registers
  49. #define CRTC_ADDRESS_PORT_COLOR 0x03d4 // CRT Controller Address and
  50. #define CRTC_DATA_PORT_COLOR 0x03d5 // Data registers in color mode
  51. #define FEAT_CTRL_WRITE_PORT_COLOR 0x03dA // Feature Control write port
  52. #define INPUT_STATUS_1_COLOR 0x03dA // Input Status 1 register read
  53. // port in color mode
  54. #define ATT_INITIALIZE_PORT_COLOR INPUT_STATUS_1_COLOR
  55. // Register to read to reset
  56. // Attribute Controller index/data
  57. // toggle in color mode
  58. //
  59. // VGA indexed register indexes.
  60. //
  61. #define IND_CURSOR_START 0x0A // index in CRTC of the Cursor Start
  62. #define IND_CURSOR_END 0x0B // and End registers
  63. #define IND_CURSOR_HIGH_LOC 0x0E // index in CRTC of the Cursor Location
  64. #define IND_CURSOR_LOW_LOC 0x0F // High and Low Registers
  65. #define IND_VSYNC_END 0x11 // index in CRTC of the Vertical Sync
  66. // End register, which has the bit
  67. // that protects/unprotects CRTC
  68. // index registers 0-7
  69. #define IND_SET_RESET_ENABLE 0x01 // index of Set/Reset Enable reg in GC
  70. #define IND_DATA_ROTATE 0x03 // index of Data Rotate reg in GC
  71. #define IND_READ_MAP 0x04 // index of Read Map reg in Graph Ctlr
  72. #define IND_GRAPH_MODE 0x05 // index of Mode reg in Graph Ctlr
  73. #define IND_GRAPH_MISC 0x06 // index of Misc reg in Graph Ctlr
  74. #define IND_BIT_MASK 0x08 // index of Bit Mask reg in Graph Ctlr
  75. #define IND_SYNC_RESET 0x00 // index of Sync Reset reg in Seq
  76. #define IND_MAP_MASK 0x02 // index of Map Mask in Sequencer
  77. #define IND_MEMORY_MODE 0x04 // index of Memory Mode reg in Seq
  78. #define IND_CRTC_PROTECT 0x11 // index of reg containing regs 0-7 in
  79. // CRTC
  80. #define START_SYNC_RESET_VALUE 0x01 // value for Sync Reset reg to start
  81. // synchronous reset
  82. #define END_SYNC_RESET_VALUE 0x03 // value for Sync Reset reg to end
  83. // synchronous reset
  84. //
  85. // Values for Attribute Controller Index register to turn video off
  86. // and on, by setting bit 5 to 0 (off) or 1 (on).
  87. //
  88. #define VIDEO_DISABLE 0
  89. #define VIDEO_ENABLE 0x20
  90. #define VGA_NUM_SEQUENCER_PORTS 5
  91. #define VGA_NUM_CRTC_PORTS 25
  92. #define VGA_NUM_GRAPH_CONT_PORTS 9
  93. #define VGA_NUM_ATTRIB_CONT_PORTS 21
  94. #define VGA_NUM_DAC_ENTRIES 256
  95. //
  96. // Value written to the Read Map register when identifying the existence of
  97. // a VGA in VgaInitialize. This value must be different from the final test
  98. // value written to the Bit Mask in that routine.
  99. //
  100. #define READ_MAP_TEST_SETTING 0x03
  101. //
  102. // Masks to keep only the significant bits of the Graphics Controller and
  103. // Sequencer Address registers. Masking is necessary because some VGAs, such
  104. // as S3-based ones, don't return unused bits set to 0, and some SVGAs use
  105. // these bits if extensions are enabled.
  106. //
  107. #define GRAPH_ADDR_MASK 0x0F
  108. #define SEQ_ADDR_MASK 0x07
  109. //
  110. // Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register.
  111. //
  112. #define CHAIN4_MASK 0x08
  113. //
  114. // Default text mode setting for various registers, used to restore their
  115. // states if VGA detection fails after they've been modified.
  116. //
  117. #define MEMORY_MODE_TEXT_DEFAULT 0x02
  118. #define BIT_MASK_DEFAULT 0xFF
  119. #define READ_MAP_DEFAULT 0x00
  120. //
  121. // prototypes
  122. //
  123. #define BI_RLE4 2
  124. #pragma pack(1)
  125. typedef struct _BITMAPFILEHEADER {
  126. USHORT bfType;
  127. ULONG bfSize;
  128. USHORT bfReserved1;
  129. USHORT bfReserved2;
  130. ULONG bfOffBits;
  131. } BITMAPFILEHEADER, *PBITMAPFILEHEADER;
  132. typedef struct _BITMAPINFOHEADER {
  133. ULONG biSize;
  134. LONG biWidth;
  135. LONG biHeight;
  136. USHORT biPlanes;
  137. USHORT biBitCount;
  138. ULONG biCompression;
  139. ULONG biSizeImage;
  140. LONG biXPelsPerMeter;
  141. LONG biYPelsPerMeter;
  142. ULONG biClrUsed;
  143. ULONG biClrImportant;
  144. } BITMAPINFOHEADER, *PBITMAPINFOHEADER;
  145. typedef struct _RGBQUAD {
  146. UCHAR rgbBlue;
  147. UCHAR rgbGreen;
  148. UCHAR rgbRed;
  149. UCHAR rgbReserved;
  150. } RGBQUAD, *PRGBQUAD;
  151. typedef struct _NTLDRGRAPHICSCONTEXT {
  152. UCHAR VgaGfxProgressBarColor;
  153. PUCHAR BmpBuffer; // Bitmap buffer
  154. PUCHAR DotBuffer; // Dots bitmap buffer
  155. ULONG ColorsUsed;
  156. RGBQUAD* Palette; // pointer to the palette in BmpBuffer (dots MUST have the same palette)
  157. } NTLDRGRAPHICSCONTEXT;
  158. #pragma pack()
  159. ////////////////////////////////////////////////////////////////////////////////
  160. VOID
  161. SetPixel(
  162. ULONG x,
  163. ULONG y,
  164. ULONG color
  165. );
  166. VOID
  167. BitBlt(
  168. ULONG x,
  169. ULONG y,
  170. ULONG width,
  171. ULONG height,
  172. PUCHAR Buffer,
  173. ULONG bpp,
  174. LONG ScanWidth
  175. );
  176. VOID
  177. SetPaletteEntryRGB(
  178. ULONG index,
  179. RGBQUAD rgb
  180. );
  181. VOID
  182. InitPaletteConversionTable();
  183. VOID
  184. InitPaletteWithBlack(
  185. VOID
  186. );
  187. VOID
  188. InitPaletteWithTable(
  189. PRGBQUAD Palette,
  190. ULONG count
  191. );
  192. VOID
  193. VidBitBlt(
  194. PUCHAR Buffer,
  195. ULONG x,
  196. ULONG y
  197. );
  198. VOID
  199. VidScreenToBufferBlt(
  200. PUCHAR Buffer,
  201. ULONG x,
  202. ULONG y,
  203. ULONG width,
  204. ULONG height,
  205. ULONG lDelta
  206. );
  207. void
  208. VidBufferToScreenBlt(
  209. PUCHAR Buffer,
  210. ULONG x,
  211. ULONG y,
  212. ULONG width,
  213. ULONG height,
  214. ULONG lDelta
  215. );