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.

135 lines
3.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* Copyright (C) 1996-1998 Robert H�hne, see COPYING.RH for details */
  2. /* This file is part of RHIDE. */
  3. /****************************** VGA REGISTERS *******************************/
  4. /*
  5. * Sequencer port and frequently used register indices
  6. */
  7. #define VGA_SEQUENCER_PORT 0x3c4
  8. #define VGA_SEQUENCER_DATA 0x3c5
  9. #define VGA_WRT_PLANE_ENB_REG 2
  10. #define VGA_MEMORY_MODE_REG 4
  11. /*
  12. * color plane operations
  13. */
  14. #define VGA_FUNC_SET 0
  15. #define VGA_FUNC_AND 8
  16. #define VGA_FUNC_OR 16
  17. #define VGA_FUNC_XOR 24
  18. /*
  19. * Graphics controller port and frequently used registers
  20. */
  21. #define VGA_GR_CTRL_PORT 0x3ce
  22. #define VGA_GR_CTRL_DATA 0x3cf
  23. #define VGA_SET_RESET_REG 0
  24. #define VGA_SET_RESET_ENB_REG 1
  25. #define VGA_COLOR_COMP_REG 2
  26. #define VGA_ROT_FN_SEL_REG 3
  27. #define VGA_RD_PLANE_SEL_REG 4
  28. #define VGA_MODE_REG 5
  29. #define VGA_MISC_REG 6
  30. #define VGA_COLOR_DONTC_REG 7
  31. #define VGA_BIT_MASK_REG 8
  32. /*************************** VESA STRUCTURE *********************************/
  33. /*
  34. * The mode information structure (without padding)
  35. This struct is taken from libgrx (vesa.h)
  36. Because I don't want to go into trouble with packing
  37. this struct I reserve only one block of memory and use
  38. macros for accessing the members */
  39. #define _BYTE(_index) _farpeekb(mode_info_selector,_index)
  40. #define _WORD(_index) _farpeekw(mode_info_selector,_index)
  41. /*
  42. typedef struct {
  43. short ModeAttributes CLY_Packed; mode attributes
  44. */
  45. #define ModeAttributes _WORD(0)
  46. /*
  47. char WinAAttributes CLY_Packed; Window A attributes
  48. char WinBAttributes CLY_Packed; Window B attributes
  49. */
  50. #define WinAAttributes _BYTE(2)
  51. #define WinBAttributes _BYTE(3)
  52. /*
  53. short WinGranularity CLY_Packed; window granularity
  54. */
  55. #define WinGranularity _WORD(4)
  56. /*
  57. short WinSize CLY_Packed; window size
  58. */
  59. #define WinSize _WORD(6)
  60. /*
  61. short WinASegment CLY_Packed; Window A start segment
  62. short WinBSegment CLY_Packed; Window B start segment
  63. */
  64. #define WinASegment _WORD(8)
  65. #define WinBSegment _WORD(10)
  66. /*
  67. void far (*WinFuncPtr)() CLY_Packed; pointer to window function
  68. short BytesPerScanLine CLY_Packed; bytes per scan line
  69. ==== extended and optional information ====
  70. short XResolution CLY_Packed; horizontal resolution
  71. short YResolution CLY_Packed; vertical resolution
  72. char XCharSize CLY_Packed; character cell width
  73. char YCharSize CLY_Packed; character cell height
  74. char NumberOfPlanes CLY_Packed; number of memory planes
  75. */
  76. #define NumberOfPlanes _BYTE(0x18)
  77. /*
  78. char BitsPerPixel CLY_Packed; bits per pixel
  79. char NumberOfBanks CLY_Packed; number of banks
  80. char MemoryModel CLY_Packed; memory model type
  81. char BankSize CLY_Packed; bank size in K
  82. char NumImagePages CLY_Packed; number of image pages
  83. char reserved[1] CLY_Packed;
  84. ==== VESA 1.2 and later ====
  85. char RedMaskSize CLY_Packed; number of bits in red mask
  86. char RedMaskPos CLY_Packed; starting bit for red mask
  87. char GreenMaskSize CLY_Packed;
  88. char GreenMaskPos CLY_Packed;
  89. char BlueMaskSize CLY_Packed;
  90. char BlueMaskPos CLY_Packed;
  91. char ReservedMaskSize CLY_Packed; reserved bits in pixel
  92. char ReservedMaskPos CLY_Packed;
  93. char DirectScreenMode CLY_Packed;
  94. } VESAmodeInfoBlock;
  95. */
  96. /************************** Inline Helpers **********************************/
  97. __inline__ void
  98. _farfill_l(unsigned short sel,unsigned long offset,unsigned long count,
  99. unsigned long value)
  100. {
  101. __asm__ __volatile__ (
  102. "pushw %%es\n"
  103. "movw %w0,%%es\n"
  104. "cld\n"
  105. "rep\n"
  106. "stosl\n"
  107. "popw %%es"
  108. :
  109. : "rm" (sel), "a" (value), "D" (offset), "c" (count));
  110. }
  111. #define RESTORE_VESA_HARD 1
  112. #define RESTORE_VESA_BIOS 2
  113. #define RESTORE_VESA_COLORS 4
  114. #define RESTORE_VESA_SVGA 8
  115. #define RESTORE_VESA_ALL 0xF
  116. #define RESTORE_VGA_HARD 1
  117. #define RESTORE_VGA_BIOS 2
  118. #define RESTORE_VGA_COLORS 4
  119. #define RESTORE_VGA_ALL 7