63 lines
1.6 KiB
FASM
63 lines
1.6 KiB
FASM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; ;;
|
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
;; ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
include 'devices.inc'
|
|
|
|
VEN_STRIDE = 8
|
|
|
|
; Returns pointer to the device id stored in data
|
|
; clears and returns value in esi
|
|
if used PCI_find_dev
|
|
proc PCI_find_dev stdcall ven_id, dev_id
|
|
|
|
push edx
|
|
xor esi, esi
|
|
|
|
mov esi, ven1_array
|
|
cmp [ven_id], VirtVendorID1
|
|
jz .next_device_id
|
|
|
|
mov esi, ven2_array
|
|
cmp [ven_id], VirtVendorID2
|
|
jnz .not_found ;unknown vendor id
|
|
|
|
.next_device_id:
|
|
mov edx, [esi] ;fewer memory accesses
|
|
|
|
test edx, edx
|
|
jz .not_found ;end of array
|
|
|
|
add esi, VEN_STRIDE
|
|
|
|
cmp edx, [dev_id]
|
|
jnz .next_device_id
|
|
|
|
;Found device
|
|
sub esi, VEN_STRIDE ;The loop adds it an one time extra
|
|
pop edx
|
|
ret
|
|
|
|
.not_found:
|
|
|
|
pop edx
|
|
xor esi, esi
|
|
ret
|
|
endp
|
|
end if
|
|
|
|
; Follow convention: {id, msg}
|
|
|
|
align 4
|
|
|
|
ven1_array dd idDevNetwork,msgDevNetwork
|
|
dd idDevBlock,msgDevBlock
|
|
dd idDevBalloon,msgDevBallon
|
|
dd idDevConsole,msgDevConsole
|
|
dd 0,0
|
|
|
|
ven2_array dd idDevNVME,msgDevNVME
|
|
dd 0,0 |