home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / at&t.asm < prev    next >
Assembly Source File  |  1995-06-25  |  7KB  |  273 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. ;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. ;converted to an AT&T driver Feb 16, 1990 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 AT&T boards
  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    1            ; Channel Attention
  39. IOREV    EQU    6            ; Board Revision/Type
  40. IOATTR    EQU    7            ; Attribute Register.
  41.  
  42. ;Attribute register contents:
  43. attr_mem    equ    03h        ;mask for memory size
  44. attr_mem_64    equ    0
  45. attr_mem_16    equ    1
  46. attr_mem_32    equ    2
  47. attr_mem_8    equ    3
  48. ;
  49. attr_bw        equ    04h        ;Bus width (0=8 bit, 1=16 bit)
  50. attr_speed    equ    08h        ;Board speed (0=10 Mhz, 1=1 Mhz)
  51. attr_c        equ    10h        ;Manchester code (0=Manchester, 1=NRZ)
  52. attr_hw        equ    20h        ;Host bus width (0=16, 1=8 bit)
  53. attr_es        equ    40h        ;Ethernet/Starlan (0 = E, 1 = S)
  54. attr_b        equ    80h        ;Boot Rom (0=No ROM, 1=ROM)
  55.  
  56.  
  57. ;
  58. ;  Data segment
  59. ;
  60.  
  61.     public    int_no
  62. int_no        db    2,0,0,0        ; interrupt number. 
  63. io_addr        dw    0360h,0        ; I/O address for card (jumpers)
  64. base_addr    dw      0d000h,0    ; base segment for board (jumper set)
  65.  
  66.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  67. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  68. driver_type    db    48        ;from the packet spec
  69. driver_name    db    20 dup(?)    ;name of the driver.
  70. driver_function    db    2
  71. parameter_list    label    byte
  72.     db    1    ;major rev of packet driver
  73.     db    9    ;minor rev of packet driver
  74.     db    14    ;length of parameter list
  75.     db    EADDR_LEN    ;length of MAC-layer address
  76.     dw    GIANT    ;MTU, including MAC headers
  77.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  78.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  79.     dw    0    ;(# of successive xmits) - 1
  80. int_num    dw    0    ;Interrupt # to hook for post-EOI
  81.             ;processing, 0 == none,
  82.  
  83. enable_network:
  84. ;  connect to network
  85.     ret
  86.  
  87.  
  88. reset_586:
  89. ;  Reset the chip
  90.     loadport
  91.     setport    IORESET
  92.     out    dx,al
  93.     ret
  94.  
  95.  
  96. doca:
  97. ;we may be called from places in which ds is unknown.
  98.     assume    ds:nothing
  99.     loadport
  100.     setport    IOCA
  101.     out    dx,al            ; send it
  102.     ret
  103.     assume    ds:code
  104. ;yet, we really should assume ds==code for the rest of this stuff.
  105.  
  106. ;
  107. ; Here we include the code that is common between 82586 implementations.
  108. ; Everything above this is resident.
  109.     include    82586.asm
  110. ; Everything below this is discarded upon installation.
  111.  
  112.     public    usage_msg
  113. usage_msg    db    "usage: at&t [options] <packet_int_no> <hardware_irq> <io_addr> <base_addr>",CR,LF,'$'
  114.  
  115.     public    copyright_msg
  116. copyright_msg    db    "Packet driver for the AT&T Starlan/Ethernet boards, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF
  117.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  118.  
  119. board_name_list    dw    board_00, board_01, board_11, board_21
  120.         dw    board_02, board_03, board_unk
  121.  
  122. board_00    db    00h, "StarLAN 1",0,47
  123. board_01    db    01h, "StarLAN 10 NAU",0,48
  124. board_11    db    11h, "StarLAN 10 R2 NAU",0,48
  125. board_21        db      21h, "Starlan 10 R3 NAU",0,48           ; new board
  126. board_02    db    02h, "EN100",0,49
  127. board_03    db    03h, "StarLAN Fiber NAU",0,55
  128. board_unk    db    -1h, "Unknown AT&T",0,48        ;just a guess.
  129.  
  130.     extrn    chrout: near
  131.  
  132. check_board:
  133.     assume    ds:code
  134.     loadport
  135.     setport    IOREV
  136.     in    al,dx
  137.     mov    bx,offset board_name_list
  138. check_board_name:
  139.     mov    si,[bx]            ;get a pointer to a string.
  140.     add    bx,2
  141.     cmp    byte ptr [si],-1    ;is this the end?
  142.     je    check_board_found
  143.     cmp    al,[si]            ;is this the right one?
  144.     jne    check_board_name
  145. check_board_found:
  146.     inc    si            ;skip the board revision number.
  147.  
  148.     mov    dx,offset this_board_msg
  149.     mov    ah,9
  150.     int    21h
  151.  
  152.     mov    ax,ds            ;copy the driver name to where
  153.     mov    es,ax            ;  we need it.
  154.     mov    di,offset driver_name
  155. check_board_copy:
  156.     lodsb
  157.     stosb
  158.     or    al,al
  159.     je    check_board_done_print
  160.     call    chrout            ;print the character.
  161.     jmp    check_board_copy
  162. check_board_done_print:
  163.     lodsb                ;copy the driver type number over
  164.     mov    driver_type,al
  165.     mov    al,CR
  166.     call    chrout
  167.     mov    al,LF
  168.     call    chrout
  169.  
  170.     loadport
  171.     setport    IOATTR
  172.     in    al,dx            ;get the bus width bit into bit zero.
  173.     shr    al,1
  174.     shr    al,1
  175.     not    al
  176.     and    al,1            ;and negate it.
  177.     mov    SCP,al            ;that makes it into the bus width flag.
  178.  
  179.     in    al,dx            ;get the manchester code
  180.     shr    al,1
  181.     shr    al,1
  182.     not    al            ;the bit is flipped.
  183.     and    al,4            ;isolate just the manchester/~nrz bit.
  184.     mov    byte ptr CBCONF_FLAGS,al
  185.  
  186.     mov    dx,io_addr    ; i/o address
  187.     in    al,dx
  188.     mov    bl,al        ; assemble pattern to check
  189.     inc    dx
  190.     in    al,dx
  191.     mov    bh,al
  192.     cmp    bx,0008h    ; pattern known to be there in ROM
  193.     jz    have_att_io
  194.     mov    dx,offset no_att_io_msg
  195.     stc
  196.     ret
  197. have_att_io:
  198.  
  199.     mov    ax,base_addr
  200.     mov    cx,2000h        ;test only what we are going to use.
  201.     call    memory_test
  202.     jz    have_att_mem
  203.     mov    dx,offset no_att_mem_msg
  204.     stc
  205.     ret
  206. have_att_mem:
  207.     clc
  208.     ret
  209.     ret
  210.  
  211.  
  212. this_board_msg    db    "This board is an AT&T ",'$'
  213. no_att_io_msg    db    "No AT&T board found at that I/O address.",CR,LF,'$'
  214. no_att_mem_msg    db    "No AT&T board found at that memory address.",CR,LF,'$'
  215.  
  216. get_address:
  217. ;get the address of the interface.
  218. ;enter with es:di -> place to get the address, cx = size of address buffer.
  219. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  220.     assume    ds:code
  221.     mov    dx,io_addr        ; Get our IO base address.
  222.     cld
  223. get_address_1:
  224.     in    al,dx            ; get a byte of the eprom address
  225.     stosb                ; put it away
  226.     inc    dx            ; next register
  227.     loop    get_address_1        ; go back for rest
  228.     ret
  229.  
  230.  
  231.     public    parse_args
  232. parse_args:
  233.     mov    di,offset int_no
  234.     call    get_number
  235.     mov    di,offset io_addr
  236.     call    get_number
  237.     mov    di,offset base_addr
  238.     call    get_number
  239.     clc
  240.     ret
  241.  
  242.  
  243. int_no_name    db    "Interrupt number ",'$'
  244. io_addr_name    db    "I/O port ",'$'
  245. base_addr_name    db    "Memory address ",'$'
  246.  
  247.  
  248.     public    print_parameters
  249. print_parameters:
  250.     mov    di,offset int_no
  251.     mov    dx,offset int_no_name
  252.     call    print_number
  253.     mov    di,offset io_addr
  254.     mov    dx,offset io_addr_name
  255.     call    print_number
  256.     mov    ax,memory_begin
  257.     mov    cl,4
  258.     shr    ax,cl
  259.     add    base_addr,ax
  260.     push    ax
  261.     mov    di,offset base_addr
  262.     mov    dx,offset base_addr_name
  263.     call    print_number
  264.     pop    ax
  265.     sub    base_addr,ax
  266.     ret
  267.  
  268.     include    memtest.asm
  269.  
  270. code    ends
  271.  
  272.     end
  273.