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.

380 lines
10 KiB

  1. title "PCI bus Support Assembley Code"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; hwpcia.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; Calls the PCI rom function to determine what type of PCI
  13. ; support is prsent, if any.
  14. ;
  15. ; Base code provided by Intel
  16. ;
  17. ; Author:
  18. ;
  19. ;--
  20. .386p
  21. .xlist
  22. include hwpci.inc
  23. .list
  24. if DBG
  25. extrn _BlPrint:PROC
  26. endif
  27. _DATA SEGMENT PARA USE16 PUBLIC 'DATA'
  28. if DBG
  29. cr equ 11
  30. PciBIOSSig db 'PCI: Scanning for "PCI "', cr, 0
  31. PciBIOSSigNotFound db 'PCI: BIOS "PCI " not found', cr, 0
  32. PciInt db 'PCI: Calling PCI_BIOS_PRESENT', cr, 0
  33. PciIntFailed db 'PCI: PCI_BIOS_PRESENT returned carry', cr, 0
  34. PciIntAhFailed db 'PCI: PCI_BIOS_PRESENT returned bad AH value', cr, 0
  35. PciIDFailed db 'PCI: PCI_BIOS_PRESENT invalid PCI id', cr, 0
  36. PciInt10IdFailed db 'PCI: PCI10_BIOS_PRESENT invalid PCI id', cr, 0
  37. PciFound db 'PCI BUS FOUND', cr, 0
  38. PciBadRead db 'PCI BAD READ', cr, 0
  39. endif
  40. _DATA ends
  41. _TEXT SEGMENT PARA USE16 PUBLIC 'CODE'
  42. ASSUME CS: _TEXT
  43. ;++
  44. ;
  45. ; BOOLEAN
  46. ; HwGetPciSystemData (
  47. ; PPCI_SYSTEM_DATA PciSystemData
  48. ; )
  49. ;
  50. ; Routine Description:
  51. ;
  52. ; This function retrieves the PCI System Data
  53. ;
  54. ; Arguments:
  55. ;
  56. ; PciSystemData - Supplies a pointer to the structure which will
  57. ; receive the PCI System Data.
  58. ;
  59. ; Return Value:
  60. ;
  61. ; True - PCI System Detected and System Data valid
  62. ; False - PCI System Not Detected
  63. ;
  64. ;--
  65. SystemInfoPointer equ [bp + 4]
  66. BiosDateFound equ [bp + 6]
  67. public _HwGetPciSystemData
  68. _HwGetPciSystemData proc
  69. push bp ; The following INT 15H destroies
  70. mov bp, sp ; ALL the general registers.
  71. push si
  72. push di
  73. push bx
  74. ;
  75. ; Set for no PCI buses present
  76. ;
  77. mov bx, SystemInfoPointer
  78. mov byte ptr [bx].NoBuses, 0
  79. ;
  80. ; Is the BIOS date >= 11/01/92? If so, make the int-1a call
  81. ;
  82. push ds
  83. cmp byte ptr [BiosDateFound], 0
  84. jnz gpci00
  85. ;
  86. ; A valid BIOS date was not found, check for "PCI " in bios code.
  87. ;
  88. if DBG
  89. push offset PciBIOSSig
  90. call _BlPrint
  91. add sp, 2
  92. endif
  93. mov bx, 0f000h
  94. mov ds, bx
  95. mov bx, 0fffch
  96. spci05: cmp dword ptr ds:[bx], ' ICP' ; 'PCI ' found at this addr?
  97. je short gpci00 ; found
  98. dec bx ; next location
  99. jnz short spci05 ; loop
  100. jmp spci_notfound ; wrapped, all done - not found
  101. gpci00:
  102. pop ds
  103. if DBG
  104. push offset PciInt
  105. call _BlPrint
  106. add sp, 2
  107. endif
  108. ;
  109. ; Check for a PCI system. Issue the PCI Present request.
  110. ;
  111. mov ax, PCI_BIOS_PRESENT ; Real Mode Presence Request
  112. int PCI_INTERFACE_INT ; Just Do It!
  113. jc gpci10 ; Carry Set => No PCI
  114. cmp ah, 0 ; If PCI Present AH == 0
  115. jne gpci12 ; AH != 0 => No PCI
  116. cmp edx, " ICP" ; "PCI" Backwards (with a trailing space)
  117. jne gpci14 ; PCI Signature in EDX => PCI Exists
  118. ;
  119. ; Found PCI BIOS Version > 1.0
  120. ;
  121. ; The only thing left to do is squirrel the data away for the caller
  122. ;
  123. mov dx, bx ; Save revision level
  124. mov bx, SystemInfoPointer ; Get caller's Pointer
  125. mov byte ptr [bx].MajorRevision, dh
  126. mov byte ptr [bx].MinorRevision, dl
  127. inc cl ; NoBuses = LastBus+1
  128. if 0
  129. ;
  130. ; Some PIC BIOS returns very large number of NoBuses. As a work-
  131. ; around we mask the value to 16, unless the BIOS also return CH as
  132. ; neg cl then we believe it.
  133. ;
  134. cmp cl, 16
  135. jbe short @f
  136. neg ch
  137. inc ch
  138. cmp cl, ch
  139. je short @f
  140. mov cl, 16
  141. @@:
  142. endif
  143. mov byte ptr [bx].NoBuses, cl
  144. mov byte ptr [bx].HwMechanism, al
  145. jmp Done ; We're done
  146. if DBG
  147. gpci10: mov ax, offset PciIntFailed
  148. jmp short gpci_oldbios
  149. gpci12: mov ax, offset PciIntAhFailed
  150. jmp short gpci_oldbios
  151. gpci14: mov ax, offset PciIDFailed
  152. gpci_oldbios:
  153. push ax
  154. call _BlPrint
  155. add sp, 2
  156. else
  157. gpci10:
  158. gpci12:
  159. gpci14:
  160. endif
  161. ;
  162. ; Look for BIOS Version 1.0, This has a different function #
  163. ;
  164. mov ax, PCI10_BIOS_PRESENT ; Real Mode Presence Request
  165. int PCI_INTERFACE_INT ; Just Do It!
  166. ; Version 1.0 has "PCI " in dx and cx, the Version number in ax, and the
  167. ; carry flag cleared. These are all the indications available.
  168. ;
  169. cmp dx, "CP" ; "PC" Backwards
  170. jne gpci50 ; PCI Signature not in DX & CX => No PCI
  171. cmp cx, " I" ; "I " Backwards
  172. jne gpci50 ; PCI Signature not in EDX => No PCI
  173. ;
  174. ; Found PCI BIOS Version 1.0
  175. ;
  176. ; The only thing left to do is squirrel the data away for the caller
  177. ;
  178. mov bx, SystemInfoPointer ; Get caller's Pointer
  179. mov byte ptr [bx].MajorRevision, ah
  180. mov byte ptr [bx].MinorRevision, al
  181. ;
  182. ; The Version 1.0 BIOS is only on early HW that had couldn't support
  183. ; Multi Function devices or multiple bus's. So without reading any
  184. ; device data, mark it as such.
  185. ;
  186. mov byte ptr [bx].HwMechanism, 2
  187. mov byte ptr [bx].NoBuses, 1
  188. jmp Done
  189. spci_notfound:
  190. pop ds ; restore ds
  191. if DBG
  192. push offset PciBIOSSigNotFound
  193. call _BlPrint
  194. add sp, 2
  195. endif
  196. jmp gpci_exit
  197. if DBG
  198. gpci50: push offset PciInt10IdFailed
  199. jmp Done10
  200. Done: push offset PciFound
  201. Done10: call _BlPrint
  202. add sp, 2
  203. else
  204. ; non-debug no prints
  205. gpci50:
  206. Done:
  207. endif
  208. gpci_exit:
  209. pop bx
  210. pop di
  211. pop si
  212. pop bp
  213. ret
  214. _HwGetPciSystemData endp
  215. RouteBuffer equ [bp + 4]
  216. ExclusiveIRQs equ [bp + 8]
  217. public _HwGetPciIrqRoutingOptions
  218. _HwGetPciIrqRoutingOptions proc
  219. push bp
  220. mov bp, sp ; Create 'C' stack frame.
  221. push ebx
  222. push edi
  223. push esi ; Save registers used.
  224. push es
  225. push ds
  226. xor edi, edi
  227. les di, RouteBuffer
  228. mov bx, 0f000h
  229. mov ds, bx
  230. xor ebx, ebx
  231. mov ax, 0B10Eh
  232. int PCI_INTERFACE_INT
  233. pop ds
  234. pop es
  235. mov di, ExclusiveIRQs
  236. mov [di], bx
  237. mov al, ah
  238. pop esi ; Restore registers.
  239. pop edi
  240. pop ebx
  241. pop bp
  242. ret
  243. _HwGetPciIrqRoutingOptions endp
  244. Bus equ [bp + 4]
  245. Device equ [bp + 6]
  246. Function equ [bp + 8]
  247. RegOffset equ [bp + 10]
  248. DataRead equ [bp + 12]
  249. public _HwGetPciConfigurationDword
  250. _HwGetPciConfigurationDword proc
  251. push bp
  252. mov bp, sp ; Create 'C' stack frame.
  253. push ebx
  254. push ecx
  255. push edi
  256. push esi ; Save registers used.
  257. push es
  258. push ds
  259. mov bl, Device
  260. shl bl, 3
  261. or bl, Function
  262. mov bh, Bus
  263. mov di, RegOffset
  264. mov ax, 0B10Ah
  265. int PCI_INTERFACE_INT
  266. jc gbadread ; Carry Set => Read failed
  267. pop ds
  268. pop es
  269. mov di, DataRead
  270. mov [di], ecx
  271. mov al, ah
  272. jmp greaddone
  273. if DBG
  274. gbadread: push offset PciBadRead
  275. call _BlPrint
  276. add sp, 2
  277. mov al, 087h
  278. else
  279. gbadread:
  280. endif
  281. greaddone: pop esi ; Restore registers.
  282. pop edi
  283. pop ecx
  284. pop ebx
  285. pop bp
  286. ret
  287. _HwGetPciConfigurationDword endp
  288. _TEXT ends
  289. end