Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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