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.

214 lines
4.6 KiB

  1. page ,160
  2. title MS-DOS BIOS int 2f handler
  3. ;
  4. ;----------------------------------------------------------------------------
  5. ;
  6. ; Modification history
  7. ;
  8. ; 26-Feb-1991 sudeepb Ported for NT DOSEm
  9. ;----------------------------------------------------------------------------
  10. ; THIS FILE SHOULD BE NAMED INT2f.ASM RATHER THAN INT13.ASM AS I HAVE RIPPED
  11. ; THE INT 13 SUPPORT. TO REDUCE CONFUSION WHEN PICKING FIXES FROM DOS 5.1
  12. ; THE NAME IS RETAINED AS IT IS.
  13. include version.inc ; set build flags
  14. include biosseg.inc ; establish bios segment structure
  15. include msequ.inc
  16. include biostruc.inc
  17. include msgroup.inc ; establish Bios_Data segment
  18. include vint.inc
  19. multMULT equ 4ah
  20. multMULTGETHMAPTR equ 1
  21. multMULTALLOCHMA equ 2
  22. Win386_RelTS equ 80h
  23. NT_WAIT_BOP equ 5Ah
  24. bop MACRO callid
  25. db 0c4h,0c4h,callid
  26. endm
  27. ;SR;
  28. ; Include file for WIN386 support
  29. ;
  30. include win386.inc
  31. extrn SysinitPresent:byte
  32. extrn FreeHMAPtr:word
  33. extrn MoveDOSIntoHMA:dword
  34. ;SR;
  35. ;New variables for Win386 support
  36. ;
  37. extrn IsWin386:byte
  38. extrn Win386_SI:byte
  39. extrn SI_Next:dword
  40. ; close data, open Bios_code segment
  41. tocode
  42. extrn Bios_Data_Word:word
  43. ; Int 2f functions to support communication of external block device
  44. ; drivers with msdisk are not supported. It also does'nt support
  45. ; function 13h which replaces the int 13 vector.
  46. ;
  47. public i2f_handler
  48. i2f_handler proc far
  49. assume ds:nothing,es:nothing
  50. cmp ah,13h
  51. jz i2f_iret
  52. cmp ah,8
  53. jz i2f_iret
  54. ;
  55. ;Check for WIN386 startup and return the BIOS instance data
  56. ;
  57. cmp ah,MULTWIN386
  58. jz win386call
  59. cmp ah, multMULT
  60. jne i2f_iret
  61. jmp handle_multmult
  62. i2f_iret:
  63. FIRET
  64. ;WIN386 startup stuff is done here. If starting up we set our WIN386 present
  65. ;flag and return instance data. If exiting, we reset the WIN386 present flag
  66. ;NOTE: We assume that the BIOS int 2fh is at the bottom of the chain.
  67. win386call:
  68. push ds
  69. mov ds,cs:Bios_Data_Word
  70. assume ds:Bios_Data
  71. cmp al, Win386_Init ; is it win386 initializing?
  72. je Win386Init
  73. cmp al, Win386_Exit ; is it win386 exiting?
  74. je Win386Exit
  75. cmp al, Win386_RelTS ; is it app release timeslice call?
  76. jne win_iret ; if not, continue int2f chain
  77. push ax ; It's the idling case - call MS BOP A
  78. xor ax,ax ; with AX = 0
  79. bop NT_WAIT_BOP
  80. pop ax
  81. xor al, al
  82. jmp short win_iret
  83. Win386Exit:
  84. test dx, 1 ; is it win386 or win286 dos extender?
  85. jnz win_iret ; if not win386, then continue
  86. and [IsWin386], 0 ; indicate that win386 is not present
  87. jmp short win_iret
  88. Win386Init:
  89. test dx, 1 ; is it win386 or win286 dos extender?
  90. jnz win_iret ; if not win386, then continue
  91. or [IsWin386], 1 ; Indicate WIN386 present
  92. mov word ptr [SI_Next], bx ; Hook our structure into chain
  93. mov word ptr [SI_Next + 2], es
  94. mov bx, offset Win386_SI ; point ES:BX to Win386_SI
  95. push ds
  96. pop es
  97. win_iret:
  98. pop ds
  99. assume ds:nothing
  100. jmp i2f_iret ;return back up the chain
  101. handle_multmult:
  102. cmp al, multMULTGETHMAPTR
  103. jne try_2
  104. push ds
  105. call HMAPtr ; get offset of free HMA
  106. mov bx, 0ffffh
  107. mov es, bx ; seg of HMA
  108. mov bx, di
  109. not bx
  110. or bx, bx
  111. jz @f
  112. inc bx
  113. @@:
  114. pop ds
  115. jmp i2f_iret
  116. try_2:
  117. cmp al, multMULTALLOCHMA
  118. jne try_3
  119. push ds
  120. mov di, 0ffffh ; assume not enough space
  121. mov es, di
  122. call HMAPtr ; get offset of free HMA
  123. assume ds:Bios_Data
  124. cmp di, 0ffffh
  125. je InsuffHMA
  126. neg di ; free space in HMA
  127. cmp bx, di
  128. jbe @f
  129. mov di, 0ffffh
  130. jmp short InsuffHMA
  131. @@:
  132. mov di, FreeHMAPtr
  133. add bx, 15
  134. and bx, 0fff0h
  135. add FreeHMAPtr, bx ; update the free pointer
  136. jnz InsuffHMA
  137. mov FreeHMAPtr, 0ffffh ; no more HMA if we have wrapped
  138. InsuffHMA:
  139. pop ds
  140. assume ds:nothing
  141. jmp i2f_iret
  142. try_3:
  143. jmp i2f_iret
  144. i2f_handler endp
  145. ;
  146. ;--------------------------------------------------------------------------
  147. ;
  148. ; procedure : HMAPtr
  149. ;
  150. ; Gets the offset of the free HMA area ( with respect to
  151. ; seg ffff )
  152. ; If DOS has not moved high, tries to move DOS high.
  153. ; In the course of doing this, it will allocate all the HMA
  154. ; and set the FreeHMAPtr to past the end of the BIOS and
  155. ; DOS code. The call to MoveDOSIntoHMA (which is a pointer)
  156. ; enters the routine in sysinit1 called FTryToMoveDOSHi.
  157. ;
  158. ; RETURNS : offset of free HMA in DI
  159. ; BIOS_DATA, seg in DS
  160. ;
  161. ;--------------------------------------------------------------------------
  162. ;
  163. HMAPtr proc near
  164. mov ds, Bios_Data_Word
  165. assume ds:Bios_Data
  166. mov di, FreeHMAPtr
  167. cmp di, 0ffffh
  168. jne @f
  169. cmp SysinitPresent, 0
  170. je @f
  171. call MoveDOSIntoHMA
  172. mov di, FreeHMAPtr
  173. @@:
  174. ret
  175. HMAPtr endp
  176. Bios_Code ends
  177. end