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

  1. version    equ    0
  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. ;Mangled to become a NI9210 driver, September 1989 by Russell Nelson
  11.  
  12. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  13.  
  14. ;   This program is free software; you can redistribute it and/or modify
  15. ;   it under the terms of the GNU General Public License as published by
  16. ;   the Free Software Foundation, version 1.
  17. ;
  18. ;   This program is distributed in the hope that it will be useful,
  19. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;   GNU General Public License for more details.
  22. ;
  23. ;   You should have received a copy of the GNU General Public License
  24. ;   along with this program; if not, write to the Free Software
  25. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. code    segment    word public
  28.     assume    cs:code, ds:code
  29.  
  30. ;
  31. ;  Equates for controlling the MICOM board
  32. ;
  33. ;  I/O addresses, writing anything in AL trips these gates
  34. ;
  35. ;  First six addresses are the EPROM board Ether address (read)
  36. ;
  37. IORESET    EQU    0            ; reset the board
  38. IOCA    EQU    2            ; execute command which is in SCB
  39. IODIS    EQU    4            ; disable network connect
  40. IOENA    EQU    6            ; enable network
  41.  
  42. ;
  43. ;  Data segment
  44. ;
  45.  
  46.     public    int_no
  47. int_no        db    2,0,0,0        ; interrupt number. 
  48. io_addr        dw    0360h,0        ; I/O address for card (pos)
  49. base_addr    dw      0d000h,0    ; base segment for board (pos)
  50.  
  51.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  52. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  53. driver_type    db    11        ;from the packet spec
  54. driver_name    db    "NI9210",0    ;name of the driver.
  55. driver_function    db    2
  56. parameter_list    label    byte
  57.     db    1    ;major rev of packet driver
  58.     db    9    ;minor rev of packet driver
  59.     db    14    ;length of parameter list
  60.     db    EADDR_LEN    ;length of MAC-layer address
  61.     dw    GIANT    ;MTU, including MAC headers
  62.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  63.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  64.     dw    0    ;(# of successive xmits) - 1
  65. int_num    dw    0    ;Interrupt # to hook for post-EOI
  66.             ;processing, 0 == none,
  67.  
  68. enable_network:
  69. ;  connect to network
  70.     loadport
  71.     setport    IOENA            ; enable network
  72.     out    dx,al            ; any al value
  73.     ret
  74.  
  75.  
  76. reset_586:
  77. ;  Reset the chip
  78.     loadport
  79.     setport    IORESET
  80.     out    dx,al
  81.     ret
  82.  
  83.  
  84. doca:
  85. ;we may be called from places in which ds is unknown.
  86.     assume    ds:nothing
  87.     loadport
  88.     setport    IOCA
  89.     out    dx,al            ; send it
  90.     ret
  91.     assume    ds:code
  92. ;yet, we really should assume ds==code for the rest of this stuff.
  93.  
  94. ;
  95. ; Here we include the code that is common between 82586 implementations.
  96. ; Everything above this is resident.
  97.     include    82586.asm
  98. ; Everything below this is discarded upon installation.
  99.  
  100.     public    usage_msg
  101. usage_msg    db    "usage: ni9210 [options] <packet_int_no> <hardware_irq> <io_addr> <base_addr>",CR,LF,'$'
  102.  
  103.     public    copyright_msg
  104. copyright_msg    db    "Packet driver for the MICOM-Interlan NI9210, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF
  105.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  106.  
  107. IRQ_MASK    equ    06h
  108. IRQ_TABLE    db    9            ; Interrupt Value 0
  109.         db    10            ; Interrupt Value 1
  110.         db    11            ; Interrupt Value 2
  111.         db    3            ; Interrupt Value 3
  112.  
  113. check_board:
  114.     mov    SCP,0            ; 16 bit bus type in scb.
  115.     ret
  116.  
  117. no_9210_msg    db    "No 9210 found.",CR,LF,'$'
  118.  
  119.  
  120. no_9210_io_msg    db    "No 9210 found at that I/O address.",CR,LF,'$'
  121. no_9210_mem_msg    db    "No 9210 found at that memory address.",CR,LF,'$'
  122.  
  123. get_address:
  124. ;get the address of the interface.
  125. ;enter with es:di -> place to get the address, cx = size of address buffer.
  126. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  127.     assume    ds:code
  128.     mov    cx,EADDR_LEN
  129.     mov    dx,io_addr        ; Get our IO base address.
  130.     cld
  131. get_address_1:
  132.     in    al,dx            ; get a byte of the eprom address
  133.     stosb                ; put it away
  134.     add    dx,2            ; next register
  135.     loop    get_address_1        ; go back for rest
  136.     ret
  137.  
  138.  
  139.     public    parse_args
  140. parse_args:
  141. ;The following code to read the POS registers is courtesy of Racal-Interlan.
  142.  
  143. ; channel selector resides at io 96h
  144. ; POS register base is at io 100h
  145. ; 9210 ID is 0DF0Fh
  146.  
  147. ; search thro' the slots for a 9210 card
  148.     mov    cx, 8            ; for all channels(slots)
  149.  
  150. ; channel select value for slots 0,1,2.. is 8,9,A etc
  151. ; start with slot 0, and then 7,6,5,4,3,2,1
  152. get_05:
  153.     mov    ax, cx            ; channel number
  154.     or    ax, 08h            ; reg. select value
  155.     mov    dx, 96h            ; channel select register
  156.     out    dx, al            ; select channel
  157.  
  158. ; read adapter id
  159.     mov    dx, 100h
  160.     in    al, dx            ; adapter id - ms byte
  161.     mov    ah, al
  162.     inc    dx
  163.     in    al, dx            ; adapter id - ls byte
  164.  
  165. ; Check if 9210
  166.     cmp    ax, 0DF0Fh
  167.     je    get_10
  168.     loop    get_05
  169.  
  170.     mov    dx,offset no_9210_msg
  171.     stc
  172.     ret
  173.  
  174. get_10:
  175. ; found our Adapter
  176.  
  177. ; Get Ni9210 I/O Address ( read POS Register 1 )
  178.     xor    ax,ax
  179.     mov    dx,103h
  180.     in    al,dx
  181.     xor    ah,ah
  182.     mov    cl,5
  183.     shl    ax,cl
  184.     mov    io_addr,ax
  185.  
  186. ; Get Ni9210 IRQ ( read POS Register 0 )
  187.     mov    dx,102h
  188.     in    al,dx
  189.     mov    bl,al
  190.     and    bx,IRQ_MASK
  191.     shr    bx,1
  192.     mov    al,IRQ_TABLE[bx]
  193.     mov    int_no,al
  194.  
  195. ; Get Memory Address ( read POS Registers 2 and 3 )
  196.     mov    dx,105h
  197.     in    al,dx
  198.     mov    ah,al
  199.     dec    dx
  200.     in    al,dx
  201.     and    ax,3fe0h
  202.     mov    cl,5
  203.     shl    ax,cl
  204.     mov    base_addr,ax
  205.  
  206.     mov    dx, 102h
  207.     in    al,dx
  208.     or    al,1            ;enable the card.
  209.     out    dx,al
  210.  
  211.     mov    dx, 96h            ;deselect the card.
  212.     xor    al,al
  213.     out    dx,al
  214.  
  215.     mov    dx,io_addr        ; i/o address
  216.     add    dx,EADDR_LEN*2        ; look past the ethernet address.
  217.     in    al,dx
  218.     mov    bl,al            ; assemble pattern to check
  219.     add    dx,2
  220.     in    al,dx
  221.     mov    bh,al
  222.     cmp    bx,05500h        ; pattern known to be there in ROM
  223.     jz    have_9210_io
  224.     mov    dx,offset no_9210_io_msg
  225.     mov    ah,9
  226.     int    21h
  227.     stc
  228.     ret
  229. have_9210_io:
  230.  
  231.     mov    ax,base_addr
  232.     mov    cx,2000h        ;test only what we are going to use.
  233.     call    memory_test
  234.     jz    have_9210_mem
  235.     mov    dx,offset no_9210_mem_msg
  236.     mov    ah,9
  237.     int    21h
  238.     stc
  239.     ret
  240. have_9210_mem:
  241.  
  242.     mov    di,offset int_no
  243.     call    get_number
  244.     mov    di,offset io_addr
  245.     call    get_number
  246.     mov    di,offset base_addr
  247.     call    get_number
  248.     clc
  249.     ret
  250.  
  251.  
  252. int_no_name    db    "Interrupt number ",'$'
  253. io_addr_name    db    "I/O port ",'$'
  254. base_addr_name    db    "Memory address ",'$'
  255.  
  256.  
  257.     public    print_parameters
  258. print_parameters:
  259.     mov    di,offset int_no
  260.     mov    dx,offset int_no_name
  261.     call    print_number
  262.     mov    di,offset io_addr
  263.     mov    dx,offset io_addr_name
  264.     call    print_number
  265.     mov    ax,memory_begin
  266.     mov    cl,4
  267.     shr    ax,cl
  268.     add    base_addr,ax
  269.     push    ax
  270.     mov    di,offset base_addr
  271.     mov    dx,offset base_addr_name
  272.     call    print_number
  273.     pop    ax
  274.     sub    base_addr,ax
  275.     ret
  276.  
  277.     include    memtest.asm
  278.  
  279. code    ends
  280.  
  281.     end
  282.