📄 pcibus.asm
字号:
;*****************************************************************************
;* PCI BUS ACCESS UTILITY FOR ACCTON EN1207B-TX 4 PCI CARD
;*
;* Author Lee Pao-Sheng
;*
;* Tool: MASM 6.10
;*
;* Release Note
;*
;* 03-11-1998 v1.00 Pre-release
;*****************************************************************************
include pcibus.inc
include macro.inc
.model small
.386
.data
;*************************
;* Data Segment *
;*************************
PCI_Access_Mechanism db 1
Address dd ?
Value dd ?
CSR9_Port dw ?
ReadPCIConfigDword dw Offset ReadPCIConfigDwordM1
ReadPCIConfigWord dw Offset ReadPCIConfigWordM1
ReadPCIConfigByte dw Offset ReadPCIConfigByteM1
WritePCIConfigDword dw Offset WritePCIConfigDwordM1
WritePCIConfigWord dw Offset WritePCIConfigWordM1
WritePCIConfigByte dw Offset WritePCIConfigByteM1
SearchPCIClassCode dw Offset SearchPCIClassCodeM1
SearchPCIDevice dw Offset SearchPCIDeviceM1
.code
Public VerifyPCIBusAccessMechanism
Public find_device_using_class_code
Public find_en1207_card
Public open_en1207_card
Public enable_en1207_card
Public open_bridge_card
Public enable_bridge_card
Public find_nic
;******************************************************************************
;* Delay1ms()
;*
;* On Entry:
;*
;* On Return: all regsiter reserved
;*
;******************************************************************************
Delay1ms proc near
push cx
mov cx, 100
@D1mLoop:
call Delay10us
loop @D1mLoop
pop cx
ret
Delay1ms endp
;******************************************************************************
;* Delay10us()
;*
;* On Entry:
;*
;* On Return: all regsiter reserved
;*
;******************************************************************************
Delay10us proc near
push word ptr 24 ;Push delay count
call Delay
add sp, 2 ;Get rid of the parameter
ret
Delay10us endp
;******************************************************************************
;* Delay1us()
;*
;* On Entry:
;*
;* On Return: all regsiter reserved
;*
;******************************************************************************
Delay1us proc near
push word ptr 2 ;Push delay count
call Delay
add sp, 2 ;Get rid of the parameter
ret
Delay1us endp
;******************************************************************************
;* Delay()
;*
;* On Entry:
;*
;* On Return: all regsiter reserved
;*
;******************************************************************************
Delay proc near
push bp ;Save BP
mov bp, sp
push ax
push bx
push cx
call ReadTickCounter ;Get initial value
mov bx, ax ;Save start value
@DwaitLoop:
call ReadTickCounter
mov cx, bx
sub cx, ax
cmp cx, [bp + 4]
jb @DwaitLoop
pop cx
pop bx
pop ax
pop bp
ret
Delay endp
;******************************************************************************
;* ReadTickCounter()
;*
;* On Entry:
;*
;* On Return: all regsiter reserved
;*
;******************************************************************************
ReadTickCounter proc near
mov al, 06h
out 43h, al ;Command 8254 to latch T0's count
in al, 40h ;Read LSB first (NEC)
mov ah, al
in al, 40h ;Read MSB (NEC)
xchg al, ah ;Get in proper order
ret
ReadTickCounter endp
;******************************************************************************
;* VerifyPCIBusAccessMechanism()
;*
;* On Entry:
;*
;* On Return: all regsiter reserved
;*
;******************************************************************************
VerifyPCIBusAccessMechanism proc near C
push eax
push edx
mov PCI_Access_Mechanism, 1
mov dx, PCI_ENABLE_REGISTER
in al, dx
push ax
mov al, 0Eh
out dx, al
SLOW
in al, dx
cmp al, 0Eh
pop ax
jne @Vpbam_M1
mov PCI_Access_Mechanism, 2
;Update All PCI Access Routine Pointer
;-------------------------------------
mov ax, Offset ReadPCIConfigDwordM2
mov ReadPCIConfigDword, ax
mov ax, Offset ReadPCIConfigWordM2
mov ReadPCIConfigWord, ax
mov ax, Offset ReadPCIConfigByteM2
mov ReadPCIConfigByte, ax
mov ax, Offset WritePCIConfigDwordM2
mov WritePCIConfigDword, ax
mov ax, Offset WritePCIConfigWordM2
mov WritePCIConfigWord, ax
mov ax, Offset WritePCIConfigByteM2
mov WritePCIConfigByte, ax
mov ax, Offset SearchPCIClassCodeM2
mov SearchPCIClassCode, ax
mov ax, Offset SearchPCIDeviceM2
mov SearchPCIDevice, ax
jmp @Vpbam_Exit
@Vpbam_M1:
@Vpbam_Exit:
pop edx
pop eax
ret
VerifyPCIBusAccessMechanism endp
;******************************************************************************
;* ReadPCIConfigDwordM1()
;*
;* On Entry: BX: bus number + device number + function number
;* ---------- ------------- ---------------
;* bit 15:8 bit 7:3 bit 2:0
;*
;* CL: register offset (should be DWORD alignment)
;*
;* On Return: EAX hold the value
;*
;******************************************************************************
ReadPCIConfigDwordM1 proc near
push edx
movzx eax, bx
shl eax, 8 ;specify bus, device, function #
or al, cl ;specify the register #
and al, 0FCh ;make it 4-byte alignment
or eax, 80000000h ;enable configuration cycle
mov dx, PCI_CONFIG_ADDRESS_REGISTER
out dx, eax
mov dx, PCI_CONFIG_DATA_REGISTER
in eax, dx
pop edx
ret
ReadPCIConfigDwordM1 endp
;******************************************************************************
;* ReadPCIConfigWordM1()
;*
;* On Entry: BX: bus number + device number + function number
;* ---------- ------------- ---------------
;* bit 15:8 bit 7:3 bit 2:0
;*
;* CL: register offset (should be WORD alignment)
;*
;* On Return: AX hold the value
;*
;******************************************************************************
ReadPCIConfigWordM1 proc near
push edx
movzx eax, bx
shl eax, 8 ;specify bus, device, function #
or al, cl ;specify the register #
and al, 0FCh ;make it 4-byte alignment
or eax, 80000000h ;enable configuration cycle
mov dx, PCI_CONFIG_ADDRESS_REGISTER
out dx, eax
mov dx, PCI_CONFIG_DATA_REGISTER
mov ax, cx
and ax, 03h
add dx, ax
in ax, dx
pop edx
ret
ReadPCIConfigWordM1 endp
;******************************************************************************
;* ReadPCIConfigByteM1()
;*
;* On Entry: BX: bus number + device number + function number
;* ---------- ------------- ---------------
;* bit 15:8 bit 7:3 bit 2:0
;*
;* CL: register offset
;*
;* On Return: AL hold the value
;*
;******************************************************************************
ReadPCIConfigByteM1 proc near
push edx
movzx eax, bx
shl eax, 8 ;specify bus, device, function #
or al, cl ;specify the register #
and al, 0FCh ;make it 4-byte alignment
or eax, 80000000h ;enable configuration cycle
mov dx, PCI_CONFIG_ADDRESS_REGISTER
out dx, eax
mov dx, PCI_CONFIG_DATA_REGISTER
mov ax, cx
and ax, 03h
add dx, ax
in al, dx
pop edx
ret
ReadPCIConfigByteM1 endp
;******************************************************************************
;* WritePCIConfigDwordM1()
;*
;* On Entry: EAX: value
;* BX: bus number + device number + function number
;* ---------- ------------- ---------------
;* bit 15:8 bit 7:3 bit 2:0
;*
;* CL: register offset (should be DWORD alignment)
;*
;* On Return:
;*
;******************************************************************************
WritePCIConfigDwordM1 proc near
push edx
push eax
movzx eax, bx
shl eax, 8 ;specify bus, device, function #
or al, cl ;specify the register #
and al, 0FCh ;make it 4-byte alignment
or eax, 80000000h ;enable configuration cycle
mov dx, PCI_CONFIG_ADDRESS_REGISTER
out dx, eax
pop eax ;restore the value
mov dx, PCI_CONFIG_DATA_REGISTER
out dx, eax
pop edx
ret
WritePCIConfigDwordM1 endp
;******************************************************************************
;* WritePCIConfigWordM1()
;*
;* On Entry: AX: value
;* BX: bus number + device number + function number
;* ---------- ------------- ---------------
;* bit 15:8 bit 7:3 bit 2:0
;*
;* CL: register offset (should be WORD alignment)
;*
;* On Return:
;*
;******************************************************************************
WritePCIConfigWordM1 proc near
push edx
push ax ;reserved the value
movzx eax, bx
shl eax, 8 ;specify bus, device, function #
or al, cl ;specify the register #
and al, 0FCh ;make it 4-byte alignment
or eax, 80000000h ;enable configuration cycle
mov dx, PCI_CONFIG_ADDRESS_REGISTER
out dx, eax
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -