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

  1. version    equ    2
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210, by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;Updated to version 1.08 Feb. 17, 1989 by Russell Nelson.
  9. ;Updated to support 1500 byte MTU April 27, 1989 By Brad Clements.
  10.  
  11. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  12.  
  13. ;   This program is free software; you can redistribute it and/or modify
  14. ;   it under the terms of the GNU General Public License as published by
  15. ;   the Free Software Foundation, version 1.
  16. ;
  17. ;   This program is distributed in the hope that it will be useful,
  18. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;   GNU General Public License for more details.
  21. ;
  22. ;   You should have received a copy of the GNU General Public License
  23. ;   along with this program; if not, write to the Free Software
  24. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. code    segment    word public
  27.     assume    cs:code, ds:code
  28.  
  29. ;
  30. ;  Equates for controlling the MICOM board
  31. ;
  32. ;  I/O addresses, writing anything in AL trips these gates
  33. ;
  34. ;  First six addresses are the EPROM board Ether address (read)
  35. ;
  36. IORESET    EQU    0            ; reset the board
  37. IOCA    EQU    1            ; execute command which is in SCB
  38. IODIS    EQU    2            ; disable network connect
  39. IOENA    EQU    3            ; enable network
  40. IOINTON    EQU    4            ; enable interrupts
  41. IOINTOF    EQU    5            ; disable interrupts, '586 thinks it still ints
  42.  
  43. ;
  44. ;  Data segment
  45. ;
  46.  
  47.     public    int_no
  48. int_no        db    2,0,0,0        ; interrupt number. 
  49. io_addr        dw    0360h,0        ; I/O address for card (jumpers)
  50. base_addr    dw      0d000h,0    ; base segment for board (jumper set)
  51.  
  52.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  53. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  54. driver_type    db    11        ;from the packet spec
  55. driver_name    db    "NI5210",0    ;name of the driver.
  56. driver_function    db    2
  57. parameter_list    label    byte
  58.     db    1    ;major rev of packet driver
  59.     db    9    ;minor rev of packet driver
  60.     db    14    ;length of parameter list
  61.     db    EADDR_LEN    ;length of MAC-layer address
  62.     dw    GIANT    ;MTU, including MAC headers
  63.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  64.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  65.     dw    0    ;(# of successive xmits) - 1
  66. int_num    dw    0    ;Interrupt # to hook for post-EOI
  67.             ;processing, 0 == none,
  68.  
  69. enable_network:
  70. ;  connect to network
  71.     loadport
  72.     setport    IOENA            ; enable network
  73.     out    dx,al            ; any al value
  74.     ret
  75.  
  76.  
  77. reset_586:
  78. ;  Reset the chip
  79.     loadport
  80.     setport    IORESET
  81.     out    dx,al
  82.     ret
  83.  
  84.  
  85. doca:
  86. ;we may be called from places in which ds is unknown.
  87.     assume    ds:nothing
  88.     loadport
  89.     setport    IOCA
  90.     out    dx,al            ; send it
  91.     ret
  92.     assume    ds:code
  93. ;yet, we really should assume ds==code for the rest of this stuff.
  94.  
  95. ;
  96. ; Here we include the code that is common between 82586 implementations.
  97. ; Everything above this is resident.
  98.     include    82586.asm
  99. ; Everything below this is discarded upon installation.
  100.  
  101.     public    usage_msg
  102. usage_msg    db    "usage: ni5210 [options] <packet_int_no> <hardware_irq> <io_addr> <base_addr>",CR,LF,'$'
  103.  
  104.     public    copyright_msg
  105. copyright_msg    db    "Packet driver for the MICOM-Interlan NI5210, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF
  106.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  107.  
  108. check_board:
  109.     mov    SCP,1
  110.     mov    dx,io_addr    ; i/o address
  111.     add    dx,EADDR_LEN    ; look past the ethernet address.
  112.     in    al,dx
  113.     mov    bl,al        ; assemble pattern to check
  114.     inc    dx
  115.     in    al,dx
  116.     mov    bh,al
  117.     cmp    bx,05500h        ; pattern known to be there in ROM
  118.     jz    have_5210_io
  119.     mov    dx,offset no_5210_io_msg
  120.     stc
  121.     ret
  122. have_5210_io:
  123.  
  124.     mov    ax,base_addr
  125.     mov    cx,2000h        ;test only what we are going to use.
  126.     call    memory_test
  127.     jz    have_5210_mem
  128.     mov    dx,offset no_5210_mem_msg
  129.     stc
  130.     ret
  131. have_5210_mem:
  132.     ret
  133.  
  134.  
  135. no_5210_io_msg    db    "No 5210 found at that I/O address.",CR,LF,'$'
  136. no_5210_mem_msg    db    "No 5210 found at that memory address.",CR,LF,'$'
  137.  
  138. get_address:
  139. ;get the address of the interface.
  140. ;enter with es:di -> place to get the address, cx = size of address buffer.
  141. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  142.     assume    ds:code
  143.     mov    cx,EADDR_LEN
  144.     mov    dx,io_addr        ; Get our IO base address.
  145.     cld
  146. get_address_1:
  147.     in    al,dx            ; get a byte of the eprom address
  148.     stosb                ; put it away
  149.     inc    dx            ; next register
  150.     loop    get_address_1        ; go back for rest
  151.     ret
  152.  
  153.  
  154.     public    parse_args
  155. parse_args:
  156.     mov    di,offset int_no
  157.     call    get_number
  158.     mov    di,offset io_addr
  159.     call    get_number
  160.     mov    di,offset base_addr
  161.     call    get_number
  162.     clc
  163.     ret
  164.  
  165.  
  166. int_no_name    db    "Interrupt number ",'$'
  167. io_addr_name    db    "I/O port ",'$'
  168. base_addr_name    db    "Memory address ",'$'
  169.  
  170.  
  171.     public    print_parameters
  172. print_parameters:
  173.     mov    di,offset int_no
  174.     mov    dx,offset int_no_name
  175.     call    print_number
  176.     mov    di,offset io_addr
  177.     mov    dx,offset io_addr_name
  178.     call    print_number
  179.     mov    ax,memory_begin
  180.     mov    cl,4
  181.     shr    ax,cl
  182.     add    base_addr,ax
  183.     push    ax
  184.     mov    di,offset base_addr
  185.     mov    dx,offset base_addr_name
  186.     call    print_number
  187.     pop    ax
  188.     sub    base_addr,ax
  189.     ret
  190.  
  191.     include    memtest.asm
  192.  
  193. code    ends
  194.  
  195.     end
  196.