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.

331 lines
7.9 KiB

  1. title "Int13 Drive parameter information detection"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; diska.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements the assembley code necessary to detect/collect
  13. ; harddisk paramter information.
  14. ;
  15. ; Author:
  16. ;
  17. ; Shie-Lin Tzong (shielint) 22-Feb-1992
  18. ;
  19. ; Environment:
  20. ;
  21. ; Real Mode 16-bit code.
  22. ;
  23. ; Revision History:
  24. ;
  25. ;
  26. ;--
  27. .386p
  28. ;
  29. ; Standard int 13 drive parameters.
  30. ; The parameters returned from int 13 function 8
  31. ;
  32. Int13DriveParameters struc
  33. DriveSelect dw 0
  34. MaxCylinders dd 0
  35. SectorsPerTrack dw 0
  36. MaxHeads dw 0
  37. NumberDrives dw 0
  38. Int13DriveParameters ends
  39. SIZE_OF_PARAMETERS equ 12
  40. ;
  41. ; Extended int 13 drive parameters
  42. ; The Drive Parameters returned from int 13 function 48h
  43. ;
  44. ExInt13DriveParameters struc
  45. ExBufferSize dw 0
  46. ExFlags dw 0
  47. ExCylinders dd 0
  48. ExHeads dd 0
  49. ExSectorsPerTrack dd 0
  50. ExSectorsPerDrive dd 0
  51. dd 0
  52. ExSectorSize dw 0
  53. ExReserved dw 0
  54. ExInt13DriveParameters ends
  55. SIZE_OF_EXTENDED_PARAMETERS equ 28
  56. ;
  57. ; Structure used by nt kernel Configuration Manager
  58. ;
  59. CmDiskGeometryDeviceData struc
  60. CmBytesPerSector dd 0
  61. CmNumberOfCylinders dd 0
  62. CmSectorsPerTrack dd 0
  63. CmNumberOfHeads dd 0
  64. CmDiskGeometryDeviceData ends
  65. SIZE_OF_CM_DISK_DATA EQU 16
  66. _DATA SEGMENT PARA USE16 PUBLIC 'DATA'
  67. public _NumberBiosDisks
  68. _NumberBiosDisks dw 0
  69. RomChain db 8 * SIZE_OF_PARAMETERS dup(?)
  70. _DATA ends
  71. _TEXT SEGMENT PARA USE16 PUBLIC 'CODE'
  72. ASSUME CS: _TEXT, DS:_DATA, SS:NOTHING
  73. ;++
  74. ;
  75. ; VOID
  76. ; GetInt13DriveParamters (
  77. ; OUT PUCHAR Buffer,
  78. ; OUT PUSHORT Size
  79. ; )
  80. ;
  81. ; Routine Description:
  82. ;
  83. ; This function calls real mode int 13h function 8 to get drive
  84. ; parameters for drive 80h - 87h.
  85. ;
  86. ; Arguments:
  87. ;
  88. ; Buffer - Supplies a pointer to a buffer to receive the drive paramter
  89. ; information.
  90. ;
  91. ; Size - Supplies a pointer to a USHORT to receive the size of the drive
  92. ; parameter information returned.
  93. ;
  94. ; Return Value:
  95. ;
  96. ; None.
  97. ;
  98. ;--
  99. Public _GetInt13DriveParameters
  100. _GetInt13DriveParameters proc
  101. push bp
  102. mov bp, sp
  103. push si
  104. push bx
  105. mov dx, 80h ; Starting from drive 80h
  106. mov cx, 0 ; count
  107. mov si, offset RomChain ; [si]->Buffer
  108. gidp00:
  109. push cx ; save count
  110. push dx ; save drive select
  111. ;
  112. ; First check if drive is present. It turns out function returns drive
  113. ; parameters even when the drive is not present.
  114. ;
  115. mov ah, 15h
  116. int 13h ; Get type of drive
  117. jc short gidp99
  118. cmp ah, 0 ; if ah=0 drive is not present
  119. jz gidp99
  120. pop dx
  121. pop cx
  122. push cx
  123. push dx
  124. mov ah, 8 ; int 13 function 8
  125. int 13h ; call int 13
  126. jc short gidp99 ; if c, fail, go exit
  127. inc _NumberBiosDisks
  128. mov al, cl
  129. and al, 3fh ; Only want bit 0 - 5
  130. mov ah, 0
  131. mov [si].SectorsPerTrack, ax
  132. shr cl, 6
  133. xchg cl, ch
  134. mov word ptr [si].MaxCylinders, cx
  135. mov word ptr [si + 2].MaxCylinders, 0
  136. mov byte ptr [si].MaxHeads, dh
  137. mov byte ptr [si + 1].MaxHeads, 0
  138. mov byte ptr [si].NumberDrives, dl
  139. mov byte ptr [si + 1].NumberDrives, 0
  140. pop dx ; get back current drive number
  141. mov [si].DriveSelect, dx
  142. inc dx
  143. pop cx ; get back count
  144. inc cx ; increase table count
  145. cmp dx, 88h ; Are we done? (dx == 88h)
  146. je short gidp100
  147. add si, SIZE_OF_PARAMETERS
  148. jmp gidp00
  149. gidp99: pop dx
  150. pop cx
  151. gidp100:
  152. mov ax, offset RomChain
  153. mov si, [bp + 4] ; [si]-> variable to receive buffer addr
  154. mov [si], ax ; return buffer address
  155. mov si, [bp + 6] ; [si]-> variable to receive buffer size
  156. mov ax, cx
  157. mov cl, SIZE_OF_PARAMETERS
  158. mul cl
  159. mov [si], ax ; return buffer size
  160. pop bx
  161. pop si
  162. pop bp
  163. ret
  164. _GetInt13DriveParameters endp
  165. ;++
  166. ;
  167. ; BOOLEAN
  168. ; IsExtendedInt13Available
  169. ; USHORT DriveNumber
  170. ; )
  171. ;
  172. ; Routine Description:
  173. ;
  174. ; This function checks if extended int13 functions available.
  175. ;
  176. ; Arguments:
  177. ;
  178. ; DriveNumber - the drive number to check for.
  179. ;
  180. ; Return Value:
  181. ;
  182. ; TRUE if extended int 13 service is available. Otherwise a value of
  183. ; FALSE is returned.
  184. ;
  185. ;--
  186. Public _IsExtendedInt13Available
  187. _IsExtendedInt13Available proc
  188. push bp
  189. mov bp, sp
  190. push bx
  191. mov dl, [bp+4] ; get DriveNumber parameter
  192. mov ah, 41h
  193. mov bx, 55aah
  194. int 13h
  195. jc short Ieda90
  196. cmp bx, 0AA55h
  197. jne short Ieda90
  198. test cx, 1 ; bit 0 = Extended disk access is supported
  199. jz short Ieda90
  200. mov ax, 1
  201. jmp short IedaExit
  202. Ieda90:
  203. xor eax, eax
  204. IedaExit:
  205. pop bx
  206. pop bp
  207. ret
  208. _IsExtendedInt13Available endp
  209. ;++
  210. ;
  211. ; USHORT
  212. ; GetExtendedDriveParameters
  213. ; USHORT DriveNumber,
  214. ; FPCM_DISK_GEOMETRY_DEVICE_DATA DeviceData
  215. ; )
  216. ;
  217. ; Routine Description:
  218. ;
  219. ; This function use extended int13 service function 48h to get
  220. ; drive parameters.
  221. ;
  222. ; Arguments:
  223. ;
  224. ; DriveNumber - the drive number to get the drive parameters.
  225. ;
  226. ; DeviceData - supplies a far pointer to a buffer to receive the parameters.
  227. ;
  228. ;
  229. ; Return Value:
  230. ;
  231. ; Size of DeviceData. If the extended int 13 service is not available,
  232. ; a zero value will be returned.
  233. ;
  234. ;--
  235. Public _GetExtendedDriveParameters
  236. _GetExtendedDriveParameters proc
  237. push bp
  238. mov bp, sp
  239. push si
  240. push bx
  241. sub sp, SIZE_OF_EXTENDED_PARAMETERS
  242. mov dl, [bp+4] ; get DriveNumber parameter
  243. mov si, sp ; [si]-> Local buffer
  244. mov word ptr [si].ExBufferSize, SIZE_OF_EXTENDED_PARAMETERS
  245. mov ah, 48h
  246. int 13h
  247. jc short Gedp90
  248. or ah, ah ; Make sure there is no error
  249. jnz short Gedp90 ; if error, exit
  250. cmp [si].ExBufferSize, ExReserved
  251. jl short Gedp90 ; the retruned data is too small to be useful
  252. mov bx, [bp+6]
  253. mov ax, [bp+8]
  254. mov es, ax ; (es:bx)->Caller's buffer
  255. ASSUME es:NOTHING
  256. mov eax, [si].ExCylinders
  257. mov es:[bx].CmNumberOfCylinders, eax
  258. mov eax, [si].ExHeads
  259. mov es:[bx].CmNumberOfHeads, eax
  260. mov eax, [si].ExSectorsPerTrack
  261. mov es:[bx].CmSectorsPerTrack, eax
  262. xor eax, eax
  263. mov ax, [si].ExSectorSize
  264. mov es:[bx].CmBytesPerSector, eax
  265. mov ax, SIZE_OF_CM_DISK_DATA
  266. jmp short GedpExit
  267. Gedp90:
  268. xor eax, eax
  269. GedpExit:
  270. add sp, SIZE_OF_EXTENDED_PARAMETERS
  271. pop bx
  272. pop si
  273. pop bp
  274. ret
  275. _GetExtendedDriveParameters endp
  276. _TEXT ends
  277. end