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.

223 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. vga.h
  5. Abstract:
  6. This module contains the definitions for the code that implements the
  7. VGA device driver.
  8. Author:
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. //
  14. // Base address of VGA memory range. Also used as base address of VGA
  15. // memory when loading a font, which is done with the VGA mapped at A0000.
  16. //
  17. #define MEM_VGA 0xA0000
  18. #define MEM_VGA_SIZE 0x20000
  19. //
  20. // Index in the access range sturture for video memory
  21. // !!! This must match the VgaAccessRange structure !!!
  22. // !!! Memory is in the structure, index 2 (3rd entry) !!!
  23. #define VGA_MEMORY 2
  24. //
  25. // VGA port-related definitions.
  26. //
  27. //
  28. // Port definitions for filling the ACCSES_RANGES structure in the miniport
  29. // information, defines the range of I/O ports the VGA spans.
  30. // There is a break in the IO ports - a few ports are used for the parallel
  31. // port. Those cannot be defined in the ACCESS_RANGE, but are still mapped
  32. // so all VGA ports are in one address range.
  33. //
  34. #define VGA_BASE_IO_PORT 0x000003B0
  35. #define VGA_START_BREAK_PORT 0x000003BB
  36. #define VGA_END_BREAK_PORT 0x000003C0
  37. #define VGA_MAX_IO_PORT 0x000003DF
  38. //
  39. // VGA register definitions
  40. //
  41. // ports in monochrome mode
  42. #define CRTC_ADDRESS_PORT_MONO 0x0004 // CRT Controller Address and
  43. #define CRTC_DATA_PORT_MONO 0x0005 // Data registers in mono mode
  44. #define FEAT_CTRL_WRITE_PORT_MONO 0x000A // Feature Control write port
  45. // in mono mode
  46. #define INPUT_STATUS_1_MONO 0x000A // Input Status 1 register read
  47. // port in mono mode
  48. #define ATT_INITIALIZE_PORT_MONO INPUT_STATUS_1_MONO
  49. // Register to read to reset
  50. // Attribute Controller index/data
  51. #define ATT_ADDRESS_PORT 0x0010 // Attribute Controller Address and
  52. #define ATT_DATA_WRITE_PORT 0x0010 // Data registers share one port
  53. // for writes, but only Address is
  54. // readable at 0x3C0
  55. #define ATT_DATA_READ_PORT 0x0011 // Attribute Controller Data reg is
  56. // readable here
  57. #define MISC_OUTPUT_REG_WRITE_PORT 0x0012 // Miscellaneous Output reg write
  58. // port
  59. #define INPUT_STATUS_0_PORT 0x0012 // Input Status 0 register read
  60. // port
  61. #define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013 // Bit 0 enables/disables the
  62. // entire VGA subsystem
  63. #define SEQ_ADDRESS_PORT 0x0014 // Sequence Controller Address and
  64. #define SEQ_DATA_PORT 0x0015 // Data registers
  65. #define DAC_PIXEL_MASK_PORT 0x0016 // DAC pixel mask reg
  66. #define DAC_ADDRESS_READ_PORT 0x0017 // DAC register read index reg,
  67. // write-only
  68. #define DAC_STATE_PORT 0x0017 // DAC state (read/write),
  69. // read-only
  70. #define DAC_ADDRESS_WRITE_PORT 0x0018 // DAC register write index reg
  71. #define DAC_DATA_REG_PORT 0x0019 // DAC data transfer reg
  72. #define FEAT_CTRL_READ_PORT 0x001A // Feature Control read port
  73. #define MISC_OUTPUT_REG_READ_PORT 0x001C // Miscellaneous Output reg read
  74. // port
  75. #define GRAPH_ADDRESS_PORT 0x001E // Graphics Controller Address
  76. #define GRAPH_DATA_PORT 0x001F // and Data registers
  77. #define CRTC_ADDRESS_PORT_COLOR 0x0024 // CRT Controller Address and
  78. #define CRTC_DATA_PORT_COLOR 0x0025 // Data registers in color mode
  79. #define FEAT_CTRL_WRITE_PORT_COLOR 0x002A // Feature Control write port
  80. #define INPUT_STATUS_1_COLOR 0x002A // Input Status 1 register read
  81. // port in color mode
  82. #define ATT_INITIALIZE_PORT_COLOR INPUT_STATUS_1_COLOR
  83. // Register to read to reset
  84. // Attribute Controller index/data
  85. // toggle in color mode
  86. //
  87. // VGA indexed register indexes.
  88. //
  89. #define IND_CURSOR_START 0x0A // index in CRTC of the Cursor Start
  90. #define IND_CURSOR_END 0x0B // and End registers
  91. #define IND_CURSOR_HIGH_LOC 0x0E // index in CRTC of the Cursor Location
  92. #define IND_CURSOR_LOW_LOC 0x0F // High and Low Registers
  93. #define IND_VSYNC_END 0x11 // index in CRTC of the Vertical Sync
  94. // End register, which has the bit
  95. // that protects/unprotects CRTC
  96. // index registers 0-7
  97. #define IND_SET_RESET_ENABLE 0x01 // index of Set/Reset Enable reg in GC
  98. #define IND_DATA_ROTATE 0x03 // index of Data Rotate reg in GC
  99. #define IND_READ_MAP 0x04 // index of Read Map reg in Graph Ctlr
  100. #define IND_GRAPH_MODE 0x05 // index of Mode reg in Graph Ctlr
  101. #define IND_GRAPH_MISC 0x06 // index of Misc reg in Graph Ctlr
  102. #define IND_BIT_MASK 0x08 // index of Bit Mask reg in Graph Ctlr
  103. #define IND_SYNC_RESET 0x00 // index of Sync Reset reg in Seq
  104. #define IND_MAP_MASK 0x02 // index of Map Mask in Sequencer
  105. #define IND_MEMORY_MODE 0x04 // index of Memory Mode reg in Seq
  106. #define IND_CRTC_PROTECT 0x11 // index of reg containing regs 0-7 in
  107. // CRTC
  108. #define IND_START_ADRS_H 0x0C // index in CRTC of Start Address (high)
  109. #define IND_START_ADRS_L 0x0D // index in CRTC of Start Address (low)
  110. #define IND_LINE_COMPARE 0x18 // index in CRTC of Line Compare (bit7-0)
  111. #define IND_LINE_COMPARE8 0x07 // index in CRTC of Line Compare (bit8)
  112. #define IND_LINE_COMPARE9 0x09 // index in CRTC of Line Compare (bit9)
  113. #define IND_SET_RESET 0x00 // index of Set/Reset Plane Color Register in Graph Ctrl
  114. #define IND_COLOR_DONT_CARE 0x07 // index of Color Don't Care Register in Graph Ctrl
  115. #define START_SYNC_RESET_VALUE 0x01 // value for Sync Reset reg to start
  116. // synchronous reset
  117. #define END_SYNC_RESET_VALUE 0x03 // value for Sync Reset reg to end
  118. // synchronous reset
  119. //
  120. // Values for Attribute Controller Index register to turn video off
  121. // and on, by setting bit 5 to 0 (off) or 1 (on).
  122. //
  123. #define VIDEO_DISABLE 0
  124. #define VIDEO_ENABLE 0x20
  125. //
  126. // Value written to the Read Map register when identifying the existence of
  127. // a VGA in VgaInitialize. This value must be different from the final test
  128. // value written to the Bit Mask in that routine.
  129. //
  130. #define READ_MAP_TEST_SETTING 0x03
  131. //
  132. // Masks to keep only the significant bits of the Graphics Controller and
  133. // Sequencer Address registers. Masking is necessary because some VGAs, such
  134. // as S3-based ones, don't return unused bits set to 0, and some SVGAs use
  135. // these bits if extensions are enabled.
  136. //
  137. #define GRAPH_ADDR_MASK 0x0F
  138. #define SEQ_ADDR_MASK 0x07
  139. //
  140. // IND_DATA_ROTATE : index of Data Rotate reg in GC
  141. //
  142. #define DR_ROT_CNT 0x07 // Data Rotate Count
  143. #define DR_SET 0x00 // Data Unmodified
  144. #define DR_AND 0x08 // Data ANDed with latches
  145. #define DR_OR 0x10 // Data ORed with latches
  146. #define DR_XOR 0x18 // Data XORed with latches
  147. //
  148. // IND_GRAPH_MODE : index of Mode reg in Graph Ctlr
  149. //
  150. #define M_PROC_WRITE 0x00 // Write processor data rotated
  151. #define M_LATCH_WRITE 0x01 // Write latched data
  152. #define M_COLOR_WRITE 0x02 // Write processor data as color
  153. #define M_AND_WRITE 0x03 // Write (procdata AND bitmask)
  154. #define M_DATA_READ 0x00 // Read selected plane
  155. #define M_COLOR_READ 0x08 // Read color compare
  156. //
  157. // Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register.
  158. //
  159. #define CHAIN4_MASK 0x08
  160. //
  161. // Default text mode setting for various registers, used to restore their
  162. // states if VGA detection fails after they've been modified.
  163. //
  164. #define MEMORY_MODE_TEXT_DEFAULT 0x02
  165. #define BIT_MASK_DEFAULT 0xFF
  166. #define READ_MAP_DEFAULT 0x00
  167. //
  168. // Palette-related info.
  169. //
  170. //
  171. // Highest valid DAC color register index.
  172. //
  173. #define VIDEO_MAX_COLOR_REGISTER 0xFF
  174. //
  175. // Highest valid palette register index
  176. //
  177. #define VIDEO_MAX_PALETTE_REGISTER 0x0F