home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / driver6s / ni9210.asm < prev    next >
Assembly Source File  |  1990-03-15  |  6KB  |  212 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, 1989, Russell Nelson
  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    byte 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. BASE_OFFSET    equ    0        ; board's memory starts at zero.
  43. GET_ADDR_INC    equ    2        ; increment the I/O address by two.
  44.  
  45. ;
  46. ;  Data segment
  47. ;
  48.  
  49.     public    int_no
  50. int_no        db    2,0,0,0        ; interrupt number. 
  51. io_addr        dw    0360h,0        ; I/O address for card (pos)
  52. base_addr    dw      0d000h,0    ; base segment for board (pos)
  53.  
  54.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  55. driver_class    db    1        ;from the packet spec
  56. driver_type    db    11        ;from the packet spec
  57. driver_name    db    "NI9210",0    ;name of the driver.
  58. driver_function    db    2
  59. parameter_list    label    byte
  60.     db    1    ;major rev of packet driver
  61.     db    9    ;minor rev of packet driver
  62.     db    14    ;length of parameter list
  63.     db    EADDR_LEN    ;length of MAC-layer address
  64.     dw    GIANT    ;MTU, including MAC headers
  65.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  66.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  67.     dw    0    ;(# of successive xmits) - 1
  68.     dw    0    ;Interrupt # to hook for post-EOI
  69.             ;processing, 0 == none,
  70.  
  71. lbca:
  72. doca:
  73. ;we may be called from places in which ds is unknown.
  74.     assume    ds:nothing
  75.     loadport
  76.     setport    IOCA
  77.     out    dx,al            ; send it
  78.     ret
  79.     assume    ds:code
  80. ;yet, we really should assume ds==code for the rest of this stuff.
  81.  
  82. ;
  83. ; Here we include the code that is common between 82586 implementations.
  84. ; Everything above this is resident.
  85.     include    82586.asm
  86. ; Everything below this is discarded upon installation.
  87.  
  88.     public    usage_msg
  89. usage_msg    db    "usage: ni9210 <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  90.  
  91.     public    copyright_msg
  92. copyright_msg    db    "Packet driver for the MICOM-Interlan NI9210, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF
  93.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  94.  
  95. IRQ_MASK    equ    06h
  96. IRQ_TABLE    db    9            ; Interrupt Value 0
  97.         db    10            ; Interrupt Value 1
  98.         db    11            ; Interrupt Value 2
  99.         db    3            ; Interrupt Value 3
  100.  
  101. check_board:
  102.     mov    SCP,0            ; 16 bit bus type in scb.
  103.  
  104. ;The following code to read the POS registers is courtesy of Racal-Interlan.
  105.  
  106. ; channel selector resides at io 96h
  107. ; POS register base is at io 100h
  108. ; 9210 ID is 0DF0Fh
  109.  
  110. ; search thro' the slots for a 9210 card
  111.     mov    cx, 8            ; for all channels(slots)
  112.  
  113. ; channel select value for slots 0,1,2.. is 8,9,A etc
  114. ; start with slot 0, and then 7,6,5,4,3,2,1
  115. get_05:
  116.     mov    ax, cx            ; channel number
  117.     or    ax, 08h            ; reg. select value
  118.     mov    dx, 96h            ; channel select register
  119.     out    dx, al            ; select channel
  120.  
  121. ; read adapter id
  122.     mov    dx, 100h
  123.     in    al, dx            ; adapter id - ms byte
  124.     mov    ah, al
  125.     inc    dx
  126.     in    al, dx            ; adapter id - ls byte
  127.  
  128. ; Check if 9210
  129.     cmp    ax, 0DF0Fh
  130.     je    get_10
  131.     loop    get_05
  132.  
  133.     mov    dx,offset no_9210_msg
  134.     jmp    error
  135.  
  136. get_10:
  137. ; found our Adapter
  138.  
  139. ; Get Ni9210 I/O Address ( read POS Register 1 )
  140.     xor    ax,ax
  141.     mov    dx,103h
  142.     in    al,dx
  143.     xor    ah,ah
  144.     mov    cl,5
  145.     shl    ax,cl
  146.     mov    io_addr,ax
  147.  
  148. ; Get Ni9210 IRQ ( read POS Register 0 )
  149.     mov    dx,102h
  150.     in    al,dx
  151.     mov    bl,al
  152.     and    bx,IRQ_MASK
  153.     shr    bx,1
  154.     mov    al,IRQ_TABLE[bx]
  155.     mov    int_no,al
  156.  
  157. ; Get Memory Address ( read POS Registers 2 and 3 )
  158.     mov    dx,105h
  159.     in    al,dx
  160.     mov    ah,al
  161.     dec    dx
  162.     in    al,dx
  163.     and    ax,3fe0h
  164.     mov    cl,5
  165.     shl    ax,cl
  166.     mov    base_addr,ax
  167.  
  168.     mov    dx, 102h
  169.     in    al,dx
  170.     or    al,1            ;enable the card.
  171.     out    dx,al
  172.  
  173.     mov    dx, 96h            ;deselect the card.
  174.     xor    al,al
  175.     out    dx,al
  176.  
  177.     mov    dx,io_addr        ; i/o address
  178.     add    dx,EADDR_LEN*GET_ADDR_INC    ; look past the ethernet address.
  179.     in    al,dx
  180.     mov    bl,al            ; assemble pattern to check
  181.     add    dx,GET_ADDR_INC
  182.     in    al,dx
  183.     mov    bh,al
  184.     cmp    bx,05500h        ; pattern known to be there in ROM
  185.     jz    have_9210_io
  186.     pop    dx            ;drop our return address
  187.     mov    dx,offset no_9210_io_msg
  188.     jmp    error
  189. have_9210_io:
  190.  
  191.     mov    ax,base_addr
  192.     mov    cx,2000h        ;test only what we are going to use.
  193.     call    memory_test
  194.     jz    have_9210_mem
  195.     pop    dx            ;drop our return address
  196.     mov    dx,offset no_9210_mem_msg
  197.     jmp    error
  198. have_9210_mem:
  199.     ret
  200.  
  201. no_9210_msg    db    "No 9210 found.",CR,LF,'$'
  202.  
  203.  
  204. no_9210_io_msg    db    "No 9210 found at that I/O address.",CR,LF,'$'
  205. no_9210_mem_msg    db    "No 9210 found at that memory address.",CR,LF,'$'
  206.  
  207.     include    memtest.asm
  208.  
  209. code    ends
  210.  
  211.     end
  212.