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.

821 lines
27 KiB

  1. PAGE ,132
  2. TITLE DXFUNC.ASM -- Dos Extender Function Handlers
  3. ; Copyright (c) Microsoft Corporation 1988-1991. All Rights Reserved.
  4. ;****************************************************************
  5. ;* *
  6. ;* DXFUNC.ASM - Dos Extender Function Handlers *
  7. ;* *
  8. ;****************************************************************
  9. ;* *
  10. ;* Module Description: *
  11. ;* *
  12. ;* This module contains the functions for handling the Dos *
  13. ;* Extender user functions. These are functions called by *
  14. ;* the client application to request special Dos Extender *
  15. ;* services. *
  16. ;* *
  17. ;* Any INT 2Fh requests that aren't Dos Extender functions *
  18. ;* are handled by switching to real mode and passing control *
  19. ;* on to the previous owner of the real mode INT 2Fh vector. *
  20. ;* This is accomplished by jumping into the interrupt *
  21. ;* reflector entry vector at the location for int 2fh. *
  22. ;* *
  23. ;****************************************************************
  24. ;* Revision History: *
  25. ;* *
  26. ;* 01/09/91 amitc At switch out time Co-Processor being reset*
  27. ;* 11/29/90 amitc Replaced FnSuspend/FnResume by FnObsolete *
  28. ;* These are not needed anymore for 3.1 *
  29. ;* 11/29/90 amitc Modified RMInt2FHandler to respond to the *
  30. ;* BuildChain SWAPI call. *
  31. ;* 11/29/90 amitc Added a SWAPI CallIn function to be called *
  32. ;* by the task switcher. *
  33. ;* 11/16/90 jimmat Added DPMI MS-DOS Extension support *
  34. ;* 08/08/90 earleh Started changes to make DOSX a DPMI server *
  35. ;* 8/29/89 jimmat Added real mode Int 2Fh hook *
  36. ;* 6/23/89 jimmat Added DOSX Info Int 2Fh *
  37. ;* 6/16/89 jimmat Ifdef'd out most DOSX Int 2Fh services *
  38. ;* 6/15/89 jimmat Added suspend/resume Int 2Fh hooks, and *
  39. ;* Win/386 compatible Int 31h check *
  40. ;* 6/14/89 jimmat Removed PTRACE hooks & unused DynaLink code *
  41. ;* 5/19/89 jimmat Reduce # mode switches by ignoring Win/386 *
  42. ;* Int 2Fh/1680h idle calls *
  43. ;* 5/07/89 jimmat Added Int 2Fh protected mode hook to XMS *
  44. ;* driver *
  45. ;* 3/21/89 jimmat Corrected problem with jmping to wrong int *
  46. ;* 2Fh handler if not for the DOS extender *
  47. ;* 3/09/89 jimmat Added FNDynaLink function *
  48. ;* 02/10/89 (GeneA): change Dos Extender from small model to *
  49. ;* medium model *
  50. ;* 01/24/89 (GeneA): removed all real mode dos extender *
  51. ;* function handlers. *
  52. ;* 09/29/88 (GeneA): created *
  53. ; 18-Dec-1992 sudeepb Changed cli/sti to faster FCLI/FSTI
  54. ;* *
  55. ;****************************************************************
  56. .286p
  57. .287
  58. ; -------------------------------------------------------
  59. ; INCLUDE FILE DEFINITIONS
  60. ; -------------------------------------------------------
  61. include segdefs.inc
  62. include gendefs.inc
  63. include pmdefs.inc
  64. include dosx.inc
  65. include hostdata.inc
  66. include intmac.inc
  67. include dpmi.inc
  68. include stackchk.inc
  69. include bop.inc
  70. ; -------------------------------------------------------
  71. ; GENERAL SYMBOL DEFINITIONS
  72. ; -------------------------------------------------------
  73. XMS_INS_CHK equ 00h ;Installition check function
  74. WIN386_FUNC equ 16h ;Windows Enhanced mode Int 2Fh ID
  75. WIN386_VER equ 00h ;Windows 386 version
  76. WIN386_INIT equ 05h ;Windows/386 & DOSX startup call
  77. W386_Get_Device_API equ 84h ;es:di -> device API
  78. DPMI_DETECT equ 87h ;WIN386/DPMI detection call
  79. DPMI_VER equ 005ah ;version 0.90 served here
  80. DPMI_SUCCESS equ 0000h ;zero to indicate success
  81. DPMI_FLAGS equ 0001h ;32 bit support
  82. ;DPMI client requesting 32-bit support
  83. DPMI_MSDOS_VER equ 0100h ;WIN386/DPMI MS-DOS Extensions version 01.00
  84. DPMI_MSDOS_API_GET_VER equ 0000h ;Get MS-DOS Extension version call
  85. DPMI_MSDOS_API_GET_LDT equ 0100h ;Get LDT Base selector call
  86. ; -------------------------------------------------------
  87. ; EXTERNAL SYMBOL DEFINITIONS
  88. ; -------------------------------------------------------
  89. extrn AllocateSelector:NEAR
  90. extrn FreeSelector:NEAR
  91. extrn ParaToLinear:NEAR
  92. externFP NSetSegmentDscr
  93. externNP NSetSegmentAccess
  94. extrn DupSegmentDscr:NEAR
  95. extrn XMScontrol:NEAR
  96. IFDEF WOW
  97. extrn Wow32IntrRefl:near
  98. ENDIF
  99. extrn HookNetBiosHwInt:NEAR
  100. extrn AllocateExceptionStack:NEAR
  101. DXSTACK segment
  102. extrn rgw2FStack:WORD
  103. DXSTACK ends
  104. ; -------------------------------------------------------
  105. ; DATA SEGMENT DEFINITIONS
  106. ; -------------------------------------------------------
  107. DXDATA segment
  108. extrn selPSPChild:WORD
  109. extrn segPSPChild:WORD
  110. extrn idCpuType:WORD
  111. extrn DtaSegment:WORD
  112. extrn DtaSelector:WORD
  113. extrn DtaOffset:WORD
  114. IFDEF WOW
  115. extrn Wow16BitHandlers:WORD
  116. extrn selEHStack:WORD
  117. ENDIF
  118. IFDEF WOW_x86
  119. extrn FastBop:FWORD
  120. ENDIF
  121. ;
  122. ; Count of DPMI clients active (that have entered protected mode).
  123. ;
  124. public cDPMIClients
  125. cDPMIClients dw 0
  126. public selCurrentHostData, segCurrentHostData, DpmiFlags, DpmiSegAttr
  127. selCurrentHostData dw 0
  128. segCurrentHostData dw 0
  129. DpmiSegAttr dw 0
  130. DpmiFlags dw 0
  131. DXDATA ends
  132. ; -------------------------------------------------------
  133. ; CODE SEGMENT VARIABLES
  134. ; -------------------------------------------------------
  135. DXCODE segment
  136. extrn segDXData:WORD
  137. extrn PrevInt2FHandler:DWORD
  138. DXCODE ends
  139. DXPMCODE segment
  140. extrn selDgroupPM:WORD
  141. EXTRN MakeLowSegment:PROC
  142. DXPMCODE ends
  143. ; -------------------------------------------------------
  144. DXPMCODE segment
  145. assume cs:DXPMCODE
  146. ; WOW
  147. ; -------------------------------------------------------
  148. ;
  149. ; Simulate VCD API's. DX contains function number.
  150. ;
  151. assume ds:NOTHING,es:NOTHING,ss:NOTHING
  152. public VCD_PM_Svc_Call
  153. VCD_PM_Svc_Call:
  154. DPMIBOP VcdPmSvcCall32
  155. retf
  156. ; -------------------------------------------------------
  157. ; XMSfunc - The following routine provides a protected mode
  158. ; service for XMS Int 2Fh services. Two services are
  159. ; implemented: XMS driver installation check, and obtain
  160. ; XMS driver control function address.
  161. ;
  162. ; Input: UserAL - function request
  163. ; Output: UserAL - XMS driver installed flag, or
  164. ; UserES:BX - XMS driver control function address
  165. ; Errors: none
  166. ; Uses: all registers may be used
  167. assume ds:DGROUP,es:NOTHING,ss:NOTHING
  168. public XMSfunc
  169. XMSfunc proc near
  170. cmp al,XMS_INS_CHK ;XMS driver installation check?
  171. jnz @f
  172. mov byte ptr [bp].fnsUserAX,80h ;indicate driver is installed
  173. ret
  174. @@:
  175. ; It must be an obtain XMS driver control function address request
  176. mov [bp].fnsUserBX,offset DXPMCODE:XMScontrol
  177. mov [bp].fnsUserES,cs
  178. ret
  179. XMSfunc endp
  180. ; -------------------------------------------------------
  181. subttl DPMI MS-DOS Extension API
  182. page
  183. ; -------------------------------------------------------
  184. ; DPMI MS-DOS EXTENSION API
  185. ; -------------------------------------------------------
  186. ;
  187. ; The following routine implements the DPMI MS-DOS Extensions
  188. ; API. This API must be 'detected' by the use of the
  189. ; DMPI_MSDOS_EXT Int 2F function (above).
  190. public DPMI_MsDos_API
  191. DPMI_MsDos_API proc far
  192. cmp ax, DPMI_MSDOS_API_GET_VER ;Get version call?
  193. jne DPMI_MsDos_API_Not_Ver
  194. mov ax,DPMI_MSDOS_VER
  195. jmp short DPMI_MsDos_API_Exit
  196. DPMI_MsDos_API_Not_Ver:
  197. cmp ax, DPMI_MSDOS_API_GET_LDT ;Get LDT Base call?
  198. jne DPMI_MsDos_Api_Failed
  199. ifdef WOW_x86
  200. mov ax,SEL_WOW_LDT or STD_RING ; yup, give it to 'em
  201. else
  202. mov ax,SEL_LDT_ALIAS or STD_RING ; yup, give it to 'em
  203. endif
  204. DPMI_MsDos_API_Exit:
  205. clc ;Succss
  206. ret
  207. DPMI_MsDos_API_Failed:
  208. stc ;Unsupported function
  209. ret
  210. DPMI_MsDos_API endp
  211. DXPMCODE ends
  212. ; -------------------------------------------------------
  213. DXCODE segment
  214. assume cs:DXCODE
  215. ; -------------------------------------------------------
  216. ;
  217. ; -------------------------------------------------------
  218. ;
  219. ; DPMI_Client_Pmode_Entry -- This routine is the entry
  220. ; point for a DPMI client to switch to protected mode.
  221. ; Reference: DOS Protected Mode Interface Specification 0.9
  222. ; Section 5.2: Calling the Real to Protected
  223. ; Mode Switch Entry Point
  224. ;
  225. ; Entry: AX = Flags
  226. ; Bit 0 = 1 if program is a 32-bit application
  227. ; ES = Real mode segment of DPMI host data area. This is the
  228. ; size of the data area we specified in RMInt2FHandler,
  229. ; below.
  230. ;
  231. ; Returns:
  232. ; Success: Carry clear.
  233. ; Program is in protected mode.
  234. ; CS = 16-bit selector with base of real mode
  235. ; CS and a 64k limit.
  236. ; SS = 16-bit selector with base of real mode
  237. ; SS and a 64k limit.
  238. ; DS = 16-bit selector with base of real mode
  239. ; DS and a 64k limit.
  240. ; ES = Selector to program's PSP with a 100h
  241. ; byte limit.
  242. ; 80386, 80486:
  243. ; FS, GS = 0
  244. ; All other registers preserved.
  245. ;
  246. ; Failure: Carry flag set.
  247. ; Program is in real mode.
  248. ;
  249. ; Exceptions:
  250. ; 32-bit programs not (yet) supported. Any attempt to load
  251. ; a 32-bit program by this mechanism returns failure.
  252. ;
  253. ; The only error that can occur here is a failure to allocate
  254. ; sufficient selectors.
  255. ;
  256. ;
  257. ; Structure of the stack frame used to store the client's registers
  258. ; while implementing the DPMI protected mode entry.
  259. ;
  260. DPMI_Client_Frame STRUC
  261. Client_ES dw ? ; Client's ES
  262. Client_DS dw ? ; Client's DS
  263. Client_DI dw ? ; Client's DI
  264. Client_SI dw ? ; Client's SI
  265. Client_Pusha_BP dw ? ; BP at pusha
  266. Client_Pusha_SP dw ? ; SP at pusha
  267. Client_BX dw ? ; Client's BX
  268. Client_DX dw ? ; Client's DX
  269. Client_CX dw ? ; Client's CX
  270. Client_AX dw ? ; Client's AX
  271. Client_Flags dw ? ; Client's flags
  272. Client_IP dw ? ; Client's IP, lsw of return
  273. Client_CS dw ? ; Client's CS, msw of return
  274. DPMI_Client_Frame ENDS
  275. public DPMI_Client_Pmode_Entry
  276. DPMI_Client_Pmode_Entry proc far
  277. ;
  278. ; Reject any 32-bit program requests.
  279. ;
  280. IFNDEF WOW
  281. test ax, DPMI_32BIT ; 32-bit application?
  282. stc ; yep, refuse to do it
  283. jz dcpe_flags_ok ; no, try to get into Pmode
  284. jmp dcpe_x
  285. dcpe_flags_ok:
  286. ENDIF
  287. IFDEF WOW
  288. stc
  289. ENDIF
  290. pushf ;save client's flags (with carry set)
  291. pusha ;save caller's general registers
  292. push ds ;save caller's DS
  293. push es ;save caller's ES
  294. mov bp, sp ;create the stack frame
  295. dossvc 62h ;now get caller's PSP address
  296. mov di, bx ;and store it here for a while
  297. push es
  298. dossvc 2fh ;get caller's dta address
  299. mov ax, segDXData ;get our DGROUP
  300. mov ds, ax ;point to it
  301. mov DtaSegment,es
  302. mov DtaOffset,bx
  303. pop es
  304. ;
  305. ; For now, we only support one DPMI client application at a time.
  306. ;
  307. ;; cmp cDPMIClients,0 ;Any active?
  308. ;; je @F
  309. ;; jmp dcpe_return
  310. @@: mov ax,[segCurrentHostData]
  311. mov es:[HdSegParent],ax ; save rm link
  312. mov ax,es
  313. mov [segCurrentHostData],ax
  314. mov ax,[bp].Client_AX ; get dpmi flags
  315. mov es:[HdFlags],ax ; save for future reference
  316. mov DpmiFlags,ax
  317. test ax,DPMI_32BIT
  318. jne cpe10
  319. mov DpmiSegAttr,0
  320. jmp cpe20
  321. cpe10: mov DpmiSegAttr,AB_BIG
  322. cpe20: mov si, ss ;SI = caller SS
  323. mov ax, ds ;use a DOSX stack during the mode
  324. ;switch
  325. FCLI
  326. mov ss, ax
  327. mov sp, offset DGROUP:rgw2FStack
  328. SwitchToProtectedMode
  329. mov ax, si ;make a selector for client's stack
  330. mov bx, STD_DATA
  331. or bx, DpmiSegAttr
  332. call MakeLowSegment
  333. jnc got_client_stack_selector
  334. jmp dcpe_error_exit ;back out if error
  335. got_client_stack_selector:
  336. or al,STD_TBL_RING
  337. mov ss, ax ;back to client's stack
  338. .386p
  339. movzx esp,bp
  340. .286p
  341. ; push [bp.Client_Flags] ;enable interupts if client had
  342. ; npopf ;them enabled
  343. ;
  344. ; After DOSX enters protected mode, convert the caller's segment registers
  345. ; to PMODE selectors, replacing the values in the client's register image
  346. ; on the stack. First, allocate the three or four selectors we will need.
  347. ;
  348. xor ax,ax ;an invalid selector
  349. push ax ;marker
  350. mov cx,4 ;CS, PSP, Environ, Host data
  351. cmp si,[bp.Client_DS] ;Client SS == Client DS ?
  352. je dcpe_allocate_loop
  353. inc cx
  354. dcpe_allocate_loop:
  355. call AllocateSelector
  356. jnc @F
  357. jmp dcpe_pfail
  358. @@:
  359. or al,STD_TBL_RING
  360. push ax
  361. loop dcpe_allocate_loop
  362. mov dx,[bp.Client_CS] ;get client CS paragraph
  363. call ParaToLinear ;convert to linear address in BX:DX
  364. mov cx,0ffffh ;limit = 64k
  365. pop ax ;get one of the selectors allocated
  366. mov [bp.Client_CS],ax ;save value for client
  367. cCall NSetSegmentDscr,<ax,bx,dx,0,cx,STD_CODE>
  368. mov dx, [bp.Client_DS]
  369. mov [bp.Client_DS],ss ;DS = SS for now
  370. cmp dx, si ;need separate DS selector?
  371. je dcpe_do_child_PSP
  372. call ParaToLinear ;convert to linear address in BL:DX
  373. mov cx,0ffffh ;limit = 64k
  374. pop ax ;get another selector
  375. mov [bp.Client_DS],ax ;save value for client
  376. push di
  377. mov di,STD_DATA
  378. or di,DpmiSegAttr
  379. cCall NSetSegmentDscr,<ax,bx,dx,0,cx,di>
  380. pop di
  381. dcpe_do_child_PSP:
  382. mov dx,[bp.Client_ES] ; get HostData selector
  383. call ParaToLinear
  384. mov cx,HOST_DATA_SIZE ; limit = size of HostData
  385. pop ax ; get another selector
  386. push [selCurrentHostData]
  387. mov [selCurrentHostData],ax ; save for us
  388. cCall NSetSegmentDscr,<ax,bx,dx,0,cx,STD_DATA>
  389. mov es,ax
  390. pop ax
  391. mov es:[HdSelParent],ax
  392. mov ax,SelPSPChild
  393. mov es:[HdPSPParent],ax
  394. mov dx, di ;get client PSP paragraph
  395. mov segPSPChild, di
  396. call ParaToLinear ;convert to linear address in BL:DX
  397. mov cx,100h ;limit = 100h
  398. pop ax ;get another selector
  399. mov [bp.Client_ES],ax ;save value for client
  400. mov selPSPChild, ax ;save a copy for DOSX
  401. cCall NSetSegmentDscr,<ax,bx,dx,0,cx,STD_DATA>
  402. mov es:[HdSelPSP],ax
  403. mov es,ax ;point to client's PSP
  404. mov dx,es:segEnviron ;fetch client's environment pointer
  405. call ParaToLinear ;convert to linear address in BL:DX
  406. mov cx,0ffffh ;limit = 32k
  407. pop ax ;get another selector
  408. mov es:segEnviron,ax ;save client's environment selector
  409. cCall NSetSegmentDscr,<ax,bx,dx,0,cx,STD_DATA>
  410. ; We need to set up the DTA selector
  411. mov dx,DtaSegment
  412. cmp dx,segPSPChild
  413. jne dcpe_50
  414. mov dx,selPSPChild
  415. mov DtaSelector,dx
  416. jmp dcpe_60
  417. dcpe_50:
  418. mov cx,1
  419. call AllocateSelector
  420. jnc @f
  421. jmp dcpe_free_client_stack
  422. @@: or al,STD_TBL_RING
  423. mov DtaSelector,ax
  424. call ParaToLinear
  425. cCall NSetSegmentDscr,<ax,bx,dx,0,0ffffh,STD_DATA>
  426. dcpe_60:
  427. inc cDPMIClients ;increment count of Pmode clients
  428. cmp cDPMIClients, 1 ; first client?
  429. jne @f ; already taken care of
  430. call AllocateExceptionStack
  431. call DpmiStackSizeInit
  432. call DpmiSizeInit
  433. FBOP BOP_DPMI,DpmiInUse,FastBop
  434. ;
  435. @@:
  436. ;
  437. ; Everything OK. Clear error flag, and return to caller.
  438. ;
  439. not byte ptr [bp.Client_Flags]
  440. ;reverse status flags, clearing carry
  441. ; Let 32 bit code know if this is a 32 or 16 bit application
  442. mov ax,DpmiFlags
  443. push selPSPChild
  444. push DtaSelector
  445. push DtaOffset
  446. FBOP BOP_DPMI,InitApp,FastBop
  447. add sp,4
  448. cmp cDPMIClients, 1 ; first client?
  449. jne @f ; already taken care of
  450. ; Note: We have to do InitApp before we try to hook the netbios
  451. ; interrupt. If we don't, we will fault in the dos extender.
  452. ; (HookNetBiosHwInt calls int 21, enabling interrupts)
  453. call HookNetBiosHwInt
  454. @@:
  455. ; jmp far ptr dcpe_return ;avoid need for fix ups
  456. db 0EAh
  457. dw offset DXCODE:dcpe_return
  458. dw SEL_DXCODE OR STD_RING
  459. ;
  460. ; If we get here, it means DOSX failed to allocate enough selectors for the
  461. ; client. Deallocate those which have been allocated, switch back to
  462. ; real mode, and return an error to the caller. Selectors to deallocate
  463. ; are on the stack, pushed after a zero word. Then switch to a DOSX stack,
  464. ; deallocate the client stack selector, and switch to real mode.
  465. ;
  466. dcpe_pfail:
  467. pop ax ;any selectors allocated?
  468. or ax,ax ; (we pushed a zero before allocating)
  469. jz dcpe_free_client_stack ;done
  470. call FreeSelector ;free the selector
  471. jnc dcpe_pfail ;free any more
  472. dcpe_free_client_stack:
  473. mov di, ss ;make copy of client stack selector
  474. mov ax, ds ;have to be on a DOSX stack to do this
  475. FCLI
  476. mov ss, ax
  477. mov sp, offset DGROUP:rgw2FStack
  478. mov ax, di ;free client stack selector
  479. call FreeSelector
  480. dcpe_error_exit:
  481. ;
  482. ; Error exit from protected mode. Any allocated selectors have already
  483. ; been freed. Switch to real mode, restore client stack, pop off client's
  484. ; registers, return with the carry flag set.
  485. ;
  486. SwitchToRealMode
  487. mov ss, si ;restore client stack
  488. errnz <dcpe_return-$>
  489. dcpe_return: ; The next line must restore the stack.
  490. mov sp, bp
  491. jc dcpe_return_1 ; error return
  492. ;
  493. ; Pop the client's registers off the stack frame, switch back to the
  494. ; client's stack, and return.
  495. ;
  496. dcpe_return_1:
  497. pop es ;pop copy of PSP selector/segment
  498. pop ds ;pop client DS selector/segment
  499. popa ;pop client's general registers
  500. npopf ;restore interrupt flag, return status
  501. dcpe_x:
  502. retf ;and out of here
  503. DPMI_Client_Pmode_Entry endp
  504. ; -------------------------------------------------------
  505. ; REAL MODE FUNCTION HANDLER
  506. ; -------------------------------------------------------
  507. ;
  508. ; RMInt2FHandler -- This routine hooks the real mode Int 2Fh chain
  509. ; and watches for 'interesting' Int 2Fh calls.
  510. ;
  511. ; WIN386/DOSX startup broadcast
  512. ; DPMI server detection
  513. ; Switcher API functions
  514. ;
  515. assume ds:NOTHING,es:NOTHING,ss:NOTHING
  516. public RMInt2FHandler
  517. RMInt2FHandler proc near
  518. cmp ah,WIN386_FUNC ;WIN386/DOSX/DPMI call?
  519. jz rm2f_0
  520. rm2f_chain:
  521. jmp [PrevInt2FHandler] ;no, just chain it on...
  522. rm2f_0:
  523. if 0 ; don't claim to be win 3.1 in enhanced mode
  524. cmp al,WIN386_INIT ;WIN386/DOSX startup attempt?
  525. jnz rm2f_1 ;no
  526. mov cx,-1 ;yes, don't let'm load
  527. jmp rm2f_x
  528. endif
  529. cmp al,W386_Get_Device_API ;not supported
  530. jne rm2f_1
  531. xor di,di
  532. mov es,di
  533. jmp rm2f_x
  534. rm2f_1:
  535. cmp al,DPMI_DETECT ;DPMI detection?
  536. jnz rm2f_2 ;no
  537. mov ax,DPMI_SUCCESS ;yes, return Pmode switch entry
  538. mov bx,DPMI_FLAGS ;flags
  539. push segDXData
  540. pop es
  541. assume es:DXDATA
  542. mov cl,byte ptr es:[idCpuType] ;CPU type
  543. assume es:nothing
  544. mov dx,DPMI_VER ;DPMI server version
  545. mov si,(HOST_DATA_SIZE + 15) / 16
  546. push cs ;entry point is in this segment
  547. pop es ;prospective client wants
  548. lea di,DPMI_Client_Pmode_Entry ;switch entry point in ES:DI
  549. jmp rm2f_x ;done
  550. rm2f_2:
  551. if 0 ; don't claim to be windows
  552. cmp al,WIN386_VER ;Windows 386 version check?
  553. jnz rm2f_chain ;no, chain the interrupt
  554. mov ax, 0a03h
  555. else
  556. jmp rm2f_chain
  557. endif
  558. rm2f_x:
  559. iret
  560. RMInt2FHandler endp
  561. ;--------------------------------------------------------------------------------
  562. DXCODE ends
  563. IFDEF WOW
  564. DXPMCODE segment
  565. assume cs:DXPMCODE
  566. ;----------------------------------------------------------------------
  567. ;
  568. ; DpmiSizeInit -- This routine insures that the appropriately sized
  569. ; interrupt handlers will be called
  570. ;
  571. ; Inputs: None
  572. ; Outputs: None
  573. ;
  574. public DpmiSizeInit
  575. assume ds:dgroup,es:nothing,ss:nothing
  576. DpmiSizeInit proc
  577. push ax
  578. push bx
  579. push cx
  580. push si
  581. push di
  582. push es
  583. rpushf
  584. FCLI
  585. test DpmiFlags,DPMI_32BIT
  586. jnz dsi20
  587. cCall NSetSegmentAccess,<selDgroupPM,STD_DATA>
  588. cCall NSetSegmentAccess,<selEHStack,STD_DATA>
  589. jmp dsi90
  590. dsi20:
  591. ;
  592. ; Copy 16 bit handler addresses
  593. ;
  594. .386p
  595. lea di,Wow16BitHandlers
  596. mov ax,ds
  597. mov es,ax
  598. assume es:DGROUP
  599. push ds
  600. mov ax,SEL_IDT OR STD_RING
  601. mov ds,ax
  602. assume ds:nothing
  603. mov si,0
  604. mov cx,256
  605. dsi40: movsd
  606. add si,4
  607. loop dsi40
  608. pop ds
  609. ;
  610. ; Put 32 bit handlers into IDT
  611. ;
  612. mov ax,SEL_IDT OR STD_RING
  613. mov es,ax
  614. mov es:[1h*8].offDest,offset DXPMCODE:Wow32IntrRefl+1h*6
  615. mov es:[3h*8].offDest,offset DXPMCODE:Wow32IntrRefl+3h*6
  616. mov es:[10h*8].offDest,offset DXPMCODE:Wow32IntrRefl+10h*6
  617. mov es:[13h*8].offDest,offset DXPMCODE:Wow32IntrRefl+13h*6
  618. mov es:[15h*8].offDest,offset DXPMCODE:Wow32IntrRefl+15h*6
  619. mov es:[19h*8].offDest,offset DXPMCODE:Wow32IntrRefl+19h*6
  620. mov es:[21h*8].offDest,offset DXPMCODE:Wow32IntrRefl+21h*6
  621. mov es:[25h*8].offDest,offset DXPMCODE:Wow32IntrRefl+25h*6
  622. mov es:[26h*8].offDest,offset DXPMCODE:Wow32IntrRefl+26h*6
  623. mov es:[28h*8].offDest,offset DXPMCODE:Wow32IntrRefl+28h*6
  624. mov es:[30h*8].offDest,offset DXPMCODE:Wow32IntrRefl+30h*6
  625. mov es:[33h*8].offDest,offset DXPMCODE:Wow32IntrRefl+33h*6
  626. mov es:[41h*8].offDest,offset DXPMCODE:Wow32IntrRefl+41h*6
  627. ;
  628. ; Set up the IDT, and dpmi32 state
  629. ;
  630. mov ax,es ; Idt selector
  631. mov bx,VDM_INT_32
  632. DPMIBOP InitIDT
  633. assume ds:DGROUP
  634. dsi90: rpopf
  635. pop es
  636. pop di
  637. pop si
  638. pop cx
  639. pop bx
  640. pop ax
  641. ret
  642. DpmiSizeInit endp
  643. assume ds:DGROUP, es:NOTHING, ss:NOTHING
  644. DpmiStackSizeInit proc
  645. push ax
  646. test DpmiFlags,DPMI_32BIT
  647. jz @f
  648. ;
  649. ; Make the dgroup selector 32 bit
  650. ;
  651. ; NOTE: The following equ is only necessary to get the cmacro package
  652. ; to pass the correct value to NSetSegmentAccess
  653. NEW_DX_DATA equ STD_DATA OR AB_BIG
  654. cCall NSetSegmentAccess,<selDgroupPM,NEW_DX_DATA>
  655. cCall NSetSegmentAccess,<selEHStack,NEW_DX_DATA>
  656. .286p
  657. @@:
  658. pop ax
  659. ret
  660. DpmiStackSizeInit endp
  661. DXPMCODE ends
  662. ENDIF
  663. ;
  664. ;****************************************************************
  665. end