home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / ni6510.asm < prev    next >
Assembly Source File  |  1995-06-25  |  5KB  |  207 lines

  1. version    equ    1
  2.  
  3. ; Copyright, 1990-1992, Russell Nelson, Crynwr Software
  4.  
  5. ;   This program is free software; you can redistribute it and/or modify
  6. ;   it under the terms of the GNU General Public License as published by
  7. ;   the Free Software Foundation, version 1.
  8. ;
  9. ;   This program is distributed in the hope that it will be useful,
  10. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ;   GNU General Public License for more details.
  13. ;
  14. ;   You should have received a copy of the GNU General Public License
  15. ;   along with this program; if not, write to the Free Software
  16. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. comment /
  19.  
  20. I found a problem when using the Interlan NI6510 Packet Driver with 16 bit DMA.
  21. I looked at the source and I think I found the bug.  I've tested the fixed code
  22. and it seems to work fine for all possible DMA settings, at least over here.
  23.  
  24. Anto Prijosoesilo,
  25. Network & Microcomputer Consultant,
  26. University of North Texas Computing Center,
  27. Denton, Texas
  28.  
  29. /
  30.  
  31.     .286                ;the 6510 requires a 286.
  32.  
  33.     include    defs.asm
  34.  
  35. DATA_REG    equ    0
  36. ADDR_REG    equ    2
  37. RESET        equ    4
  38. CONFIG        equ    5
  39. EBASE        equ    8
  40.  
  41. code    segment    para public
  42.     assume    cs:code, ds:code
  43.  
  44.     public    int_no
  45. int_no    db    2,0,0,0            ;must be four bytes long for get_number.
  46. io_addr    dw    -1,-1
  47. dma_no    db    ?,0,0,0
  48.  
  49.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  50. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  51. driver_type    db    35        ;from the packet spec
  52. driver_name    db    'NI6510',0    ;name of the driver.
  53. driver_function    db    2        ;basic, extended
  54. parameter_list    label    byte
  55.     db    1    ;major rev of packet driver
  56.     db    9    ;minor rev of packet driver
  57.     db    14    ;length of parameter list
  58.     db    EADDR_LEN    ;length of MAC-layer address
  59.     dw    GIANT    ;MTU, including MAC headers
  60.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  61.     dw    RECEIVE_BUF_COUNT-1    ;(# of back-to-back MTU rcvs) - 1
  62.     dw    TRANSMIT_BUF_COUNT-1    ;(# of successive xmits) - 1
  63. int_num    dw    0    ;Interrupt # to hook for post-EOI
  64.             ;processing, 0 == none,
  65.  
  66. reset_lance    macro
  67.     loadport
  68.     setport    RESET
  69.     out    dx,al
  70.     endm
  71.  
  72.     include    lance.asm
  73.  
  74.     public    usage_msg
  75. usage_msg    db    "usage: ni6510 [options] <packet_int_no> <hardware_irq> <io_addr>",CR,LF,'$'
  76. no_board_msg    db    "No NI6510 detected.",CR,LF,'$'
  77. have_eb_msg    db    "Use the NE2100 packet driver instead.",CR,LF,'$'
  78. io_addr_funny_msg    label    byte
  79.         db    "No NI6510 detected, continuing anyway.",CR,LF,'$'
  80. bad_reset_msg    db    "Unable to reset the NI6510.",CR,LF,'$'
  81. bad_init_msg    db    "Unable to initialize the NI6510.",CR,LF,'$'
  82. no_memory_msg    db    "Unable to allocate enough memory, look at end_resident in NI6510.ASM",CR,LF,'$'
  83.  
  84.     public    copyright_msg
  85. copyright_msg    db    "Packet driver for a Racal Interlan NI6510, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+lance_version,".",'0'+version,CR,LF
  86.         db    '$'
  87.  
  88. int_nos        db    9, 12, 15, 5    ;interrupt numbers.
  89. dma_nos        db    0, 3, 5, 6    ;dma channel numbers
  90.  
  91.     public    parse_args
  92. parse_args:
  93. ;exit with nc if all went well, cy otherwise.
  94.     assume    ds:code
  95.     mov    di,offset int_no
  96.     call    get_number
  97.     mov    di,offset io_addr
  98.     call    get_number
  99.     clc
  100.     ret
  101.  
  102.  
  103. check_board:
  104.     cmp    io_addr,-1        ;Did they ask for auto-detect?
  105.     je    find_board
  106.  
  107.     call    detect_ni6510        ;no, just verify its existance.
  108.     je    find_board_found
  109.     call    detect_eb
  110.     je    find_board_eb
  111.  
  112.     mov    dx,offset io_addr_funny_msg
  113.     mov    ah,9
  114.     int    21h
  115.  
  116.     jmp    find_board_found
  117.  
  118. find_board:
  119.     mov    io_addr,300h        ;Search for the Ethernet address.
  120.     mov    io_addr+2,0
  121. find_board_0:
  122.     call    detect_ni6510
  123.     je    find_board_found
  124.     call    detect_eb
  125.     je    find_board_eb
  126. find_board_again:
  127.     add    io_addr,20h        ;not at this port, try another.
  128.     cmp    io_addr,360h
  129.     jbe    find_board_0
  130.  
  131.     mov    dx,offset no_board_msg    ;Tell them that we can't find it.
  132.     stc
  133.     ret
  134. find_board_eb:
  135.     mov    dx,offset have_eb_msg    ;Tell them to use ne2100.
  136.     stc
  137.     ret
  138. find_board_found:
  139.  
  140.     loadport            ;get the configuration register and
  141.     setport    CONFIG            ;  determine the interrupt number.
  142.     in    al,dx
  143.     shr    al,2
  144.     and    al,3
  145.     mov    bl,al
  146.     xor    bh,bh
  147.     mov    al,int_nos[bx]
  148.     mov    int_no,al
  149.  
  150. ;This routine will put the (host) DMA controller into
  151. ;cascade mode of operation.
  152.  
  153.     in    al,dx            ;get the dma channel field.
  154.     and    al,3
  155.     mov    bl,al
  156.     xor    bh,bh
  157.     mov    al,dma_nos[bx]
  158.     mov    dma_no,al
  159.  
  160.     clc
  161.     ret
  162.  
  163. detect_ni6510:
  164. ;test to see if a board is located at io_addr.
  165. ;return nz if not.
  166.     loadport
  167.     setport    EBASE
  168.     in    al,dx            ;Check for Interlan's prefix word.
  169.     cmp    al,2
  170.     jne    detect_ni6510_exit
  171.  
  172.     setport    EBASE+1
  173.     in    al,dx
  174.     cmp    al,7
  175.     jne    detect_ni6510_exit
  176.  
  177.     setport    EBASE+EADDR_LEN        ;first byte following should be 0
  178.     in    al,dx
  179.     cmp    al,0
  180.     jne    detect_ni6510_exit
  181.  
  182.     setport    EBASE+EADDR_LEN+1    ;second byte should be 55h
  183.     in    al,dx
  184.     cmp    al,55h
  185. detect_ni6510_exit:
  186.     ret
  187.  
  188. detect_eb:
  189. ;test to see if an EtherBlaster board is located at io_addr.
  190. ;return nz if not.
  191.     loadport
  192.     setport    0
  193.     in    al,dx            ;Check for Interlan's prefix word.
  194.     cmp    al,2
  195.     jne    detect_eb_exit
  196.  
  197.     setport    1
  198.     in    al,dx
  199.     cmp    al,7
  200. detect_eb_exit:
  201.     ret
  202.  
  203.  
  204. code    ends
  205.  
  206.     end
  207.