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

📄 sis900.inc

📁 MenuetOS是一个用汇编开发的32/64位PC操作系统
💻 INC
📖 第 1 页 / 共 3 页
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                                                    ;;;;  SIS900.INC                                                        ;;;;                                                                    ;;;;  Ethernet driver for Menuet OS                                     ;;;;                                                                    ;;;;  Version 0.4  26 April 2004                                        ;;;;                                                                    ;;;;  This driver is based on the SIS900 driver from                    ;;;;  the etherboot 5.0.6 project. The copyright statement is           ;;;;                                                                    ;;;;          GNU GENERAL PUBLIC LICENSE                                ;;;;             Version 2, June 1991                                   ;;;;                                                                    ;;;;  remaining parts Copyright 2004 Jason Delozier,                    ;;;;   cordata51@hotmail.com                                            ;;;;                                                                    ;;;;  See file COPYING for details                                      ;;;;                                                                    ;;;;  Updates:                                                          ;;;;    Revision Look up table and SIS635 Mac Address by Jarek Pelczar  ;;;;                                                                    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;********************************************************************;   Interface;      SIS900_reset;      SIS900_probe;      SIS900_poll;      SIS900_transmit;;********************************************************************;********************************************************************;  Comments:;    Known to work with the following SIS900 ethernet cards:;      -  Device ID: 0x0900   Vendor ID: 0x1039   Revision: 0x91;      -  Device ID: 0x0900   Vendor ID: 0x1039   Revision: 0x90;;    If your card is not listed, try it and let me know if it;    functions properly and it will be aded to the list.  If not;    we may be able to add support for it.;;  How To Use:;    Add the following lines to Ethernet.inc in their appropriate locations;;         include "Sis900.INC";         dd  0x09001039, SIS900_probe, SIS900_reset, SIS900_poll, ; SIS900_transmit;         dd  0x70161039, SIS900_probe, SIS900_reset, SIS900_poll, ; SIS900_transmit   ;untested;;  ToDo:;     -  Enable MII interface for reading speed;        and duplex settings.;;     -  Update Poll routine to support packet fragmentation.;;     -  Add additional support for other sis900 based cards;;********************************************************************; comment the next line out if you don't want debug info printed; on the debug board. This option adds a lot of bytes to the driver; so it's worth to comment it out.;        SIS900_DEBUG equ 1;* buffers and descriptorscur_rx  db  0NUM_RX_DESC    equ    4               ;* Number of RX descriptors *NUM_TX_DESC    equ    1               ;* Number of TX descriptors *RX_BUFF_SZ	    equ    1520            ;* Buffer size for each Rx buffer *TX_BUFF_SZ	    equ    1516            ;* Buffer size for each Tx buffer *align   4txd: times (3 * NUM_TX_DESC) dd 0rxd: times (3 * NUM_RX_DESC) dd 0txb equ eth_data_startrxb equ txb + (NUM_TX_DESC * TX_BUFF_SZ)SIS900_ETH_ALEN	equ	6	;* Size of Ethernet address *SIS900_ETH_HLEN	equ	14	;* Size of ethernet header *SIS900_ETH_ZLEN	equ	60	;* Minimum packet length *SIS900_DSIZE equ 0x00000fffSIS900_CRC_SIZE equ 4SIS900_RFADDR_shift equ 16;SIS900 Symbolic offsets to registers.    SIS900_cr		equ     0x0		  ; Command Register    SIS900_cfg    	equ     0x4       ; Configuration Register    SIS900_mear     equ     0x8       ; EEPROM Access Register    SIS900_ptscr    equ     0xc       ; PCI Test Control Register    SIS900_isr     	equ     0x10      ; Interrupt Status Register    SIS900_imr     	equ     0x14      ; Interrupt Mask Register    SIS900_ier     	equ     0x18      ; Interrupt Enable Register    SIS900_epar    	equ     0x18      ; Enhanced PHY Access Register    SIS900_txdp     equ     0x20      ; Transmit Descriptor Pointer Register    SIS900_txcfg    equ     0x24      ; Transmit Configuration Register    SIS900_rxdp     equ     0x30      ; Receive Descriptor Pointer Register    SIS900_rxcfg    equ     0x34      ; Receive Configuration Register    SIS900_flctrl   equ     0x38      ; Flow Control Register    SIS900_rxlen    equ     0x3c      ; Receive Packet Length Register    SIS900_rfcr     equ     0x48      ; Receive Filter Control Register    SIS900_rfdr     equ     0x4C      ; Receive Filter Data Register    SIS900_pmctrl   equ     0xB0      ; Power Management Control Register    SIS900_pmer    	equ     0xB4      ; Power Management Wake-up Event Register;SIS900 Command Register Bits    SIS900_RELOAD       equ      0x00000400    SIS900_ACCESSMODE   equ      0x00000200    SIS900_RESET        equ      0x00000100    SIS900_SWI          equ      0x00000080    SIS900_RxRESET      equ      0x00000020    SIS900_TxRESET      equ      0x00000010    SIS900_RxDIS        equ      0x00000008    SIS900_RxENA        equ      0x00000004    SIS900_TxDIS        equ      0x00000002    SIS900_TxENA        equ      0x00000001;SIS900 Configuration Register Bits    SIS900_DESCRFMT      equ    0x00000100 ; 7016 specific    SIS900_REQALG        equ    0x00000080    SIS900_SB            equ    0x00000040    SIS900_POW           equ    0x00000020    SIS900_EXD           equ    0x00000010    SIS900_PESEL         equ    0x00000008    SIS900_LPM           equ    0x00000004    SIS900_BEM           equ    0x00000001    SIS900_RND_CNT       equ    0x00000400    SIS900_FAIR_BACKOFF  equ    0x00000200    SIS900_EDB_MASTER_EN equ    0x00002000;SIS900 Eeprom Access Reigster Bits    SIS900_MDC        equ      0x00000040    SIS900_MDDIR      equ      0x00000020    SIS900_MDIO       equ      0x00000010  ; 7016 specific    SIS900_EECS       equ      0x00000008    SIS900_EECLK      equ      0x00000004    SIS900_EEDO       equ      0x00000002    SIS900_EEDI       equ      0x00000001;SIS900 TX Configuration Register Bits    SIS900_ATP        equ      0x10000000 ;Automatic Transmit Padding    SIS900_MLB        equ      0x20000000 ;Mac Loopback Enable    SIS900_HBI        equ      0x40000000 ;HeartBeat Ignore (Req for full-dup)    SIS900_CSI        equ      0x80000000 ;CarrierSenseIgnore (Req for full-du;SIS900 RX Configuration Register Bits    SIS900_AJAB       equ      0x08000000 ;    SIS900_ATX        equ      0x10000000 ;Accept Transmit Packets    SIS900_ARP        equ      0x40000000 ;accept runt packets (<64bytes)    SIS900_AEP        equ      0x80000000 ;accept error packets;SIS900 Interrupt Reigster Bits    SIS900_WKEVT           equ      0x10000000    SIS900_TxPAUSEEND      equ      0x08000000    SIS900_TxPAUSE         equ      0x04000000    SIS900_TxRCMP          equ      0x02000000    SIS900_RxRCMP          equ      0x01000000    SIS900_DPERR           equ      0x00800000    SIS900_SSERR           equ      0x00400000    SIS900_RMABT           equ      0x00200000    SIS900_RTABT           equ      0x00100000    SIS900_RxSOVR          equ      0x00010000    SIS900_HIBERR          equ      0x00008000    SIS900_SWINT           equ      0x00001000    SIS900_MIBINT          equ      0x00000800    SIS900_TxURN           equ      0x00000400    SIS900_TxIDLE          equ      0x00000200    SIS900_TxERR           equ      0x00000100    SIS900_TxDESC          equ      0x00000080    SIS900_TxOK            equ      0x00000040    SIS900_RxORN           equ      0x00000020    SIS900_RxIDLE          equ      0x00000010    SIS900_RxEARLY         equ      0x00000008    SIS900_RxERR           equ      0x00000004    SIS900_RxDESC          equ      0x00000002    SIS900_RxOK            equ      0x00000001;SIS900 Interrupt Enable Reigster Bits    SIS900_IE      equ      0x00000001;SIS900 Revision ID	SIS900B_900_REV       equ      0x03	SIS630A_900_REV       equ      0x80	SIS630E_900_REV       equ      0x81	SIS630S_900_REV       equ      0x82	SIS630EA1_900_REV     equ      0x83	SIS630ET_900_REV      equ      0x84	SIS635A_900_REV       equ      0x90	SIS900_960_REV        equ      0x91;SIS900 Receive Filter Control Register Bits    SIS900_RFEN          equ 0x80000000    SIS900_RFAAB         equ 0x40000000    SIS900_RFAAM         equ 0x20000000    SIS900_RFAAP         equ 0x10000000    SIS900_RFPromiscuous equ 0x70000000;SIS900 Reveive Filter Data Mask    SIS900_RFDAT equ  0x0000FFFF;SIS900 Eeprom Address    SIS900_EEPROMSignature equ 0x00    SIS900_EEPROMVendorID  equ 0x02    SIS900_EEPROMDeviceID  equ 0x03    SIS900_EEPROMMACAddr   equ 0x08    SIS900_EEPROMChecksum  equ 0x0b;The EEPROM commands include the alway-set leading bit.;SIS900 Eeprom Command    SIS900_EEread          equ 0x0180    SIS900_EEwrite         equ 0x0140    SIS900_EEerase         equ 0x01C0    SIS900_EEwriteEnable   equ 0x0130    SIS900_EEwriteDisable  equ 0x0100    SIS900_EEeraseAll      equ 0x0120    SIS900_EEwriteAll      equ 0x0110    SIS900_EEaddrMask      equ 0x013F    SIS900_EEcmdShift 	   equ 16;For SiS962 or SiS963, request the eeprom software access	SIS900_EEREQ 	equ 0x00000400	SIS900_EEDONE 	equ 0x00000200	SIS900_EEGNT 	equ 0x00000100;General Varibles	SIS900_pci_revision:     db	  0	SIS900_Status		     dd   0x03000000sis900_specific_table:;    dd SIS630A_900_REV,Get_Mac_SIS630A_900_REV,0;    dd SIS630E_900_REV,Get_Mac_SIS630E_900_REV,0    dd SIS630S_900_REV,Get_Mac_SIS635_900_REV,0    dd SIS630EA1_900_REV,Get_Mac_SIS635_900_REV,0    dd SIS630ET_900_REV,Get_Mac_SIS635_900_REV,0;SIS630ET_900_REV_SpecialFN    dd SIS635A_900_REV,Get_Mac_SIS635_900_REV,0    dd SIS900_960_REV,SIS960_get_mac_addr,0    dd SIS900B_900_REV,SIS900_get_mac_addr,0    dd 0,0,0,0 ; end of listsis900_get_mac_func:	dd 0sis900_special_func:	dd 0sis900_table_entries:	db 8;***************************************************************************;   Function;      SIS900_probe;   Description;      Searches for an ethernet card, enables it and clears the rx buffer;      If a card was found, it enables the ethernet -> TCPIP link;not done  - still need to probe mii transcievers;***************************************************************************if defined SIS900_DEBUGSIS900_Debug_Str_Unsupported db 'Sorry your card is unsupported ',13,10,0end ifSIS900_probe:;******Wake Up Chip*******   mov     al, 4   mov     bh, [pci_dev]   mov     ecx, 0   mov     ah, [pci_bus]   mov     bl, 0x40   call    pci_write_reg;*******Set some PCI Settings*********   call    SIS900_adjust_pci_device;*****Get Card Revision******   mov     al, 1					;one byte to read   mov     bh, [pci_dev]   mov     ah, [pci_bus]   mov     bl, 0x08				    ;Revision Register   call    pci_read_reg   mov [SIS900_pci_revision], al	;save the revision for later use;****** Look up through the sis900_specific_table   mov     esi,sis900_specific_table.probe_loop:   cmp     dword [esi],0 		; Check if we reached end of the list   je      .probe_loop_failed   cmp     al,[esi]			; Check if revision is OK   je      .probe_loop_ok   add     esi,12 			; Advance to next entry   jmp     .probe_loop.probe_loop_failed:   jmp     SIS900_Probe_Unsupported;*********Find Get Mac Function*********.probe_loop_ok:   mov      eax,[esi+4]		; Get pointer to "get MAC" function   mov      [sis900_get_mac_func],eax   mov      eax,[esi+8]		; Get pointer to special initialization fn   mov      [sis900_special_func],eax;******** Get MAC ********   call     dword [sis900_get_mac_func];******** Call special initialization fn if requested ********   cmp      dword [sis900_special_func],0   je       .no_special_init   call     dword [sis900_special_func].no_special_init:;******** Set table entries ********   mov      al,[SIS900_pci_revision]   cmp      al,SIS635A_900_REV   jae      .ent16   cmp      al,SIS900B_900_REV   je       .ent16   jmp      .ent8.ent16:   mov      byte [sis900_table_entries],16.ent8:;*******Probe for mii transceiver*******;TODO!!*********************;*******Initialize Device*******   call sis900_init   ret   SIS900_Probe_Unsupported:if defined SIS900_DEBUG   mov     esi, SIS900_Debug_Str_Unsupported   call    sys_msg_board_strend if   ret;***************************************************************************; Function: sis900_init;; Description: resets the ethernet controller chip and various;    data structures required for sending and receiving packets.;; Arguments:;; returns:   none;not done;***************************************************************************sis900_init:   call SIS900_reset		   ;Done   call SIS900_init_rxfilter   ;Done   call SIS900_init_txd        ;Done   call SIS900_init_rxd		   ;Done   call SIS900_set_rx_mode     ;done   call SIS900_set_tx_mode   ;call SIS900_check_mode   ret   ;***************************************************************************;   Function;      SIS900_reset;   Description;      disables interrupts and soft resets the controller chip;;done+;***************************************************************************if defined SIS900_DEBUG   SIS900_Debug_Reset_Failed db 'Reset Failed ',0end ifSIS900_reset:   ;******Disable Interrupts and reset Receive Filter*******   mov      ebp, [io_addr]	; base address   xor      eax, eax    	; 0 to initialize   lea      edx,[ebp+SIS900_ier]   out      dx, eax			; Write 0 to location   lea      edx,[ebp+SIS900_imr]   out      dx, eax			; Write 0 to location   lea      edx,[ebp+SIS900_rfcr]   out      dx, eax			; Write 0 to location   ;*******Reset Card***********************************************   lea      edx,[ebp+SIS900_cr]   in 	    eax, dx			        ; Get current Command Register   or       eax, SIS900_RESET		; set flags   or 	    eax, SIS900_RxRESET	    ;   or		eax, SIS900_TxRESET	    ;   out	    dx, eax			        ; Write new Command Register   ;*******Wait Loop************************************************   lea      edx,[ebp+SIS900_isr]   mov      ecx, [SIS900_Status]    ; Status we would like to see from card   mov      ebx, 2001               ; only loop 1000 timesSIS900_Wait:   dec      ebx					    ; 1 less loop   jz       SIS900_DoneWait_e		; 1000 times yet?   in       eax, dx				    ; move interrup status to eax   and      eax, ecx   xor      ecx, eax   jz       SIS900_DoneWait   jmp      SIS900_WaitSIS900_DoneWait_e:if defined SIS900_DEBUG   mov esi, SIS900_Debug_Reset_Failed   call sys_msg_board_strend ifSIS900_DoneWait:   ;*******Set Configuration Register depending on Card Revision********   lea      edx,[ebp+SIS900_cfg]   mov      eax, SIS900_PESEL		    ; Configuration Register Bit   mov      bl, [SIS900_pci_revision]   ; card revision   mov      cl, SIS635A_900_REV	        ; Check card revision   cmp      bl, cl   je       SIS900_RevMatch   mov      cl, SIS900B_900_REV	        ; Check card revision   cmp      bl, cl   je       SIS900_RevMatch   out      dx, eax			            ; no revision match   jmp      SIS900_Reset_CompleteSIS900_RevMatch:				        ; Revision match   or       eax, SIS900_RND_CNT	        ; Configuration Register Bit   out      dx, eaxSIS900_Reset_Complete:

⌨️ 快捷键说明

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