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

  1. version    equ    1
  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. ;3c523 version Dan Lanciani ddl@harvard.* (received 5-18-89)
  9. ;Added Brad Clements' 1500 byte MTU, Russell Nelson.
  10. ;Changed it into a UB NIC-PS/2 driver, 10/90
  11.  
  12. ;  Copyright 1990-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 ubnicps2 board
  32. ;
  33. IO_CSR    equ    0
  34. IO_CA    equ    1
  35.  
  36.     public    int_no
  37. int_no        db    3,0,0,0        ; interrupt number
  38. io_addr        dw    300h,0        ; I/O address for card
  39. base_addr    dw      0d000h,0    ; RAM segment for board
  40. eprom_addr    dw      0c000h,0    ; EPROM segment for board
  41.  
  42.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  43. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  44. driver_type    db    41        ;from the packet spec
  45. driver_name    db    "UB NIC-PS2",0    ;name of the driver.
  46. driver_function    db    2
  47. parameter_list    label    byte
  48.     db    1    ;major rev of packet driver
  49.     db    9    ;minor rev of packet driver
  50.     db    14    ;length of parameter list
  51.     db    EADDR_LEN    ;length of MAC-layer address
  52.     dw    GIANT    ;MTU, including MAC headers
  53.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  54.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  55.     dw    0    ;(# of successive xmits) - 1
  56. int_num    dw    0    ;Interrupt # to hook for post-EOI
  57.             ;processing, 0 == none,
  58.  
  59. enable_network:
  60. ;  connect to network
  61.     loadport
  62.     setport    IO_CSR            ; enable network
  63.     in    al,dx
  64.     and    al,not 2        ;turn off loopback.
  65.     or    al,8            ;turn on 82586 interrupts.
  66.     out    dx,al
  67.     ret
  68.  
  69.  
  70. reset_586:
  71. ;  Reset the chip
  72.     loadport
  73.     setport    IO_CSR
  74.     in    al,dx
  75.     or    al,1
  76.     out    dx,al        ; reset the chip
  77.     jmp    $+2
  78.     jmp    $+2
  79.     jmp    $+2
  80.     and    al,not 1
  81.     out    dx,al        ; done resetting the chip
  82.     jmp    $+2
  83.     jmp    $+2
  84.     jmp    $+2
  85.     ret
  86.  
  87.  
  88. doca:
  89. ;we may be called from places in which ds is unknown.
  90.     assume    ds:nothing
  91.     loadport
  92.     setport IO_CA
  93.     out    dx, al
  94.     ret
  95.     assume    ds:code
  96. ;yet, we really should assume ds==code for the rest of this stuff.
  97.  
  98.  
  99. ;
  100. ; Here we include the code that is common between 82586 implementations.
  101. ; Everything above this is resident.
  102.     include    82586.asm
  103. ; Everything below this is discarded upon installation.
  104.  
  105.     public    usage_msg
  106. usage_msg    db    "usage: ubnicps2 [options] <packet_int_no> <hardware_irq> <io_addr> <base_addr>",CR,LF,'$'
  107.  
  108.     public    copyright_msg
  109. copyright_msg    db    "Packet driver for the ubnicps2, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF,'$'
  110.  
  111. check_board:
  112.     mov    SCP,0            ; 16 bit bus type in scb.
  113.     ret
  114.  
  115. no_ubnicps2_msg    db    "No ubnicps2 found in the system",CR,LF,'$'
  116.  
  117.     public    parse_args
  118. parse_args:
  119. ; search all slots for a ubnicps2 card
  120.     mov    cx, 8            ; for all channels(slots)
  121.  
  122. ; channel select value for slots 0,1,2.. is 8,9,A etc
  123. ; start with slot 0, and then 7,6,5,4,3,2,1
  124. get_05:
  125.     mov    ax, cx            ; channel number
  126.     or    ax, 08h            ; reg. select value
  127.     out    96h, al            ; select channel
  128.  
  129. ; read adapter id
  130.     mov    dx, 101h
  131.     in    al, dx            ; adapter id - ms byte
  132.     mov    ah, al
  133.     dec    dx
  134.     in    al, dx            ; adapter id - ls byte
  135.  
  136. ; Check if ubnicps2
  137.     cmp    ax, 0eff5h
  138.     je    get_10
  139.     loop    get_05
  140.  
  141.     mov    dx,offset no_ubnicps2_msg
  142.     mov    ah,9
  143.     int    21h
  144.     stc
  145.     ret
  146.  
  147. get_10:
  148. ; found our Adapter
  149.  
  150. ; Get ubnicps2 I/O address
  151.     mov    dx,102h
  152.     in    al,dx
  153.     mov    bl,al
  154.     xor    bh,bh
  155.     shl    bx,1            ;should start at bit 2, now at bit 1.
  156.     and    bx,1ch
  157.     or    bx,1540h
  158.     mov    io_addr,bx
  159.  
  160. ; Set ubnicps2 IRQ.  Unbelievably, it only uses interrupt number 3.
  161.     mov    int_no,3
  162.  
  163. ; Get ubnicps2 RAM address
  164.     mov    dx,103h
  165.     in    al,dx
  166.     xor    bl,bl
  167.     mov    bh,al            ;put it in the high byte.
  168.     mov    cl,4
  169.     shl    bx,cl
  170.     mov    base_addr,bx
  171.  
  172. ; Get ubnicps2 EPROM address
  173.     mov    dx,104h
  174.     in    al,dx
  175.     xor    bl,bl
  176.     mov    bh,al            ;put it in the high byte.
  177.     mov    cl,4
  178.     shl    bx,cl
  179.     mov    eprom_addr,bx
  180.  
  181. ; Get ubnicps2 RAM address bits.
  182.     mov    dx,105h
  183.     in    al,dx
  184.     mov    bl,al
  185.     xor    bh,bh
  186.     mov    cl,10-0            ;should start at bit 10, now at bit 0.
  187.     shl    bx,cl
  188.     and    bx,0c00h
  189.     or    base_addr,bx
  190.  
  191. ; Get ubnicps2 EPROM address bits.
  192.     mov    dx,105h
  193.     in    al,dx
  194.     mov    bl,al
  195.     xor    bh,bh
  196.     mov    cl,10-2            ;should start at bit 10, now at bit 2.
  197.     shl    bx,cl
  198.     and    bx,0c00h
  199.     or    eprom_addr,bx
  200.  
  201.     mov    dx, 102h
  202.     in    al,dx
  203.     or    al,1            ;enable the card.
  204.     out    dx,al
  205.  
  206.     xor    al,al
  207.     out    96h,al            ;deselect the card.
  208.  
  209.     mov    di,offset int_no
  210.     call    get_number
  211.     mov    di,offset io_addr
  212.     call    get_number
  213.     mov    di,offset base_addr
  214.     call    get_number
  215.     clc
  216.     ret
  217.  
  218.  
  219. int_no_name    db    "Interrupt number ",'$'
  220. io_addr_name    db    "I/O port ",'$'
  221. base_addr_name    db    "Memory address ",'$'
  222.  
  223.  
  224.     public    print_parameters
  225. print_parameters:
  226.     mov    di,offset int_no
  227.     mov    dx,offset int_no_name
  228.     call    print_number
  229.     mov    di,offset io_addr
  230.     mov    dx,offset io_addr_name
  231.     call    print_number
  232.     mov    ax,memory_begin
  233.     mov    cl,4
  234.     shr    ax,cl
  235.     add    base_addr,ax
  236.     push    ax
  237.     mov    di,offset base_addr
  238.     mov    dx,offset base_addr_name
  239.     call    print_number
  240.     pop    ax
  241.     sub    base_addr,ax
  242.     ret
  243.  
  244. get_address:
  245. ;get the address of the interface.
  246. ;enter with es:di -> place to get the address, cx = size of address buffer.
  247. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  248.     assume    ds:code
  249.     push    ds            ;save ds.
  250.     mov    ds,eprom_addr        ;point to the eprom.
  251.     mov    si,10h
  252.     cld
  253. get_address_1:
  254.     lodsw                ;we have to get words,
  255.     stosb                ;  and store bytes.
  256.     loop    get_address_1        ; go back for rest
  257.     pop    ds
  258.     ret
  259.  
  260.  
  261.     include    memtest.asm
  262.  
  263. code    ends
  264.  
  265.     end
  266.