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

  1. ;-----------------------------------------------------------------------------
  2. ; It is safe to assume that the command unit is up and running ready
  3. ; for the first send.  And that there are at least two send buffers 
  4. ; available.
  5. ;
  6. ; This procedure works by sending a 64 byte packet to itself.  We do not turn
  7. ; on loopback, so we do not expect to see a receive.  Instead, we
  8. ; expect to see that the send completed OK.  If the send does not complete OK, 
  9. ; then this routine switches to other connectors and the test is repeated. 
  10. ;-----------------------------------------------------------------------------
  11. auto_connector:
  12.  
  13. ; Let's start doing the test send with AUI option first.  If we tried BNC
  14. ; first, and they were using AUI, it would seem like the BNC worked.  So
  15. ; we switch to AUI, which turns off the BNC power supply.
  16.     MOV    connection_type, CONN_AUI
  17.     CALL    write_connector_setting_to_hardware
  18.  
  19. ; Test connection to see if it works.  Jump if it does.
  20.     call    test_send
  21.     clc
  22.     je    auto_connector_exit
  23.  
  24. ; Toggle AUI/Other setting and try to send a packet.  Jump if send 
  25. ; works.  Now try sending on BNC.
  26.     MOV    connection_type, CONN_BNC
  27.     CALL    write_connector_setting_to_hardware
  28.     call    test_send
  29.     clc
  30.     je    auto_connector_exit
  31.  
  32. ; Here if we just tried a send the BNC.  If this is 
  33. ; a three connector card, then we toggle the BNC/TPE setting.
  34. ; Jump if connection is found.
  35.     MOV    connection_type, CONN_TPE
  36.     CALL    write_connector_setting_to_hardware
  37.     call    test_send
  38.     clc
  39.     je    auto_connector_exit
  40.     stc
  41. auto_connector_exit:
  42.     ret
  43.  
  44.  
  45. test_packet    label    byte
  46.     db    EADDR_LEN dup(?)
  47.     db    EADDR_LEN dup(?)
  48.     db    00h,2eh            ;A 46 in network order
  49.     db    0,0            ;DSAP=0 & SSAP=0 fields
  50.     db    0f3h,0            ;Control (Test Req + P bit set)
  51.  
  52. ;-----------------------------------------------------------------------------
  53. ; This procedure sends a packet on the wire and wait for the send to
  54. ; complete.  It the checks to see if the send completed OK and returns
  55. ; the results.
  56. ;-----------------------------------------------------------------------------
  57. test_send:
  58.  
  59.     mov    si,offset rom_address    ;set the destination address.
  60.     movseg    es,cs
  61.     mov    di,offset test_packet
  62.     repmov    EADDR_LEN
  63.     mov    si,offset rom_address    ;set the source address.
  64.     repmov    EADDR_LEN
  65.  
  66.     mov    cx,60
  67.     mov    si,offset test_packet
  68.     call    send_pkt
  69.  
  70.     CALL    ReadTickCounter
  71.     MOV    CX, AX
  72.  
  73.     mov    bp,io_addr
  74.     lea    dx, [bp].@TxCB_Status
  75. send_test_wait:
  76.     in    ax,dx
  77.     test    ax,8000h        ;did it finish?
  78.     jne    send_test_done
  79.  
  80. ; See if we have been here for a millisecond.  Jump if not.
  81.     call    ReadTickCounter
  82.     neg    ax
  83.     add    ax, cx
  84.     cmp    ax, one_mil
  85.     jb    send_test_wait
  86.  
  87.     in    ax,dx            ;get the transmit status back again.
  88.  
  89. send_test_done:
  90.  
  91.     mov    cx, ax            ; Save status in CX.
  92.  
  93. ; The send block at the head of the list completed OK.  Clear the
  94. ; transmit command block status.
  95.     xor    ax, ax
  96.     out    dx, ax
  97.  
  98. ; Send is complete.  Get the status and compare to OK send and return.
  99. ; Save flags for return.
  100.  
  101.     and    cx, 0f000h
  102.     cmp    cx, 0a000h
  103.     ret
  104.  
  105.