Leaked source code of windows server 2003
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.

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