📄 pcnet32.inc
字号:
.L5: call dword [pcnet32_access.write_csr] cmp [pcnet32_private.mii],0 je .L6 test [pcnet32_private.options],PCNET32_PORT_ASEL jnz .L6 mov ebx,32 call dword [pcnet32_access.read_bcr] and eax,not 0x38 test [pcnet32_private.options],PCNET32_PORT_FD jz .L7 or eax,0x10.L7: test [pcnet32_private.options],PCNET32_PORT_100 jz .L8 or eax,0x08.L8: call dword [pcnet32_access.write_bcr] jmp .L9.L6: test [pcnet32_private.options],PCNET32_PORT_ASEL jz .L9 mov ebx,32; PutStr "ASEL, enable auto-negotiation" call dword [pcnet32_access.read_bcr] and eax,not 0x98 or eax,0x20 call dword [pcnet32_access.write_bcr].L9: cmp [pcnet32_private.ltint],0 je .L10 mov ebx,5 call dword [pcnet32_access.read_csr] or eax,(1 shl 14) call dword [pcnet32_access.write_csr].L10: mov eax,[pcnet32_private.options] and eax,PCNET32_PORT_PORTSEL shl eax,7 mov [pcnet32_private.mode],ax mov [pcnet32_private.filter],dword 0xffffffff mov [pcnet32_private.filter+4],dword 0xffffffff call pcnet32_init_ring mov ebx,1 mov eax,pcnet32_private and eax,0xffff call dword [pcnet32_access.write_csr] mov eax,pcnet32_private mov ebx,2 shr eax,16 call dword [pcnet32_access.write_csr] mov ebx,4 mov eax,0x0915 call dword [pcnet32_access.write_csr] mov ebx,0 mov eax,1 call dword [pcnet32_access.write_csr] mov ecx,100.L11: xor ebx,ebx call dword [pcnet32_access.read_csr] test ax,0x100 jnz .L12 loop .L11.L12:; PutStr "hardware reset" xor ebx,ebx mov eax,0x0002 call dword [pcnet32_access.write_csr] xor ebx,ebx call dword [pcnet32_access.read_csr]; PutStr "PCNET reset complete" retpcnet32_adjust_pci_device: ;*******Get current setting************************ mov al, 2 ;read a word mov bh, [pci_dev] mov ah, [pci_bus] mov bl, 0x04 ;from command Register call pci_read_reg ;******see if its already set as bus master******** mov bx, ax and bx,5 cmp bx,5 je pcnet32_adjust_pci_device_Latency ;******Make card a bus master******* mov cx, ax ;value to write mov bh, [pci_dev] mov al, 2 ;write a word or cx,5 mov ah, [pci_bus] mov bl, 0x04 ;to command register call pci_write_reg ;******Check latency setting***********pcnet32_adjust_pci_device_Latency: ;*******Get current latency setting************************; mov al, 1 ;read a byte; mov bh, [pci_dev]; mov ah, [pci_bus]; mov bl, 0x0D ;from Lantency Timer Register; call pci_read_reg ;******see if its aat least 64 clocks********; cmp ax,64; jge pcnet32_adjust_pci_device_Done ;******Set latency to 32 clocks*******; mov cx, 64 ;value to write; mov bh, [pci_dev]; mov al, 1 ;write a byte; mov ah, [pci_bus]; mov bl, 0x0D ;to Lantency Timer Register; call pci_write_reg ;******Check latency setting***********pcnet32_adjust_pci_device_Done: retpcnet32_probe: mov ebp,[io_addr] call pcnet32_wio_reset xor ebx,ebx call pcnet32_wio_read_csr cmp eax,4 jne .try_dwio call pcnet32_wio_check and al,al jz .try_dwio; PutStr "Using WIO" mov esi,pcnet32_wio jmp .L1.try_dwio: call pcnet32_dwio_reset xor ebx,ebx call pcnet32_dwio_read_csr cmp eax,4 jne .no_dev call pcnet32_dwio_check and al,al jz .no_dev; PutStr "Using DWIO" mov esi,pcnet32_dwio jmp .L1.no_dev:; PutStr "PCNET32 not found" ret.L1: mov edi,pcnet32_access mov ecx,7 cld rep movsd mov ebx,88 call dword [pcnet32_access.read_csr] mov ecx,eax mov ebx,89 call dword [pcnet32_access.read_csr] shl eax,16 or eax,ecx mov ecx,eax and ecx,0xfff cmp ecx,3 jne .no_dev shr eax,12 and eax,0xffff mov [pcnet32_private.chip_version],eax; PutStr "PCNET32 chip version OK" mov [pcnet32_private.fdx],0 mov [pcnet32_private.mii],0 mov [pcnet32_private.fset],0 mov [pcnet32_private.dxsuflo],0 mov [pcnet32_private.ltint],0 mov eax,[pcnet32_private.chip_version] cmp eax,0x2420 je .L2 cmp eax,0x2430 je .L3 cmp eax,0x2621 je .L4 cmp eax,0x2623 je .L5 cmp eax,0x2624 je .L6 cmp eax,0x2625 je .L7 cmp eax,0x2626 je .L8 cmp eax,0x2627 je .L9; PutStr "Invalid chip rev" jmp .no_dev.L2:; PutStr "PCnet/PCI 79C970" jmp .L10.L3:; PutStr "PCnet/PCI 79C970" jmp .L10.L4:; PutStr "PCnet/PCI II 79C970A" mov [pcnet32_private.fdx],1 jmp .L10.L5:; PutStr "PCnet/FAST 79C971" mov [pcnet32_private.fdx],1 mov [pcnet32_private.mii],1 mov [pcnet32_private.fset],1 mov [pcnet32_private.ltint],1 jmp .L10.L6:; PutStr "PCnet/FAST+ 79C972" mov [pcnet32_private.fdx],1 mov [pcnet32_private.mii],1 mov [pcnet32_private.fset],1 jmp .L10.L7:; PutStr "PCnet/FAST III 79C973" mov [pcnet32_private.fdx],1 mov [pcnet32_private.mii],1 jmp .L10.L8:; PutStr "PCnet/Home 79C978" mov [pcnet32_private.fdx],1 mov ebx,49 call dword [pcnet32_access.read_bcr] call dword [pcnet32_access.write_bcr] jmp .L10.L9:; PutStr "PCnet/FAST III 79C975" mov [pcnet32_private.fdx],1 mov [pcnet32_private.mii],1.L10: cmp [pcnet32_private.fset],1 jne .L11 mov ebx,18 call dword [pcnet32_access.read_bcr] or eax,0x800 call dword [pcnet32_access.write_bcr] mov ebx,80 call dword [pcnet32_access.read_csr] and eax,0xc00 or eax,0xc00 call dword [pcnet32_access.write_csr] mov [pcnet32_private.dxsuflo],1 mov [pcnet32_private.ltint],1.L11: ; read MAC mov edi,node_addr mov edx,ebp mov ecx,6.Lmac: in al,dx stosb inc edx loop .Lmac; PutStr "MAC read" call pcnet32_adjust_pci_device; PutStr "PCI done" mov eax,PCNET32_PORT_ASEL mov [pcnet32_private.options],eax mov [pcnet32_private.mode],word 0x0003 mov [pcnet32_private.tlen_rlen],word (PCNET32_TX_RING_LEN_BITS or PCNET32_RX_RING_LEN_BITS) mov esi,node_addr mov edi,pcnet32_private.phys_addr cld movsd movsw mov [pcnet32_private.filter],dword 0 mov [pcnet32_private.filter+4],dword 0 mov dword [pcnet32_private.rx_ring],pcnet32_rx_ring mov dword [pcnet32_private.tx_ring],pcnet32_tx_ring; PutStr "Switching to 32" mov ebx,20 mov eax,2 call dword [pcnet32_access.write_bcr] mov ebx,1 mov eax,(pcnet32_private and 0xffff) call dword [pcnet32_access.write_csr] mov ebx,2 mov eax,(pcnet32_private shr 16) and 0xffff call dword [pcnet32_access.write_csr] mov ebx,0 mov eax,1 call dword [pcnet32_access.write_csr] mov esi,1 call delay_ms call pcnet32_reset mov eax, [pci_data] mov [eth_status], eax retpcnet32_poll: xor eax,eax mov [eth_rx_data_len],ax mov eax,[pcnet32_private.cur_rx] and eax,PCNET32_RX_RING_MOD_MASK mov ebx,eax imul esi,eax,PCNET32_PKT_BUF_SZ add esi,pcnet32_rxb shl ebx,4 add ebx,pcnet32_rx_ring mov cx,[ebx+pcnet32_rx_head.status] test cx,0x8000 jnz .L1 cmp ch,3 jne .L1; PutStr "PCNETRX" mov ecx,[ebx+pcnet32_rx_head.msg_length] and ecx,0xfff sub ecx,4 mov [eth_rx_data_len],cx push ecx shr ecx,2 mov edi,Ether_buffer cld rep movsd pop ecx and ecx,3 rep movsb mov [ebx+pcnet32_rx_head.buf_length],word PCNET32_PKT_BUF_SZ_NEG or [ebx+pcnet32_rx_head.status],word 0x8000 inc [pcnet32_private.cur_rx].L1: ret; Pointer to 48 bit destination address in edi; Type of packet in bx; size of packet in ecx; pointer to packet data in esipcnet32_xmit: push edi push esi push ebx push ecx; PutStr "PCNETTX" mov esi,edi mov edi,[pcnet32_private.cur_tx] imul edi,PCNET32_PKT_BUF_SZ add edi,pcnet32_txb ; edi=ptxb mov eax,edi cld ; copy MAC movsd movsw mov esi,node_addr cld movsd movsw mov [edi],bx add edi,2 mov esi,[esp+8] mov ecx,[esp] push ecx shr ecx,2 cld rep movsd pop ecx and ecx,3 rep movsb; mov ecx,[esp]; add ecx,14 ; ETH_HLEN; xor eax,eax; pad to min length (60=ETH_ZLEN); cmp ecx,60; jae .L1; sub ecx,60; cld; rep stosb;.L1: mov edi,pcnet32_tx_ring+0 ; entry=0 mov ecx,[esp] add ecx,14 cmp cx,60 jae .L1 mov cx,60.L1: neg cx mov [edi+pcnet32_tx_head.length],cx mov [edi+pcnet32_tx_head.misc],dword 0 mov [edi+pcnet32_tx_head.base],eax mov [edi+pcnet32_tx_head.status],word 0x8300 ; trigger an immediate send poll mov ebx,0 mov eax,0x0008 ; 0x0048 mov ebp,[io_addr] call dword [pcnet32_access.write_csr] mov dword [pcnet32_private.cur_tx],0 ; wait for TX to complete mov ecx,[0xfdf0] add ecx,100.L2: mov ax,[edi+pcnet32_tx_head.status] test ax,0x8000 jz .L3 cmp ecx,[0xfdf0] jb .L4 mov esi,10 call delay_ms jnz .L2.L4:; PutStr "PCNET: Send timeout".L3: mov dword [edi+pcnet32_tx_head.base],0 pop ecx pop ebx pop esi pop edi ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -