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.

274 lines
4.9 KiB

  1. TITLE LDFASTB - FastBoot procedure
  2. .xlist
  3. include kernel.inc
  4. include newexe.inc
  5. include pdb.inc
  6. include tdb.inc
  7. include eems.inc
  8. .list
  9. if PMODE32
  10. .386
  11. endif
  12. externA __ahincr
  13. externFP GlobalReAlloc
  14. sBegin NRESCODE
  15. assumes CS,NRESCODE
  16. assumes DS,NOTHING
  17. assumes ES,NOTHING
  18. sEnd NRESCODE
  19. DataBegin
  20. externB Kernel_flags
  21. externW pGlobalHeap
  22. externW win_show
  23. externW hLoadBlock
  24. externW segLoadBlock
  25. externD lpBootApp
  26. ife ROM
  27. externW cpShrink
  28. externW cpShrunk
  29. endif
  30. DataEnd
  31. sBegin INITCODE
  32. assumes CS,CODE
  33. assumes DS,NOTHING
  34. assumes ES,NOTHING
  35. externNP MyLock
  36. if PMODE32
  37. externNP get_arena_pointer32
  38. else
  39. externNP get_arena_pointer
  40. endif
  41. externNP get_physical_address
  42. externNP set_physical_address
  43. externNP get_rover_2
  44. ;-----------------------------------------------------------------------;
  45. ; Shrink ;
  46. ; ;
  47. ; This shrinks what's left of win.bin. The part at the front of win.bin;
  48. ; that has been loaded already is expendable. The part of win.bin ;
  49. ; that has not been loaded yet is moved down over the expended part. ;
  50. ; This does not change the segment that win.bin starts at. The ;
  51. ; partition is then realloced down in size. ;
  52. ; ;
  53. ; Arguments: ;
  54. ; none ;
  55. ; ;
  56. ; Returns: ;
  57. ; ;
  58. ; Error Returns: ;
  59. ; ;
  60. ; Registers Preserved: ;
  61. ; DI,SI,DS,ES ;
  62. ; ;
  63. ; Registers Destroyed: ;
  64. ; AX,BX,CX,DX ;
  65. ; ;
  66. ; Calls: ;
  67. ; BigMove ;
  68. ; GlobalReAlloc ;
  69. ; MyLock ;
  70. ; ;
  71. ; History: ;
  72. ; ;
  73. ; Fri Feb 27, 1987 01:20:57p -by- David N. Weise [davidw] ;
  74. ; Documented it and added this nifty comment block. ;
  75. ;-----------------------------------------------------------------------;
  76. assumes ds, nothing
  77. assumes es, nothing
  78. cProc Shrink,<PUBLIC,NEAR>
  79. cBegin nogen
  80. ife ROM
  81. CheckKernelDS
  82. ReSetKernelDS
  83. push es
  84. push si
  85. push di
  86. mov ax,[segLoadBlock] ; Get current address
  87. mov bx, ax
  88. if PMODE32
  89. mov ds, pGlobalHeap
  90. UnSetKernelDS
  91. cCall get_arena_pointer32,<ax>
  92. mov edx, ds:[eax].pga_size
  93. shr edx, 4
  94. SetKernelDS
  95. else
  96. cCall get_arena_pointer,<ax>
  97. mov es,ax
  98. mov dx,es:[ga_size] ; get size of whole block
  99. endif
  100. mov ax,bx
  101. mov es,ax ; es is destination
  102. xor bx,bx
  103. xchg [cpShrink],bx ; Get amount to shrink by
  104. add [cpShrunk],bx ; Keep track of how much we have shrunk
  105. sub dx,bx ; get new size
  106. push dx ; save new size
  107. push ds ; save kernel ds
  108. if PMODE32
  109. mov ds, ax
  110. movzx esi, bx
  111. shl esi, 4 ; Start of new block
  112. xor edi, edi ; Where it will go
  113. movzx ecx, dx
  114. shl ecx, 2 ; Dwords
  115. cld ; Move it down.
  116. rep movs dword ptr es:[edi], dword ptr ds:[esi]
  117. db 67h ; 386 BUG, DO NOT REMOVE
  118. nop ; 386 BUG, DO NOT REMOVE
  119. else
  120. push dx
  121. xor cx,cx
  122. REPT 4
  123. shl bx,1
  124. rcl cx,1
  125. ENDM
  126. cCall get_physical_address,<es>
  127. add ax,bx
  128. adc dx,cx
  129. push es
  130. call get_rover_2
  131. smov ds,es
  132. assumes ds, nothing
  133. pop es
  134. cCall set_physical_address,<ds>
  135. pop dx
  136. call BigMove ; move it on down
  137. endif ; PMODE32
  138. pop ds
  139. CheckKernelDS
  140. ReSetKernelDS
  141. pop ax ; get back size in paragraphs
  142. mov cx,4
  143. xor dx,dx ; convert to bytes
  144. il3e:
  145. shl ax,1
  146. rcl dx,1
  147. loop il3e
  148. cCall GlobalReAlloc,<hLoadBlock,dxax,cx>
  149. cCall MyLock,<hLoadBlock>
  150. mov [segLoadBlock],ax
  151. pop di
  152. pop si
  153. pop es
  154. endif ;ROM
  155. ret
  156. cEnd nogen
  157. ;-----------------------------------------------------------------------;
  158. ; BigMove ;
  159. ; ;
  160. ; Moves a large partition down in memory. ;
  161. ; ;
  162. ; Arguments: ;
  163. ; DX = paragraph count to move ;
  164. ; ES = destination segment ;
  165. ; DS = source segment ;
  166. ; ;
  167. ; Returns: ;
  168. ; ;
  169. ; Error Returns: ;
  170. ; ;
  171. ; Registers Preserved: ;
  172. ; None ;
  173. ; ;
  174. ; Registers Destroyed: ;
  175. ; AX,BX,CX,DX,DI,SI,DS,ES ;
  176. ; ;
  177. ; Calls: ;
  178. ; nothing ;
  179. ; ;
  180. ; History: ;
  181. ; ;
  182. ; Fri Feb 27, 1987 01:08:43p -by- David N. Weise [davidw] ;
  183. ; Documented it and added this nifty comment block. ;
  184. ;-----------------------------------------------------------------------;
  185. assumes ds, nothing
  186. assumes es, nothing
  187. ife ROM
  188. ife PMODE32
  189. cProc BigMove,<PUBLIC,NEAR>
  190. cBegin nogen
  191. if PMODE32
  192. movzx ecx, dx
  193. shl ecx, 2
  194. xor esi, esi
  195. xor edi, edi
  196. cld
  197. rep movsd
  198. ret
  199. else
  200. mov bx,dx
  201. mov cl,12
  202. add bx,0FFFh
  203. shr bx,cl ; count +1 of 10000h byte moves
  204. xor si,si ; ds:0 is source
  205. xor di,di ; es:0 is dest
  206. cld
  207. jmps BM2
  208. BM1:
  209. int 3 ; IF WE HIT THIS, KRNL286.EXE IS
  210. int 3 ; TOO BIG, FIX THE FOLLOWING!!!
  211. sub dx,1000h
  212. ;;;ife PMODE32
  213. mov cx,8000h
  214. rep movsw ; si,di are 0
  215. ;;;else
  216. ;;; mov cx, 4000h
  217. ;;; rep movsd
  218. ;;;endif
  219. mov ax,ds
  220. add ax,__ahincr
  221. mov ds,ax
  222. mov ax,es
  223. add ax,__ahincr
  224. mov es,ax
  225. BM2: dec bx
  226. jnz BM1
  227. ;;;ife PMODE32
  228. mov cl,3 ; convert to words
  229. shl dx,cl
  230. mov cx,dx
  231. rep movsw ; si,di are 0
  232. ;;;else
  233. ;;; shl dx, 2 ; dwords
  234. ;;; mov cx, dx
  235. ;;; rep movsd
  236. ;;;endif
  237. endif
  238. ret
  239. cEnd nogen
  240. endif ; PMODE32
  241. endif ; ROM
  242. sEnd INITCODE
  243. end