home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / driver6s / 3c523.asm < prev    next >
Assembly Source File  |  1990-04-13  |  6KB  |  268 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, 1989, Russell Nelson
  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    byte public
  27.     assume    cs:code, ds:code
  28.  
  29. ;
  30. ;  Equates for controlling the 3c523 board
  31. ;
  32. IOC    EQU    6
  33.  
  34. BASE_OFFSET    EQU    0c000h        ; base offset for the board.
  35. GET_ADDR_INC    equ    1
  36.  
  37.     public    int_no
  38. int_no        db    3,0,0,0        ; interrupt number
  39. io_addr        dw    300h,0        ; I/O address for card
  40. base_addr    dw      0c000h,0    ; base segment for board
  41.  
  42.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  43. driver_class    db    1        ;from the packet spec
  44. driver_type    db    13        ;from the packet spec
  45. driver_name    db    "3C523",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.     dw    0    ;Interrupt # to hook for post-EOI
  57.             ;processing, 0 == none,
  58.  
  59. doca:
  60. ;we may be called from places in which ds is unknown.
  61.     assume    ds:nothing
  62.     loadport
  63.     setport IOC
  64.     mov    al, 0c7h
  65.     pushf
  66.     cli
  67.     out    dx, al
  68.     jmp    $+2
  69.     jmp    $+2
  70.     jmp    $+2
  71.     mov    al, 087h
  72.     out    dx, al
  73.     popf
  74.     ret
  75.     assume    ds:code
  76. ;yet, we really should assume ds==code for the rest of this stuff.
  77.  
  78.  
  79. ;
  80. ; Here we include the code that is common between 82586 implementations.
  81. ; Everything above this is resident.
  82.     include    82586.asm
  83. ; Everything below this is discarded upon installation.
  84.  
  85.     public    usage_msg
  86. usage_msg    db    "usage: 3c523 <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  87.  
  88.     public    copyright_msg
  89. copyright_msg    db    "Packet driver for the 3C523, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF
  90.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  91.  
  92. comment \
  93.  
  94.     The 3c523 responds with adapter code 0x6042 at slot
  95. registers xxx0 and xxx1.  The setup register is at xxx2 and
  96. contains the following bits:
  97.  
  98. 0: card enable
  99. 2,1: csr address select
  100.     00 = 0300
  101.     01 = 1300
  102.     10 = 2300
  103.     11 = 3300
  104. 4,3: shared memory address select
  105.     00 = 0c0000
  106.     01 = 0c8000
  107.     10 = 0d0000
  108.     11 = 0d8000
  109. 5: set to disable on-board thinnet
  110. 7,6: (read-only) shows selected irq
  111.     00 = 12
  112.     01 = 7
  113.     10 = 3
  114.     11 = 9
  115.  
  116. The interrupt-select register is at xxx3 and uses one bit per irq.
  117.  
  118. 0: int 12
  119. 1: int 7
  120. 2: int 3
  121. 3: int 9
  122.  
  123.     Again, the documentation stresses that the setup register
  124. should never be written.  The interrupt-select register may be
  125. written with the value corresponding to bits 7.6 in
  126. the setup register to insure corret setup.
  127.  
  128. \
  129.  
  130. IRQ_MASK    equ    0c0h
  131. IRQ_TABLE    db    12            ; Interrupt Value 0
  132.         db    7            ; Interrupt Value 1
  133.         db    3            ; Interrupt Value 2
  134.         db    9            ; Interrupt Value 3
  135.  
  136. check_board:
  137.     mov    SCP,1            ; 8 bit bus type in scb.
  138.  
  139.   if 1
  140.     loadport
  141.     setport    IOC
  142.     mov    al,23h
  143.     out    dx,al        ; reset the chip
  144.     jmp    $+2
  145.     jmp    $+2
  146.     jmp    $+2
  147.     mov    al,63h
  148.     out    dx,al        ; reset the chip
  149.     jmp    $+2
  150.     jmp    $+2
  151.     jmp    $+2
  152.     mov    al,23h
  153.     out    dx,al        ; reset the chip
  154.     jmp    $+2
  155.     jmp    $+2
  156.     jmp    $+2
  157.     ret
  158.   else
  159.  
  160. ; search all slots for a 3c523 card
  161.     mov    cx, 8            ; for all channels(slots)
  162.  
  163. ; channel select value for slots 0,1,2.. is 8,9,A etc
  164. ; start with slot 0, and then 7,6,5,4,3,2,1
  165. get_05:
  166.     mov    ax, cx            ; channel number
  167.     or    ax, 08h            ; reg. select value
  168.     out    96h, al            ; select channel
  169.  
  170. ; read adapter id
  171.     mov    dx, 100h
  172.     in    al, dx            ; adapter id - ms byte
  173.     mov    ah, al
  174.     inc    dx
  175.     in    al, dx            ; adapter id - ls byte
  176.  
  177. ; Check if 3c523
  178.     cmp    ax, 06042h
  179.     je    get_10
  180.     loop    get_05
  181.  
  182.     mov    dx,offset no_3c523_msg
  183.     jmp    error
  184.  
  185. get_10:
  186. ; found our Adapter
  187.  
  188. ; Get 3c523 IRQ ( read POS Register 0 )
  189.     mov    dx,102h
  190.     in    al,dx
  191.     mov    bl,al
  192.     and    bx,IRQ_MASK
  193.     mov    cl,6
  194.     shr    bx,cl
  195.     mov    al,IRQ_TABLE[bx]
  196.     mov    int_no,al
  197.  
  198. ; Get 3c523 memory address ( read POS Register 0 )
  199.     mov    dx,102h
  200.     in    al,dx
  201.     mov    bl,al
  202.     xor    bh,bh
  203.     mov    cl,11-3
  204.     shl    bx,cl
  205.     and    bx,01800h
  206.     or    bx,0c000h
  207.     mov    base_addr,bx
  208.  
  209. ; Get 3c523 I/O address ( read POS Register 0 )
  210.     mov    dx,102h
  211.     in    al,dx
  212.     mov    bl,al
  213.     xor    bh,bh
  214.     mov    cl,12-1            ;should start at bit 12, now at bit 1.
  215.     shl    bx,cl
  216.     and    bx,3000h
  217.     or    bx,0300h
  218.     mov    io_addr,bx
  219.  
  220.     mov    dx, 102h
  221.     in    al,dx
  222.     or    al,1            ;enable the card.
  223.     out    dx,al
  224.  
  225.     xor    al,al
  226.     out    96h,al            ;deselect the card.
  227.  
  228.     loadport
  229.     setport    IOC
  230.     mov    al,23h
  231.     out    dx,al        ; reset the chip
  232.     jmp    $+2
  233.     jmp    $+2
  234.     jmp    $+2
  235.     mov    al,63h
  236.     out    dx,al        ; reset the chip
  237.     jmp    $+2
  238.     jmp    $+2
  239.     jmp    $+2
  240.     mov    al,23h
  241.     out    dx,al        ; reset the chip
  242.     jmp    $+2
  243.     jmp    $+2
  244.     jmp    $+2
  245.     ret
  246.  
  247. no_3c523_msg    db    "No 3c523 found at that memory address.",CR,LF,'$'
  248.   endif
  249.  
  250. lbca:    loadport
  251.     setport IOC
  252.     mov    al, 0e3h
  253.     out    dx, al
  254.     jmp    $+2
  255.     jmp    $+2
  256.     jmp    $+2
  257.     mov    al, 0a3h
  258.     out    dx, al
  259.     ret
  260.  
  261.  
  262.     include    memtest.asm
  263.  
  264. code    ends
  265.  
  266.     end
  267.  
  268.