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.

478 lines
11 KiB

  1. PAGE ,132
  2. TITLE DXHPBIOS.ASM -- Dos Extender HP Extended BIOS Mapping
  3. ; Copyright (c) Microsoft Corporation 1988-1991. All Rights Reserved.
  4. ;***********************************************************************
  5. ;
  6. ; DXHPBIOS.ASM -- Dos Extender HP Extended BIOS Mapping
  7. ;
  8. ;-----------------------------------------------------------------------
  9. ;
  10. ; This module provides the 286 DOS extender's protected-to-real mode
  11. ; mapping of selected HP Vectra Extended BIOS services.
  12. ;
  13. ;-----------------------------------------------------------------------
  14. ;
  15. ; 08/25/89 jimmat Original version
  16. ; 18-Dec-1992 sudeepb Changed cli/sti to faster FCLI/FSTI
  17. ;
  18. ;***********************************************************************
  19. .286p
  20. ; -------------------------------------------------------
  21. ; INCLUDE FILE DEFINITIONS
  22. ; -------------------------------------------------------
  23. .xlist
  24. .sall
  25. include segdefs.inc
  26. include gendefs.inc
  27. include pmdefs.inc
  28. include interupt.inc
  29. IFDEF ROM
  30. include dxrom.inc
  31. ENDIF
  32. include intmac.inc
  33. include stackchk.inc
  34. include bop.inc
  35. .list
  36. ; -------------------------------------------------------
  37. ; GENERAL SYMBOL DEFINITIONS
  38. ; -------------------------------------------------------
  39. F_INS_XCHGFIX equ 06h
  40. ; -------------------------------------------------------
  41. ; EXTERNAL SYMBOL DEFINITIONS
  42. ; -------------------------------------------------------
  43. extrn EnterIntHandler:NEAR
  44. extrn LeaveIntHandler:NEAR
  45. extrn EnterRealMode:NEAR
  46. extrn EnterProtectedMode:NEAR
  47. extrn ParaToLDTSelector:NEAR
  48. extrn PMIntrEntryVector:NEAR
  49. ; -------------------------------------------------------
  50. ; DATA SEGMENT DEFINITIONS
  51. ; -------------------------------------------------------
  52. DXDATA segment
  53. extrn regUserSS:WORD
  54. extrn regUserSP:WORD
  55. extrn pbReflStack:WORD
  56. extrn bReflStack:WORD
  57. extrn fHardwareIntMoved:BYTE
  58. public HPxBiosVectorRM
  59. HPxBiosVectorRM dd ? ;offset to RM HP Int handler
  60. PMCallBack dd 0 ;protected mode call back CS:IP
  61. HPDriverHeader dw ? ;segment of HP driver header block
  62. HPDriverSegSel dw 0,0 ;segment/selector pairs
  63. dw 0,0
  64. dw 0,0
  65. dw -1
  66. DXDATA ends
  67. ; -------------------------------------------------------
  68. ; CODE SEGMENT VARIABLES
  69. ; -------------------------------------------------------
  70. DXCODE segment
  71. IFNDEF ROM
  72. extrn segDXData:WORD
  73. extrn selDgroup:WORD
  74. extrn PrevInt69Handler:DWORD
  75. ENDIF
  76. DXCODE ends
  77. ; -------------------------------------------------------
  78. subttl HP Extended BIOS Mapping Interface
  79. page
  80. ; -------------------------------------------------------
  81. ; HP EXTENDED BIOS MAPPING INTERFACE
  82. ; -------------------------------------------------------
  83. DXPMCODE segment
  84. assume cs:DXPMCODE
  85. ; -------------------------------------------------------
  86. ; HPxBIOS -- Interrupt routine for the HP Vectra Extended
  87. ; BIOS service calls. Currently, on the F_INS_XCHGFIX
  88. ; service is supported, and this is not mapped transparently!
  89. ; This support was added for the Windows HP mouse driver.
  90. ;
  91. ; Input: Various registers
  92. ; Output: Various registers
  93. ; Errors:
  94. ; Uses: All registers preserved, other than return values
  95. ;
  96. ; The following services are supported:
  97. ;
  98. ; AH=06 - F_INS_XCHGFIX (non transparent pm->rm mapping)
  99. ;
  100. assume ds:NOTHING,es:NOTHING,ss:NOTHING
  101. public HPxBIOS
  102. HPxBIOS proc near
  103. cmp ah,F_INS_XCHGFIX ;is this F_INS_XCHGFIX?
  104. jz @f
  105. jmp PMIntrEntryVector + 3*6Fh ;if not, just pass it on
  106. @@:
  107. call EnterIntHandler ;build an interrupt stack frame
  108. assume ds:DGROUP,es:DGROUP ; also sets up addressability
  109. cld ;cya...
  110. ; Save the protected mode CS:IP. NOTE: we only support one call back
  111. ; address (the last one)! This works for the current mouse driver, but
  112. ; may not work for other drivers.
  113. mov ax,[bp].pmUserDI
  114. mov word ptr PMCallBack,ax
  115. mov ax,[bp].pmUserES
  116. mov word ptr [PMCallBack+2],ax
  117. ; Execute the real mode HP Extended BIOS service
  118. SwitchToRealMode
  119. assume ds:DGROUP,es:DGROUP
  120. xor ax,ax
  121. mov es,ax
  122. assume es:NOTHING
  123. mov ax,es:[6Fh*4]
  124. mov word ptr [HPxBiosVectorRM],ax
  125. mov ax,es:[6Fh*4+2]
  126. mov word ptr [HPxBiosVectorRM+2],ax
  127. test byte ptr [bp].pmUserFL+1,02h ;enable interrupts if
  128. jz @f ; caller had them enabled
  129. FSTI
  130. @@:
  131. pop es
  132. pop ds
  133. assume ds:NOTHING,es:NOTHING
  134. popa
  135. push ax ;set our own call back routine,
  136. mov ax,cs ; which will invoke the PM one
  137. mov es,ax
  138. pop ax
  139. mov di,offset RMCallBack
  140. FCLI
  141. call ss:[HPxBiosVectorRM]
  142. pushf
  143. FCLI
  144. pusha
  145. push ds
  146. push es
  147. mov bp,sp ;restore stack frame pointer
  148. IFDEF ROM
  149. push ss
  150. pop ds
  151. ELSE
  152. mov ds,selDgroup ;HP BIOS seems to change DS on us
  153. ENDIF
  154. assume ds:DGROUP
  155. SwitchToProtectedMode
  156. assume ds:DGROUP,es:DGROUP
  157. ; Perform fixups on the return values.
  158. mov ax,[bp].intUserES ;we return real mode ES in BP!
  159. mov [bp].intUserBP,ax
  160. call LeaveIntHandler ;restore caller's registers, stack
  161. assume ds:NOTHING,es:NOTHING
  162. iret
  163. HPxBIOS endp
  164. ; -------------------------------------------------------
  165. DXPMCODE ends
  166. ; -------------------------------------------------------
  167. subttl HP Pointing Device Handler
  168. page
  169. ; -------------------------------------------------------
  170. ; HP POINTING DEVICE HANDLER
  171. ; -------------------------------------------------------
  172. DXCODE segment
  173. assume cs:DXCODE
  174. ; -------------------------------------------------------
  175. ; RMCallBack -- This routine is the RM entry point for
  176. ; the HP Pointing Device Handler. It switches the
  177. ; processor to protected mode and transfers control to the
  178. ; user pointing device handler. When that completes,
  179. ; it switches back to real mode and returns control to
  180. ; the HP BIOS.
  181. ;
  182. ; Input: none
  183. ; Output: none
  184. ; Errors: none
  185. assume ds:NOTHING,es:NOTHING,ss:NOTHING
  186. public RMCallBack
  187. RMCallBack proc near
  188. cld
  189. push es ;save BIOS ds/es on it's stack
  190. push ds
  191. IFDEF ROM
  192. SetRMDataSeg
  193. ELSE
  194. mov ds,selDgroup ;setup addressability to DOSX DGROUP
  195. ENDIF
  196. assume ds:DGROUP
  197. mov HPDriverHeader,es ;save ES driver header block segment
  198. ; Allocate a new stack frame, and then switch to the local stack
  199. ; frame.
  200. FCLI ;protect global regUserXX vars
  201. mov regUserSP,sp ;save entry stack pointer so we can restore it
  202. mov regUSerSS,ss ;save segment too
  203. IFDEF ROM
  204. push ds
  205. pop ss
  206. ELSE
  207. mov ss,selDgroup ;switch to our own stack frame
  208. ENDIF
  209. mov sp,pbReflStack
  210. sub pbReflStack,CB_STKFRAME ;adjust pointer to next stack frame
  211. FIX_STACK
  212. push regUserSS ;save HP BIOS stack address
  213. push regUserSP ; so we can restore it later
  214. push SEL_DXDATA or STD_RING ;DOSX DS to be poped in PM
  215. pusha ;save general registers
  216. ; We are now running on our own stack, so we can switch into protected mode.
  217. SwitchToProtectedMode
  218. assume ds:DGROUP,es:DGROUP
  219. ; See if we've already mapped a selector to the HPDriverHeader segment. We
  220. ; have a table of 3 segment/selector pairs because the current Windows
  221. ; mouse driver support up to 3 pointing devices (all with the same call
  222. ; back address).
  223. mov ax,HPDriverHeader ;get segment to map
  224. FSTI ;don't need ints disabled now
  225. mov bx,offset DGROUP:HPDriverSegSel-4
  226. rmcb_cmp_seg:
  227. add bx,4
  228. cmp word ptr [bx],ax ;same segment?
  229. jne @f
  230. mov es,word ptr [bx+2] ; yes, get selector to ES
  231. jmp short rmcb_sel_set
  232. @@:
  233. cmp word ptr [bx],0 ;empty table slot?
  234. je rmcb_new_seg
  235. cmp word ptr [bx],-1 ;end of table?
  236. jne rmcb_cmp_seg
  237. ; Haven't seen this segment before, map a selector for it
  238. rmcb_new_seg:
  239. mov cx,ax ;save segment in cx
  240. mov dx,bx ;save table offset in dx
  241. mov bx,STD_DATA ;want a data selector
  242. call ParaToLDTSelector
  243. jnc @f ;BIG TROUBLE if can't create selector!
  244. popa ; don't even call users routine
  245. jmp short rmcb50
  246. @@:
  247. mov es,ax
  248. assume es:NOTHING
  249. mov bx,dx ;save this seg/sel pair if not
  250. cmp word ptr [bx],-1 ; at the end of the table
  251. je rmcb_sel_set
  252. mov word ptr [bx],cx
  253. mov word ptr [bx+2],ax
  254. rmcb_sel_set:
  255. popa ;restore general registers
  256. ; Build an iret frame on the stack so that the user's
  257. ; routine will return to us when it is finished.
  258. pushf
  259. push cs
  260. push offset rmcb50
  261. ; Build a far return frame on the stack to use to transfer control to the
  262. ; user's protected mode routine
  263. push word ptr [PMCallBack+2]
  264. push word ptr [PMCallBack]
  265. ; At this point the stack looks like this:
  266. ;
  267. ; [14] stack segment of original stack
  268. ; [12] stack pointer of original stack
  269. ; [10] protect mode dos extender data segment
  270. ; [8] flags
  271. ; [6] segment of return address back to here
  272. ; [4] offset of return address back here
  273. ; [2] segment of user routine
  274. ; [0] offset of user routine
  275. ; Execute the user's pointing device handler
  276. retf
  277. ; The users handler will return here after it is finsished.
  278. rmcb50:
  279. cld
  280. pop ds ;restore DOSX DS
  281. assume ds:DGROUP,es:NOTHING
  282. FCLI ;protect global regUserXX vars
  283. pop regUserSP
  284. pop regUserSS
  285. ; Switch back to real mode.
  286. push ax ;preserve AX
  287. SwitchToRealMode
  288. assume ds:DGROUP,es:DGROUP
  289. pop ax
  290. ; Switch back to the original stack.
  291. CHECK_STACK
  292. mov ss,regUserSS
  293. mov sp,regUserSP
  294. ; Deallocate the stack frame that we are using.
  295. add pbReflStack,CB_STKFRAME
  296. ; And return to the HP BIOS
  297. pop ds
  298. pop es
  299. iret
  300. RMCallBack endp
  301. ; -------------------------------------------------------
  302. subttl Classic HP Vectra Keyboard Hook
  303. page
  304. ; -------------------------------------------------------
  305. ; CLASSIC HP VECTRA KEYBOARD HOOK
  306. ; -------------------------------------------------------
  307. IFNDEF ROM
  308. public RMVectraKbdHook
  309. assume ds:NOTHING,es:NOTHING,ss:NOTHING
  310. ; If the master PIC has been remapped, we process the interrupt ourselves,
  311. ; otherwise, we just pass it on to the previous Int 69h handler (which
  312. ; is most likely the HP Vectra BIOS).
  313. RMVectraKbdHook proc near
  314. push ds
  315. mov ds,segDXData
  316. assume ds:DGROUP
  317. test fHardwareIntMoved,0FFh ;PIC been remapped?
  318. pop ds
  319. assume ds:NOTHING
  320. jnz @f
  321. jmp [PrevInt69Handler] ; no, get out of the way
  322. @@:
  323. push ax
  324. mov al,61h ; yes, EOI the third slave PIC
  325. out 7Ch,al
  326. pop ax
  327. int 51h ; and simulate an IRQ 1 interrupt
  328. iret
  329. RMVectraKbdHook endp
  330. ENDIF
  331. DXCODE ends
  332. ; -------------------------------------------------------
  333. DXPMCODE segment
  334. assume cs:DXPMCODE
  335. ; -------------------------------------------------------
  336. IFNDEF ROM
  337. public PMVectraKbdHook
  338. assume ds:NOTHING,es:NOTHING,ss:NOTHING
  339. PMVectraKbdHook proc near
  340. push ax ;EOI the third slave PIC
  341. mov al,61h
  342. out 7Ch,al
  343. pop ax
  344. int 51h ;simulate an IRQ 1 interrupt
  345. iret ;back we go
  346. PMVectraKbdHook endp
  347. ENDIF
  348. ; -------------------------------------------------------
  349. DXPMCODE ends
  350. ;****************************************************************
  351. end