home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / 3c523.asm < prev    next >
Assembly Source File  |  1995-06-25  |  6KB  |  302 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.  
  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 3c523 board
  31. ;
  32. IOC    EQU    6
  33.  
  34.     public    int_no
  35. int_no        db    3,0,0,0        ; interrupt number
  36. io_addr        dw    300h,0        ; I/O address for card
  37. base_addr    dw      0c000h,0    ; base segment for board
  38.  
  39.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  40. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  41. driver_type    db    13        ;from the packet spec
  42. driver_name    db    "3C523",0    ;name of the driver.
  43. driver_function    db    2
  44. parameter_list    label    byte
  45.     db    1    ;major rev of packet driver
  46.     db    9    ;minor rev of packet driver
  47.     db    14    ;length of parameter list
  48.     db    EADDR_LEN    ;length of MAC-layer address
  49.     dw    GIANT    ;MTU, including MAC headers
  50.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  51.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  52.     dw    0    ;(# of successive xmits) - 1
  53. int_num    dw    0    ;Interrupt # to hook for post-EOI
  54.             ;processing, 0 == none,
  55.  
  56. ca_high    db    0a3h + 40h
  57. ca_low    db    0a3h
  58.  
  59.  
  60.     include    popf.asm
  61.  
  62. enable_network:
  63.     mov    ca_high,087h + 40h
  64.     mov    ca_low,087h
  65.     ret
  66.  
  67.  
  68. reset_586:
  69. ;  Reset the chip
  70.     loadport
  71.     setport    IOC
  72.     mov    al,0a3h
  73.     out    dx,al        ; reset the chip
  74.     jmp    $+2
  75.     jmp    $+2
  76.     jmp    $+2
  77.     mov    al,23h
  78.     out    dx,al        ; reset the chip
  79.     jmp    $+2
  80.     jmp    $+2
  81.     jmp    $+2
  82.     mov    al,0a3h
  83.     out    dx,al        ; reset the chip
  84.     jmp    $+2
  85.     jmp    $+2
  86.     jmp    $+2
  87.     ret
  88.  
  89. doca:
  90. ;we may be called from places in which ds is unknown.
  91.     assume    ds:nothing
  92.     loadport
  93.     setport IOC
  94.     mov    al,ca_high
  95.     pushf
  96.     cli
  97.     out    dx, al
  98.     jmp    $+2
  99.     jmp    $+2
  100.     jmp    $+2
  101.     mov    al,ca_low
  102.     out    dx, al
  103.     popf
  104.     ret
  105.     assume    ds:code
  106. ;yet, we really should assume ds==code for the rest of this stuff.
  107.  
  108.  
  109. ;
  110. ; Here we include the code that is common between 82586 implementations.
  111. ; Everything above this is resident.
  112.     include    82586.asm
  113. ; Everything below this is discarded upon installation.
  114.  
  115.     public    usage_msg
  116. usage_msg    db    "usage: 3c523 [options] <packet_int_no> <hardware_irq> <io_addr> <base_addr>",CR,LF,'$'
  117.  
  118.     public    copyright_msg
  119. copyright_msg    db    "Packet driver for the 3C523, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF
  120.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  121.  
  122. comment \
  123.  
  124.     The 3c523 responds with adapter code 0x6042 at slot
  125. registers xxx0 and xxx1.  The setup register is at xxx2 and
  126. contains the following bits:
  127.  
  128. 0: card enable
  129. 2,1: csr address select
  130.     00 = 0300
  131.     01 = 1300
  132.     10 = 2300
  133.     11 = 3300
  134. 4,3: shared memory address select
  135.     00 = 0c0000
  136.     01 = 0c8000
  137.     10 = 0d0000
  138.     11 = 0d8000
  139. 5: set to disable on-board thinnet
  140. 7,6: (read-only) shows selected irq
  141.     00 = 12
  142.     01 = 7
  143.     10 = 3
  144.     11 = 9
  145.  
  146. The interrupt-select register is at xxx3 and uses one bit per irq.
  147.  
  148. 0: int 12
  149. 1: int 7
  150. 2: int 3
  151. 3: int 9
  152.  
  153.     Again, the documentation stresses that the setup register
  154. should never be written.  The interrupt-select register may be
  155. written with the value corresponding to bits 7.6 in
  156. the setup register to insure corret setup.
  157.  
  158. \
  159.  
  160. IRQ_MASK    equ    0c0h
  161. IRQ_TABLE    db    12            ; Interrupt Value 0
  162.         db    7            ; Interrupt Value 1
  163.         db    3            ; Interrupt Value 2
  164.         db    9            ; Interrupt Value 3
  165.  
  166. check_board:
  167.     mov    SCP,0            ; 16 bit bus type in scb.
  168.     clc
  169.     ret
  170.  
  171. no_3c523_msg    db    "No 3c523 found in your system.",CR,LF,'$'
  172.  
  173. get_address:
  174. ;get the address of the interface.
  175. ;enter with es:di -> place to get the address, cx = size of address buffer.
  176. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  177.     assume    ds:code
  178.     mov    dx,io_addr        ; Get our IO base address.
  179.     cld
  180. get_address_1:
  181.     in    al,dx            ; get a byte of the eprom address
  182.     stosb                ; put it away
  183.     inc    dx            ; next register
  184.     loop    get_address_1        ; go back for rest
  185.     ret
  186.  
  187.  
  188.     public    parse_args
  189. parse_args:
  190. ; search all slots for a 3c523 card
  191.     mov    cx, 8            ; for all channels(slots)
  192.  
  193. ; channel select value for slots 0,1,2.. is 8,9,A etc
  194. ; start with slot 0, and then 7,6,5,4,3,2,1
  195. get_05:
  196.     mov    ax, cx            ; channel number
  197.     or    ax, 08h            ; reg. select value
  198.     out    96h, al            ; select channel
  199.  
  200. ; read adapter id
  201.     mov    dx, 101h
  202.     in    al, dx            ; adapter id - ms byte
  203.     mov    ah, al
  204.     dec    dx
  205.     in    al, dx            ; adapter id - ls byte
  206.  
  207. ; Check if 3c523
  208.     cmp    ax, 06042h
  209.     je    get_10
  210.     loop    get_05
  211.  
  212.     mov    dx,offset no_3c523_msg
  213.     mov    ah,9
  214.     int    21h
  215.     stc
  216.     ret
  217.  
  218. get_10:
  219. ; found our Adapter
  220.  
  221. ; Get 3c523 IRQ ( read POS Register 0 )
  222.     mov    dx,102h
  223.     in    al,dx
  224.     mov    bl,al
  225.     and    bx,IRQ_MASK
  226.     mov    cl,6
  227.     shr    bx,cl
  228.     mov    al,IRQ_TABLE[bx]
  229.     mov    int_no,al
  230.  
  231. ; Get 3c523 memory address ( read POS Register 0 )
  232.     mov    dx,102h
  233.     in    al,dx
  234.     mov    bl,al
  235.     xor    bh,bh
  236.     mov    cl,11-3
  237.     shl    bx,cl
  238.     and    bx,01800h
  239.     or    bx,0c000h
  240.     mov    base_addr,bx
  241.  
  242. ; Get 3c523 I/O address ( read POS Register 0 )
  243.     mov    dx,102h
  244.     in    al,dx
  245.     mov    bl,al
  246.     xor    bh,bh
  247.     mov    cl,12-1            ;should start at bit 12, now at bit 1.
  248.     shl    bx,cl
  249.     and    bx,3000h
  250.     or    bx,0300h
  251.     mov    io_addr,bx
  252.  
  253.     mov    dx, 102h
  254.     in    al,dx
  255.     or    al,1            ;enable the card.
  256.     out    dx,al
  257.  
  258.     xor    al,al
  259.     out    96h,al            ;deselect the card.
  260.  
  261.     mov    di,offset int_no
  262.     call    get_number
  263.     mov    di,offset io_addr
  264.     call    get_number
  265.     mov    di,offset base_addr
  266.     call    get_number
  267.     clc
  268.     ret
  269.  
  270.  
  271. int_no_name    db    "Interrupt number ",'$'
  272. io_addr_name    db    "I/O port ",'$'
  273. base_addr_name    db    "Memory address ",'$'
  274.  
  275.  
  276.     public    print_parameters
  277. print_parameters:
  278.     mov    di,offset int_no
  279.     mov    dx,offset int_no_name
  280.     call    print_number
  281.     mov    di,offset io_addr
  282.     mov    dx,offset io_addr_name
  283.     call    print_number
  284.     mov    ax,memory_begin
  285.     mov    cl,4
  286.     shr    ax,cl
  287.     add    base_addr,ax
  288.     push    ax
  289.     mov    di,offset base_addr
  290.     mov    dx,offset base_addr_name
  291.     call    print_number
  292.     pop    ax
  293.     sub    base_addr,ax
  294.     ret
  295.  
  296.     include    memtest.asm
  297.  
  298. code    ends
  299.  
  300.     end
  301.  
  302.