.data
message1 db '---------------------------------------------------',13,10
db 'Index Bus. Dev. func. DeviceID VendorID DeviceType',13,10
db '---------------------------------------------------',13,10
db '$'
return db 13,10,'$'
moreMessage db 'press any key for more .',13,10,'$'
bus db 00h
dev db 00h
func db 00h
bcode db 00h
Lindex db 00h
bc00 db 'Device built before Define BC','$'
bc01 db 'Mass Storage Controller','$'
bc02 db 'Network Controller','$'
bc03 db 'Display Controller','$'
bc04 db 'Mutimedia device','$'
bc05 db 'Memory Controller','$'
bc06 db 'Bridge device','$'
bc07 db 'Simple communication controllers','$'
bc08 db 'Base system peripherals','$'
bc09 db 'Input devices','$'
bc0a db 'Docking stations','$'
bc0b db 'Processors','$'
bc0c db 'Serial bus controllers','$'
bc0d db 'Wireless controller','$'
bc0e db 'Intelligent I/O controllers','$'
bc0f db 'Satellite communication controllers','$'
bc10 db 'Encryption/Decryption controllers','$'
bc11 db 'Data acquisition and signal processing controllers','$'
BCTable label byte
dw offset bc00
dw offset bc01
dw offset bc02
dw offset bc03
dw offset bc04
dw offset bc05
dw offset bc06
dw offset bc07
dw offset bc08
dw offset bc09
dw offset bc0a
dw offset bc0b
dw offset bc0c
.stack
;--------------------------------------------------------------------
;Display the character '0'~'9' and 'A'~'F'
;
;Input : DL = Number
;Ouput : None
;--------------------------------------------------------------------
Disp_chr proc
push dx
push ax
cmp dl,10
jns letter
add dl,30h
jmp down
letter:
add dl,37h
down:
mov ah,2
int 21h
pop ax
pop dx
ret
Disp_chr endp
;--------------------------------------------------------------------
;Display the Bus number,Device number and Function number
;
;Input : EBX = Bus#, Dev#, Func#
;Output : None
;--------------------------------------------------------------------
Disp_add proc
;;;;;;Display Bus Number
rol ebx,16
mov dl,bl
and dl,0fh
call Disp_chr
call Disp_spc
call Disp_spc
call Disp_spc
call Disp_spc
;;;;;;Display Device Number
;;;;;;Display the high 1 bit
rol ebx,1
mov dl,bl
and dl,1
call Disp_chr
;;;;;;Display the low 4 bits
rol ebx,4
mov dl,bl
and dl,0fh
call Disp_chr
call Disp_spc
call Disp_spc
call Disp_spc
call Disp_spc
;;;;;;Display Function Number
rol ebx,3
mov dl,bl
and dl,7
call Disp_chr
call Disp_spc
call Disp_spc
call Disp_spc
call Disp_spc
mov cl,4
p: rol eax,4
mov dl,al
and dl,0fh
call disp_chr
dec cl
jnz p
call disp_spc
call disp_spc
call disp_spc
call disp_spc
call disp_spc
pop cx
ret
disp_sp endp
;----------------------------------------------
disp_sd proc
push cx
mov cl,4
rol eax,16
p1: rol eax,4
mov dl,al
and dl,0fh
call disp_chr
dec cl
jnz p1
call disp_spc
call disp_spc
pop cx
ret
disp_sd endp
;---------------------
;-------------------------------------------------------------------
;------------------------------------------------------------
;Start Program Here
;------------------------------------------------------------
Begin:
;;;;;;Display the table head
mov ah,9
mov dx,seg message1
mov ds,dx
mov dx,offset message1
int 21h
; Add Scan PCI Code here
;loop1:
loop1:
and eax,00000000h
and ebx,00000000h
mov ah,dev
mov cl,03h
rol ah,cl
add ah,func
mov al,00h ;register num.=00h
mov bx,ax
mov ax,8000h
add al,bus
mov cl,10h
rol eax,cl
add eax,ebx
mov ebx,eax ;save bus#,dev#,func# in ebx
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in eax,dx
cmp ax,0ffffh
; int 3h
jz next2
display:
;;;;;;;;;Get Base ClassCode and save it in bcode memory
push eax
mov eax,ebx
add eax,08h
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in eax,dx
mov cl,08h
rol eax,cl
mov bcode,al
call Disp_spc
call Disp_spc
;;;;;;;;;display the PCI Devices list index
push ax
mov al,Lindex
mov cl,4
rol al,cl
mov dl,al
and dl,0fh
call Disp_chr
rol al,cl
mov dl,al
and dl,0fh
call Disp_chr
;;;;;inc Lindex
inc al
mov Lindex,al
pop ax
call Disp_spc
call Disp_spc
;;;;;;;;;display the bus number, device number , function number
call disp_add
pop eax
push eax
pop eax
push eax
call Disp_spc
call disp_sp
pop eax
call Disp_spc
call disp_sd
;;;;;;Display Base Class Code
push eax
mov al,bcode
sal al,1
mov ah,0
mov si, offset BCTable
add si, ax
mov dx,word ptr ds:[si]
mov ah,09h
int 21h
pop eax
;;;;;;change to a new line
push eax
mov ah,9
mov dx,seg return
mov ds,dx
mov dx,offset return
int 21h
pop eax
;;;;;;;;;;;check the cusor at the bottom of the screen
1、用PCILIST.EXE 测试的结果是:
===============================================
PC/AT PCI device list [ PCIlist ] Version 1.36 Copyright(C) 2003-09 傑傝傕
PCI BIOS Version 2.10, Last bus number(BIOS)=2, Configuration mechanism #1
Bus Dev Func Class Vendor IRQ INT B/M P/E I/O MEM MWI SER PED DPD SED CL
[0]:[ 0] PCI--HOST Intel -- Yes No No Yes No No - - - -
[0]:[ 1] GFX bridge Intel -- Yes No Yes Yes No Yes - - - -
[0]:[29]:[0] USB Intel 12 [A] Yes No Yes No No No - - - -
[0]:[29]:[1] USB Intel 3 [B] Yes No Yes No No No - - - -
[0]:[29]:[2] USB Intel 11 [C] Yes No Yes No No No - - - -
[0]:[29]:[3] USB Intel 12 [A] Yes No Yes No No No - - - -
[0]:[29]:[7] USB 2.0 Intel 5 [D] Yes No No Yes No No - - - -
[0]:[30] LPC bridge Intel -- Yes No Yes Yes No Yes - - - -
[0]:[31]:[0] PCI--ISA Intel -- Yes No Yes Yes No No - - - -
[0]:[31]:[1] IDE ctrl. Intel -- [A] Yes No Yes Yes No No - - - -
[0]:[31]:[2] IDE ctrl. Intel 11 [A] Yes No Yes No No No - - - -
[0]:[31]:[3] SM bus Intel 10 [B] No No Yes No No No - - - -
[0]:[31]:[5] MM-AUDIO Intel 10 [B] Yes No Yes Yes No No - - - -
[1]:[ 0] VGA-VIDEO ATI ** Yes No Yes Yes No No - - - 8
[2]:[ 1] IEEE1394 Texas Ins 10 [A] Yes No No Yes No No - - - 8
[2]:[ 2] EtherNet RealTEK 11 [A] Yes No Yes Yes No No - - - -
[2]:[ 9] EtherNet RealTEK 10 [A] Yes No Yes Yes No No - - - -
===============================================
Bus Dev Func Slot Vend Dev. Class Name Subclass Name
----------------------------------------------------------------
0 0 0 0 8086 2570 Bridge CPU/PCI
0 1 0 1 8086 2571 Bridge PCI/PCI
0 1D 0 1D 8086 24D2 Serial Bus USB
0 1D 1 1D 8086 24D4 Serial Bus USB
0 1E 0 1E 8086 244E Bridge PCI/PCI
0 1F 0 1F 8086 24D0 Bridge PCI/ISA
0 1F 1 1F 8086 24DB Disk IDE
1 0 0 20 1002 5159 Display VGA
2 1 0 41 104C 8024 Serial Bus Firewire
2 2 0 42 10EC 8139 Network Ethernet
2 9 0 49 10EC 8139 Network Ethernet
11 PCI devices found
3、用PCISLEEP.EXE 测试的结果是:
===============================================
PCI BIOS version 2.10, highest bus number is 2.
bus.device(.function) [vendor:model] classcode(/iface) vendor class [details]
BusDevf vend:type class vendor description...
-----------------------------------------------------------------------------
00.00 8086:2570 0600 Intel CPU host bridge
00.01 8086:2571 0604 Intel PCI bridge [00->01]
00.1d.0 8086:24d2 0c03 Intel USB controller
00.1d.1 8086:24d4 0c03 Intel USB controller
00.1d.2 8086:24d7 0c03 Intel USB controller
00.1d.3 8086:24de 0c03 Intel USB controller
00.1d.7 8086:24dd 0c03/20 Intel USB controller [D3]
00.1e 8086:244e 0604 Intel PCI bridge [00->02]
00.1f.0 8086:24d0 0601 Intel ISA bridge
00.1f.1 8086:24db 0101/8a Intel IDE controller
00.1f.2 8086:24d1 0101/8f Intel IDE controller
00.1f.3 8086:24d3 0c05 Intel SMBus controller
00.1f.5 8086:24d5 0401 Intel audio [D3]
01.00 1002:5159 0300 ATI VGA graphics [D1,D3]
02.01 104c:8024 0c00/10 TI FireWire IEEE1394 [D1,D3]
02.02 10ec:8139 0200 Realtek LAN / Ethernet [D1,D3]
02.09 10ec:8139 0200 Realtek LAN / Ethernet [D1,D3]