📄 pci.inc
字号:
lea si,PCIBusNoBuf
mov ds:[si],bl
mov dl,HeaderPosCol+2bh-17h
call CalaFixedCursorposn ; Ouput=ax
call GetFixCursorValue ; BL=value
lea si,PCIDevFuncNoBuf
shl bl,3
mov ds:[si],bl
mov dl,HeaderPosCol+2fh-17h
call CalaFixedCursorposn ; Ouput=ax
call GetFixCursorValue ; BL=value
lea si,PCIDevFuncNoBuf
mov al,ds:[si]
or al,bl
mov ds:[si],al
ret
;-------------------------------------------------------;
; ReadPciReg ;
; Input :EAX=Bus/Dev/Func/Reg ;
; BH =0/1/2 Byte/Word/Dword ;
; Ouput :AL/AX/EAX =Value of read ;
;-------------------------------------------------------;
ReadPciReg:
push dx
push ax
and al,0fch
or eax,80000000h
mov dx,0cf8h
out dx,eax
mov dl,0fch
pop ax
and al,03h
add dl,al
cmp bh,0
jz ReadByte
cmp bh,1
jz ReadWord
cmp bh,2
jz ReadDword
ReadByte:
in al,dx
jmp short ExitReadPciReg
ReadWord:
in ax,dx
jmp short ExitReadPciReg
ReadDword:
in eax,dx
ExitReadPciReg:
pop dx
ret
;-------------------------------------------------------;
; WritePciReg ;
; Input :EAX=Bus/Dev/Func/Reg ;
; BH =0/1/2 Byte/Word/Dword ;
; CL/CX/ECX=Data to write ;
;--------------------------------------------------------;
WritePciReg:
push dx
push ax
and al,0fch
or eax,80000000h
mov dx,0cf8h
out dx,eax
mov dl,0fch
pop ax
and al,03h
add dl,al
mov eax,ecx
cmp bh,0
jz WriteByte
cmp bh,1
jz WriteWord
cmp bh,2
jz WriteDword
WriteByte:
out dx,al
jmp short ExitWritePciReg
WriteWord:
out dx,ax
jmp short ExitWritePciReg
WriteDword:
out dx,eax
ExitWritePciReg:
pop dx
ret
;---------------------------------------
;Input : BL
PCIDeviceRead:
xor edx,edx
lea si,PCIBusNo
mov dh,ds:[si]
lea si,PCIDevFuncNo
mov dl,ds:[si]
shl edx,8
or dl,bl
mov eax,edx
lea si,AccessMethod
mov bh,ds:[si]
call ReadPciReg
ret
;---------------------------------------
;Input : BL/BX/EBX=DATA
; CH=reg
PCIDeviceWrite:
push eax
push edx
lea si,PCIBusNo
mov dh,ds:[si]
lea si,PCIDevFuncNo
mov dl,ds:[si]
shl edx,8
or dl,ch
mov ecx,ebx ; CL=DATA
mov eax,edx
lea si,AccessMethod
mov bh,ds:[si]
call WritePciReg
pop edx
pop eax
ret
;---------------------------------------
SearchPCIDevice:
lea si,PCIBusNoBuf
mov al,0
mov ds:[si],al
lea si,PCIDevFuncNoBuf
mov ds:[si],al
LoopSearchPCIDevice:
xor eax,eax
;;>>>K.W. Thu 01-31-2002 11:03:55
push dx
push ax
call GetCursor
mov dl,HeaderPosCol+26h-17h
cmp dx,MaxPCIDeviceWindown
pop ax
pop dx
jae SearchPCILIstEnd
;;<<<K.W. Thu 01-31-2002 11:03:57
LoopSearchPCIDevice1:
xor eax,eax
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
lea di,PCIBusNoBuf
mov ah,ds:[di]
shl eax,8
mov bh,1
call ReadPciReg
cmp ax,00000h
jz PCIListNextFunc
cmp ax,0ffffh
jz PCIListNextFunc
call CheckMultiFunction
jnc PCIListDevFound
PCIListNextFunc:
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
inc al
mov ds:[di],al
cmp al,0
jz NextListBus
jmp LoopSearchPCIDevice
NextListBus:
lea di,PCIBusNoBuf
mov al,ds:[di]
inc al
cmp al,10h
jz SearchPCILIstEnd
and al,0fh
mov ds:[di],al
jmp LoopSearchPCIDevice
PCIListDevFound:
call GetSetListCursorAttr
lea si,MiddleEdgeLine
call DisplayString
call DisplayFixedPCIAddressN
call GetCursor
add dl,2
call SetCursor
push dx
mov cx,dx
mov dx,cx
add dl,51
mov bh,Cyan+LightColor
call SetWindowsAttribute
pop dx
inc dl
call SetCursor
call DisplayClassCode
mov al,0ffh
jmp PCIListNextFunc
SearchPCILIstEnd:
call GetSetListCursorAttr
dec dh
mov dl,HeaderPosCol+26h-17h
lea si,LasPCIListDev
mov ds:[si],dx
lea si,BottomEdgeLine
call DisplayString
ret
;---------------------------------------
DisplayFixedPCIAddress:
mov dx,PCIBusNoPosn-1
call SetCursor
lea di,PCIBusNoBuf
mov al,ds:[di]
call DisplayHex
mov dx,PCIDevNoPosn-1
call SetCursor
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
shr al,3
call DisplayHex
mov dx,PCIFuncNoPosn-1
call SetCursor
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
and al,07h
call DisplayHex
ret
;---------------------------------------
DisplayFixedPCIAddressN:
mov dl,HeaderPosCol+27h-17h
call SetCursor
lea di,PCIBusNoBuf
mov al,ds:[di]
call DisplayHex
mov dl,HeaderPosCol+2bh-17h
call SetCursor
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
shr al,3
call DisplayHex
mov dl,HeaderPosCol+2fh-17h
call SetCursor
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
and al,07h
call DisplayHex
ret
;---------------------------------------
GetSetListCursorAttr:
call GetCursor
mov dl,HeaderPosCol+25h-17h
inc dh
mov cx,dx
add dx,0dh
mov bh,PCIListWindowColor
push cx
call SetWindowsAttribute
pop cx
mov dx,cx
call SetCursor
ret
;--------------------------
CheckMultiFunction:
xor eax,eax
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
test al,07h
jz DifferentDevice
lea di,PCIBusNoBuf
mov ah,ds:[di]
and al,0f8h
shl eax,8
or al,0eh
mov bh,0
call ReadPciReg
test al,80h
jz SingleFunctionDev
DifferentDevice:
clc
ret
SingleFunctionDev:
stc
ret
comment \
xor eax,eax
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
test al,07h
jz DifferentDevice
mov cx,16
CheckSameDeviceLoop:
push cx
dec cx
shl cx,2
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
lea di,PCIBusNoBuf
mov ah,ds:[di]
and al,0f8h
shl eax,8
or al,cl
mov bh,2
call ReadPciReg
push eax
xor eax,eax
lea di,PCIDevFuncNoBuf
mov al,ds:[di]
lea di,PCIBusNoBuf
mov ah,ds:[di]
shl eax,8
or al,cl
mov bh,2
call ReadPciReg
pop ebx
pop cx
cmp eax,ebx
jnz DifferentDevice
loop CheckSameDeviceLoop
stc
ret
DifferentDevice:
clc
\
ret
;---------------------------------------
GetPciAddressFromScreen:
pusha
mov dx,PCIBusNoPosn
call CalaFixedCursorposn ;Ouput=AX
mov cx,2
call GetPortAddressFromScreen
lea si,PCIBusNoBuf
mov ds:[si],al
lea si,PCIBusNo
mov ds:[si],al
mov dx,PCIDevNoPosn
call CalaFixedCursorposn ;Ouput=AX
mov cx,2
call GetPortAddressFromScreen
shl ax,3
lea si,PCIDevFuncNoBuf
mov ds:[si],al
mov dx,PCIFuncNoPosn
call CalaFixedCursorposn ;Ouput=AX
mov cx,2
call GetPortAddressFromScreen
lea si,PCIDevFuncNoBuf
mov bl,ds:[si]
or al,bl
mov ds:[si],al
lea si,PCIDevFuncNo
mov ds:[si],al
popa
ret
;---------------------------------------
DisplayPCIDeviceInformation:
pushad
call DisplayVendorName
call DisplayClassCode
mov ax,53
call ClearClassLine
call DisplayMorePCIInfo
popad
ret
;--------------------
DisplayMorePCIInfo:
mov cx,PCIonitorTiltePosn
mov dx,cx
add dl,22
mov bh,(Cyan shl 4)+Red
call ChangeWindowsAttribute
mov dx,PCIonitorTiltePosn
call SetCursor
lea si,PCIInfo
call DisplayString
mov cx,PCIonitorTiltePosn+0100h
mov dx,cx
add dl,22
add dh,NO_MorePciDeviceInfoTBL-1
mov bh,(Blue shl 4)+White
call ChangeWindowsAttribute
mov dx,PCIonitorTiltePosn+0100h
mov di,offset cs:MorePciDeviceInfoTBL
mov cx,NO_MorePciDeviceInfoTBL
LoopDisplayMorePCIInfo:
push cx
push dx
call SetCursor
mov si,cs:[di+4]
call DisplayString
lea si,PCIBusNo
xor eax,eax
mov ah,ds:[si]
lea si,PCIDevFuncNo
mov al,ds:[si]
shl eax,8
or al,cs:[di]
mov bh,cs:[di+2]
call ReadPCIReg
mov bh,cs:[di+2]
cmp bh,0
jz DisplayByte
cmp bh,1
jz DisplayWord
rol eax,8
call DisplayHex
rol eax,8
call DisplayHex
rol eax,8
call DisplayHex
rol eax,8
jmp short DisplayByte
DisplayWord:
xchg ah,al
call DisplayHex
xchg ah,al
DisplayByte:
call DisplayHex
pop dx
add di,8
inc dh
pop cx
loop LoopDisplayMorePCIInfo
ret
;--------------------
DisplayClassCode:
lea si,PCIBusNoBuf
xor eax,eax
mov ah,ds:[si]
lea si,PCIDevFuncNoBuf
mov al,ds:[si]
shl eax,8
or al,08h
mov bh,2
call ReadPciReg ; Output = eax
lea si,PCIClaseCodeDisplay
FindClassCodeAgain:
mov ebx,dword ptr ds:[si]
cmp ebx,0ffffffffh
jz ClassCodeNotFound
and eax,0ffffff00h
push eax
mov edx,ebx
and edx,0000ff00h
cmp edx,0000ff00h
jnz CompareClassCode
or eax,0000ff00h
CompareClassCode:
cmp eax,ebx
pop eax
jz ClassCodeFound
add si,4
LoopPointNextClassCode:
push eax
mov al,ds:[si]
inc si
cmp al,00h
pop eax
jz FindClassCodeAgain
jmp short LoopPointNextClassCode
ClassCodeFound:
add si,4
call DisplayString
ClassCodeNotFound:
ret
;--------------------
;Input:al
ClearClassLine:
push ax
call GetCursor
mov cx,dx
pop ax
sub al,cl
add dl,al
mov bh,Green
call ClearWindowsCharAttribute
ret
;--------------------
DisplayVendorName:
mov cx,PCIClaassCodePosn
mov dx,cx
add dl,50
mov bh,Green+LightColor
call ChangeWindowsAttribute
mov dx,PCIClaassCodePosn
call SetCursor
lea si,PCIBusNo
xor eax,eax
mov ah,ds:[si]
lea si,PCIDevFuncNo
mov al,ds:[si]
shl eax,8
mov bh,1
call ReadPciReg ; Output = ax
lea si,PCIVendorDisplay
FindVendorIDAgain:
mov bx,word ptr ds:[si]
cmp bx,0ffffh
jz EndFVendor
cmp ax,bx
jz VendorFound
add si,2
LoopPointNextVendor:
push ax
mov al,ds:[si]
inc si
cmp al,00h
pop ax
jz FindVendorIDAgain
jmp short LoopPointNextVendor
VendorFound:
add si,2
call DisplayString
mov al,' '
call DisplayChar
ret
EndFVendor:
ret
;-------------------
CheckPME:
ret
;-------------------
MorePciDeviceInfoTBL label byte
; REG String
dw 0000h, 1, offset ds:PCIVenID, 00h
dw 0002h, 1, offset ds:PCIDevID, 00h
dw 0008h, 0, offset ds:PCIRevID, 00h
dw 000dh, 0, offset ds:PCILatency, 00h
dw 002ch, 1, offset ds:PCISVenDevID, 00h
dw 002eh, 1, offset ds:PCISDevID, 00h
dw 0010h, 2, offset ds:PCIBA0, 00h
dw 0014h, 2, offset ds:PCIBA1, 00h
dw 0018h, 2, offset ds:PCIBA2, 00h
dw 001ch, 2, offset ds:PCIBA3, 00h
dw 0020h, 2, offset ds:PCIBA4, 00h
dw 0024h, 2, offset ds:PCIBA5, 00h
dw 0030h, 2, offset ds:PCIEXTRom, 00h
dw 003ch, 0, offset ds:PCIIRQ, 00h
dw 003dh, 0, offset ds:PCIPin, 00h
dw 003eh, 0, offset ds:PCIMinG, 00h
dw 003fh, 0, offset ds:PCIMaxL, 00h
dw 0034h, 0, offset ds:PCIPME, offset cs:CheckPME
NO_MorePciDeviceInfoTBL equ ($ - offset cs:MorePciDeviceInfoTBL)/8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -