?? il.asm
字號:
jc short test_bnc
using_aui:
mov dx, offset cgroup:using_AUI_msg ; Setup message for AUI
jmp short announce_media
test_BNC: ; AUI failed, now try BNC
mov connector, BNC
if CHIP EQ INTEL_82596
LOAD_PORT PLXP_USER_PINS
in al, dx
and al, NOT PLXP_USER_0 AND NOT PLXP_USER_1
out dx, al
else
; debug 82557 code required from Intel to select BNC connector
endif
mov ax,0016h ; Delay about 600 msec for front_end setup
call wait
cmp temp_connector, BNC_CONNECTOR
je short using_bnc
call send_on_connector
jc short test_TPE
using_bnc:
mov dx, offset cgroup:using_10B_2_msg ; Setup message for BNC
jmp short announce_media
test_TPE: ; BNC failed, now try TPE
mov connector, TPE
if CHIP EQ INTEL_82596
LOAD_PORT PLXP_USER_PINS
in al, dx
or al, PLXP_USER_0 OR PLXP_USER_1
out dx, al
else
; debug 82557 code required from Intel to select TPE connector
endif
mov ax,0016h ; Delay about 600 msec for front_end setup
call wait
cmp temp_connector, TPE_CONNECTOR
je short using_tpe
call send_on_connector
jc short default_aui
using_tpe:
mov dx, offset cgroup:using_10B_T_msg ; Setup message for twisted pair
jmp short announce_media
default_aui:
mov connector, AUI ; At this point all connectors have failed
if CHIP EQ INTEL_82596
LOAD_PORT PLXP_USER_PINS
in al, dx ; Use AUI as default connector
or al, PLXP_USER_1
and al, NOT PLXP_USER_0
out dx, al
else
; debug 82557 code required from Intel to select AUI connector
endif
mov dx, offset cgroup:using_AUI_msg ; Setup message for AUI
announce_media:
print_it
ret
do_select_media ENDP
send_on_connector PROC NEAR
mov [di].tx_status, 0h
if CHIP EQ INTEL_82596
mov scb_buff.scb_cbl_add, di
endif
call issue_cmd
mov ax, 1 ; Wait, if necessary, for about 27 msec
call set_timeout
wait_for_send:
mov ax, [di].tx_status
test ax, CB_STATUS_COMPLETE
jnz short send_complete
call do_timeout ; Any more time left ?
jnz short wait_for_send ; Continue to wait if so
if CHIP EQ INTEL_82596
mov scb_buff.scb_command, CU_ABORT ; Abort the command
C_ATTENTION
else
; debug 82557 code required for an ABORT
endif
error_send_on_connector:
stc ; Indicate failure
ret
send_complete:
mov ax, [di].tx_status ; Check if status bits are ok
test ax, CB_STATUS_OK
jz short error_send_on_connector
if CHIP EQ INTEL_82596
test ax, CB_TX_NO_CARRIER_SENSE ; Also need to check for carrier
jnz short error_send_on_connector
else
; debug 82557 code required from INTEL to check for carrier
endif
clc ; Indicate success
ret
send_on_connector ENDP
setup_test_packet PROC NEAR
mov cx, RUNT
lea di, temp_buffer ; Buffer to use for test packets
push di ; Save start address of buffer
mov eax, (EL_BIT + TRANSMIT)*10000h
stosd ; Store the action command word + status word
if CHIP EQ INTEL_82596
mov ax, -1 ; Set the address of next command to NULL
stosw ; Store the link address - next command
stosw ; TBD offset is also null
else
mov eax, -1 ; Set the address of next command to NULL
stosd ; Store the link address - next command
stosd ; TBD offset is also null
endif
mov ax, RUNT OR TX_EOF_BIT ; Set length of data
stosw
if CHIP EQ INTEL_82596
xor ax, ax
else
mov ax, TX_THRESHOLD ; Set TX threshold
endif
stosw
mov si, offset cgroup:rom_address ; Set destination address as us
movsd
movsw
mov si, offset cgroup:rom_address
movsd
movsw
mov ax, RUNT - EADDR_LEN*2 + 2 ; Set packet size (2 * address + size)
stosw
pop di ; Recover start address of buffer
ret
setup_test_packet ENDP
if CHIP EQ INTEL_82557
no_setup_routine:
ret
if 0
dump_phy:
mov bx,0
dump_phy_1:
call read_phy_reg
jnc short dump_phy_2
mov al,'!'
call chrout
jmp short dump_phy_3
dump_phy_2:
call wordout
dump_phy_3:
mov al,' '
call chrout
inc bx
cmp bx,20h
jb dump_phy_1
ret
endif
get_speed_from_phy_82555:
mov bx,16 ; Find speed of link
call read_phy_reg
test ax, 0002h ; Go if autoneg says 100.
mov speed, FAST_100 ; Got a fast link
jne short get_speed_from_phy_82555_1
mov speed, SLOW_10 ; Got a slow link
get_speed_from_phy_82555_1:
ret
get_speed_from_phy_83840:
mov bx,25 ; Find speed of link
call read_phy_reg
test ax, 0040h ; any fast link pulses?
mov speed, FAST_100 ; Assume a fast link
je short get_speed_from_phy_83840_1 ;go if so.
mov speed, SLOW_10 ; Got a slow link
get_speed_from_phy_83840_1:
ret
setup_82555_routine:
mov get_speed_from_phy, offset cgroup:get_speed_from_phy_82555
jmp short into_setup_routine
setup_83840_routine:
mov get_speed_from_phy, offset cgroup:get_speed_from_phy_83840
into_setup_routine:
push bx
mov bx, PHY_CTRL_REG_FAST + PHY_CTRL_REG_AUTO_ENBL
or bx, PHY_CTRL_REG_RESTART_AUTO + PHY_CTRL_REG_FULL
mov bx, 8000h
mov dx,PHY_CONTROL_REG ; Start negotiation
call write_phy_reg
print wait_neg_msg
mov ax, 100h ; Set wait for negotiation
call set_timeout
mov last_timeout, 100h
wait_neg_done:
mov ax, timeout ; The READ_PHY_REG code uses the
mov copy_timeout, ax ; set_timeout code so these 3
mov ax, timeout_counter ; values must be 'saved'
mov copy_timeout_counter, ax
mov ax, timeout_value
mov copy_timeout_value, ax
mov bx,PHY_STATUS_REG ; Check if negotiation completed
call read_phy_reg
test ax, PHY_STA_NWAY_COMPLETE ; Is it done ?
jnz short can_partner_neg ; Jump if so
mov ax, copy_timeout_counter ; Restore the saved values from
mov timeout_counter, ax ; the set_timeout call
mov ax, copy_timeout_value
mov timeout_value, ax
mov ax, copy_timeout
mov timeout, ax
cmp last_timeout, ax ; Display an occasional '.' to
je short no_period ; inform user that driver is still
mov last_timeout, ax ; alive
and ax, 07h
jne short no_period
mov al, '.'
call chrout
no_period:
call do_timeout ; Any more time left ?
jnz short wait_neg_done ; Yes - check again
print negotiation_problem ; Announce problem
jmp short no_negotiation_bits ; Try to continue
can_partner_neg:
call crlf
mov bx,PHY_EXP_REG ; Check if partner can negotiate
call read_phy_reg
test ax, PHY_ANE_LP_AUTONEG
jnz short use_neg_results ; Yes - use results
print no_lp_msg ; Announce no negotiation
no_negotiation_bits:
mov forced_speed_duplex, 0 ; Assume no forced parameters
mov duplex, HALF_DUPLEX ; Default = half duplex
cmp user_duplex, 0 ; Has user specified duplex
je short duplex_set ; Jump if not
mov forced_speed_duplex, 1 ; Record a forced speed/duplex
mov ax, user_duplex ; Get user duplex
mov duplex, ax ; And store
duplex_set:
; call dump_phy
call get_speed_from_phy
cmp user_speed, 0 ; Has user specified speed
je short speed_set ; Jump if not
mov forced_speed_duplex, 1 ; Record a forced speed/duplex
mov ax, user_speed ; Get user speed
mov speed, ax ; And store
speed_set: ; Decide what message to display
xor bx, bx
cmp forced_speed_duplex, 0 ; Check if forced parameters used
je short no_forced_params
mov bx, 04h ; Forced => messages 4-7
no_forced_params:
cmp speed, FAST_100
jne short slow_speed
add bx, 02h
slow_speed:
cmp duplex, FULL_DUPLEX
jne short using_half_duplex
inc bx
using_half_duplex:
sal bx, 1 ; Convert to a word count
mov dx, speed_duplex_msg[bx]
jmp done_83840_speed_duplex
use_neg_results:
mov bx,PHY_ADVERT_REG ; Read our capability
call read_phy_reg
and ax, LINK_ABILITY_BITS ; Ignore other bits
mov cx, ax ; Store for later
mov bx,PHY_LINK_PART_REG ; Read link partner's capability
call read_phy_reg
and ax, LINK_ABILITY_BITS ; Ignore other bits
jnz short get_common_capabilities ; Should have some bits set
print no_neg_bits_msg ; Announce problem
jmp no_negotiation_bits ; Try to continue
get_common_capabilities:
and ax, cx ; Get the common technology
jnz short get_highest_priority ; Should have some bits in common
print no_common_capability ; Announce problem
jmp no_negotiation_bits ; Try to continue
get_highest_priority:
; Apply the priority resolution to the common technolgies
test ax, TX_FULL_BIT
jnz short tx_full
test ax, T4_HALF_BIT
jnz short t4_half
test ax, TX_HALF_BIT
jnz short tx_half
test ax, T_FULL_BIT
jnz short t_full
t_half:
mov speed, SLOW_10
mov duplex, HALF_DUPLEX
mov dx, offset cgroup:t_half_msg
jmp short done_83840_speed_duplex
tx_full:
mov speed, FAST_100
mov duplex, FULL_DUPLEX
mov dx, offset cgroup:tx_full_msg
jmp short done_83840_speed_duplex
t4_half:
mov speed, FAST_100
mov duplex, HALF_DUPLEX
mov dx, offset cgroup:t4_half_msg
jmp short done_83840_speed_duplex
tx_half:
mov speed, FAST_100
mov duplex, HALF_DUPLEX
mov dx, offset cgroup:tx_half_msg
jmp short done_83840_speed_duplex
t_full:
mov speed, SLOW_10
mov duplex, FULL_DUPLEX
mov dx, offset cgroup:t_full_msg
done_83840_speed_duplex:
print_it ; Announce speed / duplex found
mov bx,NSC_CONG_CTRL_REG ; Apply neccessary fixes
call read_phy_reg
mov bx, ax
or bx, NSC_TX_CONG_F_CONNECT ; This bit always needs to be set
cmp duplex, HALF_DUPLEX
je short no_full_duplex_fix
or bx, NSC_TX_CONG_TXREADY ; Needs to be set for full duplex
no_full_duplex_fix:
mov dx,NSC_CONG_CTRL_REG ; Write the fix
call write_phy_reg
pop bx
ret
endif
public find_base
find_base PROC NEAR
call get_pci_info ; Go and search the card
jc short f_b_failed ; Jump if card not found
;get the command register.
mov ah, PCI_FUNCTION_ID ; Get IO base
mov al, READ_PCI_CONFIG_WORD
mov bx, pci_bus_dev_no ; Recover the bus / device number
mov di, COMMAND_REGISTER
int PCI_BIOS_INTERRUPT
cmp ah, PCI_SUCCESSFULL
jne short f_b_failed
;turn on bus master mode.
or cl, CMD_BUS_MASTER + CMD_IO_SPACE + CMD_MEMORY_SPACE
;write it back out again.
mov ah, PCI_FUNCTION_ID ; Get IO base
mov al, WRITE_PCI_CONFIG_WORD
mov di, 4h ;COMMAND_REGISTER
int PCI_BIOS_INTERRUPT
ret
f_b_failed:
mov dx, offset cgroup:scan_failed ; Message to announce later
stc ; Set carry and return
ret
find_base ENDP
get_pci_info PROC NEAR
mov si,slot_no
sub si,16+1 ;specified as 16, we need to be -1.
try_next_index:
inc si ; Start out with index # = 0
mov di,offset cgroup:device_id_list
try_next_device:
mov cx,[di]
add di,2
jcxz error_get_pci_info ; Not found in this slot - exit
mov ah, PCI_FUNCTION_ID
mov al, FIND_PCI_DEVICE
mov dx, VENDOR_ID
mov deviceid, cx
mov vendorid, dx
int PCI_BIOS_INTERRUPT
cmp ah, PCI_SUCCESSFULL
jne try_next_device
mov ah, PCI_FUNCTION_ID ; Get IO base
mov al, READ_PCI_CONFIG_DWORD
mov di, 14h ; Base address register for IO info
int PCI_BIOS_INTERRUPT
cmp ah, PCI_SUCCESSFULL
jne try_next_index
mov pci_bus_dev_no, bx ; Save bus / device number
mov bl, cl ; Check that this base register has IO info
and bl, 03h
cmp bl, 01h ; Check the IO space indicator bits
jne try_next_index ; No - should not happen
and cl, 0FCh ; Mask lower 2 bits of IO address
mov base_addr, cx
mov bx, pci_bus_dev_no ; Recover the bus / device number
mov ah, PCI_FUNCTION_ID ; Get IRQ number
mov al, READ_PCI_CONFIG_BYTE
mov di, 3ch ; PCI register for IRQ info
int PCI_BIOS_INTERRUPT
cmp ah, PCI_SUCCESSFULL
je short got_irq
print irq_problem_msg
stc
jmp try_next_index ; Continue the search.
got_irq:
mov int_no, cl
clc
ret
error_get_pci_info:
stc
ret
get_pci_info ENDP
code ends
_text segment para public 'code'
_text ends
init segment para public 'code'
init ends
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -