Board logo

标题: dos下如阿检测pci设备? [打印本页]

作者: zhgwbzhd     时间: 2006-3-29 10:50    标题: dos下如阿检测pci设备?

并且知道他是什么设备???谢谢。
作者: Kinglion     时间: 2006-4-7 04:21    标题: DOs下汇编实现PCI 扫瞄 SourceCode

---http://www.cn-dos.net/forum/viewthread.php?tid=8329&fpage=6

.model  small,c

                        .386

                        .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

                        .code

;--------------------------------------------------------------------
;Display space
;
;Input        : None
;Output        : None
;--------------------------------------------------------------------

Disp_spc        proc
               
                push  dx
                push  ax

                mov   dl,20h
                mov   ah,2
                int   21h
                pop   ax
                pop   dx
               
                ret
Disp_spc        endp


;--------------------------------------------------------------------
;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
                 
                 
                ret

Disp_add        endp
;------------------------------------
disp_sp  proc
          push cx
         
         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
                  
next2:                mov ah,func
                inc ah
                cmp ah,07h
                jg  next3
                mov func,ah
                jmp loop1

next3:          mov func,00h
                mov ah,dev
                inc ah
                cmp ah,1fh
                jg  next4
                mov dev,ah
                jmp loop1

next4:          mov func,00h
                mov dev,00h
                mov ah,bus
                inc ah
                cmp ah,0fh
                jg  N1          ;jz or jg
                mov bus,ah
                jmp loop1
        ;************************************************************
        ;************************************************************

N1:                mov   ah,4ch
                int   21h

end             Begin
作者: Chearv     时间: 2006-4-26 19:06
这个程序不错,可惜我太鸟了,看不懂。