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.

290 lines
8.5 KiB

  1. ; ========================================================
  2. if 0
  3. REBOOT.ASM
  4. Copyright (c) 1991 - Microsoft Corp.
  5. All rights reserved.
  6. Microsoft Confidential
  7. johnhe - 12/01/89
  8. endif
  9. ;-----------------------------------------------------------------------------;
  10. ; K E Y B O A R D S C A N C O D E S ;
  11. ;-----------------------------------------------------------------------------;
  12. KB_INTERCEPT EQU 4fh
  13. DEL_KEY EQU 53h
  14. ALT_SHIFT EQU 08h
  15. CTL_SHIFT EQU 04h
  16. WARM_BOOT_CODE EQU 1234h
  17. ;-----------------------------------------------------------------------------;
  18. ; BIOS DATA AREA LOCATED AT 40:00
  19. ;-----------------------------------------------------------------------------;
  20. ROM_DATA SEGMENT AT 040h
  21. org 17h
  22. KB_FLAG LABEL BYTE
  23. org 072h
  24. WarmBootFlag LABEL WORD
  25. ROM_DATA ENDS
  26. ;-----------------------------------------------------------------------------;
  27. ; CPU POWER-ON STARTUP LOCATION AT ffff:00
  28. ;-----------------------------------------------------------------------------;
  29. ROM_BIOS SEGMENT AT 0ffffh
  30. org 0
  31. PowerOnReset LABEL FAR
  32. ROM_BIOS ENDS
  33. ;-----------------------------------------------------------------------------;
  34. ;include MODEL.INC
  35. ;-----------------------------------------------------------------------------;
  36. ;.CODE
  37. _TEXT segment public 'CODE'
  38. assume cs:_TEXT,ds:nothing
  39. public _DnaReboot
  40. _DnaReboot PROC near
  41. ;RebootSystem PROC
  42. ifdef NEC_98
  43. DoInt15:
  44. ;
  45. ; 37h bit 2 is shutdown bit.
  46. ;
  47. mov al,0bh
  48. out 37h,al
  49. mov al,0fh
  50. out 37h,al
  51. mov al,0h
  52. out 0f0h,al
  53. jmp DoInt15
  54. else ; PC98
  55. mov AX,3515h
  56. int 21h ; Get int 15h vector in ES:BX
  57. mov AX,ES ; AX == Segment
  58. or AX,BX ; Is this a NULL ptr
  59. jz WarmBoot ; If zero we can't do an int 15h
  60. DoInt15:
  61. mov ax, seg WarmBootFlag
  62. mov ds, ax
  63. assume DS:ROM_DATA
  64. mov KB_FLAG,ALT_SHIFT OR CTL_SHIFT
  65. mov AX,(KB_INTERCEPT SHL 8) OR DEL_KEY
  66. int 15h ; Put Ctrl/Alt/Del into key buffer
  67. WarmBoot:
  68. cli
  69. cld
  70. mov ax, seg WarmBootFlag
  71. mov ds, ax
  72. assume DS:ROM_DATA
  73. mov WarmBootFlag, WARM_BOOT_CODE
  74. jmp PowerOnReset
  75. ; Jump to the processor power-on address FFFF:0000h
  76. endif ; NEC_98 `
  77. _DnaReboot ENDP
  78. ;RebootSystem ENDP
  79. ; ========================================================
  80. ;++
  81. ;
  82. ; BOOLEAN
  83. ; _far
  84. ; _cdecl
  85. ; DnAbsoluteSectorIo(
  86. ; IN unsigned Drive, //0=A, etc
  87. ; IN ULONG StartSector,
  88. ; IN USHORT SectorCount,
  89. ; IN OUT PVOID Buffer,
  90. ; IN BOOLEAN Write
  91. ; )
  92. ;
  93. ;--
  94. public _DnAbsoluteSectorIo
  95. _DnAbsoluteSectorIo PROC far
  96. ; params
  97. Drive equ 6
  98. Int2526Packet equ 8
  99. Write equ 18
  100. ; locals
  101. GotLock equ -2
  102. push bp
  103. mov bp,sp
  104. sub sp,2
  105. push ds
  106. push es
  107. push bx
  108. push si
  109. push di
  110. mov byte ptr [bp].GotLock,0 ; initialize lock state flag
  111. ;
  112. ; Check for Win9x by checking for version 7 or greater.
  113. ; The minor version number is 10 for OSR2.
  114. ;
  115. ; We might also be running on some other vendor's DOS 7,
  116. ; so if locking fails we try the i/o anyway.
  117. ;
  118. mov ax,3306h ; get MS-DOS version
  119. int 21h
  120. cmp bl,8 ; Is Millenium ?
  121. je milljmp ;
  122. cmp bl,7 ; check for DOS7 or above (Win9x)
  123. jb dosjmp ; not Win9x
  124. jmp winjmp ; Regular Win9x jmp
  125. dosjmp:
  126. mov bl,8 ; assume standard ioctl
  127. jmp locked ; not Win9x
  128. milljmp:
  129. mov bl,48h ; extended ioctl
  130. jmp getlock
  131. winjmp:
  132. mov bl,48h ; DOS 7 or above, assume extended ioctl
  133. cmp bh,10 ; test OSR2
  134. jae getlock ; OSR2, leave bl alone, use ext ioctl
  135. mov bl,8 ; Win9x gold, use standard ioctl
  136. getlock:
  137. push bx ; standard/extended ioctl
  138. .286
  139. push 4ah ; lock volume ioctl code
  140. .8086
  141. push [bp].Drive
  142. call LockOrUnlock
  143. jc locked ; failure, try i/o anyway
  144. inc byte ptr [bp].GotLock ; remember we have level 0 lock
  145. locked:
  146. ;
  147. ; Dirty hack -- the int25/26 buffer is laid
  148. ; out exactly the way the parameters are passed
  149. ; on the stack.
  150. ;
  151. ; In OSR2 or later case, try new int21 first. Int25/26 don't work on FAT32.
  152. ;
  153. cmp bl,48h ; OSR2 or later?
  154. mov ax,ss
  155. mov ds,ax
  156. push bx ; save OSR2 or later flag
  157. lea bx,[bp].Int2526Packet ; ds:bx = disk i/o param
  158. mov cx,0ffffh ; tell DOS to use param packet
  159. jne int2526 ; don't try new int21 on old system
  160. mov ax,7305h ; new abs disk i/o int21 call
  161. mov dl,[bp].Drive ; fetch drive
  162. inc dl ; make drive 1-based
  163. mov si,0 ; assume read
  164. cmp byte ptr [bp].Write,0 ; write operation?
  165. je doint21 ; no, read op
  166. inc si ; write op
  167. doint21:
  168. int 21h ; call DOS
  169. jnc did_io ; no error, done
  170. int2526:
  171. mov al,[bp].Drive ; fetch drive (0-based)
  172. cmp byte ptr [bp].Write,0 ; write operation?
  173. je @f ; no, read op
  174. int 26h ; abs disk write
  175. jmp short didio1
  176. @@: int 25h
  177. didio1: pop ax ; int 25/26 wierdness
  178. did_io:
  179. pop bx ; restore osr2 flag in bx
  180. .386
  181. setnc al ; convert carry status to boolean return code
  182. .8086
  183. push ax ; save return code
  184. ;
  185. ; Unlock if necessary, using same lock level
  186. ; of successful lock.
  187. ;
  188. cmp byte ptr [bp].GotLock,0
  189. je done ; no lock to undo
  190. push bx ; osr2 or later flag/ioctl category
  191. .286
  192. push 6ah ; unlock volume ioctl code
  193. .8086
  194. push [bp].Drive
  195. call LockOrUnlock
  196. done: pop ax ; restore return code in al
  197. pop di ; restore caller registers
  198. pop si
  199. pop bx
  200. pop es
  201. pop ds
  202. mov sp,bp ; restore stack frame
  203. pop bp
  204. ret
  205. _DnAbsoluteSectorIo ENDP
  206. LockOrUnlock PROC near
  207. .286
  208. pusha ; pushes 16 bytes
  209. mov bp,sp
  210. dolock:
  211. mov ch,byte ptr [bp+22] ; get ioctl category, 8 or 48
  212. mov ax,440dh ; generic ioctl code
  213. .386
  214. movzx bx,byte ptr [bp+18] ; bl = drive, bh = lock level 0
  215. .286
  216. inc bl ; convert drive to 1-based
  217. mov cl,byte ptr [bp+20] ; lock/unlock ioctl code
  218. xor dx,dx ; non-format lock
  219. int 21h
  220. jnc lockdone
  221. cmp byte ptr [bp+22],8 ; tried regular ioctl? (clobbers carry)
  222. mov byte ptr [bp+22],8 ; try regular ioctl on next pass
  223. jne dolock ; try regular ioctl
  224. stc ; error return
  225. lockdone:
  226. popa
  227. ret 6 ; carry set for return
  228. .8086
  229. LockOrUnlock ENDP
  230. _TEXT ends
  231. END
  232. ; ========================================================