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.

761 lines
26 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. et4000.h
  5. Abstract:
  6. This module contains the definitions for the code that implements the
  7. tseng et4000 device driver.
  8. Environment:
  9. Kernel mode
  10. Revision History:
  11. --*/
  12. #ifndef NO_INT10_MODE_SET
  13. #define INT10_MODE_SET 1
  14. #endif
  15. //////////////////////////////////////////////////////////////////////////////
  16. // private IOCTL info - if you touch this, do the same to the display drivers
  17. //
  18. #define IOCTL_VIDEO_GET_VIDEO_CARD_INFO \
  19. CTL_CODE (FILE_DEVICE_VIDEO, 2048, METHOD_BUFFERED, FILE_ANY_ACCESS)
  20. typedef struct _VIDEO_COPROCESSOR_INFORMATION {
  21. ULONG ulChipID; // ET3000, ET4000, W32, W32I, W32P, or ET6000
  22. ULONG ulRevLevel; // REV_A, REV_B, REV_C, REV_D, REV_UNDEF
  23. ULONG ulVideoMemory; // in bytes
  24. } VIDEO_COPROCESSOR_INFORMATION, *PVIDEO_COPROCESSOR_INFORMATION;
  25. typedef enum _CHIP_TYPE {
  26. ET3000 = 1,
  27. ET4000,
  28. W32,
  29. W32I,
  30. W32P,
  31. ET6000
  32. } CHIP_TYPE;
  33. typedef enum _REV_TYPE {
  34. REV_UNDEF = 1,
  35. REV_A,
  36. REV_B,
  37. REV_C,
  38. REV_D,
  39. } REV_TYPE;
  40. //
  41. // ET6000 PCI defines
  42. //
  43. #define ET6000_VENDOR_ID 0x100C
  44. #define ET6000_DEVICE_ID 0x3208
  45. //////////////////////////////////////////////////////////////////////////////
  46. //
  47. // Do full save and restore.
  48. //
  49. #define EXTENDED_REGISTER_SAVE_RESTORE 1
  50. //
  51. // BIOS Variables
  52. //
  53. #define BIOS_INFO_1 0x488
  54. #define PRODESIGNER_BIOS_INFO 0x4E8
  55. //
  56. // Define type of ET4000 boards
  57. //
  58. typedef enum _BOARD_TYPE {
  59. SPEEDSTARPLUS = 1,
  60. SPEEDSTAR24,
  61. SPEEDSTAR,
  62. PRODESIGNERIISEISA,
  63. PRODESIGNERIIS,
  64. PRODESIGNER2,
  65. TSENG3000,
  66. TSENG4000,
  67. TSENG4000W32,
  68. STEALTH32,
  69. TSENG6000,
  70. OTHER
  71. } BOARD_TYPE;
  72. //
  73. // Base address of VGA memory range. Also used as base address of VGA
  74. // memory when loading a font, which is done with the VGA mapped at A0000.
  75. //
  76. #define MEM_VGA 0xA0000
  77. #define MEM_VGA_SIZE 0x20000
  78. #define BANKED_FRAME_BUFFER 3
  79. #define LINEAR_FRAME_BUFFER 4
  80. //
  81. // W32 MMU stuff
  82. //
  83. #define PORT_IO_ADDR 0
  84. #define PORT_IO_LEN 0x10000
  85. // When we are banked
  86. #define BANKED_MMU_BUFFER_MEMORY_ADDR 0xB8000
  87. #define BANKED_MMU_BUFFER_MEMORY_LEN (0xBE000 - 0xB8000)
  88. #define BANKED_MMU_MEMORY_MAPPED_REGS_ADDR 0xBFF00
  89. #define BANKED_MMU_MEMORY_MAPPED_REGS_LEN (0xC0000 - 0xBFF00)
  90. #define BANKED_MMU_EXTERNAL_MAPPED_REGS_ADDR 0xBE000
  91. #define BANKED_MMU_EXTERNAL_MAPPED_REGS_LEN (0xBF000 - 0xBE000)
  92. #define BANKED_APERTURE_0_OFFSET 0x0000
  93. #define BANKED_APERTURE_1_OFFSET 0x2000
  94. #define BANKED_APERTURE_2_OFFSET 0x4000
  95. // When we are linear
  96. #define MMU_BUFFER_MEMORY_ADDR 0x200000
  97. #define MMU_BUFFER_MEMORY_LEN 0x180000
  98. #define MMU_MEMORY_MAPPED_REGS_ADDR 0x3FFF00
  99. #define MMU_MEMORY_MAPPED_REGS_LEN 0x000100
  100. #define MMU_EXTERNAL_MAPPED_REGS_ADDR 0x3FE000
  101. #define MMU_EXTERNAL_MAPPED_REGS_LEN 0x001000
  102. typedef struct {
  103. ULONG ulOffset;
  104. ULONG ulLength;
  105. } RANGE_OFFSETS;
  106. #define APERTURE_0_OFFSET 0x000000
  107. #define APERTURE_1_OFFSET 0x080000
  108. #define APERTURE_2_OFFSET 0x100000
  109. #define MMU_APERTURE_2_ACL_BIT 0x04
  110. typedef struct {
  111. ULONG ulPhysicalAddress;
  112. ULONG ulLength;
  113. ULONG ulInIoSpace;
  114. PVOID pvVirtualAddress;
  115. } W32_ADDRESS_MAPPING_INFORMATION, *PW32_ADDRESS_MAPPING_INFORMATION;
  116. //
  117. // Port definitions for filling the ACCESS_RANGES structure in the miniport
  118. // information, defines the range of I/O ports the VGA spans.
  119. // There is a break in the IO ports - a few ports are used for the parallel
  120. // port. Those cannot be defined in the ACCESS_RANGE, but are still mapped
  121. // so all VGA ports are in one address range.
  122. //
  123. #define VGA_BASE_IO_PORT 0x000003B0
  124. #define VGA_START_BREAK_PORT 0x000003BB
  125. #define VGA_END_BREAK_PORT 0x000003C0
  126. #define VGA_MAX_IO_PORT 0x000003DF
  127. //
  128. // W32 CRTCB port addresses (used for ID)
  129. //
  130. #define CRTCB_IO_PORT_BASE 0x0000217A
  131. #define CRTCB_IO_PORT_LEN 0x00000002
  132. #define CRTCB_IO_PORT_INDEX CRTCB_IO_PORT_BASE
  133. #define CRTCB_IO_PORT_DATA (CRTCB_IO_PORT_INDEX+1)
  134. #define IND_CRTCB_CHIP_ID 0xEC
  135. //
  136. // VGA register definitions
  137. //
  138. // ports in monochrome mode
  139. #define CRTC_ADDRESS_PORT_MONO 0x03B4 // CRT Controller Address and
  140. #define CRTC_DATA_PORT_MONO 0x03B5 // Data registers in mono mode
  141. #define MODE_CONTROL_PORT_MONO 0x03B8 // Tseng Mode Control port, used
  142. // here only for unlocking the
  143. // key so we can get at extended
  144. // registers
  145. #define FEAT_CTRL_WRITE_PORT_MONO 0x03BA // Feature Control write port
  146. // in mono mode
  147. #define INPUT_STATUS_1_MONO 0x03BA // Input Status 1 register read
  148. // port in mono mode
  149. #define ATT_INITIALIZE_PORT_MONO INPUT_STATUS_1_MONO
  150. // Register to read to reset
  151. // Attribute Controller index/data
  152. // toggle in mono mode
  153. #define HERCULES_COMPATIBILITY_PORT 0x03BF // used to unlock Tseng key to
  154. // get at extended ports
  155. #define ATT_ADDRESS_PORT 0x03C0 // Attribute Controller Address and
  156. #define ATT_DATA_WRITE_PORT 0x03C0 // Data registers share one port
  157. // for writes, but only Address is
  158. // readable at 0x010
  159. #define ATT_DATA_READ_PORT 0x03C1 // Attribute Controller Data reg is
  160. // readable here
  161. #define MISC_OUTPUT_REG_WRITE_PORT 0x03C2 // Miscellaneous Output reg write
  162. // port
  163. #define INPUT_STATUS_0_PORT 0x03C2 // Input Status 0 register read
  164. // port
  165. #define VIDEO_SUBSYSTEM_ENABLE_PORT 0x03C3 // Bit 0 enables/disables the
  166. // entire VGA subsystem
  167. #define SEQ_ADDRESS_PORT 0x03C4 // Sequence Controller Address and
  168. #define SEQ_DATA_PORT 0x03C5 // Data registers
  169. #define DAC_PIXEL_MASK_PORT 0x03C6 // DAC pixel mask reg
  170. #define DAC_ADDRESS_READ_PORT 0x03C7 // DAC register read index reg,
  171. // write-only
  172. #define DAC_STATE_PORT 0x03C7 // DAC state (read/write),
  173. // read-only
  174. #define DAC_ADDRESS_WRITE_PORT 0x03C8 // DAC register write index reg
  175. #define DAC_DATA_REG_PORT 0x03C9 // DAC data transfer reg
  176. #define FEAT_CTRL_READ_PORT 0x03CA // Feature Control read port
  177. #define MISC_OUTPUT_REG_READ_PORT 0x03CC // Miscellaneous Output reg read
  178. // port
  179. #define SEGMENT_SELECT_PORT 0x03CD // Tseng banking control register
  180. #define SEGMENT_SELECT_HIGH 0x03CB // Tseng W32 SegSel extension
  181. #define GRAPH_ADDRESS_PORT 0x03CE // Graphics Controller Address
  182. #define GRAPH_DATA_PORT 0x03CF // and Data registers
  183. // ports in color mode
  184. #define CRTC_ADDRESS_PORT_COLOR 0x03D4 // CRT Controller Address and
  185. #define CRTC_DATA_PORT_COLOR 0x03D5 // Data registers in color mode
  186. #define MODE_CONTROL_PORT_COLOR 0x03D8 // Tseng Mode Control port, used
  187. // here only for unlocking the
  188. // key so we can get at extended
  189. // registers
  190. #define FEAT_CTRL_WRITE_PORT_COLOR 0x03DA // Feature Control write port
  191. #define INPUT_STATUS_1_COLOR 0x03DA // Input Status 1 register read
  192. // port in color mode
  193. #define ATT_INITIALIZE_PORT_COLOR INPUT_STATUS_1_COLOR
  194. // Register to read to reset
  195. // Attribute Controller index/data
  196. // toggle in color mode
  197. //
  198. // Offsets in HardwareStateHeader->PortValue[] of save areas for non-indexed
  199. // VGA registers.
  200. //
  201. #define CRTC_ADDRESS_MONO_OFFSET 0x04
  202. #define FEAT_CTRL_WRITE_MONO_OFFSET 0x0A
  203. #define ATT_ADDRESS_OFFSET 0x10
  204. #define MISC_OUTPUT_REG_WRITE_OFFSET 0x12
  205. #define VIDEO_SUBSYSTEM_ENABLE_OFFSET 0x13
  206. #define SEQ_ADDRESS_OFFSET 0x14
  207. #define DAC_PIXEL_MASK_OFFSET 0x16
  208. #define DAC_STATE_OFFSET 0x17
  209. #define DAC_ADDRESS_WRITE_OFFSET 0x18
  210. #define GRAPH_ADDRESS_OFFSET 0x1E
  211. #define CRTC_ADDRESS_COLOR_OFFSET 0x24
  212. #define FEAT_CTRL_WRITE_COLOR_OFFSET 0x2A
  213. //
  214. // VGA indexed register indexes.
  215. //
  216. #define IND_CURSOR_START 0x0A // index in CRTC of the Cursor Start
  217. #define IND_CURSOR_END 0x0B // and End registers
  218. #define IND_CURSOR_HIGH_LOC 0x0E // index in CRTC of the Cursor Location
  219. #define IND_CURSOR_LOW_LOC 0x0F // High and Low Registers
  220. #define IND_VSYNC_END 0x11 // index in CRTC of the Vertical Sync
  221. // End register, which has the bit
  222. // that protects/unprotects CRTC
  223. // index registers 0-7
  224. #define IND_SET_RESET_ENABLE 0x01 // index of Set/Reset Enable reg in GC
  225. #define IND_DATA_ROTATE 0x03 // index of Data Rotate reg in GC
  226. #define IND_READ_MAP 0x04 // index of Read Map reg in Graph Ctlr
  227. #define IND_GRAPH_MODE 0x05 // index of Mode reg in Graph Ctlr
  228. #define IND_GRAPH_MISC 0x06 // index of Misc reg in Graph Ctlr
  229. #define IND_BIT_MASK 0x08 // index of Bit Mask reg in Graph Ctlr
  230. #define IND_SYNC_RESET 0x00 // index of Sync Reset reg in Seq
  231. #define IND_MAP_MASK 0x02 // index of Map Mask in Sequencer
  232. #define IND_MEMORY_MODE 0x04 // index of Memory Mode reg in Seq
  233. #define IND_STATE_CONTROL 0x06 // index of TS State Control reg in Seq
  234. #define IND_TS_AUX_MODE 0x07 // index of TS Aux Mode reg in Seq
  235. #define IND_CRTC_PROTECT 0x11 // index of reg containing regs 0-7 in
  236. // CRTC
  237. #define IND_RAS_CAS_CONFIG 0x32 // index of RAS/CAS Config reg in CRTC
  238. #define IND_EXT_START_ADDR 0x33 // index of Extended Start Address reg
  239. // in CRTC
  240. #define IND_CRTC_COMPAT 0x34 // index of CRTC Compatibility reg
  241. // in CRTC
  242. #define IND_OFLOW_HIGH 0x35 // index of Overflow High reg in CRTC
  243. #define IND_VID_SYS_CONFIG_1 0x36 // index of Video System Configuration
  244. #define IND_VID_SYS_CONFIG_2 0x37 // 1 & 2 registers in CRTC
  245. #define IND_ATC_MISC 0x16 // index of Miscellaneous reg in ATC
  246. #define START_SYNC_RESET_VALUE 0x01 // value for Sync Reset reg to start
  247. // synchronous reset
  248. #define END_SYNC_RESET_VALUE 0x03 // value for Sync Reset reg to end
  249. // synchronous reset
  250. #define UNLOCK_KEY_1 0x03 // value to output to Herc Compat
  251. // register as first step in unlocking
  252. // key so Tseng registers can be set
  253. #define UNLOCK_KEY_2 0xA0 // value to output to Mode Control Port
  254. // register as 2nd step in unlocking
  255. // key so Tseng registers can be set
  256. #define LOCK_KEY_1 0x00 // value to output to Herc Compat
  257. // register as first step in locking
  258. // key so Tseng registers can't be set
  259. #define LOCK_KEY_2 0x00 // value to output to Mode Control Port
  260. // register as 2nd step in locking
  261. // key so Tseng registers can't be set
  262. #define HERCULES_COMPATIBILITY_DEFAULT 0x00
  263. // value to output to Herc Compat
  264. // register to put back to MDA
  265. // compatibility
  266. #define MODE_CONTROL_PORT_COLOR_DEFAULT 0x00
  267. #define MODE_CONTROL_PORT_MONO_DEFAULT 0x00
  268. // values to output to CGA and MDA mode
  269. // registers to put to default state
  270. // (video disabled).
  271. //
  272. // Values for Attribute Controller Index register to turn video off
  273. // and on, by setting bit 5 to 0 (off) or 1 (on).
  274. //
  275. #define VIDEO_DISABLE 0
  276. #define VIDEO_ENABLE 0x20
  277. // Masks to keep only the significant bits of the Graphics Controller and
  278. // Sequencer Address registers. Masking is necessary because some VGAs, such
  279. // as S3-based ones, don't return unused bits set to 0, and some SVGAs use
  280. // these bits if extensions are enabled.
  281. //
  282. #define GRAPH_ADDR_MASK 0x0F
  283. #define SEQ_ADDR_MASK 0x07
  284. //
  285. // Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register.
  286. //
  287. #define CHAIN4_MASK 0x08
  288. //
  289. // Value written to the Read Map register when identifying the existence of
  290. // a VGA in VgaInitialize. This value must be different from the final test
  291. // value written to the Bit Mask in that routine.
  292. //
  293. #define READ_MAP_TEST_SETTING 0x03
  294. //
  295. // Default text mode setting for various registers, used to restore their
  296. // states if VGA detection fails after they've been modified.
  297. //
  298. #define MEMORY_MODE_TEXT_DEFAULT 0x02
  299. #define BIT_MASK_DEFAULT 0xFF
  300. #define READ_MAP_DEFAULT 0x00
  301. //
  302. // Palette-related info.
  303. //
  304. //
  305. // Highest valid DAC color register index.
  306. //
  307. #define VIDEO_MAX_COLOR_REGISTER 0xFF
  308. //
  309. // Highest valid palette register index
  310. //
  311. #define VIDEO_MAX_PALETTE_REGISTER 0x0F
  312. //
  313. // Indices for type of memory mapping; used in ModesVGA[], must match
  314. // MemoryMap[].
  315. //
  316. typedef enum _VIDEO_MEMORY_MAP {
  317. MemMap_Mono,
  318. MemMap_CGA,
  319. MemMap_VGA
  320. } VIDEO_MEMORY_MAP, *PVIDEO_MEMORY_MAP;
  321. //
  322. // Memory map table definition
  323. //
  324. typedef struct {
  325. ULONG MaxSize; // Maximum addressable size of memory
  326. ULONG Start; // Start address of display memory
  327. } MEMORYMAPS;
  328. //
  329. // For a mode, the type of banking supported. Controls the information
  330. // returned in VIDEO_BANK_SELECT. PlanarHCBanking includes NormalBanking.
  331. //
  332. typedef enum _BANK_TYPE {
  333. NoBanking = 0,
  334. MemMgrBanking,
  335. NormalBanking,
  336. PlanarHCBanking
  337. } BANK_TYPE, *PBANK_TYPE;
  338. //
  339. // Structure used to describe each video mode in ModesVGA[].
  340. //
  341. typedef struct {
  342. USHORT fbType; // color or monochrome, text or graphics, via
  343. // VIDEO_MODE_COLOR and VIDEO_MODE_GRAPHICS
  344. USHORT numPlanes; // # of video memory planes
  345. USHORT bitsPerPlane; // # of bits of color in each plane
  346. SHORT col; // # of text columns across screen with default font
  347. SHORT row; // # of text rows down screen with default font
  348. USHORT hres; // # of pixels across screen
  349. USHORT vres; // # of scan lines down screen
  350. USHORT wbytes; // # of bytes from start of one scan line to start of next
  351. ULONG sbytes; // total size of addressable display memory in bytes
  352. ULONG Frequency; // Vertical Frequency
  353. ULONG Interlaced; // Determines if the mode is interlaced or not
  354. BANK_TYPE banktype; // NoBanking, NormalBanking, PlanarHCBanking
  355. VIDEO_MEMORY_MAP MemMap; // index from VIDEO_MEMORY_MAP of memory
  356. // mapping used by this mode
  357. BOOLEAN ValidMode; // Determines which modes are valid.
  358. ULONG Int10ModeNumber; // Mode number via Int 10
  359. PUSHORT CmdStrings; // pointer to array of register-setting commands
  360. } VIDEOMODE, *PVIDEOMODE;
  361. //
  362. // Mode into which to put the VGA before starting a VDM, so it's a plain
  363. // vanilla VGA. (This is the mode's index in ModesVGA[], currently standard
  364. // 80x25 text mode.)
  365. //
  366. #define DEFAULT_MODE 0
  367. //
  368. // Info used by the Validator functions and save/restore code.
  369. // Structure used to trap register accesses that must be done atomically.
  370. //
  371. //
  372. // Number of each type of indexed register in a standard VGA, used by
  373. // validator and state save/restore functions.
  374. //
  375. // Note: VDMs currently only support basic VGAs only.
  376. //
  377. #define VGA_NUM_SEQUENCER_PORTS 5
  378. #define VGA_NUM_CRTC_PORTS 25
  379. #define VGA_NUM_GRAPH_CONT_PORTS 9
  380. #define VGA_NUM_ATTRIB_CONT_PORTS 21
  381. #define VGA_NUM_DAC_ENTRIES 256
  382. #ifdef EXTENDED_REGISTER_SAVE_RESTORE
  383. //
  384. // Indices to start save/restore in extension registers:
  385. // For both chip types
  386. #define ET4000_SEQUENCER_EXT_START 0x06
  387. #define ET4000_SEQUENCER_EXT_END 0x07
  388. #define ET4000_CRTC_EXT_START 0x31
  389. #define ET4000_CRTC_EXT_END 0x37
  390. #define ET4000_CRTC_1_EXT_START 0x3F
  391. #define ET4000_CRTC_1_EXT_END 0x3F
  392. #define ET4000_ATTRIB_EXT_START 0x16
  393. #define ET4000_ATTRIB_EXT_END 0x16
  394. //
  395. // Number of extended regs for both chip types.
  396. //
  397. #define ET4000_NUM_SEQUENCER_EXT_PORTS (ET4000_SEQUENCER_EXT_END - ET4000_SEQUENCER_EXT_START + 1)
  398. #define ET4000_NUM_CRTC_EXT_PORTS (ET4000_CRTC_EXT_END - ET4000_CRTC_EXT_START + 1) + \
  399. (ET4000_CRTC_1_EXT_END - ET4000_CRTC_1_EXT_START + 1)
  400. #define ET4000_NUM_ATTRIB_EXT_PORTS (ET4000_ATTRIB_EXT_END - ET4000_ATTRIB_EXT_START + 1)
  401. //
  402. // set values for save/restore area based on largest value for a chipset.
  403. //
  404. #define EXT_NUM_GRAPH_CONT_PORTS 0
  405. #define EXT_NUM_SEQUENCER_PORTS ET4000_NUM_SEQUENCER_EXT_PORTS
  406. #define EXT_NUM_CRTC_PORTS ET4000_NUM_CRTC_EXT_PORTS
  407. #define EXT_NUM_ATTRIB_CONT_PORTS ET4000_NUM_ATTRIB_EXT_PORTS
  408. #define EXT_NUM_DAC_ENTRIES 0
  409. #else
  410. #define EXT_NUM_GRAPH_CONT_PORTS 0
  411. #define EXT_NUM_SEQUENCER_PORTS 0
  412. #define EXT_NUM_CRTC_PORTS 0
  413. #define EXT_NUM_ATTRIB_CONT_PORTS 0
  414. #define EXT_NUM_DAC_ENTRIES 0
  415. #endif
  416. #define VGA_MAX_VALIDATOR_DATA 100
  417. #define VGA_VALIDATOR_UCHAR_ACCESS 1
  418. #define VGA_VALIDATOR_USHORT_ACCESS 2
  419. #define VGA_VALIDATOR_ULONG_ACCESS 3
  420. typedef struct _VGA_VALIDATOR_DATA {
  421. ULONG Port;
  422. UCHAR AccessType;
  423. ULONG Data;
  424. } VGA_VALIDATOR_DATA, *PVGA_VALIDATOR_DATA;
  425. //
  426. // Number of bytes to save in each plane.
  427. //
  428. #define VGA_PLANE_SIZE 0x10000
  429. //
  430. // These constants determine the offsets within the
  431. // VIDEO_HARDWARE_STATE_HEADER structure that are used to save and
  432. // restore the VGA's state.
  433. //
  434. #define VGA_HARDWARE_STATE_SIZE sizeof(VIDEO_HARDWARE_STATE_HEADER)
  435. #define VGA_BASIC_SEQUENCER_OFFSET (VGA_HARDWARE_STATE_SIZE + 0)
  436. #define VGA_BASIC_CRTC_OFFSET (VGA_BASIC_SEQUENCER_OFFSET + \
  437. VGA_NUM_SEQUENCER_PORTS)
  438. #define VGA_BASIC_GRAPH_CONT_OFFSET (VGA_BASIC_CRTC_OFFSET + \
  439. VGA_NUM_CRTC_PORTS)
  440. #define VGA_BASIC_ATTRIB_CONT_OFFSET (VGA_BASIC_GRAPH_CONT_OFFSET + \
  441. VGA_NUM_GRAPH_CONT_PORTS)
  442. #define VGA_BASIC_DAC_OFFSET (VGA_BASIC_ATTRIB_CONT_OFFSET + \
  443. VGA_NUM_ATTRIB_CONT_PORTS)
  444. #define VGA_BASIC_LATCHES_OFFSET (VGA_BASIC_DAC_OFFSET + \
  445. (3 * VGA_NUM_DAC_ENTRIES))
  446. #define VGA_EXT_SEQUENCER_OFFSET (VGA_BASIC_LATCHES_OFFSET + 4)
  447. #define VGA_EXT_CRTC_OFFSET (VGA_EXT_SEQUENCER_OFFSET + \
  448. EXT_NUM_SEQUENCER_PORTS)
  449. #define VGA_EXT_GRAPH_CONT_OFFSET (VGA_EXT_CRTC_OFFSET + \
  450. EXT_NUM_CRTC_PORTS)
  451. #define VGA_EXT_ATTRIB_CONT_OFFSET (VGA_EXT_GRAPH_CONT_OFFSET +\
  452. EXT_NUM_GRAPH_CONT_PORTS)
  453. #define VGA_EXT_DAC_OFFSET (VGA_EXT_ATTRIB_CONT_OFFSET + \
  454. EXT_NUM_ATTRIB_CONT_PORTS)
  455. #define VGA_VALIDATOR_OFFSET (VGA_EXT_DAC_OFFSET + 4 * EXT_NUM_DAC_ENTRIES)
  456. #define VGA_VALIDATOR_AREA_SIZE sizeof (ULONG) + (VGA_MAX_VALIDATOR_DATA * \
  457. sizeof (VGA_VALIDATOR_DATA)) + \
  458. sizeof (ULONG) + \
  459. sizeof (ULONG) + \
  460. sizeof (PVIDEO_ACCESS_RANGE)
  461. #define VGA_MISC_DATA_AREA_OFFSET VGA_VALIDATOR_OFFSET + VGA_VALIDATOR_AREA_SIZE
  462. #define VGA_MISC_DATA_AREA_SIZE 0
  463. #define VGA_PLANE_0_OFFSET VGA_MISC_DATA_AREA_OFFSET + VGA_MISC_DATA_AREA_SIZE
  464. #define VGA_PLANE_1_OFFSET VGA_PLANE_0_OFFSET + VGA_PLANE_SIZE
  465. #define VGA_PLANE_2_OFFSET VGA_PLANE_1_OFFSET + VGA_PLANE_SIZE
  466. #define VGA_PLANE_3_OFFSET VGA_PLANE_2_OFFSET + VGA_PLANE_SIZE
  467. //
  468. // Space needed to store all state data.
  469. //
  470. #define VGA_TOTAL_STATE_SIZE VGA_PLANE_3_OFFSET + VGA_PLANE_SIZE
  471. //
  472. // Device extension for the driver object. This data is only used
  473. // locally, so this structure can be added to as needed.
  474. //
  475. typedef struct _HW_DEVICE_EXTENSION {
  476. PUCHAR IOAddress; // base I/O address of VGA ports
  477. PVOID VideoMemoryAddress; // base virtual memory address of VGA memory
  478. ULONG AdapterMemorySize; // size, in bytes, of the memory on the
  479. // board.
  480. ULONG ModeIndex; // index of current mode in ModesVGA[]
  481. ULONG NumAvailableModes; // number of valid modes on this device
  482. PVIDEOMODE CurrentMode; // pointer to VIDEOMODE structure for
  483. // current mode.
  484. CHIP_TYPE ulChipID;
  485. REV_TYPE ulRevLevel;
  486. USHORT FontPelColumns; // Width of the font in pels
  487. USHORT FontPelRows; // height of the font in pels
  488. VIDEO_CURSOR_POSITION CursorPosition; // current cursor position
  489. UCHAR CursorEnable; // whether cursor is enabled or not
  490. UCHAR CursorTopScanLine; // Cursor Start register setting (top scan)
  491. UCHAR CursorBottomScanLine; // Cursor End register setting (bottom scan)
  492. UCHAR BoardID; // Used to Identify Diamond boards
  493. PHYSICAL_ADDRESS PhysicalVideoMemoryBase; // physical memory address and
  494. ULONG PhysicalVideoMemoryLength; // length of display memory
  495. PHYSICAL_ADDRESS PhysicalFrameBase; // physical memory address and
  496. ULONG PhysicalFrameLength; // length of display memory for the
  497. // current mode.
  498. PUSHORT BiosArea; // address of the BIOS area
  499. USHORT OriginalBiosData; // Orignal value in the Bios data area.
  500. BOOLEAN bLinearModeSupported; // Do we support linear modes?
  501. BOOLEAN bInLinearMode; // Are we currently in a linear mode?
  502. ULONG ulSlot; // the slot that the card is in
  503. //
  504. // These 4 fields must be at the end of the device extension and must be
  505. // kept in this order since this data will be copied to and from the save
  506. // state buffer that is passed to and from the VDM.
  507. //
  508. ULONG TrappedValidatorCount; // number of entries in the Trapped
  509. // validator data Array.
  510. VGA_VALIDATOR_DATA TrappedValidatorData[VGA_MAX_VALIDATOR_DATA];
  511. // Data trapped by the validator routines
  512. // but not yet played back into the VGA
  513. // register.
  514. ULONG SequencerAddressValue; // Determines if the Sequencer Address Port
  515. // is currently selecting the SyncReset data
  516. // register.
  517. ULONG CurrentNumVdmAccessRanges; // Number of access ranges in
  518. // the access range array pointed
  519. // to by the next field
  520. PVIDEO_ACCESS_RANGE CurrentVdmAccessRange; // Access range currently
  521. // associated to the VDM
  522. } HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION;
  523. //
  524. // Function prototypes.
  525. //
  526. //
  527. // Entry points for the VGA validator. Used in VgaEmulatorAccessEntries[].
  528. //
  529. VP_STATUS
  530. VgaValidatorUcharEntry (
  531. ULONG Context,
  532. ULONG Port,
  533. UCHAR AccessMode,
  534. PUCHAR Data
  535. );
  536. VP_STATUS
  537. VgaValidatorUshortEntry (
  538. ULONG Context,
  539. ULONG Port,
  540. UCHAR AccessMode,
  541. PUSHORT Data
  542. );
  543. VP_STATUS
  544. VgaValidatorUlongEntry (
  545. ULONG Context,
  546. ULONG Port,
  547. UCHAR AccessMode,
  548. PULONG Data
  549. );
  550. BOOLEAN
  551. VgaPlaybackValidatorData (
  552. PVOID Context
  553. );
  554. //
  555. // Bank switch code start and end labels, define in HARDWARE.ASM
  556. //
  557. extern UCHAR BankSwitchStart;
  558. extern UCHAR PlanarHCBankSwitchStart;
  559. extern UCHAR EnablePlanarHCStart;
  560. extern UCHAR DisablePlanarHCStart;
  561. extern UCHAR BankSwitchEnd;
  562. //
  563. // Vga init scripts for font loading
  564. //
  565. extern USHORT EnableA000Data[];
  566. extern USHORT DisableA000Color[];
  567. extern MEMORYMAPS MemoryMaps[];
  568. extern VIDEOMODE ModesVGA[];
  569. extern ULONG NumVideoModes;
  570. extern RANGE_OFFSETS RangeOffsets[2][2];
  571. #define NUM_VGA_ACCESS_RANGES 3
  572. extern VIDEO_ACCESS_RANGE VgaAccessRange[];
  573. #define VGA_NUM_EMULATOR_ACCESS_ENTRIES 6
  574. extern EMULATOR_ACCESS_ENTRY VgaEmulatorAccessEntries[];
  575. #define NUM_MINIMAL_VGA_VALIDATOR_ACCESS_RANGE 4
  576. extern VIDEO_ACCESS_RANGE MinimalVgaValidatorAccessRange[];
  577. #define NUM_FULL_VGA_VALIDATOR_ACCESS_RANGE 2
  578. extern VIDEO_ACCESS_RANGE FullVgaValidatorAccessRange[];
  579. //
  580. // functions used in both modules.
  581. //
  582. VOID
  583. UnlockET4000ExtendedRegs(
  584. PHW_DEVICE_EXTENSION HwDeviceExtension
  585. );
  586. VOID
  587. LockET4000ExtendedRegs(
  588. PHW_DEVICE_EXTENSION HwDeviceExtension
  589. );
  590. #define VESA_POWER_FUNCTION 0x4f10
  591. #define VESA_POWER_ON 0x0000
  592. #define VESA_POWER_STANDBY 0x0100
  593. #define VESA_POWER_SUSPEND 0x0200
  594. #define VESA_POWER_OFF 0x0400
  595. #define VESA_GET_POWER_FUNC 0x0000
  596. #define VESA_SET_POWER_FUNC 0x0001
  597. #define VESA_STATUS_SUCCESS 0x004f
  598. #define QUERY_MONITOR_ID 0x22446688
  599. #define QUERY_NONDDC_MONITOR_ID 0x11223344