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.

281 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vesa.h
  5. Abstract:
  6. This module implements VESA support.
  7. Author:
  8. Erick Smith (ericks) Sep. 2000
  9. Environment:
  10. kernel mode only
  11. Revision History:
  12. --*/
  13. #define VBE_GET_CONTROLLER_INFO 0x4F00
  14. #define VBE_GET_MODE_INFO 0x4F01
  15. #define VBE_SET_MODE 0x4F02
  16. #define VBE_GET_MODE 0x4F03
  17. #define VBE_SAVE_RESTORE_STATE 0x4F04
  18. #define VBE_WINDOW_CONTROL 0x4F05
  19. #define VBE_SCANLINE 0x4F06
  20. #define VBE_DISPLAY_START 0x4F07
  21. #define VBE_PALLET_FORMAT 0x4F08
  22. #define VBE_PALLET_DATA 0x4F09
  23. #define VBE_PROTECTED_MODE 0x4F0A
  24. #define VBE_PIXEL_CLOCK 0x4F0B
  25. #define VESA_POWER_FUNCTION 0x4f10
  26. #define VESA_POWER_ON 0x0000
  27. #define VESA_POWER_STANDBY 0x0100
  28. #define VESA_POWER_SUSPEND 0x0200
  29. #define VESA_POWER_OFF 0x0400
  30. #define VESA_GET_POWER_FUNC 0x0000
  31. #define VESA_SET_POWER_FUNC 0x0001
  32. #define VESA_STATUS_SUCCESS 0x004F
  33. #define VESA_SUCCESS(Status) (((Status) & 0xFFFF) == VESA_STATUS_SUCCESS)
  34. //
  35. // VESA SuperVGA structures
  36. //
  37. #pragma pack(1)
  38. typedef struct _VGA_INFO_BLOCK
  39. {
  40. ULONG VesaSignature;
  41. USHORT VbeVersion;
  42. ULONG OemStringPtr;
  43. ULONG Capabilities;
  44. ULONG VideoModePtr;
  45. USHORT TotalMemory;
  46. //
  47. // VBE 2.0
  48. //
  49. USHORT OemSoftwareRev;
  50. ULONG OemVendorNamePtr;
  51. ULONG OemProductNamePtr;
  52. ULONG OemProductRevPtr;
  53. UCHAR Reserved[222];
  54. UCHAR OemData[256];
  55. } VGA_INFO_BLOCK, *PVGA_INFO_BLOCK;
  56. typedef struct _MODE_INFO_BLOCK
  57. {
  58. USHORT ModeAttributes;
  59. UCHAR WinAAttributes;
  60. UCHAR WinBAttributes;
  61. USHORT WinGranularity;
  62. USHORT WinSize;
  63. USHORT WinASegment;
  64. USHORT WinBSegment;
  65. ULONG WinFuncPtr;
  66. USHORT BytesPerScanLine;
  67. USHORT XResolution;
  68. USHORT YResolution;
  69. UCHAR XCharSize;
  70. UCHAR YCharSize;
  71. UCHAR NumberOfPlanes;
  72. UCHAR BitsPerPixel;
  73. UCHAR NumberOfBanks;
  74. UCHAR MemoryModel;
  75. UCHAR BankSize;
  76. UCHAR NumberOfImagePages;
  77. UCHAR Reserved1;
  78. UCHAR RedMaskSize;
  79. UCHAR RedFieldPosition;
  80. UCHAR GreenMaskSize;
  81. UCHAR GreenFieldPosition;
  82. UCHAR BlueMaskSize;
  83. UCHAR BlueFieldPosition;
  84. UCHAR RsvdMaskSize;
  85. UCHAR RsvdFieldPosition;
  86. UCHAR DirectColorModeInfo;
  87. //
  88. // VBE 2.0
  89. //
  90. ULONG PhysBasePtr;
  91. ULONG Reserved2;
  92. USHORT Reserved3;
  93. //
  94. // VBE 3.0
  95. //
  96. USHORT LinBytesPerScanLine;
  97. UCHAR BnkNumberOfImagePages;
  98. UCHAR LinNumberOfImagePages;
  99. UCHAR LinRedMaskSize;
  100. UCHAR LinRedFieldPosition;
  101. UCHAR LinGreenMaskSize;
  102. UCHAR LinGreenFieldPosition;
  103. UCHAR LinBlueMaskSize;
  104. UCHAR LinBlueFieldPosition;
  105. UCHAR LinRsvdMaskSize;
  106. UCHAR LinRsvdFieldPosition;
  107. ULONG MaxPixelClock;
  108. UCHAR Reserved4[190];
  109. } MODE_INFO_BLOCK, *PMODE_INFO_BLOCK;
  110. typedef struct _PALETTE_ENTRY
  111. {
  112. UCHAR Blue;
  113. UCHAR Green;
  114. UCHAR Red;
  115. UCHAR Alignment;
  116. } PALETTE_ENTRY, *PPALETTE_ENTRY;
  117. #pragma pack()
  118. typedef struct _VESA_INFO
  119. {
  120. USHORT ModeNumber;
  121. ULONG FrameBufferSize;
  122. MODE_INFO_BLOCK ModeInfoBlock;
  123. ULONG HardwareStateSize;
  124. UCHAR HardwareState[];
  125. } VESA_INFO, *PVESA_INFO;
  126. #define VDM_TRANSFER_SEGMENT 0x2000
  127. #define VDM_TRANSFER_OFFSET 0x0000
  128. #define VBE_CAP_DAC_WIDTH_8BPP 0x01
  129. #define VBE_CAP_NOT_VGA 0x02
  130. #define VBE_CAP_VSYNC_ON_PALETTE_UPDATE 0x04
  131. #define VBE_CAP_STEREO_SIGNAL 0x08
  132. #define VBE_CAP_STEREO_EVC_CONNECTOR 0x10
  133. #define SEG(x) ((x) >> 16)
  134. #define OFF(x) ((x) & 0xffff)
  135. #define TRANSFER_ADDRESS ((VDM_TRANSFER_SEGMENT << 4) + VDM_TRANSFER_OFFSET)
  136. #define INFOBLOCK_OFFSET(x) ((SEG((x)) << 4) + OFF((x)) - TRANSFER_ADDRESS)
  137. #define IS_LINEAR_MODE(x) (((x)->fbType & VIDEO_MODE_LINEAR) ? TRUE : FALSE)
  138. VOID
  139. InitializeModeTable(
  140. PVOID HwDeviceExtension
  141. );
  142. BOOLEAN
  143. ValidateVbeInfo(
  144. PHW_DEVICE_EXTENSION hwDeviceExtension,
  145. PVGA_INFO_BLOCK InfoBlock
  146. );
  147. VOID
  148. UpdateRegistry(
  149. PHW_DEVICE_EXTENSION hwDeviceExtension,
  150. PWSTR ValueName,
  151. PUCHAR Value
  152. );
  153. ULONG
  154. GetVideoMemoryBaseAddress(
  155. PHW_DEVICE_EXTENSION hwDeviceExtension,
  156. PVIDEOMODE pRequestedMode
  157. );
  158. VP_STATUS
  159. VBESetMode(
  160. PHW_DEVICE_EXTENSION HwDeviceExtension,
  161. USHORT VesaModeNumber
  162. );
  163. USHORT
  164. VBEGetMode(
  165. PHW_DEVICE_EXTENSION HwDeviceExtension
  166. );
  167. VP_STATUS
  168. VBEGetModeInfo(
  169. PHW_DEVICE_EXTENSION hwDeviceExtension,
  170. USHORT ModeNumber,
  171. PMODE_INFO_BLOCK ModeInfoBlock
  172. );
  173. ULONG
  174. VBESaveState(
  175. PHW_DEVICE_EXTENSION HwDeviceExtension,
  176. PCHAR StateBuffer
  177. );
  178. VP_STATUS
  179. VBERestoreState(
  180. PHW_DEVICE_EXTENSION HwDeviceExtension,
  181. PCHAR StateBuffer,
  182. ULONG Size
  183. );
  184. VP_STATUS
  185. VBESetDisplayWindow(
  186. PHW_DEVICE_EXTENSION hwDeviceExtension,
  187. UCHAR WindowSelect,
  188. USHORT WindowNumber
  189. );
  190. USHORT
  191. VBEGetDisplayWindow(
  192. PHW_DEVICE_EXTENSION hwDeviceExtension,
  193. UCHAR WindowSelect
  194. );
  195. USHORT
  196. VBEGetScanLineLength(
  197. PHW_DEVICE_EXTENSION HwDeviceExtension
  198. );
  199. VP_STATUS
  200. VesaSaveHardwareState(
  201. PHW_DEVICE_EXTENSION HwDeviceExtension,
  202. PVIDEO_HARDWARE_STATE HardwareState,
  203. ULONG HardwareStateSize,
  204. USHORT ModeNumber
  205. );
  206. PCHAR
  207. SaveFrameBuffer(
  208. PHW_DEVICE_EXTENSION hwDeviceExtension,
  209. PVESA_INFO pVesaInfo
  210. );
  211. BOOLEAN
  212. IsSavedModeVesa(
  213. PVIDEO_HARDWARE_STATE HardwareState
  214. );
  215. VP_STATUS
  216. VesaRestoreHardwareState(
  217. PHW_DEVICE_EXTENSION HwDeviceExtension,
  218. PVIDEO_HARDWARE_STATE HardwareState,
  219. ULONG HardwareStateSize
  220. );
  221. ULONG
  222. RestoreFrameBuffer(
  223. PHW_DEVICE_EXTENSION hwDeviceExtension,
  224. PVESA_INFO pVesaInfo,
  225. PCHAR FrameBufferData
  226. );