Subversion Repositories Kolibri OS

Rev

Rev 261 | Blame | Last modification | View Log | Download | RSS feed

  1. $Revision: 425 $
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;                                                                    ;;
  4. ;;  SIS900.INC                                                        ;;
  5. ;;                                                                    ;;
  6. ;;  Ethernet driver for Menuet OS                                     ;;
  7. ;;                                                                    ;;
  8. ;;  Version 0.4  26 April 2004                                        ;;
  9. ;;                                                                    ;;
  10. ;;  This driver is based on the SIS900 driver from                    ;;
  11. ;;  the etherboot 5.0.6 project. The copyright statement is           ;;
  12. ;;                                                                    ;;
  13. ;;          GNU GENERAL PUBLIC LICENSE                                ;;
  14. ;;             Version 2, June 1991                                   ;;
  15. ;;                                                                    ;;
  16. ;;  remaining parts Copyright 2004 Jason Delozier,                    ;;
  17. ;;   cordata51@hotmail.com                                            ;;
  18. ;;                                                                    ;;
  19. ;;  See file COPYING for details                                      ;;
  20. ;;                                                                    ;;
  21. ;;  Updates:                                                          ;;
  22. ;;    Revision Look up table and SIS635 Mac Address by Jarek Pelczar  ;;
  23. ;;                                                                    ;;
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;********************************************************************
  26. ;   Interface
  27. ;      SIS900_reset
  28. ;      SIS900_probe
  29. ;      SIS900_poll
  30. ;      SIS900_transmit
  31. ;
  32. ;********************************************************************
  33. ;********************************************************************
  34. ;  Comments:
  35. ;    Known to work with the following SIS900 ethernet cards:
  36. ;      -  Device ID: 0x0900   Vendor ID: 0x1039   Revision: 0x91
  37. ;      -  Device ID: 0x0900   Vendor ID: 0x1039   Revision: 0x90
  38. ;
  39. ;    If your card is not listed, try it and let me know if it
  40. ;    functions properly and it will be aded to the list.  If not
  41. ;    we may be able to add support for it.
  42. ;
  43. ;  How To Use:
  44. ;    Add the following lines to Ethernet.inc in their appropriate locations
  45. ;
  46. ;         include "Sis900.INC"
  47. ;         dd  0x09001039, SIS900_probe, SIS900_reset, SIS900_poll,
  48. ; SIS900_transmit
  49. ;         dd  0x70161039, SIS900_probe, SIS900_reset, SIS900_poll,
  50. ; SIS900_transmit   ;untested
  51. ;
  52. ;  ToDo:
  53. ;     -  Enable MII interface for reading speed
  54. ;        and duplex settings.
  55. ;
  56. ;     -  Update Poll routine to support packet fragmentation.
  57. ;
  58. ;     -  Add additional support for other sis900 based cards
  59. ;
  60. ;********************************************************************
  61.  
  62. ; comment the next line out if you don't want debug info printed
  63. ; on the debug board. This option adds a lot of bytes to the driver
  64. ; so it's worth to comment it out.
  65. ;        SIS900_DEBUG equ 1
  66.  
  67.  
  68. ;* buffers and descriptors
  69. cur_rx  db  0
  70. NUM_RX_DESC    equ    4               ;* Number of RX descriptors *
  71. NUM_TX_DESC    equ    1               ;* Number of TX descriptors *
  72. RX_BUFF_SZ          equ    1520            ;* Buffer size for each Rx buffer *
  73. TX_BUFF_SZ          equ    1516            ;* Buffer size for each Tx buffer *
  74.  
  75. uglobal
  76. align   4
  77. txd: times (3 * NUM_TX_DESC) dd 0
  78. rxd: times (3 * NUM_RX_DESC) dd 0
  79. endg
  80.  
  81. txb equ eth_data_start
  82. rxb equ txb + (NUM_TX_DESC * TX_BUFF_SZ)
  83. SIS900_ETH_ALEN equ     6       ;* Size of Ethernet address *
  84. SIS900_ETH_HLEN equ     14      ;* Size of ethernet header *
  85. SIS900_ETH_ZLEN equ     60      ;* Minimum packet length *
  86. SIS900_DSIZE equ 0x00000fff
  87. SIS900_CRC_SIZE equ 4
  88. SIS900_RFADDR_shift equ 16
  89. ;SIS900 Symbolic offsets to registers.
  90.     SIS900_cr           equ     0x0               ; Command Register
  91.     SIS900_cfg          equ     0x4       ; Configuration Register
  92.     SIS900_mear     equ     0x8       ; EEPROM Access Register
  93.     SIS900_ptscr    equ     0xc       ; PCI Test Control Register
  94.     SIS900_isr          equ     0x10      ; Interrupt Status Register
  95.     SIS900_imr          equ     0x14      ; Interrupt Mask Register
  96.     SIS900_ier          equ     0x18      ; Interrupt Enable Register
  97.     SIS900_epar         equ     0x18      ; Enhanced PHY Access Register
  98.     SIS900_txdp     equ     0x20      ; Transmit Descriptor Pointer Register
  99.     SIS900_txcfg    equ     0x24      ; Transmit Configuration Register
  100.     SIS900_rxdp     equ     0x30      ; Receive Descriptor Pointer Register
  101.     SIS900_rxcfg    equ     0x34      ; Receive Configuration Register
  102.     SIS900_flctrl   equ     0x38      ; Flow Control Register
  103.     SIS900_rxlen    equ     0x3c      ; Receive Packet Length Register
  104.     SIS900_rfcr     equ     0x48      ; Receive Filter Control Register
  105.     SIS900_rfdr     equ     0x4C      ; Receive Filter Data Register
  106.     SIS900_pmctrl   equ     0xB0      ; Power Management Control Register
  107.     SIS900_pmer         equ     0xB4      ; Power Management Wake-up Event Register
  108. ;SIS900 Command Register Bits
  109.     SIS900_RELOAD       equ      0x00000400
  110.     SIS900_ACCESSMODE   equ      0x00000200
  111.     SIS900_RESET        equ      0x00000100
  112.     SIS900_SWI          equ      0x00000080
  113.     SIS900_RxRESET      equ      0x00000020
  114.     SIS900_TxRESET      equ      0x00000010
  115.     SIS900_RxDIS        equ      0x00000008
  116.     SIS900_RxENA        equ      0x00000004
  117.     SIS900_TxDIS        equ      0x00000002
  118.     SIS900_TxENA        equ      0x00000001
  119. ;SIS900 Configuration Register Bits
  120.     SIS900_DESCRFMT      equ    0x00000100 ; 7016 specific
  121.     SIS900_REQALG        equ    0x00000080
  122.     SIS900_SB            equ    0x00000040
  123.     SIS900_POW           equ    0x00000020
  124.     SIS900_EXD           equ    0x00000010
  125.     SIS900_PESEL         equ    0x00000008
  126.     SIS900_LPM           equ    0x00000004
  127.     SIS900_BEM           equ    0x00000001
  128.     SIS900_RND_CNT       equ    0x00000400
  129.     SIS900_FAIR_BACKOFF  equ    0x00000200
  130.     SIS900_EDB_MASTER_EN equ    0x00002000
  131. ;SIS900 Eeprom Access Reigster Bits
  132.     SIS900_MDC        equ      0x00000040
  133.     SIS900_MDDIR      equ      0x00000020
  134.     SIS900_MDIO       equ      0x00000010  ; 7016 specific
  135.     SIS900_EECS       equ      0x00000008
  136.     SIS900_EECLK      equ      0x00000004
  137.     SIS900_EEDO       equ      0x00000002
  138.     SIS900_EEDI       equ      0x00000001
  139. ;SIS900 TX Configuration Register Bits
  140.     SIS900_ATP        equ      0x10000000 ;Automatic Transmit Padding
  141.     SIS900_MLB        equ      0x20000000 ;Mac Loopback Enable
  142.     SIS900_HBI        equ      0x40000000 ;HeartBeat Ignore (Req for full-dup)
  143.     SIS900_CSI        equ      0x80000000 ;CarrierSenseIgnore (Req for full-du
  144. ;SIS900 RX Configuration Register Bits
  145.     SIS900_AJAB       equ      0x08000000 ;
  146.     SIS900_ATX        equ      0x10000000 ;Accept Transmit Packets
  147.     SIS900_ARP        equ      0x40000000 ;accept runt packets (<64bytes)
  148.     SIS900_AEP        equ      0x80000000 ;accept error packets
  149. ;SIS900 Interrupt Reigster Bits
  150.     SIS900_WKEVT           equ      0x10000000
  151.     SIS900_TxPAUSEEND      equ      0x08000000
  152.     SIS900_TxPAUSE         equ      0x04000000
  153.     SIS900_TxRCMP          equ      0x02000000
  154.     SIS900_RxRCMP          equ      0x01000000
  155.     SIS900_DPERR           equ      0x00800000
  156.     SIS900_SSERR           equ      0x00400000
  157.     SIS900_RMABT           equ      0x00200000
  158.     SIS900_RTABT           equ      0x00100000
  159.     SIS900_RxSOVR          equ      0x00010000
  160.     SIS900_HIBERR          equ      0x00008000
  161.     SIS900_SWINT           equ      0x00001000
  162.     SIS900_MIBINT          equ      0x00000800
  163.     SIS900_TxURN           equ      0x00000400
  164.     SIS900_TxIDLE          equ      0x00000200
  165.     SIS900_TxERR           equ      0x00000100
  166.     SIS900_TxDESC          equ      0x00000080
  167.     SIS900_TxOK            equ      0x00000040
  168.     SIS900_RxORN           equ      0x00000020
  169.     SIS900_RxIDLE          equ      0x00000010
  170.     SIS900_RxEARLY         equ      0x00000008
  171.     SIS900_RxERR           equ      0x00000004
  172.     SIS900_RxDESC          equ      0x00000002
  173.     SIS900_RxOK            equ      0x00000001
  174. ;SIS900 Interrupt Enable Reigster Bits
  175.     SIS900_IE      equ      0x00000001
  176. ;SIS900 Revision ID
  177.         SIS900B_900_REV       equ      0x03
  178.         SIS630A_900_REV       equ      0x80
  179.         SIS630E_900_REV       equ      0x81
  180.         SIS630S_900_REV       equ      0x82
  181.         SIS630EA1_900_REV     equ      0x83
  182.         SIS630ET_900_REV      equ      0x84
  183.         SIS635A_900_REV       equ      0x90
  184.         SIS900_960_REV        equ      0x91
  185. ;SIS900 Receive Filter Control Register Bits
  186.     SIS900_RFEN          equ 0x80000000
  187.     SIS900_RFAAB         equ 0x40000000
  188.     SIS900_RFAAM         equ 0x20000000
  189.     SIS900_RFAAP         equ 0x10000000
  190.     SIS900_RFPromiscuous equ 0x70000000
  191. ;SIS900 Reveive Filter Data Mask
  192.     SIS900_RFDAT equ  0x0000FFFF
  193. ;SIS900 Eeprom Address
  194.     SIS900_EEPROMSignature equ 0x00
  195.     SIS900_EEPROMVendorID  equ 0x02
  196.     SIS900_EEPROMDeviceID  equ 0x03
  197.     SIS900_EEPROMMACAddr   equ 0x08
  198.     SIS900_EEPROMChecksum  equ 0x0b
  199. ;The EEPROM commands include the alway-set leading bit.
  200. ;SIS900 Eeprom Command
  201.     SIS900_EEread          equ 0x0180
  202.     SIS900_EEwrite         equ 0x0140
  203.     SIS900_EEerase         equ 0x01C0
  204.     SIS900_EEwriteEnable   equ 0x0130
  205.     SIS900_EEwriteDisable  equ 0x0100
  206.     SIS900_EEeraseAll      equ 0x0120
  207.     SIS900_EEwriteAll      equ 0x0110
  208.     SIS900_EEaddrMask      equ 0x013F
  209.     SIS900_EEcmdShift      equ 16
  210. ;For SiS962 or SiS963, request the eeprom software access
  211.         SIS900_EEREQ    equ 0x00000400
  212.         SIS900_EEDONE   equ 0x00000200
  213.         SIS900_EEGNT    equ 0x00000100
  214. ;General Varibles
  215.         SIS900_pci_revision:     db       0
  216.         SIS900_Status                dd   0x03000000
  217. sis900_specific_table:
  218. ;    dd SIS630A_900_REV,Get_Mac_SIS630A_900_REV,0
  219. ;    dd SIS630E_900_REV,Get_Mac_SIS630E_900_REV,0
  220.     dd SIS630S_900_REV,Get_Mac_SIS635_900_REV,0
  221.     dd SIS630EA1_900_REV,Get_Mac_SIS635_900_REV,0
  222.     dd SIS630ET_900_REV,Get_Mac_SIS635_900_REV,0;SIS630ET_900_REV_SpecialFN
  223.     dd SIS635A_900_REV,Get_Mac_SIS635_900_REV,0
  224.     dd SIS900_960_REV,SIS960_get_mac_addr,0
  225.     dd SIS900B_900_REV,SIS900_get_mac_addr,0
  226.     dd 0,0,0,0 ; end of list
  227. sis900_get_mac_func:    dd 0
  228. sis900_special_func:    dd 0
  229. sis900_table_entries:   db 8
  230.  
  231. ;***************************************************************************
  232. ;   Function
  233. ;      SIS900_probe
  234. ;   Description
  235. ;      Searches for an ethernet card, enables it and clears the rx buffer
  236. ;      If a card was found, it enables the ethernet -> TCPIP link
  237. ;not done  - still need to probe mii transcievers
  238. ;***************************************************************************
  239. if defined SIS900_DEBUG
  240. SIS900_Debug_Str_Unsupported db 'Sorry your card is unsupported ',13,10,0
  241. end if
  242. SIS900_probe:
  243. ;******Wake Up Chip*******
  244.    mov     al, 4
  245.    mov     bh, [pci_dev]
  246.    mov     ecx, 0
  247.    mov     ah, [pci_bus]
  248.    mov     bl, 0x40
  249.    call    pci_write_reg
  250. ;*******Set some PCI Settings*********
  251.    call    SIS900_adjust_pci_device
  252. ;*****Get Card Revision******
  253.    mov     al, 1                                        ;one byte to read
  254.    mov     bh, [pci_dev]
  255.    mov     ah, [pci_bus]
  256.    mov     bl, 0x08                                 ;Revision Register
  257.    call    pci_read_reg
  258.    mov [SIS900_pci_revision], al        ;save the revision for later use
  259. ;****** Look up through the sis900_specific_table
  260.    mov     esi,sis900_specific_table
  261. .probe_loop:
  262.    cmp     dword [esi],0                ; Check if we reached end of the list
  263.    je      .probe_loop_failed
  264.    cmp     al,[esi]                     ; Check if revision is OK
  265.    je      .probe_loop_ok
  266.    add     esi,12                       ; Advance to next entry
  267.    jmp     .probe_loop
  268. .probe_loop_failed:
  269.    jmp     SIS900_Probe_Unsupported
  270. ;*********Find Get Mac Function*********
  271. .probe_loop_ok:
  272.    mov      eax,[esi+4]         ; Get pointer to "get MAC" function
  273.    mov      [sis900_get_mac_func],eax
  274.    mov      eax,[esi+8]         ; Get pointer to special initialization fn
  275.    mov      [sis900_special_func],eax
  276. ;******** Get MAC ********
  277.    call     dword [sis900_get_mac_func]
  278. ;******** Call special initialization fn if requested ********
  279.    cmp      dword [sis900_special_func],0
  280.    je       .no_special_init
  281.    call     dword [sis900_special_func]
  282. .no_special_init:
  283. ;******** Set table entries ********
  284.    mov      al,[SIS900_pci_revision]
  285.    cmp      al,SIS635A_900_REV
  286.    jae      .ent16
  287.    cmp      al,SIS900B_900_REV
  288.    je       .ent16
  289.    jmp      .ent8
  290. .ent16:
  291.    mov      byte [sis900_table_entries],16
  292. .ent8:
  293. ;*******Probe for mii transceiver*******
  294. ;TODO!!*********************
  295. ;*******Initialize Device*******
  296.    call sis900_init
  297.    ret
  298.  
  299. SIS900_Probe_Unsupported:
  300. if defined SIS900_DEBUG
  301.    mov     esi, SIS900_Debug_Str_Unsupported
  302.    call    sys_msg_board_str
  303. end if
  304.    ret
  305. ;***************************************************************************
  306. ; Function: sis900_init
  307. ;
  308. ; Description: resets the ethernet controller chip and various
  309. ;    data structures required for sending and receiving packets.
  310. ;
  311. ; Arguments:
  312. ;
  313. ; returns:   none
  314. ;not done
  315. ;***************************************************************************
  316. sis900_init:
  317.    call SIS900_reset               ;Done
  318.    call SIS900_init_rxfilter   ;Done
  319.    call SIS900_init_txd        ;Done
  320.    call SIS900_init_rxd            ;Done
  321.    call SIS900_set_rx_mode     ;done
  322.    call SIS900_set_tx_mode
  323.    ;call SIS900_check_mode
  324.    ret
  325.  
  326. ;***************************************************************************
  327. ;   Function
  328. ;      SIS900_reset
  329. ;   Description
  330. ;      disables interrupts and soft resets the controller chip
  331. ;
  332. ;done+
  333. ;***************************************************************************
  334. if defined SIS900_DEBUG
  335.    SIS900_Debug_Reset_Failed db 'Reset Failed ',0
  336. end if
  337. SIS900_reset:
  338.    ;******Disable Interrupts and reset Receive Filter*******
  339.    mov      ebp, [io_addr]      ; base address
  340.    xor      eax, eax            ; 0 to initialize
  341.    lea      edx,[ebp+SIS900_ier]
  342.    out      dx, eax                     ; Write 0 to location
  343.    lea      edx,[ebp+SIS900_imr]
  344.    out      dx, eax                     ; Write 0 to location
  345.    lea      edx,[ebp+SIS900_rfcr]
  346.    out      dx, eax                     ; Write 0 to location
  347.    ;*******Reset Card***********************************************
  348.    lea      edx,[ebp+SIS900_cr]
  349.    in       eax, dx                             ; Get current Command Register
  350.    or       eax, SIS900_RESET           ; set flags
  351.    or       eax, SIS900_RxRESET     ;
  352.    or           eax, SIS900_TxRESET         ;
  353.    out      dx, eax                             ; Write new Command Register
  354.    ;*******Wait Loop************************************************
  355.    lea      edx,[ebp+SIS900_isr]
  356.    mov      ecx, [SIS900_Status]    ; Status we would like to see from card
  357.    mov      ebx, 2001               ; only loop 1000 times
  358. SIS900_Wait:
  359.    dec      ebx                                     ; 1 less loop
  360.    jz       SIS900_DoneWait_e           ; 1000 times yet?
  361.    in       eax, dx                                 ; move interrup status to eax
  362.    and      eax, ecx
  363.    xor      ecx, eax
  364.    jz       SIS900_DoneWait
  365.    jmp      SIS900_Wait
  366. SIS900_DoneWait_e:
  367. if defined SIS900_DEBUG
  368.    mov esi, SIS900_Debug_Reset_Failed
  369.    call sys_msg_board_str
  370. end if
  371. SIS900_DoneWait:
  372.    ;*******Set Configuration Register depending on Card Revision********
  373.    lea      edx,[ebp+SIS900_cfg]
  374.    mov      eax, SIS900_PESEL               ; Configuration Register Bit
  375.    mov      bl, [SIS900_pci_revision]   ; card revision
  376.    mov      cl, SIS635A_900_REV         ; Check card revision
  377.    cmp      bl, cl
  378.    je       SIS900_RevMatch
  379.    mov      cl, SIS900B_900_REV         ; Check card revision
  380.    cmp      bl, cl
  381.    je       SIS900_RevMatch
  382.    out      dx, eax                                 ; no revision match
  383.    jmp      SIS900_Reset_Complete
  384. SIS900_RevMatch:                                        ; Revision match
  385.    or       eax, SIS900_RND_CNT         ; Configuration Register Bit
  386.    out      dx, eax
  387. SIS900_Reset_Complete:
  388.    mov      eax, [pci_data]
  389.    mov      [eth_status], eax
  390.    ret
  391.  
  392. ;***************************************************************************
  393. ; Function: sis_init_rxfilter
  394. ;
  395. ; Description: sets receive filter address to our MAC address
  396. ;
  397. ; Arguments:
  398. ;
  399. ; returns:
  400. ;done+
  401. ;***************************************************************************
  402. SIS900_init_rxfilter:
  403.    ;****Get Receive Filter Control Register ********
  404.    mov      ebp, [io_addr]          ; base address
  405.    lea      edx,[ebp+SIS900_rfcr]
  406.    in       eax, dx                         ; get register
  407.    push     eax
  408.    ;****disable packet filtering before setting filter*******
  409.    mov      eax, SIS900_RFEN    ;move receive filter enable flag
  410.    not      eax                         ;1s complement
  411.    pop      ebx                         ;and with our saved register
  412.    and      eax, ebx                    ;disable receiver
  413.    push     ebx                 ;save filter for another use
  414.    out      dx, eax                     ;set receive disabled
  415.    ;********load MAC addr to filter data register*********
  416.    xor      ecx, ecx
  417. SIS900_RXINT_Mac_Write:
  418.    ;high word of eax tells card which mac byte to write
  419.    mov      eax, ecx
  420.    lea      edx,[ebp+SIS900_rfcr]
  421.    shl      eax, 16                                             ;
  422.    out      dx, eax                                             ;
  423.    lea      edx,[ebp+SIS900_rfdr]
  424.    mov      ax,  word [node_addr+ecx*2] ; Get Mac ID word
  425.    out      dx, ax                                              ; Send Mac ID
  426.    inc      cl                                                  ; send next word
  427.    cmp      cl, 3                                               ; more to send?
  428.    jne      SIS900_RXINT_Mac_Write
  429.    ;********enable packet filitering *****
  430.    pop      eax                             ;old register value
  431.    lea      edx,[ebp+SIS900_rfcr]
  432.    or       eax, SIS900_RFEN    ;enable filtering
  433.    out      dx, eax             ;set register
  434.    ret
  435.  
  436. ;***************************************************************************
  437. ;*
  438. ;* Function: sis_init_txd
  439. ;*
  440. ;* Description: initializes the Tx descriptor
  441. ;*
  442. ;* Arguments:
  443. ;*
  444. ;* returns:
  445. ;*done
  446. ;***************************************************************************
  447. SIS900_init_txd:
  448.    ;********** initialize TX descriptor **************
  449.    mov     [txd], dword 0       ;put link to next descriptor in link field
  450.    mov     [txd+4],dword 0      ;clear status field
  451.    mov     [txd+8], dword txb   ;save address to buffer ptr field
  452.    ;*************** load Transmit Descriptor Register ***************
  453.    mov     dx, [io_addr]            ; base address
  454.    add     dx, SIS900_txdp      ; TX Descriptor Pointer
  455.    mov     eax, txd                         ; First Descriptor
  456.    out     dx, eax                              ; move the pointer
  457.    ret
  458.  
  459. ;***************************************************************************
  460. ;* Function: sis_init_rxd
  461. ;*
  462. ;* Description: initializes the Rx descriptor ring
  463. ;*
  464. ;* Arguments:
  465. ;*
  466. ;* Returns:
  467. ;*done
  468. ;***************************************************************************
  469. SIS900_init_rxd:
  470.    xor      ecx,ecx
  471.    mov      [cur_rx], cl                                        ;Set cuurent rx discriptor to 0
  472.    ;******** init RX descriptors ********
  473. SIS900_init_rxd_Loop:
  474.     mov     eax, ecx                                        ;current descriptor
  475.     imul    eax, 12                         ;
  476.     mov     ebx, ecx                                        ;determine next link descriptor
  477.     inc     ebx                             ;
  478.     cmp     ebx, NUM_RX_DESC                ;
  479.     jne     SIS900_init_rxd_Loop_0          ;
  480.     xor     ebx, ebx                        ;
  481. SIS900_init_rxd_Loop_0:                    ;
  482.     imul    ebx, 12                         ;
  483.     add     ebx, rxd                        ;
  484.     mov     [rxd+eax], ebx                                      ;save link to next descriptor
  485.     mov     [rxd+eax+4],dword RX_BUFF_SZ        ;status bits init to buf size
  486.     mov     ebx, ecx                                            ;find where the buf is located
  487.     imul    ebx,RX_BUFF_SZ                  ;
  488.     add     ebx, rxb                        ;
  489.     mov     [rxd+eax+8], ebx                            ;save buffer pointer
  490.     inc     ecx                                                     ;next descriptor
  491.     cmp     ecx, NUM_RX_DESC                ;
  492.     jne     SIS900_init_rxd_Loop            ;
  493.     ;********* load Receive Descriptor Register with address of first
  494.     ; descriptor*********
  495.     mov     dx, [io_addr]
  496.     add     dx, SIS900_rxdp
  497.     mov     eax, rxd
  498.     out     dx, eax
  499.     ret
  500.  
  501. ;***************************************************************************
  502. ;* Function: sis900_set_tx_mode
  503. ;*
  504. ;* Description:
  505. ;*    sets the transmit mode to allow for full duplex
  506. ;*
  507. ;*
  508. ;* Arguments:
  509. ;*
  510. ;* Returns:
  511. ;*
  512. ;* Comments:
  513. ;*     If you are having problems transmitting packet try changing the
  514. ;*     Max DMA Burst, Possible settings are as follows:
  515. ;*         0x00000000 = 512 bytes
  516. ;*         0x00100000 = 4 bytes
  517. ;*         0x00200000 = 8 bytes
  518. ;*         0x00300000 = 16 bytes
  519. ;*         0x00400000 = 32 bytes
  520. ;*         0x00500000 = 64 bytes
  521. ;*         0x00600000 = 128 bytes
  522. ;*         0x00700000 = 256 bytes
  523. ;***************************************************************************
  524. SIS900_set_tx_mode:
  525.    mov      ebp,[io_addr]
  526.    lea      edx,[ebp+SIS900_cr]
  527.    in       eax, dx                         ; Get current Command Register
  528.    or       eax, SIS900_TxENA   ;Enable Receive
  529.    out      dx, eax
  530.    lea      edx,[ebp+SIS900_txcfg]; Transmit config Register offset
  531.    mov      eax, SIS900_ATP             ;allow automatic padding
  532.    or       eax, SIS900_HBI             ;allow heartbeat ignore
  533.    or       eax, SIS900_CSI             ;allow carrier sense ignore
  534.    or       eax, 0x00600000     ;Max DMA Burst
  535.    or       eax, 0x00000100     ;TX Fill Threshold
  536.    or       eax, 0x00000020     ;TX Drain Threshold
  537.    out      dx, eax
  538.    ret
  539.  
  540. ;***************************************************************************
  541. ;* Function: sis900_set_rx_mode
  542. ;*
  543. ;* Description:
  544. ;*    sets the receive mode to accept all broadcast packets and packets
  545. ;*    with our MAC address, and reject all multicast packets.  Also allows
  546. ;*    full-duplex
  547. ;*
  548. ;* Arguments:
  549. ;*
  550. ;* Returns:
  551. ;*
  552. ;* Comments:
  553. ;*     If you are having problems receiving packet try changing the
  554. ;*     Max DMA Burst, Possible settings are as follows:
  555. ;*         0x00000000 = 512 bytes
  556. ;*         0x00100000 = 4 bytes
  557. ;*         0x00200000 = 8 bytes
  558. ;*         0x00300000 = 16 bytes
  559. ;*         0x00400000 = 32 bytes
  560. ;*         0x00500000 = 64 bytes
  561. ;*         0x00600000 = 128 bytes
  562. ;*         0x00700000 = 256 bytes
  563. ;***************************************************************************
  564. SIS900_mc_filter: times 16 dw 0
  565. SIS900_set_rx_mode:
  566.    mov      ebp,[io_addr]
  567.     ;**************update Multicast Hash Table in Receive Filter
  568.    mov      ebx, 0xffff
  569.    xor      cl, cl
  570. SIS900_set_rx_mode_Loop:
  571.    mov      eax, ecx
  572.    shl      eax, 1
  573.    mov      [SIS900_mc_filter+eax], ebx
  574.    lea      edx,[ebp+SIS900_rfcr]           ; Receive Filter Control Reg offset
  575.    mov      eax, 4                                          ;determine table entry
  576.    add      al, cl
  577.    shl      eax, 16
  578.    out      dx, eax                                         ;tell card which entry to modify
  579.    lea      edx,[ebp+SIS900_rfdr]           ; Receive Filter Control Reg offset
  580.    mov      eax, ebx                                ;entry value
  581.    out      dx, ax                                          ;write value to table in card
  582.    inc      cl                                              ;next entry
  583.    cmp      cl,[sis900_table_entries]   ;
  584.    jl       SIS900_set_rx_mode_Loop
  585.    ;*******Set Receive Filter Control Register*************
  586.    lea      edx,[ebp+SIS900_rfcr]       ; Receive Filter Control Register offset
  587.    mov      eax, SIS900_RFAAB           ;accecpt all broadcast packets
  588.    or       eax, SIS900_RFAAM           ;accept all multicast packets
  589.    or       eax, SIS900_RFAAP           ;Accept all packets
  590.    or       eax, SIS900_RFEN            ;enable receiver filter
  591.    out      dx, eax
  592.    ;******Enable Receiver************
  593.    lea      edx,[ebp+SIS900_cr] ; Command Register offset
  594.    in       eax, dx                         ; Get current Command Register
  595.    or       eax, SIS900_RxENA   ;Enable Receive
  596.    out      dx, eax
  597.    ;*********Set
  598.    lea      edx,[ebp+SIS900_rxcfg]      ; Receive Config Register offset
  599.    mov      eax, SIS900_ATX                     ;Accept Transmit Packets
  600.                                     ; (Req for full-duplex and PMD Loopback)
  601.    or       eax, 0x00600000                     ;Max DMA Burst
  602.    or       eax, 0x00000002                     ;RX Drain Threshold, 8X8 bytes or 64bytes
  603.    out      dx, eax                                     ;
  604.    ret
  605.  
  606. ;***************************************************************************
  607. ; *     SIS960_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
  608. ; *     @pci_dev: the sis900 pci device
  609. ; *     @net_dev: the net device to get address for
  610. ; *
  611. ; *     SiS962 or SiS963 model, use EEPROM to store MAC address. And EEPROM
  612. ; *     is shared by
  613. ; *     LAN and 1394. When access EEPROM, send EEREQ signal to hardware first
  614. ; *     and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be access
  615. ; *     by LAN, otherwise is not. After MAC address is read from EEPROM, send
  616. ; *     EEDONE signal to refuse EEPROM access by LAN.
  617. ; *     The EEPROM map of SiS962 or SiS963 is different to SiS900.
  618. ; *     The signature field in SiS962 or SiS963 spec is meaningless.
  619. ; *     MAC address is read into @net_dev->dev_addr.
  620. ; *done
  621. ;*
  622. ;* Return 0 is EAX = failure
  623. ;*Done+
  624. ;***************************************************************************
  625. if defined SIS900_DEBUG
  626. SIS900_Debug_Str_GetMac_Start db 'Attempting to get SIS900 Mac ID: ',13,10,0
  627. SIS900_Debug_Str_GetMac_Failed db 'Access to EEprom Failed',13,10,0
  628. SIS900_Debug_Str_GetMac_Address db 'Your Mac ID is: ',0
  629. SIS900_Debug_Str_GetMac_Address2 db 'Your SIS96x Mac ID is: ',0
  630. end if
  631. SIS960_get_mac_addr:
  632.    mov      ebp,[io_addr]
  633.    ;**********Send Request for eeprom access*********************
  634.    lea      edx,[ebp+SIS900_mear]               ; Eeprom access register
  635.    mov      eax, SIS900_EEREQ                   ; Request access to eeprom
  636.    out      dx, eax                                             ; Send request
  637.    xor      ebx,ebx                                             ;
  638.    ;******Loop 4000 times and if access not granted error out*****
  639. SIS96X_Get_Mac_Wait:
  640.    in       eax, dx                                     ;get eeprom status
  641.    and      eax, SIS900_EEGNT       ;see if eeprom access granted flag is set
  642.    jnz      SIS900_Got_EEP_Access       ;if it is, go access the eeprom
  643.    inc      ebx                                         ;else keep waiting
  644.    cmp      ebx, 4000                           ;have we tried 4000 times yet?
  645.    jl       SIS96X_Get_Mac_Wait     ;if not ask again
  646.    xor      eax, eax                ;return zero in eax indicating failure
  647.    ;*******Debug **********************
  648. if defined SIS900_DEBUG
  649.    mov esi,SIS900_Debug_Str_GetMac_Failed
  650.    call sys_msg_board_str
  651. end if
  652.    jmp SIS960_get_mac_addr_done
  653.    ;**********EEprom access granted, read MAC from card*************
  654. SIS900_Got_EEP_Access:
  655.     ; zero based so 3-16 bit reads will take place
  656.    mov      ecx, 2
  657. SIS96x_mac_read_loop:
  658.    mov      eax, SIS900_EEPROMMACAddr    ;Base Mac Address
  659.    add      eax, ecx                                 ;Current Mac Byte Offset
  660.    push     ecx
  661.    call     sis900_read_eeprom           ;try to read 16 bits
  662.    pop      ecx
  663.    mov      [node_addr+ecx*2], ax        ;save 16 bits to the MAC ID varible
  664.    dec      ecx                          ;one less word to read
  665.    jns      SIS96x_mac_read_loop         ;if more read more
  666.    mov      eax, 1                       ;return non-zero indicating success
  667.    ;*******Debug Print MAC ID to debug window**********************
  668. if defined SIS900_DEBUG
  669.    mov esi,SIS900_Debug_Str_GetMac_Address2
  670.    call sys_msg_board_str
  671.    mov edx, node_addr
  672.    call Create_Mac_String
  673. end if
  674.    ;**********Tell EEPROM We are Done Accessing It*********************
  675. SIS960_get_mac_addr_done:
  676.    lea      edx,[ebp+SIS900_mear]               ; Eeprom access register
  677.    mov      eax, SIS900_EEDONE           ;tell eeprom we are done
  678.    out      dx,eax
  679.    ret
  680. ;***************************************************************************
  681. ;*      sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model
  682. ;*      @pci_dev: the sis900 pci device
  683. ;*      @net_dev: the net device to get address for
  684. ;*
  685. ;*      Older SiS900 and friends, use EEPROM to store MAC address.
  686. ;*      MAC address is read from read_eeprom() into @net_dev->dev_addr.
  687. ;* done/untested
  688. ;***************************************************************************
  689. SIS900_get_mac_addr:
  690.    ;*******Debug **********************
  691. if defined SIS900_DEBUG
  692.    mov esi,SIS900_Debug_Str_GetMac_Start
  693.    call sys_msg_board_str
  694. end if
  695.    ;******** check to see if we have sane EEPROM *******
  696.    mov      eax, SIS900_EEPROMSignature  ;Base Eeprom Signature
  697.    call     sis900_read_eeprom           ;try to read 16 bits
  698.    cmp ax, 0xffff
  699.    je SIS900_Bad_Eeprom
  700.    cmp ax, 0
  701.    je SIS900_Bad_Eeprom
  702.    ;**************Read MacID**************
  703.    ; zero based so 3-16 bit reads will take place
  704.    mov      ecx, 2
  705. SIS900_mac_read_loop:
  706.    mov      eax, SIS900_EEPROMMACAddr    ;Base Mac Address
  707.    add      eax, ecx                                 ;Current Mac Byte Offset
  708.    push     ecx
  709.    call     sis900_read_eeprom           ;try to read 16 bits
  710.    pop      ecx
  711.    mov      [node_addr+ecx*2], ax        ;save 16 bits to the MAC ID storage
  712.    dec      ecx                          ;one less word to read
  713.    jns      SIS900_mac_read_loop         ;if more read more
  714.    mov      eax, 1                       ;return non-zero indicating success
  715.    ;*******Debug Print MAC ID to debug window**********************
  716. if defined SIS900_DEBUG
  717.    mov esi,SIS900_Debug_Str_GetMac_Address
  718.    call sys_msg_board_str
  719.    mov edx, node_addr
  720.    call Create_Mac_String
  721. end if
  722.    ret
  723.  
  724. SIS900_Bad_Eeprom:
  725.    xor eax, eax
  726.    ;*******Debug **********************
  727. if defined SIS900_DEBUG
  728.    mov esi,SIS900_Debug_Str_GetMac_Failed
  729.    call sys_msg_board_str
  730. end if
  731.    ret
  732. ;***************************************************************************
  733. ;*      Get_Mac_SIS635_900_REV: - Get MAC address for model 635
  734. ;*
  735. ;*
  736. ;***************************************************************************
  737. Get_Mac_SIS635_900_REV:
  738. if defined SIS900_DEBUG
  739.     mov     esi,SIS900_Debug_Str_GetMac_Start
  740.     call    sys_msg_board_str
  741. end if
  742.     mov     ebp,[io_addr]
  743.     lea     edx,[ebp+SIS900_rfcr]
  744.     in      eax,dx
  745.     mov     edi,eax ; EDI=rfcrSave
  746.     lea     edx,[ebp+SIS900_cr]
  747.     or      eax,SIS900_RELOAD
  748.     out     dx,eax
  749.     xor     eax,eax
  750.     out     dx,eax
  751.     ; Disable packet filtering before setting filter
  752.     lea     edx,[ebp+SIS900_rfcr]
  753.     mov     eax,edi
  754.     and     edi,not SIS900_RFEN
  755.     out     dx,eax
  756.     ; Load MAC to filter data register
  757.     xor     ecx,ecx
  758.     mov     esi,node_addr
  759. .get_mac_loop:
  760.     lea     edx,[ebp+SIS900_rfcr]
  761.     mov     eax,ecx
  762.     shl     eax,SIS900_RFADDR_shift
  763.     out     dx,eax
  764.     lea     edx,[ebp+SIS900_rfdr]
  765.     in      eax,dx
  766.     mov     [esi],ax
  767.     add     esi,2
  768.     inc     ecx
  769.     cmp     ecx,3
  770.     jne .get_mac_loop
  771.     ; Enable packet filtering
  772.     ;lea     edx,[ebp+SIS900_rfcr]
  773.     ;mov     eax,edi
  774.     ;or      eax,SIS900_RFEN
  775.     ;out     dx, eax
  776.    ;*******Debug Print MAC ID to debug window**********************
  777. if defined SIS900_DEBUG
  778.     mov     esi,SIS900_Debug_Str_GetMac_Address
  779.     call    sys_msg_board_str
  780.     mov     edx, node_addr
  781.     call    Create_Mac_String
  782. end if
  783.     ret
  784. ;***************************************************************************
  785. ;* Function: sis900_read_eeprom
  786. ;*
  787. ;* Description: reads and returns a given location from EEPROM
  788. ;*
  789. ;* Arguments: eax - location:       requested EEPROM location
  790. ;*
  791. ;* Returns:   eax :                contents of requested EEPROM location
  792. ;*
  793. ; Read Serial EEPROM through EEPROM Access Register, Note that location is
  794. ;   in word (16 bits) unit */
  795. ;done+
  796. ;***************************************************************************
  797. sis900_read_eeprom:
  798.    push      esi
  799.    push      edx
  800.    push      ecx
  801.    push      ebx
  802.    mov       ebp,[io_addr]
  803.    mov       ebx, eax              ;location of Mac byte to read
  804.    or        ebx, SIS900_EEread    ;
  805.    lea       edx,[ebp+SIS900_mear] ; Eeprom access register
  806.    xor       eax, eax              ; start send
  807.    out       dx,eax
  808.    call      SIS900_Eeprom_Delay_1
  809.    mov       eax, SIS900_EECLK
  810.    out       dx, eax
  811.    call      SIS900_Eeprom_Delay_1
  812.     ;************ Shift the read command (9) bits out. *********
  813.    mov       cl, 8                                      ;
  814. sis900_read_eeprom_Send:
  815.    mov       eax, 1
  816.    shl       eax, cl
  817.    and       eax, ebx
  818.    jz SIS900_Read_Eeprom_8
  819.    mov       eax, 9
  820.    jmp       SIS900_Read_Eeprom_9
  821. SIS900_Read_Eeprom_8:
  822.    mov       eax, 8
  823. SIS900_Read_Eeprom_9:
  824.    out       dx, eax
  825.    call      SIS900_Eeprom_Delay_1
  826.    or        eax, SIS900_EECLK
  827.    out       dx, eax
  828.    call      SIS900_Eeprom_Delay_1
  829.    cmp       cl, 0
  830.    je        sis900_read_eeprom_Send_Done
  831.    dec       cl
  832.    jmp       sis900_read_eeprom_Send
  833.    ;*********************
  834. sis900_read_eeprom_Send_Done:
  835.    mov       eax, SIS900_EECS           ;
  836.    out       dx, eax
  837.    call      SIS900_Eeprom_Delay_1
  838.     ;********** Read 16-bits of data in ***************
  839.     mov      cx, 16                             ;16 bits to read
  840. sis900_read_eeprom_Send2:
  841.     mov      eax, SIS900_EECS
  842.     out      dx, eax
  843.     call     SIS900_Eeprom_Delay_1
  844.     or       eax, SIS900_EECLK
  845.     out      dx, eax
  846.     call     SIS900_Eeprom_Delay_1
  847.     in       eax, dx
  848.     shl      ebx, 1
  849.     and      eax, SIS900_EEDO
  850.     jz       SIS900_Read_Eeprom_0
  851.     or       ebx, 1
  852. SIS900_Read_Eeprom_0:
  853.    dec       cx
  854.    jnz       sis900_read_eeprom_Send2
  855.    ;************** Terminate the EEPROM access. **************
  856.    xor       eax, eax
  857.    out       dx, eax
  858.    call      SIS900_Eeprom_Delay_1
  859.    mov       eax, SIS900_EECLK
  860.    out       dx, eax
  861.    mov       eax, ebx
  862.    and       eax, 0x0000ffff                    ;return only 16 bits
  863.    pop       ebx
  864.    pop       ecx
  865.    pop       edx
  866.    pop       esi
  867.    ret
  868. ;***************************************************************************
  869. ;   Function
  870. ;      SIS900_Eeprom_Delay_1
  871. ;   Description
  872. ;
  873. ;
  874. ;
  875. ;
  876. ;***************************************************************************
  877. SIS900_Eeprom_Delay_1:
  878.    push eax
  879.    in eax, dx
  880.    pop eax
  881.    ret
  882.  
  883. ;***************************************************************************
  884. ;   Function
  885. ;      SIS900_poll
  886. ;   Description
  887. ;      polls card to see if there is a packet waiting
  888. ;
  889. ;  Currently only supports one descriptor per packet, if packet is fragmented
  890. ;  between multiple descriptors you will lose part of the packet
  891. ;***************************************************************************
  892. if defined SIS900_DEBUG
  893. SIS900_Debug_Pull_Packet_good db 'Good Packet Waiting: ',13,10,0
  894. SIS900_Debug_Pull_Bad_Packet_Status db 'Bad Packet Waiting: Status',13,10,0
  895. SIS900_Debug_Pull_Bad_Packet_Size db 'Bad Packet Waiting: Size',13,10,0
  896. end if
  897. SIS900_poll:
  898.     ;**************Get Status **************
  899.     xor       eax, eax                      ;get RX_Status
  900.     mov      [eth_rx_data_len], ax
  901.     mov       al, [cur_rx]          ;find current discriptor
  902.     imul      eax, 12               ;
  903.     mov       ecx, [rxd+eax+4]          ; get receive status
  904.     ;**************Check Status **************
  905.     mov       ebx, ecx                          ;move status
  906.     ;Check RX_Status to see if packet is waiting
  907.     and       ebx, 0x80000000
  908.     jnz       SIS900_poll_IS_packet
  909.     ret
  910.    ;**********There is a packet waiting check it for errors**************
  911. SIS900_poll_IS_packet:
  912.     mov       ebx, ecx                          ;move status
  913.     and       ebx, 0x67C0000            ;see if there are any errors
  914.     jnz       SIS900_Poll_Error_Status
  915.    ;**************Check size of packet*************
  916.    and       ecx, SIS900_DSIZE                                  ;get packet size minus CRC
  917.    cmp       cx, SIS900_CRC_SIZE
  918.    ;make sure packet contains data
  919.    jle       SIS900_Poll_Error_Size
  920.    ;*******Copy Good Packet to receive buffer******
  921.    sub      cx, SIS900_CRC_SIZE                             ;dont want crc
  922.    mov      word [eth_rx_data_len], cx          ;save size of packet
  923.    ;**********Continue copying packet****************
  924.    push     ecx
  925.    ; first copy dword-wise, divide size by 4
  926.    shr      ecx, 2
  927.    mov      esi, [rxd+eax+8]                            ; set source
  928.    mov      edi, Ether_buffer               ; set destination
  929.    cld                                                                          ; clear direction
  930.    rep      movsd                                                       ; copy the dwords
  931.    pop      ecx
  932.    and      ecx, 3                                                  ;
  933.    rep      movsb
  934.    ;********Debug, tell user we have a good packet*************
  935. if defined SIS900_DEBUG
  936.    mov      esi, SIS900_Debug_Pull_Packet_good
  937.    call     sys_msg_board_str
  938. end if
  939.    jmp SIS900_Poll_Cnt                      ;
  940.    ;*************Error occured let user know through debug window***********
  941. SIS900_Poll_Error_Status:
  942. if defined SIS900_DEBUG
  943.                 mov      esi, SIS900_Debug_Pull_Bad_Packet_Status
  944.                 call     sys_msg_board_str
  945. end if
  946.                 jmp      SIS900_Poll_Cnt
  947. SIS900_Poll_Error_Size:
  948. if defined SIS900_DEBUG
  949.                 mov      esi, SIS900_Debug_Pull_Bad_Packet_Size
  950.                 call     sys_msg_board_str
  951. end if
  952.    ;*************Increment to next available descriptor**************
  953. SIS900_Poll_Cnt:
  954.     ;Reset status, allow ethernet card access to descriptor
  955.    mov      ecx, RX_BUFF_SZ
  956.    mov      [rxd+eax+4], ecx                ;
  957.    inc      [cur_rx]                                            ;get next descriptor
  958.    and      [cur_rx],3                      ;only 4 descriptors 0-3
  959.    ;******Enable Receiver************
  960.    mov          ebp, [io_addr]      ; Base Address
  961.    lea      edx,[ebp+SIS900_cr] ; Command Register offset
  962.    in       eax, dx                         ; Get current Command Register
  963.    or       eax, SIS900_RxENA   ;Enable Receive
  964.    out      dx, eax
  965.    ret
  966. ;***************************************************************************
  967. ;   Function
  968. ;      SIS900_transmit
  969. ;   Description
  970. ;      Transmits a packet of data via the ethernet card
  971. ;         Pointer to 48 bit destination address in edi
  972. ;         Type of packet in bx
  973. ;         size of packet in ecx
  974. ;         pointer to packet data in esi
  975. ;
  976. ;      only one transmit descriptor is used
  977. ;
  978. ;***************************************************************************
  979. if defined SIS900_DEBUG
  980. SIS900_Debug_Transmit_Packet db 'Transmitting Packet: ',13,10,0
  981. SIS900_Debug_Transmit_Packet_Err db 'Transmitting Packet Error: ',13,10,0
  982. end if
  983. SIS900_transmit:
  984.    mov          ebp, [io_addr]      ; Base Address
  985.    ;******** Stop the transmitter ********
  986.    lea      edx,[ebp+SIS900_cr] ; Command Register offset
  987.    in       eax, dx                         ; Get current Command Register
  988.    or       eax, SIS900_TxDIS   ; Disable Transmitter
  989.    out      dx, eax
  990.    ;*******load Transmit Descriptor Register *******
  991.    lea      edx,[ebp+SIS900_txdp]
  992.    mov      eax, txd
  993.    out      dx, eax
  994.    ;******* copy packet to descriptor*******
  995.    push    esi
  996.    mov     esi, edi                ;copy destination addess
  997.    mov     edi, txb
  998.    cld
  999.    movsd
  1000.    movsw
  1001.    mov     esi, node_addr  ;copy my mac address
  1002.    movsd
  1003.    movsw
  1004.    mov     [edi], bx       ;copy packet type
  1005.    add     edi, 2
  1006.    pop     esi             ;restore pointer to source of packet
  1007.    push    ecx             ;save packet size
  1008.    shr     ecx, 2          ;divide by 4, size in bytes send in dwords
  1009.    rep     movsd                   ;copy data to decriptor
  1010.    pop     ecx                     ;restore packet size
  1011.    push    ecx             ;save packet size
  1012.    and     ecx, 3          ;last three bytes if not a multiple of 4
  1013.    rep     movsb
  1014.    ;**************set length tag**************
  1015.    pop     ecx                           ;restore packet size
  1016.    add     ecx, SIS900_ETH_HLEN  ;add header to length
  1017.    and     ecx, SIS900_DSIZE     ;
  1018.    ;**************pad to minimum packet size **************not needed
  1019.    ;cmp       ecx, SIS900_ETH_ZLEN
  1020.    ;jge       SIS900_transmit_Size_Ok
  1021.    ;push      ecx
  1022.    ;mov       ebx, SIS900_ETH_ZLEN
  1023.    ;sub       ebx, ecx
  1024.    ;mov       ecx, ebx
  1025.    ;rep       movsb
  1026.    ;pop       ecx
  1027. SIS900_transmit_Size_Ok:
  1028.    mov      [txd+4], dword 0x80000000                   ;card owns descriptor
  1029.    or       [txd+4], ecx                                                ;set size of packet
  1030. if defined SIS900_DEBUG
  1031.    mov      esi, SIS900_Debug_Transmit_Packet
  1032.    call     sys_msg_board_str
  1033. end if
  1034.    ;***************restart the transmitter ********
  1035.    lea      edx,[ebp+SIS900_cr]
  1036.    in       eax, dx                         ; Get current Command Register
  1037.    or       eax, SIS900_TxENA   ; Enable Transmitter
  1038.    out      dx, eax
  1039.    ;****make sure packet transmitted successfully****
  1040. ;   mov      esi,10
  1041. ;   call     delay_ms
  1042.    mov      eax, [txd+4]
  1043.    and      eax, 0x6200000
  1044.    jz       SIS900_transmit_OK
  1045.    ;**************Tell user there was an error through debug window
  1046. if defined SIS900_DEBUG
  1047.    mov      esi, SIS900_Debug_Transmit_Packet_Err
  1048.    call     sys_msg_board_str
  1049. end if
  1050. SIS900_transmit_OK:
  1051.    ;******** Disable interrupts by clearing the interrupt mask. ********
  1052.    lea      edx,[ebp+SIS900_imr]            ; Interupt Mask Register
  1053.    xor      eax, eax
  1054.    out      dx,eax
  1055.    ret
  1056.  
  1057. ;***************************************************************************
  1058. ;* Function: Create_Mac_String
  1059. ;*
  1060. ;* Description: Converts the 48 bit value to a string for display
  1061. ;*
  1062. ;* String Format: XX:XX:XX:XX:XX:XX
  1063. ;*
  1064. ;* Arguments: node_addr is location of 48 bit MAC ID
  1065. ;*
  1066. ;* Returns:   Prints string to general debug window
  1067. ;*
  1068. ;*
  1069. ;done
  1070. ;***************************************************************************
  1071. if defined SIS900_DEBUG
  1072.  
  1073. SIS900_Char_String    db '0','1','2','3','4','5','6','7','8','9'
  1074.                       db 'A','B','C','D','E','F'
  1075. Mac_str_build: times 20 db 0
  1076. Create_Mac_String:
  1077.    pusha
  1078.    xor ecx, ecx
  1079. Create_Mac_String_loop:
  1080.    mov al,byte [edx+ecx];[node_addr+ecx]
  1081.    push eax
  1082.    shr eax, 4
  1083.    and eax, 0x0f
  1084.    mov bl, byte [SIS900_Char_String+eax]
  1085.    mov [Mac_str_build+ecx*3], bl
  1086.    pop eax
  1087.    and eax, 0x0f
  1088.    mov bl, byte [SIS900_Char_String+eax]
  1089.    mov [Mac_str_build+1+ecx*3], bl
  1090.    cmp ecx, 5
  1091.    je Create_Mac_String_done
  1092.    mov bl, ':'
  1093.    mov [Mac_str_build+2+ecx*3], bl
  1094.    inc ecx
  1095.    jmp Create_Mac_String_loop
  1096. Create_Mac_String_done:                                 ;Insert CR and Zero Terminate
  1097.    mov [Mac_str_build+2+ecx*3],byte 13
  1098.    mov [Mac_str_build+3+ecx*3],byte 10
  1099.    mov [Mac_str_build+4+ecx*3],byte 0
  1100.    mov esi, Mac_str_build
  1101.    call sys_msg_board_str                               ;Print String to message board
  1102.    popa
  1103.    ret
  1104. end if
  1105. ;***************************************************************************
  1106. ;*      Set device to be a busmaster in case BIOS neglected to do so.
  1107. ;*      Also adjust PCI latency timer to a reasonable value, 64.
  1108. ;***************************************************************************
  1109. SIS900_adjust_pci_device:
  1110.    ;*******Get current setting************************
  1111.    mov     al, 2                                        ;read a word
  1112.    mov     bh, [pci_dev]
  1113.    mov     ah, [pci_bus]
  1114.    mov     bl, 0x04                                 ;from command Register
  1115.    call    pci_read_reg
  1116.    ;******see if its already set as bus master********
  1117.    mov      bx, ax
  1118.    and      bx,5
  1119.    cmp      bx,5
  1120.    je       SIS900_adjust_pci_device_Latency
  1121.    ;******Make card a bus master*******
  1122.    mov      cx, ax                              ;value to write
  1123.    mov     bh, [pci_dev]
  1124.    mov     al, 2                                ;write a word
  1125.    or       cx,5
  1126.    mov     ah, [pci_bus]
  1127.    mov     bl, 0x04                             ;to command register
  1128.    call    pci_write_reg
  1129.    ;******Check latency setting***********
  1130. SIS900_adjust_pci_device_Latency:
  1131.    ;*******Get current latency setting************************
  1132.    mov     al, 1                                        ;read a byte
  1133.    mov     bh, [pci_dev]
  1134.    mov     ah, [pci_bus]
  1135.    mov     bl, 0x0D                                 ;from Lantency Timer Register
  1136.    call    pci_read_reg
  1137.    ;******see if its aat least 64 clocks********
  1138.    cmp      ax,64
  1139.    jge      SIS900_adjust_pci_device_Done
  1140.    ;******Set latency to 32 clocks*******
  1141.    mov     cx, 64                               ;value to write
  1142.    mov     bh, [pci_dev]
  1143.    mov     al, 1                                ;write a byte
  1144.    mov     ah, [pci_bus]
  1145.    mov     bl, 0x0D                             ;to Lantency Timer Register
  1146.    call    pci_write_reg
  1147.    ;******Check latency setting***********
  1148. SIS900_adjust_pci_device_Done:
  1149.    ret
  1150.