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.

304 lines
11 KiB

  1. title "Cirrus Logic ASM routines"
  2. ;
  3. ;ONE_64K_BANK equ 1
  4. TWO_32K_BANKS equ 1
  5. ;++
  6. ;
  7. ; Copyright (c) 1992 Microsoft Corporation
  8. ;
  9. ; Module Name:
  10. ;
  11. ; vgahard.asm
  12. ;
  13. ; Abstract:
  14. ;
  15. ; This module implements the banding code for the Cirrus Logic 6410,6420
  16. ; and 542x VGA's.
  17. ;
  18. ; Environment:
  19. ;
  20. ; Kernel mode only.
  21. ;
  22. ; Revision History:
  23. ;
  24. ;
  25. ;--
  26. .386p
  27. .xlist
  28. include callconv.inc
  29. .list
  30. ;----------------------------------------------------------------------------
  31. ;
  32. ; Cirrus Logic banking control ports.
  33. ;
  34. GRAPHICS_ADDRESS_PORT equ 03ceh ;banking control here
  35. CL6420_BANKING_INDEX_PORT_A equ 0eh ;banking index register A is GR0E
  36. CL6420_BANKING_INDEX_PORT_B equ 0fh ;banking index register B is GR0F
  37. CL542x_BANKING_INDEX_PORT_A equ 09h ;banking index register A is GR09
  38. CL542x_BANKING_INDEX_PORT_B equ 0ah ;banking index register B is GR0A
  39. SEQ_ADDRESS_PORT equ 03C4h ;Sequencer Address register
  40. IND_MEMORY_MODE equ 04h ;Memory Mode reg. index in Sequencer
  41. CHAIN4_MASK equ 08h ;Chain4 bit in Memory Mode register
  42. ;----------------------------------------------------------------------------
  43. ;_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
  44. ; ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  45. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  46. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  47. ;
  48. ; Bank switching code. This is a 1-64K-read/1-64K-write bank adapter
  49. ; (VideoBanked1R1W).
  50. ;
  51. ; Input:
  52. ; EAX = desired read bank mapping
  53. ; EDX = desired write bank mapping
  54. ;
  55. ; Note: values must be correct, with no stray bits set; no error
  56. ; checking is performed.
  57. ;
  58. public _CL64xxBankSwitchStart
  59. public _CL64xxBankSwitchEnd
  60. public _CL64xxPlanarHCBankSwitchStart
  61. public _CL64xxPlanarHCBankSwitchEnd
  62. public _CL64xxEnablePlanarHCStart
  63. public _CL64xxEnablePlanarHCEnd
  64. public _CL64xxDisablePlanarHCStart
  65. public _CL64xxDisablePlanarHCEnd
  66. public _CL542xBankSwitchStart
  67. public _CL542xBankSwitchEnd
  68. public _CL542xPlanarHCBankSwitchStart
  69. public _CL542xPlanarHCBankSwitchEnd
  70. public _CL542xEnablePlanarHCStart
  71. public _CL542xEnablePlanarHCEnd
  72. public _CL542xDisablePlanarHCStart
  73. public _CL542xDisablePlanarHCEnd
  74. public _CL543xBankSwitchStart
  75. public _CL543xBankSwitchEnd
  76. public _CL543xPlanarHCBankSwitchStart
  77. public _CL543xPlanarHCBankSwitchEnd
  78. align 4
  79. ;----------------------------------------------------------------------------
  80. _CL64xxBankSwitchStart proc ;start of bank switch code
  81. _CL64xxPlanarHCBankSwitchStart: ;start of planar HC bank switch code,
  82. ; which is the same code as normal
  83. ; bank switching
  84. shl eax,3 ;shift them to bits 7-4
  85. shl edx,3 ;shift them to bits 7-4
  86. ;!!!! NOTE: The October 1992 release NT VGA driver assumes that the Graphics
  87. ; index is not changed by the bank switch code. We save it on the
  88. ; stack (and save the write bank value in the high order of edx)
  89. ; and restore it at the end of the routine. If the NT VGA driver
  90. ; changes so that it is the index need not be preserved, this code
  91. ; could be simplified (and speeded up!)
  92. rol edx,16 ; save write value
  93. mov ah,al
  94. mov dx,GRAPHICS_ADDRESS_PORT ;banking control port
  95. in al,dx ; save graphics index
  96. push eax
  97. mov al,CL6420_BANKING_INDEX_PORT_A
  98. out dx,ax ;select the READ bank
  99. rol edx,16
  100. mov ah,dl
  101. mov al,CL6420_BANKING_INDEX_PORT_B
  102. mov dx,GRAPHICS_ADDRESS_PORT ;banking control port
  103. out dx,ax ;select the WRITE bank
  104. pop eax
  105. out dx,al
  106. ret
  107. _CL64xxBankSwitchEnd:
  108. _CL64xxPlanarHCBankSwitchEnd:
  109. align 4
  110. _CL64xxEnablePlanarHCStart:
  111. mov dx,SEQ_ADDRESS_PORT
  112. in al,dx
  113. push eax ;preserve the state of the Seq Address
  114. mov al,IND_MEMORY_MODE
  115. out dx,al ;point to the Memory Mode register
  116. inc edx
  117. in al,dx ;get the state of the Memory Mode reg
  118. and al,NOT CHAIN4_MASK ;turn off Chain4 to make memory planar
  119. out dx,al
  120. dec edx
  121. pop eax
  122. out dx,al ;restore the original Seq Address
  123. ERA1_INDEX equ 0A1h
  124. mov dx,GRAPHICS_ADDRESS_PORT
  125. in al,dx
  126. push eax ;preserve the Graphics Index
  127. mov al,ERA1_INDEX
  128. out dx,al ;point to ERA1
  129. inc edx
  130. in al,dx ; get ERA1
  131. and al,not 30h ; turn off the shift bits
  132. out dx,al
  133. dec edx
  134. pop eax
  135. out dx,al ;restore the original Graphics Index
  136. ret
  137. _CL64xxEnablePlanarHCEnd:
  138. align 4
  139. _CL64xxDisablePlanarHCStart:
  140. mov dx,SEQ_ADDRESS_PORT
  141. in al,dx
  142. push eax ;preserve the state of the Seq Address
  143. mov al,IND_MEMORY_MODE
  144. out dx,al ;point to the Memory Mode register
  145. inc edx
  146. in al,dx ;get the state of the Memory Mode reg
  147. or al,CHAIN4_MASK ;turn on Chain4 to make memory linear
  148. out dx,al
  149. dec edx
  150. pop eax
  151. out dx,al ;restore the original Seq Address
  152. mov dx,GRAPHICS_ADDRESS_PORT
  153. in al,dx
  154. push eax ;preserve the Graphics Index
  155. mov al,ERA1_INDEX
  156. out dx,al ;point to ERA1
  157. inc edx
  158. in al,dx ; get ERA1
  159. and al,not 30h
  160. or al,20h
  161. out dx,al
  162. dec edx
  163. pop eax
  164. out dx,al ;restore the original Graphics Index
  165. ret
  166. _CL64xxDisablePlanarHCEnd:
  167. _CL64xxBankSwitchStart endp
  168. _CL542xBankSwitchStart proc ;start of bank switch code
  169. _CL542xPlanarHCBankSwitchStart: ;start of planar HC bank switch code,
  170. ; which is the same code as normal
  171. ; bank switching
  172. shl eax,3 ;shift them to bits 7-4
  173. shl edx,3 ;shift them to bits 7-4
  174. ;!!!! NOTE: The October 1992 release NT VGA driver assumes that the Graphics
  175. ; index is not changed by the bank switch code. We save it on the
  176. ; stack (and save the write bank value in the high order of edx)
  177. ; and restore it at the end of the routine. If the NT VGA driver
  178. ; changes so that it is the index need not be preserved, this code
  179. ; could be simplified (and speeded up!)
  180. rol edx,16 ; save write value
  181. mov ah,al
  182. mov dx,GRAPHICS_ADDRESS_PORT ;banking control port
  183. in al,dx
  184. push eax
  185. mov al,CL542x_BANKING_INDEX_PORT_A
  186. out dx,ax ;select the READ bank
  187. rol edx,16 ; restore write value
  188. mov ah,dl
  189. mov al,CL542x_BANKING_INDEX_PORT_B
  190. mov dx,GRAPHICS_ADDRESS_PORT ;banking control port
  191. out dx,ax ;select the WRITE bank
  192. pop eax
  193. out dx,al
  194. ret
  195. _CL542xBankSwitchEnd:
  196. _CL542xPlanarHCBankSwitchEnd:
  197. align 4
  198. _CL542xEnablePlanarHCStart:
  199. mov dx,SEQ_ADDRESS_PORT
  200. in al,dx
  201. push eax ;preserve the state of the Seq Address
  202. mov al,IND_MEMORY_MODE
  203. out dx,al ;point to the Memory Mode register
  204. inc edx
  205. in al,dx ;get the state of the Memory Mode reg
  206. and al,NOT CHAIN4_MASK ;turn off Chain4 to make memory planar
  207. out dx,al
  208. dec edx
  209. pop eax
  210. out dx,al ;restore the original Seq Address
  211. ret
  212. _CL542xEnablePlanarHCEnd:
  213. align 4
  214. _CL542xDisablePlanarHCStart:
  215. mov dx,SEQ_ADDRESS_PORT
  216. in al,dx
  217. push eax ;preserve the state of the Seq Address
  218. mov al,IND_MEMORY_MODE
  219. out dx,al ;point to the Memory Mode register
  220. inc edx
  221. in al,dx ;get the state of the Memory Mode reg
  222. or al,CHAIN4_MASK ;turn on Chain4 to make memory linear
  223. out dx,al
  224. dec edx
  225. pop eax
  226. out dx,al ;restore the original Seq Address
  227. ret
  228. _CL542xDisablePlanarHCEnd:
  229. _CL542xBankSwitchStart endp
  230. ;
  231. ; 543x banking assumes 16k granularity to allow up to 4-meg modes
  232. ;
  233. _CL543xBankSwitchStart proc ;start of bank switch code
  234. _CL543xPlanarHCBankSwitchStart: ;start of planar HC bank switch code,
  235. ; which is the same code as normal
  236. ; bank switching
  237. shl eax,1 ;shift them to bits 4-1
  238. shl edx,1 ;shift them to bits 4-1
  239. ;!!!! NOTE: The October 1992 release NT VGA driver assumes that the Graphics
  240. ; index is not changed by the bank switch code. We save it on the
  241. ; stack (and save the write bank value in the high order of edx)
  242. ; and restore it at the end of the routine. If the NT VGA driver
  243. ; changes so that it is the index need not be preserved, this code
  244. ; could be simplified (and speeded up!)
  245. rol edx,16 ; save write value
  246. mov ah,al
  247. mov dx,GRAPHICS_ADDRESS_PORT ;banking control port
  248. in al,dx
  249. push eax
  250. mov al,CL542x_BANKING_INDEX_PORT_A
  251. out dx,ax ;select the READ bank
  252. rol edx,16 ; restore write value
  253. mov ah,dl
  254. mov al,CL542x_BANKING_INDEX_PORT_B
  255. mov dx,GRAPHICS_ADDRESS_PORT ;banking control port
  256. out dx,ax ;select the WRITE bank
  257. pop eax
  258. out dx,al
  259. ret
  260. _CL543xBankSwitchEnd:
  261. _CL543xPlanarHCBankSwitchEnd:
  262. _CL543xBankSwitchStart endp
  263. _TEXT ends
  264. end