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.

321 lines
7.7 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. endif
  39. _DATA ends
  40. _TEXT SEGMENT PARA USE16 PUBLIC 'CODE'
  41. ASSUME CS: _TEXT
  42. ;++
  43. ;
  44. ; BOOLEAN
  45. ; HwGetPciSystemData (
  46. ; PPCI_SYSTEM_DATA PciSystemData
  47. ; )
  48. ;
  49. ; Routine Description:
  50. ;
  51. ; This function retrieves the PCI System Data
  52. ;
  53. ; Arguments:
  54. ;
  55. ; PciSystemData - Supplies a pointer to the structure which will
  56. ; receive the PCI System Data.
  57. ;
  58. ; Return Value:
  59. ;
  60. ; True - PCI System Detected and System Data valid
  61. ; False - PCI System Not Detected
  62. ;
  63. ;--
  64. SystemInfoPointer equ [bp + 4]
  65. BiosDateFound equ [bp + 6]
  66. public _HwGetPciSystemData
  67. _HwGetPciSystemData proc
  68. push bp ; The following INT 15H destroies
  69. mov bp, sp ; ALL the general registers.
  70. push si
  71. push di
  72. push bx
  73. ;
  74. ; Set for no PCI buses present
  75. ;
  76. mov bx, SystemInfoPointer
  77. mov byte ptr [bx].NoBuses, 0
  78. ;
  79. ; Is the BIOS date >= 11/01/92? If so, make the int-1a call
  80. ;
  81. push ds
  82. cmp byte ptr [BiosDateFound], 0
  83. jnz gpci00
  84. ;
  85. ; A valid BIOS date was not found, check for "PCI " in bios code.
  86. ;
  87. if DBG
  88. push offset PciBIOSSig
  89. call _BlPrint
  90. add sp, 2
  91. endif
  92. mov bx, 0f000h
  93. mov ds, bx
  94. mov bx, 0fffch
  95. spci05: cmp dword ptr ds:[bx], ' ICP' ; 'PCI ' found at this addr?
  96. je short gpci00 ; found
  97. dec bx ; next location
  98. jnz short spci05 ; loop
  99. jmp spci_notfound ; wrapped, all done - not found
  100. gpci00:
  101. pop ds
  102. if DBG
  103. push offset PciInt
  104. call _BlPrint
  105. add sp, 2
  106. endif
  107. ;
  108. ; Check for a PCI system. Issue the PCI Present request.
  109. ;
  110. mov ax, PCI_BIOS_PRESENT ; Real Mode Presence Request
  111. int PCI_INTERFACE_INT ; Just Do It!
  112. jc gpci10 ; Carry Set => No PCI
  113. cmp ah, 0 ; If PCI Present AH == 0
  114. jne gpci12 ; AH != 0 => No PCI
  115. cmp edx, " ICP" ; "PCI" Backwards (with a trailing space)
  116. jne gpci14 ; PCI Signature in EDX => PCI Exists
  117. ;
  118. ; Found PCI BIOS Version > 1.0
  119. ;
  120. ; The only thing left to do is squirrel the data away for the caller
  121. ;
  122. mov dx, bx ; Save revision level
  123. mov bx, SystemInfoPointer ; Get caller's Pointer
  124. mov byte ptr [bx].MajorRevision, dh
  125. mov byte ptr [bx].MinorRevision, dl
  126. inc cl ; NoBuses = LastBus+1
  127. if 0
  128. ;
  129. ; Some PIC BIOS returns very large number of NoBuses. As a work-
  130. ; around we mask the value to 16, unless the BIOS also return CH as
  131. ; neg cl then we believe it.
  132. ;
  133. cmp cl, 16
  134. jbe short @f
  135. neg ch
  136. inc ch
  137. cmp cl, ch
  138. je short @f
  139. mov cl, 16
  140. @@:
  141. endif
  142. mov byte ptr [bx].NoBuses, cl
  143. mov byte ptr [bx].HwMechanism, al
  144. jmp Done ; We're done
  145. if DBG
  146. gpci10: mov ax, offset PciIntFailed
  147. jmp short gpci_oldbios
  148. gpci12: mov ax, offset PciIntAhFailed
  149. jmp short gpci_oldbios
  150. gpci14: mov ax, offset PciIDFailed
  151. gpci_oldbios:
  152. push ax
  153. call _BlPrint
  154. add sp, 2
  155. else
  156. gpci10:
  157. gpci12:
  158. gpci14:
  159. endif
  160. ;
  161. ; Look for BIOS Version 1.0, This has a different function #
  162. ;
  163. mov ax, PCI10_BIOS_PRESENT ; Real Mode Presence Request
  164. int PCI_INTERFACE_INT ; Just Do It!
  165. ; Version 1.0 has "PCI " in dx and cx, the Version number in ax, and the
  166. ; carry flag cleared. These are all the indications available.
  167. ;
  168. cmp dx, "CP" ; "PC" Backwards
  169. jne gpci50 ; PCI Signature not in DX & CX => No PCI
  170. cmp cx, " I" ; "I " Backwards
  171. jne gpci50 ; PCI Signature not in EDX => No PCI
  172. ;
  173. ; Found PCI BIOS Version 1.0
  174. ;
  175. ; The only thing left to do is squirrel the data away for the caller
  176. ;
  177. mov bx, SystemInfoPointer ; Get caller's Pointer
  178. mov byte ptr [bx].MajorRevision, ah
  179. mov byte ptr [bx].MinorRevision, al
  180. ;
  181. ; The Version 1.0 BIOS is only on early HW that had couldn't support
  182. ; Multi Function devices or multiple bus's. So without reading any
  183. ; device data, mark it as such.
  184. ;
  185. mov byte ptr [bx].HwMechanism, 2
  186. mov byte ptr [bx].NoBuses, 1
  187. jmp Done
  188. spci_notfound:
  189. pop ds ; restore ds
  190. if DBG
  191. push offset PciBIOSSigNotFound
  192. call _BlPrint
  193. add sp, 2
  194. endif
  195. jmp gpci_exit
  196. if DBG
  197. gpci50: push offset PciInt10IdFailed
  198. jmp Done10
  199. Done: push offset PciFound
  200. Done10: call _BlPrint
  201. add sp, 2
  202. else
  203. ; non-debug no prints
  204. gpci50:
  205. Done:
  206. endif
  207. gpci_exit:
  208. pop bx
  209. pop di
  210. pop si
  211. pop bp
  212. ret
  213. _HwGetPciSystemData endp
  214. RouteBuffer equ [bp + 4]
  215. ExclusiveIRQs equ [bp + 8]
  216. public _HwGetPciIrqRoutingOptions
  217. _HwGetPciIrqRoutingOptions proc
  218. push bp
  219. mov bp, sp ; Create 'C' stack frame.
  220. push ebx
  221. push edi
  222. push esi ; Save registers used.
  223. push es
  224. push ds
  225. xor edi, edi
  226. les di, RouteBuffer
  227. mov bx, 0f000h
  228. mov ds, bx
  229. xor ebx, ebx
  230. mov ax, 0B10Eh
  231. int PCI_INTERFACE_INT
  232. pop ds
  233. pop es
  234. mov di, ExclusiveIRQs
  235. mov [di], bx
  236. mov al, ah
  237. pop esi ; Restore registers.
  238. pop edi
  239. pop ebx
  240. pop bp
  241. ret
  242. _HwGetPciIrqRoutingOptions endp
  243. _TEXT ends
  244. end