⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sis900.inc

📁 MenuetOS是一个用汇编开发的32/64位PC操作系统
💻 INC
📖 第 1 页 / 共 3 页
字号:
   mov      eax, [pci_data]   mov      [eth_status], eax   ret   ;***************************************************************************; Function: sis_init_rxfilter;; Description: sets receive filter address to our MAC address;; Arguments:;; returns:;done+;***************************************************************************SIS900_init_rxfilter:   ;****Get Receive Filter Control Register ********   mov      ebp, [io_addr]	    ; base address   lea      edx,[ebp+SIS900_rfcr]   in       eax, dx			    ; get register   push     eax   ;****disable packet filtering before setting filter*******   mov      eax, SIS900_RFEN    ;move receive filter enable flag   not      eax			        ;1s complement   pop      ebx			        ;and with our saved register   and      eax, ebx			;disable receiver   push     ebx                 ;save filter for another use   out      dx, eax		        ;set receive disabled   ;********load MAC addr to filter data register*********   xor      ecx, ecxSIS900_RXINT_Mac_Write:   ;high word of eax tells card which mac byte to write   mov      eax, ecx					   lea      edx,[ebp+SIS900_rfcr]   shl      eax, 16						;   out      dx, eax						;   lea      edx,[ebp+SIS900_rfdr]   mov      ax,  word [node_addr+ecx*2] ; Get Mac ID word   out      dx, ax						; Send Mac ID   inc      cl							; send next word   cmp      cl, 3						; more to send?   jne      SIS900_RXINT_Mac_Write   ;********enable packet filitering *****   pop      eax				    ;old register value   lea      edx,[ebp+SIS900_rfcr]   or       eax, SIS900_RFEN    ;enable filtering   out      dx, eax             ;set register   ret;***************************************************************************;*;* Function: sis_init_txd;*;* Description: initializes the Tx descriptor;*;* Arguments:;*;* returns:;*done;***************************************************************************SIS900_init_txd:   ;********** initialize TX descriptor **************   mov     [txd], dword 0       ;put link to next descriptor in link field   mov     [txd+4],dword 0      ;clear status field   mov     [txd+8], dword txb	;save address to buffer ptr field   ;*************** load Transmit Descriptor Register ***************   mov     dx, [io_addr]	    ; base address   add     dx, SIS900_txdp      ; TX Descriptor Pointer   mov     eax, txd			    ; First Descriptor   out     dx, eax				; move the pointer   ret;***************************************************************************;* Function: sis_init_rxd;*;* Description: initializes the Rx descriptor ring;*;* Arguments:;*;* Returns:;*done;***************************************************************************SIS900_init_rxd:   xor      ecx,ecx   mov      [cur_rx], cl					;Set cuurent rx discriptor to 0   ;******** init RX descriptors ********SIS900_init_rxd_Loop:    mov     eax, ecx					    ;current descriptor    imul    eax, 12                         ;    mov     ebx, ecx					    ;determine next link descriptor    inc     ebx                             ;    cmp     ebx, NUM_RX_DESC                ;    jne     SIS900_init_rxd_Loop_0          ;    xor     ebx, ebx                        ;SIS900_init_rxd_Loop_0:                    ;    imul    ebx, 12                         ;    add     ebx, rxd                        ;    mov     [rxd+eax], ebx					;save link to next descriptor    mov     [rxd+eax+4],dword RX_BUFF_SZ	;status bits init to buf size    mov     ebx, ecx						;find where the buf is located    imul    ebx,RX_BUFF_SZ                  ;    add     ebx, rxb                        ;    mov     [rxd+eax+8], ebx				;save buffer pointer    inc     ecx							    ;next descriptor    cmp     ecx, NUM_RX_DESC                ;    jne     SIS900_init_rxd_Loop            ;    ;********* load Receive Descriptor Register with address of first     ; descriptor*********    mov     dx, [io_addr]    add     dx, SIS900_rxdp    mov     eax, rxd    out     dx, eax    ret;***************************************************************************;* Function: sis900_set_tx_mode;*;* Description:;*    sets the transmit mode to allow for full duplex;*;*;* Arguments:;*;* Returns:;*;* Comments:;*     If you are having problems transmitting packet try changing the;*     Max DMA Burst, Possible settings are as follows:;*         0x00000000 = 512 bytes;*         0x00100000 = 4 bytes;*         0x00200000 = 8 bytes;*         0x00300000 = 16 bytes;*         0x00400000 = 32 bytes;*         0x00500000 = 64 bytes;*         0x00600000 = 128 bytes;*         0x00700000 = 256 bytes;***************************************************************************SIS900_set_tx_mode:   mov      ebp,[io_addr]   lea      edx,[ebp+SIS900_cr]   in 	    eax, dx			    ; Get current Command Register   or 	    eax, SIS900_TxENA   ;Enable Receive   out 	    dx, eax   lea      edx,[ebp+SIS900_txcfg]; Transmit config Register offset   mov      eax, SIS900_ATP		;allow automatic padding   or       eax, SIS900_HBI		;allow heartbeat ignore   or       eax, SIS900_CSI		;allow carrier sense ignore   or       eax, 0x00600000     ;Max DMA Burst   or       eax, 0x00000100     ;TX Fill Threshold   or       eax, 0x00000020     ;TX Drain Threshold   out      dx, eax   ret;***************************************************************************;* Function: sis900_set_rx_mode;*;* Description:;*    sets the receive mode to accept all broadcast packets and packets;*    with our MAC address, and reject all multicast packets.  Also allows ;*    full-duplex;*;* Arguments:;*;* Returns:;*;* Comments:;*     If you are having problems receiving packet try changing the;*     Max DMA Burst, Possible settings are as follows:;*         0x00000000 = 512 bytes;*         0x00100000 = 4 bytes;*         0x00200000 = 8 bytes;*         0x00300000 = 16 bytes;*         0x00400000 = 32 bytes;*         0x00500000 = 64 bytes;*         0x00600000 = 128 bytes;*         0x00700000 = 256 bytes;***************************************************************************SIS900_mc_filter: times 16 dw 0SIS900_set_rx_mode:   mov      ebp,[io_addr]    ;**************update Multicast Hash Table in Receive Filter    mov      ebx, 0xffff   xor      cl, clSIS900_set_rx_mode_Loop:   mov      eax, ecx   shl      eax, 1   mov      [SIS900_mc_filter+eax], ebx   lea      edx,[ebp+SIS900_rfcr]	    ; Receive Filter Control Reg offset   mov      eax, 4					    ;determine table entry   add      al, cl   shl      eax, 16   out      dx, eax					    ;tell card which entry to modify   lea      edx,[ebp+SIS900_rfdr]	    ; Receive Filter Control Reg offset   mov      eax, ebx				    ;entry value   out      dx, ax					    ;write value to table in card   inc      cl						    ;next entry   cmp      cl,[sis900_table_entries]   ;   jl       SIS900_set_rx_mode_Loop   ;*******Set Receive Filter Control Register*************   lea      edx,[ebp+SIS900_rfcr]	; Receive Filter Control Register offset   mov      eax, SIS900_RFAAB		;accecpt all broadcast packets   or       eax, SIS900_RFAAM		;accept all multicast packets   or       eax, SIS900_RFAAP		;Accept all packets   or       eax, SIS900_RFEN		;enable receiver filter   out      dx, eax   ;******Enable Receiver************   lea      edx,[ebp+SIS900_cr] ; Command Register offset   in 	    eax, dx			    ; Get current Command Register   or 	    eax, SIS900_RxENA   ;Enable Receive   out 	    dx, eax   ;*********Set   lea      edx,[ebp+SIS900_rxcfg]	; Receive Config Register offset   mov      eax, SIS900_ATX			;Accept Transmit Packets                                     ; (Req for full-duplex and PMD Loopback)   or       eax, 0x00600000			;Max DMA Burst   or       eax, 0x00000002			;RX Drain Threshold, 8X8 bytes or 64bytes   out      dx, eax					;   ret;***************************************************************************; *	SIS960_get_mac_addr: - Get MAC address for SiS962 or SiS963 model; *	@pci_dev: the sis900 pci device; *	@net_dev: the net device to get address for; *; *	SiS962 or SiS963 model, use EEPROM to store MAC address. And EEPROM; *	is shared by; *	LAN and 1394. When access EEPROM, send EEREQ signal to hardware first; *	and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be access; *	by LAN, otherwise is not. After MAC address is read from EEPROM, send; *	EEDONE signal to refuse EEPROM access by LAN.; *	The EEPROM map of SiS962 or SiS963 is different to SiS900.; *	The signature field in SiS962 or SiS963 spec is meaningless.; *	MAC address is read into @net_dev->dev_addr.; *done;*;* Return 0 is EAX = failure;*Done+;***************************************************************************if defined SIS900_DEBUGSIS900_Debug_Str_GetMac_Start db 'Attempting to get SIS900 Mac ID: ',13,10,0SIS900_Debug_Str_GetMac_Failed db 'Access to EEprom Failed',13,10,0SIS900_Debug_Str_GetMac_Address db 'Your Mac ID is: ',0SIS900_Debug_Str_GetMac_Address2 db 'Your SIS96x Mac ID is: ',0end ifSIS960_get_mac_addr:   mov      ebp,[io_addr]   ;**********Send Request for eeprom access*********************   lea      edx,[ebp+SIS900_mear]		; Eeprom access register   mov      eax, SIS900_EEREQ			; Request access to eeprom   out      dx, eax						; Send request   xor      ebx,ebx						;   ;******Loop 4000 times and if access not granted error out*****SIS96X_Get_Mac_Wait:   in       eax, dx					;get eeprom status   and      eax, SIS900_EEGNT       ;see if eeprom access granted flag is set   jnz      SIS900_Got_EEP_Access	;if it is, go access the eeprom   inc      ebx						;else keep waiting   cmp      ebx, 4000				;have we tried 4000 times yet?   jl       SIS96X_Get_Mac_Wait	    ;if not ask again   xor      eax, eax                ;return zero in eax indicating failure   ;*******Debug **********************if defined SIS900_DEBUG   mov esi,SIS900_Debug_Str_GetMac_Failed   call sys_msg_board_strend if   jmp SIS960_get_mac_addr_done   ;**********EEprom access granted, read MAC from card*************SIS900_Got_EEP_Access:    ; zero based so 3-16 bit reads will take place   mov      ecx, 2						 SIS96x_mac_read_loop:   mov      eax, SIS900_EEPROMMACAddr    ;Base Mac Address   add      eax, ecx				     ;Current Mac Byte Offset   push     ecx   call     sis900_read_eeprom           ;try to read 16 bits   pop      ecx   mov      [node_addr+ecx*2], ax        ;save 16 bits to the MAC ID varible   dec      ecx                          ;one less word to read   jns      SIS96x_mac_read_loop         ;if more read more   mov      eax, 1                       ;return non-zero indicating success   ;*******Debug Print MAC ID to debug window**********************if defined SIS900_DEBUG   mov esi,SIS900_Debug_Str_GetMac_Address2   call sys_msg_board_str   mov edx, node_addr   call Create_Mac_Stringend if   ;**********Tell EEPROM We are Done Accessing It*********************SIS960_get_mac_addr_done:   lea      edx,[ebp+SIS900_mear]		; Eeprom access register   mov      eax, SIS900_EEDONE           ;tell eeprom we are done   out 	    dx,eax   ret;***************************************************************************;*	sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model;*	@pci_dev: the sis900 pci device;*	@net_dev: the net device to get address for;*;*	Older SiS900 and friends, use EEPROM to store MAC address.;*	MAC address is read from read_eeprom() into @net_dev->dev_addr.;* done/untested;***************************************************************************SIS900_get_mac_addr:   ;*******Debug **********************if defined SIS900_DEBUG   mov esi,SIS900_Debug_Str_GetMac_Start   call sys_msg_board_strend if   ;******** check to see if we have sane EEPROM *******   mov      eax, SIS900_EEPROMSignature  ;Base Eeprom Signature   call     sis900_read_eeprom           ;try to read 16 bits   cmp ax, 0xffff   je SIS900_Bad_Eeprom   cmp ax, 0   je SIS900_Bad_Eeprom   ;**************Read MacID**************   ; zero based so 3-16 bit reads will take place   mov      ecx, 2						 SIS900_mac_read_loop:   mov      eax, SIS900_EEPROMMACAddr    ;Base Mac Address   add      eax, ecx				     ;Current Mac Byte Offset   push     ecx   call     sis900_read_eeprom           ;try to read 16 bits   pop      ecx   mov      [node_addr+ecx*2], ax        ;save 16 bits to the MAC ID storage   dec      ecx                          ;one less word to read   jns      SIS900_mac_read_loop         ;if more read more   mov      eax, 1                       ;return non-zero indicating success   ;*******Debug Print MAC ID to debug window**********************if defined SIS900_DEBUG   mov esi,SIS900_Debug_Str_GetMac_Address   call sys_msg_board_str   mov edx, node_addr   call Create_Mac_Stringend if   ret   SIS900_Bad_Eeprom:   xor eax, eax   ;*******Debug **********************if defined SIS900_DEBUG   mov esi,SIS900_Debug_Str_GetMac_Failed   call sys_msg_board_strend if   ret;***************************************************************************;*	Get_Mac_SIS635_900_REV: - Get MAC address for model 635;*;*;***************************************************************************Get_Mac_SIS635_900_REV:if defined SIS900_DEBUG    mov     esi,SIS900_Debug_Str_GetMac_Start    call    sys_msg_board_strend if    mov     ebp,[io_addr]    lea     edx,[ebp+SIS900_rfcr]    in      eax,dx    mov     edi,eax ; EDI=rfcrSave    lea     edx,[ebp+SIS900_cr]    or      eax,SIS900_RELOAD    out     dx,eax    xor     eax,eax    out     dx,eax    ; Disable packet filtering before setting filter    lea     edx,[ebp+SIS900_rfcr]    mov     eax,edi    and     edi,not SIS900_RFEN    out     dx,eax    ; Load MAC to filter data register    xor     ecx,ecx    mov     esi,node_addr.get_mac_loop:    lea     edx,[ebp+SIS900_rfcr]    mov     eax,ecx    shl     eax,SIS900_RFADDR_shift    out     dx,eax    lea     edx,[ebp+SIS900_rfdr]    in      eax,dx    mov     [esi],ax    add     esi,2    inc     ecx    cmp     ecx,3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -