home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / NETWORK / PCBRI120.ZIP / BRIDGE.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-02-27  |  8.3 KB  |  275 lines

  1. ;;****************************************************************************
  2. ;;                      bridge.asm          bridge.asm
  3. ;;****************************************************************************
  4. ;;
  5. ;;  Copyright (C) 1989 Northwestern University, Vance Morrison
  6. ;;
  7. ;;
  8. ;; Permission to view, compile, and modify for LOCAL (intra-organization) 
  9. ;; USE ONLY is hereby granted, provided that this copyright and permission 
  10. ;; notice appear on all copies.  Any other use by permission only.
  11. ;;
  12. ;; Northwestern University makes no representations about the suitability 
  13. ;; of this software for any purpose.  It is provided "as is" without expressed 
  14. ;; or implied warranty.  See the copywrite notice file for complete details.
  15. ;;
  16. ;;*************************************************************************
  17. ;;
  18. ;; bridge.asm implemtents a simple two interface ethernet bridge
  19. ;;
  20. ;; AUTHOR: Vance Morrison
  21. ;; DATE:   5/24/89
  22. ;; ADDRESS: morrison@accuvax.nwu.edu
  23. ;;****************************************************************************
  24.  
  25.     dosseg
  26.     .model small
  27.     .stack 500h  
  28.     JUMPS                       ;; deal with long displacement
  29.                                 ;; jumps automaticly
  30.  
  31.     include debug.inc
  32.     include memory.inc
  33.     include wd8003e.inc
  34.     include if.inc
  35.     include bridge.inc
  36.     include buffer.inc
  37.     include queue.inc
  38.     include qif.inc
  39.     include slip.inc
  40.     include i8250.inc
  41.     include packet.inc
  42.     include 3c507.inc
  43.  
  44.        .data
  45.     db  'Copywrite (c) 1989, Vance Morrison, Northwestern University', 13,10, 0
  46.     db  'VERSION 1.20 ', 0
  47.     db  'REVISION 10  ', 0
  48.  
  49.         ; a place to put the command line
  50. comline_count db 0 
  51. comline       db 127 dup (0)        
  52.  
  53. baud_rate_div dw 0                      ;; used for remote bridging
  54.  
  55. ;; small helper macro
  56. MY_SET_MTU MACRO name, mtu
  57.     if_&name&_mtu = mtu
  58. ENDM
  59.  
  60.      cur_if = 1
  61.  
  62. ;;*************************************************************************
  63. ;; start declaration section.   Comment in your coices
  64.  
  65.         ;; the first WD8013EBT card
  66.  ;   WDE_DECLARE %cur_if, 280H, 0D000H, 0H, 1, 64, 1  ;; promiscuous ,16K, 16bit
  67.  ;   IF_DECLARE %cur_if, %cur_if, WDE
  68.  ;   cur_if = cur_if + 1
  69.  
  70.         ;; the second WD8013EBT card
  71.  ;   WDE_DECLARE %cur_if, 2A0H, 0D800H, 0H, 1, 64, 1  ;; promiscuous ,16K, 16bit
  72.  ;   IF_DECLARE %cur_if, %cur_if, WDE
  73.  ;   cur_if = cur_if + 1
  74.  
  75.         ;; the third WD8013EBT card
  76.  ;   WDE_DECLARE %cur_if, 2C0H, 0A000H, 0H, 1, 64, 1  ;; promiscuous ,16K, 16bit
  77.  ;   IF_DECLARE %cur_if, %cur_if, WDE
  78.  ;   cur_if = cur_if + 1
  79.  
  80.         ;; the first WD8003EBT card
  81.  ;   WDE_DECLARE %cur_if, 280H, 0D000H, 0H, 1, 128    ;; promiscuous,  32K
  82.  ;   IF_DECLARE %cur_if, %cur_if, WDE
  83.  ;   cur_if = cur_if + 1
  84.     
  85.         ;; the second WD8003EBT card
  86.  ;   WDE_DECLARE %cur_if, 2A0H, 0D800H, 0H, 1, 128    ;; promiscuous,  32K
  87.  ;   IF_DECLARE %cur_if, %cur_if, WDE
  88.  ;   cur_if = cur_if + 1
  89.     
  90.         ;; the first WD8003E Ethernet card or WD8003S(H) Starlan card
  91.      WDE_DECLARE %cur_if, 280H, 0D000H, 0H, 1, 32     ;; promiscuous,  8K
  92.      IF_DECLARE %cur_if, %cur_if, WDE
  93.      cur_if = cur_if + 1
  94.  
  95.         ;; a second WD8003E Ethernet card or WD8003S(H) Starlan card
  96.  ;   WDE_DECLARE %cur_if, 2A0H, 0D800H, 0H, 1, 32     ;; promiscuous,  8K
  97.  ;   IF_DECLARE %cur_if, %cur_if, WDE
  98.  ;   cur_if = cur_if + 1
  99.  
  100.         ;; a serial card for a remote bridge
  101.      I8250_DECLARE %cur_if, SLIP, %cur_if, IBM_COM1_PORT, IBM_COM1_IRQ, 0
  102.      tmp = cur_if*10                                 ;; generate temp names
  103.      BUFF_DECLARE %(tmp+1), 3200                      ;; the read buffer
  104.      QUEUE_DECLARE %(tmp+2), 5, %(size qif_entry)     ;; the read queue
  105.      BUFF_DECLARE %(tmp+3), 10240                     ;; the write buffer
  106.      QUEUE_DECLARE %(tmp+4), 16, %(size qif_entry) ;; the write queue
  107.      SLIP_DECLARE %cur_if,%cur_if,%(tmp+1),%(tmp+2),%(tmp+3),%(tmp+4)
  108.      MY_SET_MTU %cur_if, 1518                         ;; overide default MTU
  109.      Q_IF_DECLARE %cur_if,%(tmp+1),%(tmp+2),%(tmp+3),%(tmp+4),SLIP,%cur_if
  110.      IF_DECLARE %cur_if, %cur_if, Q
  111.      cur_if = cur_if + 1
  112.  
  113.         ;; a packet driver entry
  114.  ;   PKT_DECLARE %cur_if, 60H, 01, 1    ;; <name> <Int num> <Class (Eth=1), prom
  115.  ;   IF_DECLARE %cur_if, %cur_if, PKT
  116.  ;   cur_if = cur_if + 1
  117.  
  118.         ;; a second packet driver entry
  119.  ;   PKT_DECLARE %cur_if, 61H, 01, 1    ;; <name> <Int num> <Class (Eth=1), prom
  120.  ;   IF_DECLARE %cur_if, %cur_if, PKT
  121.  ;   cur_if = cur_if + 1
  122.  
  123.         ;; a 3C507 card entry 64K of memory at D0000H
  124.  ;   C507_DECLARE %cur_if, 280H, 0D000H, 10000H, 1   ;; name,io,seg,len,prom
  125.  ;   IF_DECLARE %cur_if, %cur_if, C507
  126.  ;   cur_if = cur_if + 1
  127.  
  128.         ;; a 3C507 card entry 64K of memory at C0000H
  129.  ;   C507_DECLARE %cur_if, 2A0H, 0C000H, 10000H, 1   ;; name,io,seg,len,prom
  130.  ;   IF_DECLARE %cur_if, %cur_if, C507
  131.  ;   cur_if = cur_if + 1
  132.  
  133. ;; end declaration section
  134. ;;*************************************************************************
  135.  
  136.      num_dls = cur_if - 1
  137.      mybridge = 1
  138.      BDG_DECLARE %mybridge, 1, %num_dls, 1
  139.  
  140.  
  141. ;;************************************************************************
  142. ;; This routine converts the ASCII base ten number pointed to by SI and
  143. ;; returns the number in AX.  It also updates SI to point to the next
  144. ;; char in the string.  This routine skips preceeding space and stops
  145. ;; conversion at the first non-digit.  Clearly this routine can' handle
  146. ;; numbers up to 64K
  147.  
  148. ASCII_TO_BINARY_in_SI_out_AX_SI_const_BP_DI_ES MACRO
  149.     local top_loop, next_char, conv_string, space_loop, done
  150.  
  151.     space_loop:
  152.         mov CL, [SI]
  153.         cmp CL, ' '         ; skip space
  154.         jnz conv_string
  155.         inc SI
  156.         jmp space_loop
  157.     conv_string:
  158.  
  159.     xor AX, AX
  160.     xor CH, CH
  161.     top_loop:
  162.         sub CL, '0'         ; is it a digit
  163.         jl done
  164.         cmp CL, 9
  165.         jg done
  166.  
  167.         mov DX, AX          ; AX = AX * 10
  168.         shl AX, 1
  169.         shl AX, 1
  170.         add AX, DX
  171.         shl AX, 1
  172.         
  173.         add AX, CX
  174.     next_char:
  175.         inc SI
  176.     mov CL, [SI]
  177.     jmp top_loop
  178.  
  179.     done:
  180. ENDM
  181.  
  182.  
  183. ;;************************************************************************
  184.     .code
  185.  
  186.     ;; insert code for all interfaces
  187.     IRP idx,<1,2,3,4,5,6,7,8>
  188.        WDE_REAL_DEFINE idx     
  189.        I8250_REAL_DEFINE idx
  190.        PKT_REAL_DEFINE idx     
  191.        C507_REAL_DEFINE idx     
  192.     endm
  193.  
  194.     DB_DEFINE           
  195.  
  196. bridge_start:
  197.     ;; save the command line
  198.     mov SI, 80h
  199.     mov AX, @DATA 
  200.     mov ES, AX
  201.     mov DI, offset comline_count
  202.     mov CX, 40h
  203.     rep
  204.     movsw
  205.  
  206.     mov AX, @DATA       ;; initialize data segment
  207.     mov DS, AX
  208.     cld                 ;; direction forward
  209.  
  210.         ; if this is a remote bridge
  211.     ifdef i8250_declared
  212.         mov SI, offset comline
  213.         ASCII_TO_BINARY_in_SI_out_AX_SI_const_BP_DI_ES      ;; get the baud rate
  214.         cmp AX, 0
  215.         jnz not_default
  216.             mov AX, 19200                   ;; 19.2 is the default
  217.         not_default:
  218.         shr AX, 1                           ;; compute the baud rate div
  219.         mov BX, AX
  220.         mov AX, 57600
  221.         xor DX, DX
  222.         div BX
  223.         mov baud_rate_div, AX
  224.     endif
  225.  
  226.     IRP idx,<1,2,3,4,5,6,7,8>       ;; call definition code
  227.     if idx le num_dls
  228.         WDE_DEFINE idx     
  229.  
  230.         BUFF_DEFINE %(idx*10+1)
  231.         QUEUE_DEFINE %(idx*10+2)
  232.         BUFF_DEFINE %(idx*10+3)
  233.         QUEUE_DEFINE %(idx*10+4)
  234.         Q_IF_DEFINE idx     
  235.         SLIP_DEFINE idx     
  236.         mov BX, baud_rate_div 
  237.         I8250_DEFINE_in_BX idx, serial_fail
  238.  
  239.         PKT_DEFINE idx, packet_fail
  240.  
  241.         C507_DEFINE_out_AX idx, card_fail
  242.     endif
  243.     endm
  244.  
  245.     BDG_DEFINE %mybridge
  246.  
  247.     ;; start looking for packets
  248.     big_loop:
  249.     IRP idx,<1,2,3,4,5,6,7,8>
  250.     local next
  251.     if idx le num_dls
  252.         BDG_IF_R_ACCESS_out_BX_CX_ES idx, next
  253.         BDG_IF_R_FREE_const_BX_CX_BP_SI_DI_ES idx    ;; throw it away
  254.         next:
  255.     endif
  256.     endm
  257.     jmp big_loop
  258.  
  259.     packet_fail:
  260.         print_reg <error configuring ethernet card.  Code = >, AX
  261.         jmp terminate
  262.  
  263.     packet_fail:
  264.         print <error configuring packet driver>
  265.         jmp terminate
  266.  
  267.     serial_fail:
  268.         print <error configuring serial port>
  269.     terminate:
  270.         mov AH, 4CH
  271.         int 21H
  272. END bridge_start
  273.  
  274.  
  275.