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.

154 lines
5.2 KiB

  1. /*/****************************************************************************
  2. * name: MGASysInit
  3. *
  4. * description: Initialise the SYSTEM related hardware of the MGA device.
  5. *
  6. * designed: Bart Simpson, february 10, 1993
  7. * last modified: $Author: bleblanc $, $Date: 94/11/09 10:48:18 $
  8. *
  9. * version: $Id: SYS.C 1.10 94/11/09 10:48:18 bleblanc Exp $
  10. *
  11. * parameters: BYTE* to init buffer
  12. * modifies: MGA hardware
  13. * calls: GetMGAConfiguration, GetMGAMctlwtst
  14. * returns: -
  15. ******************************************************************************/
  16. #include "switches.h"
  17. #include "g3dstd.h"
  18. #include "caddi.h"
  19. #include "def.h"
  20. #include "mga.h"
  21. #include "global.h"
  22. #include "proto.h"
  23. #include "mgai.h"
  24. #ifdef WINDOWS_NT
  25. #include "video.h"
  26. #if defined(ALLOC_PRAGMA)
  27. #pragma alloc_text(PAGE,MGASysInit)
  28. #endif
  29. #endif
  30. VOID MGASysInit(BYTE* pInitBuffer)
  31. {
  32. DWORD DST0, DST1, Info;
  33. DWORD TmpDword;
  34. BYTE DUB_SEL, TmpByte;
  35. volatile BYTE _Far *pDevice;
  36. #if( defined(WINDOWS) || defined(OS2))
  37. ((struct {unsigned short o; short s;}*) &pDevice)->o = *((WORD*)(pInitBuffer + INITBUF_MgaOffset));
  38. ((struct {unsigned short o; short s;}*) &pDevice)->s = *((WORD*)(pInitBuffer + INITBUF_MgaSegment));
  39. #else
  40. #ifdef WINDOWS_NT
  41. // ((struct {unsigned short o; short s;}*) &pDevice)->o = *((WORD*)(pInitBuffer + INITBUF_MgaOffset));
  42. // ((struct {unsigned short o; short s;}*) &pDevice)->s = *((WORD*)(pInitBuffer + INITBUF_MgaSegment));
  43. pDevice = (BYTE *)(*((DWORD*)(pInitBuffer + INITBUF_MgaOffset)));
  44. #else
  45. #ifdef __MICROSOFTC600__
  46. /*** DOS real-mode 32-bit address ***/
  47. pDevice = *((DWORD*)(pInitBuffer + INITBUF_MgaOffset));
  48. #else
  49. /*** DOS protected-mode 48-bit address ***/
  50. ((struct {unsigned long o; short s;}*) &pDevice)->o = *((DWORD*)(pInitBuffer + INITBUF_MgaOffset));
  51. ((struct {unsigned long o; short s;}*) &pDevice)->s = *((WORD*)(pInitBuffer + INITBUF_MgaSegment));
  52. #endif
  53. #endif
  54. #endif
  55. /*** ##### DUBIC PATCH Disable mouse IRQ and proceed ###### ***/
  56. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), 0x08);
  57. mgaReadBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DUB_SEL), DUB_SEL);
  58. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DUB_SEL), 0x00);
  59. /*** ###################################################### ***/
  60. /*** Get System Configuration ***/
  61. GetMGAConfiguration(pDevice, &DST0, &DST1, &Info);
  62. /*** Program the DRAWING ENGINE items in the TITAN ***/
  63. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_MCTLWTST), GetMGAMctlwtst(DST0, DST1));
  64. /*** Program the HOST INTERFACE items in the TITAN ***/
  65. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_IEN), 0); /*** Disable interrupts ***/
  66. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_ICLEAR), 0x0f); /*** Clear pending INT ***/
  67. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_OPMODE), TmpDword);
  68. /*** clear fields to be modified ***/
  69. TmpDword &= ~((DWORD)TITAN_NOWAIT_M | (DWORD)TITAN_RFHCNT_M | (DWORD)TITAN_FBM_M |
  70. (DWORD)TITAN_HYPERPG_M | (DWORD)TITAN_TRAM_M);
  71. /*** program the fields ***/
  72. TmpDword |= (DWORD)TITAN_NOWAIT_M;
  73. /*** 15.625*40.0/64.0 DO 8.8 ***/
  74. TmpDword |= (((DWORD)(((DWORD)0x0fa0*(DWORD)0x2800/(DWORD)0x4000)>>8) << TITAN_RFHCNT_A) & (DWORD)TITAN_RFHCNT_M); /*** FIXED ***/
  75. TmpDword |= ((((DWORD)(*((BYTE*)(pInitBuffer + INITBUF_FBM)))) << TITAN_FBM_A) & (DWORD)TITAN_FBM_M);
  76. TmpDword |= ((((DST1 & (DWORD)TITAN_DST1_HYPERPG_M) >> TITAN_DST1_HYPERPG_A) << TITAN_HYPERPG_A) & (DWORD)TITAN_HYPERPG_M);
  77. /*** ATTENTION reversed bit according to DST1 ***/
  78. TmpDword |= ((((~DST1 & (DWORD)TITAN_DST1_TRAM_M) >> TITAN_DST1_TRAM_A) << TITAN_TRAM_A) & (DWORD)TITAN_TRAM_M);
  79. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_OPMODE), TmpDword);
  80. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_CONFIG), TmpDword);
  81. /*** clear fields to be modified ***/
  82. TmpDword &= ~((DWORD)TITAN_EXPDEV_M);
  83. /*** program the fields ***/
  84. TmpDword |= ((((DST1 & (DWORD)TITAN_DST1_EXPDEV_M) >> TITAN_DST1_EXPDEV_A) << TITAN_EXPDEV_A) & (DWORD)TITAN_EXPDEV_M);
  85. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_CONFIG), TmpDword);
  86. /*** Program the SYSTEM items in the DUBIC ***/
  87. /*** OLD code had programming of lvid[2:0] ***/
  88. /*** Program 8/16 bits device or keep actual setup as selected ***/
  89. if (*((BYTE*)(pInitBuffer + INITBUF_16)) == (BYTE)1)
  90. {
  91. mgaReadBYTE(*(pDevice + TITAN_OFFSET + TITAN_CONFIG), TmpByte);
  92. TmpByte &= ~TITAN_CONFIG_M;
  93. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_CONFIG), TmpByte | TITAN_CONFIG_16);
  94. }
  95. else
  96. {
  97. if (*((BYTE*)(pInitBuffer + INITBUF_16)) == (BYTE)2)
  98. {
  99. mgaReadBYTE(*(pDevice + TITAN_OFFSET + TITAN_CONFIG), TmpByte);
  100. TmpByte &= ~TITAN_CONFIG_M;
  101. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_CONFIG), TmpByte | TITAN_CONFIG_8);
  102. }
  103. }
  104. /*** ##### DUBIC PATCH ReEnable mouse IRQ ################# ***/
  105. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), 0x08);
  106. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DUB_SEL), DUB_SEL);
  107. /*** ###################################################### ***/
  108. }
  109.