home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / odipkt / odipkt.asm < prev    next >
Assembly Source File  |  1994-09-29  |  18KB  |  1,088 lines

  1. ; ODIPKT.ASM - Adapter provides Packet Driver interface over ODI
  2. ;
  3. ; (c) Copyright Daniel D. Lanciani 1991-1994.  All rights reserved.
  4. ;
  5. ; This unmodified source file and its executable form may be used and
  6. ; redistributed freely.  The source may be modified, and the source or
  7. ; executable versions built from the modified source may be used and
  8. ; redistributed, provided that this notice and the copyright displayed by
  9. ; the exectuable remain intact, and provided that the executable displays
  10. ; an additional message indicating that it has been modified, and by whom.
  11. ;
  12. ; Daniel D. Lanciani releases this software "as is", with no express or
  13. ; implied warranty, including, but not limited to, the implied warranties
  14. ; of merchantability and fitness for a particular purpose.
  15. ;
  16. ; Please send bug reports to ddl@harvard.harvard.edu or
  17. ;
  18. ; Dan Lanciani
  19. ; 185 Atlantic Road
  20. ; Gloucester, MA 01930
  21. ; (508) 283-4974
  22.  
  23. version    equ    20    ; for driver_info
  24. iftype    equ    71    ; for driver_info/access_type
  25. nhand    equ    8    ; max active handles
  26. mmatch    equ    8    ; max length of header match
  27. mmulti    equ    8    ; max multicast addresses
  28. pkvec    equ    69h    ; default control vector
  29. ;prescan    equ    1    ; be a pre-scan stack when chaining
  30. nosacca    equ    123    ; ARCnet type for Ethertype ACCA
  31.  
  32. hinfo    struc            ; per-handle data
  33. nmatch    dw    -1        ; header match length
  34. match    db    mmatch dup (?)    ; header match bytes
  35. recvo    dw    ?        ; receiver offset
  36. recvs    dw    ?        ; receiver segment
  37. hinfo    ends
  38.  
  39. CODE    segment word public 'CODE'
  40.     assume cs:CODE, ds:CODE, es:nothing, ss:CODE
  41.  
  42.     org    100h
  43. stack    label    byte
  44. at100h:    jmp    start
  45.  
  46. copyright db    'ODIPKT 3.0', 13, 10
  47.     db    '(c) Copyright Daniel Lanciani 1991-1994.  All rights reserved.'
  48.     db    13, 10, 'This software is provided with NO WARRANTY.', 13, 10
  49.     db    '$'
  50. myname    db    'ODIPKT', 0    ; for driver_info
  51. class    db    1        ; for driver_info
  52. cmap    db    0        ; class mapping flag
  53. inhere    db    0        ; on switched stack
  54. chain    db    0        ; chained stack
  55. arcarp    db    0, 7, 8, 0, 1, 4, 0, 0
  56.     db    10 dup (?)
  57.     align    2
  58. savpko    dw    0        ; saved vector offset
  59. savpks    dw    0        ; saved vector segment
  60. rqueue    dd    0        ; queue of pending receives
  61. psup    dd    0        ; LSL protocol support entry
  62. gsup    dd    0        ; LSL general support entry
  63. control    dd    0        ; MLID control entry
  64. config    dd    0        ; MLID configuration table
  65. myvec    dw    4 * pkvec    ; 4 * my vector
  66. alen    dw    6        ; address length
  67. off    dw    12        ; header offset for match
  68. fmin    dw    60        ; minimum frame size
  69. rmode    dw    3        ; current receiver mode
  70. rmmap    dw    0, 1, 5, 7, 7, 15
  71. nmulti    dw    0        ; number of multicast addresses
  72. mtab    db    mmulti * 6 dup (?)
  73. htab    hinfo    nhand dup (<>)    ; the handle table
  74. htabe    label    byte
  75. stab    dw    14 dup (0)    ; for get_statistics
  76. ptab    db    1, 9, 14, 6    ; for get_parameters
  77.     dw    1514, mmulti * 6, 0, 0, 0
  78.  
  79. sECB    db    52 dup (0)    ; transmit ECB
  80.  
  81. StkChn    dd    0        ; Link
  82. Board    dw    0
  83. Posit    dw    0
  84. Handler    dd    0
  85. Cont    dd    0
  86.     dw    0        ; ID
  87.     dw    03dfh        ; Mask
  88.     dw    0        ; Reserved
  89.  
  90. upcall    proc    far
  91. transcom:push    ds
  92.     push    bp
  93.     mov    ax, cs
  94.     mov    ds, ax
  95.     cmp    word ptr es:8[si], 0
  96.     jz    trans1
  97.     add    stab + 20, 1
  98.     adc    stab + 22, 0
  99. trans1:    mov    bx, 1
  100.     call    psup
  101.     pop    bp
  102.     pop    ds
  103.     ret
  104.  
  105. recvcom:push    di
  106.     cmp    cs:chain, 0
  107.     jz    rcvnc
  108.     cld
  109.     push    ds
  110.     les    di, [di]
  111.     mov    ax, cs
  112.     mov    ds, ax
  113.     cmp    class, 3
  114.     jnz    @f
  115.     test    byte ptr es:8[di], 80h
  116.     jz    @f
  117.     mov    al, es:14[di]
  118.     and    ax, 1fh
  119.     add    di, ax
  120. @@:    add    di, off
  121.     mov    ax, di
  122.  
  123.     mov    bx, offset htab
  124. chain1:    mov    cx, [bx].nmatch
  125.     cmp    cx, -1
  126.     jz    @f
  127.     jcxz    chain2
  128.     lea    si, [bx].match
  129.     mov    di, ax
  130.     repe    cmpsb
  131.     jz    chain2
  132. @@:    add    bx, size hinfo
  133.     cmp    bx, offset htabe
  134.     jc    chain1
  135.     pop    ds
  136.     pop    di
  137.     mov    ax, 8001h
  138.     and    ax, ax
  139.     ret
  140. chain2:    pop    ds
  141.     pop    di
  142.     push    di
  143.  
  144. rcvnc:    xor    bx, bx
  145.     call    cs:psup
  146.     mov    dx, ds
  147.     jz    havebuf
  148.     jmp    nobuf
  149. havebuf:mov    cx, 4[di]
  150.     sub    cx, [di]
  151.  
  152.     cmp    cs:cmap, 8
  153.     jnz    rcvna1
  154.     mov    cx, 14
  155. rcvna1:
  156.  
  157.     mov    word ptr es:10[si], offset recvcom2
  158.     mov    word ptr es:12[si], cs
  159.     push    si
  160.     mov    ax, cs:word ptr ptab + 4
  161.     mov    word ptr es:50[si], ax
  162.     lea    ax, 52[si]
  163.     mov    word ptr es:44[si], 1
  164.     mov    word ptr es:46[si], ax
  165.     mov    word ptr es:48[si], es
  166.     add    word ptr es:46[si], cx
  167.     sub    word ptr es:50[si], cx
  168.     lds    si, [di]
  169.     mov    di, ax
  170.     cld
  171.  
  172.     cmp    cs:cmap, 8
  173.     jnz    rcvna2
  174.     xor    ah, ah
  175.     mov    al, 2[si]
  176.     or    al, al
  177.     jnz    rcvna3
  178.     mov    al, 3[si]
  179. rcvna3:    push    si
  180.     add    si, ax
  181.     cmp    byte ptr 1[si], 0ffh
  182.     jnz    rcvna4
  183.     add    si, 4
  184. rcvna4:    mov    al, [si]
  185.     mov    ah, 255
  186.     pop    si
  187. ifdef    nosacca
  188.     cmp    al, nosacca
  189.     jnz    rcvna8
  190.     mov    ax, 0accah
  191.     jmp    short rcvna7
  192. rcvna8:
  193. endif
  194.     cmp    al, 212
  195.     jnz    rcvna6
  196.     mov    ax, 0800h
  197.     jmp    short rcvna7
  198. rcvna6:    cmp    al, 213
  199.     jnz    rcvna7
  200.     mov    ax, 0806h
  201. rcvna7:    xchg    ah, al
  202.     mov    es:12[di], ax
  203.     push    di
  204.     mov    cx, 6
  205.     xor    ax, ax
  206.     rep    stosw
  207.     pop    di
  208.     mov    ax, [si]
  209.     mov    es:11[di], al
  210.     mov    es:5[di], ah
  211.     or    ah, ah
  212.     jnz    rcvna5
  213.     mov    word ptr es:[di], -1
  214.     mov    word ptr es:2[di], -1
  215.     mov    word ptr es:4[di], -1
  216.     jmp    short rcvna5
  217. rcvna2:
  218.  
  219.     rep    movsb
  220. rcvna5:    pop    si
  221.     pop    di
  222.     mov    ds, dx
  223.     xor    ax, ax
  224.     ret
  225. nobuf:    pop    di
  226.     mov    ds, dx
  227.     mov    ax, 8001h
  228.     add    cs:stab + 16, 1
  229.     adc    cs:stab + 18, 0
  230.     and    ax, ax
  231.     ret
  232.  
  233. recvcom2:push    bp
  234.     push    ds
  235.     mov    ax, cs
  236.     mov    ds, ax
  237. recv0:    cmp    inhere, 0
  238.     jz    notbusy
  239.     add    stab + 16, 1
  240.     adc    stab + 18, 0
  241.     jmp    busy
  242. notbusy:inc    inhere
  243.     mov    bx, ss
  244.     mov    cx, sp
  245.     mov    ss, ax
  246.     mov    sp, offset stack
  247.     push    bx
  248.     push    cx
  249.     push    es
  250.     push    si
  251.     cld
  252.     mov    cx, es:42[si]
  253.     add    cx, es:46[si]
  254.     add    si, 52
  255.     sub    cx, si
  256.     cmp    cx, fmin
  257.     jnc    enuf
  258.     mov    cx, fmin
  259. enuf:    push    es
  260.     push    si
  261.     push    cx
  262.     add    stab, 1
  263.     adc    stab + 2, 0
  264.     add    stab + 8, cx
  265.     adc    stab + 10, 0
  266.     mov    bx, offset htab
  267. recv1:    mov    cx, [bx].nmatch
  268.     cmp    cx, -1
  269.     jz    recv5
  270.     jcxz    recv2
  271.     mov    di, si
  272.     cmp    class, 3
  273.     jnz    norif
  274.     test    byte ptr es:8[di], 80h
  275.     jz    norif
  276.     mov    al, es:14[di]
  277.     and    ax, 1fh
  278.     add    di, ax
  279. norif:    add    di, off
  280.     lea    si, [bx].match
  281.     repe    cmpsb
  282.     jnz    recv5
  283. recv2:    pop    cx
  284.     push    cx
  285.     push    bx
  286.     xor    ax, ax
  287.     call    dword ptr [bx].recvo
  288.     pop    bx
  289.     cld
  290.     mov    ax, es
  291.     or    ax, di
  292.     jz    recv7
  293.     pop    cx
  294.     pop    si
  295.     pop    ds
  296.     push    ds
  297.     push    si
  298.     push    cx
  299.     push    di
  300.     shr    cx, 1
  301.     rep    movsw
  302.     jnc    recv3
  303.     movsb
  304. recv3:    pop    si
  305.     pop    cx
  306.     push    cx
  307.     mov    ax, es
  308.     mov    ds, ax
  309.     push    bx
  310.     cmp    cs:cmap, 8
  311.     jnz    noararp
  312.     cmp    word ptr 12[si], 0608h
  313.     jnz    noararp
  314.     call    arar2etar
  315. noararp:mov    ax, 1
  316.     call    dword ptr cs:[bx].recvo
  317.     pop    bx
  318.     cld
  319.     cli
  320.     mov    ax, cs
  321.     mov    ds, ax
  322. recv5:    pop    cx
  323.     pop    si
  324.     pop    es
  325.     add    bx, size hinfo
  326.     cmp    bx, offset htabe
  327.     jnc    recv6
  328.     push    es
  329.     push    si
  330.     push    cx
  331.     jmp    recv1
  332. recv7:    cli
  333.     mov    ax, cs
  334.     mov    ds, ax
  335.     add    stab + 24, 1
  336.     adc    stab + 26, 0
  337.     jmp    short recv5
  338. recv6:    pop    si
  339.     pop    es
  340.     pop    cx
  341.     pop    bx
  342.     mov    ss, bx
  343.     mov    sp, cx
  344.     dec    inhere
  345.     mov    ax, cs
  346.     mov    ds, ax
  347.     mov    bx, 1
  348.     call    psup
  349.     les    si, rqueue
  350.     mov    ax, es
  351.     or    ax, si
  352.     jz    recv8
  353.     mov    ax, es:[si]
  354.     mov    word ptr rqueue, ax
  355.     mov    ax, es:2[si]
  356.     mov    word ptr rqueue + 2, ax
  357.     mov    ax, cs
  358.     jmp    recv0
  359. recv8:    pop    ds
  360.     pop    bp
  361.     ret
  362. busy:    mov    di, offset rqueue
  363. busy1:    mov    ax, [di]
  364.     or    ax, 2[di]
  365.     jz    busy2
  366.     lds    di, [di]
  367.     jmp    short busy1
  368. busy2:    mov    es:[si], ax
  369.     mov    es:2[si], ax
  370.     mov    [di], si
  371.     mov    2[di], es
  372.     jmp    short recv8
  373. pcont:    mov    ax, 8008h
  374.     and    ax, ax
  375.     ret
  376. upcall    endp
  377.  
  378. arar2etar:mov    word ptr 14[si], 100h
  379.     mov    byte ptr 18[si], 6
  380.     mov    ax, 30[si]
  381.     mov    40[si], ax
  382.     mov    ax, 28[si]
  383.     mov    38[si], ax
  384.     mov    al, 27[si]
  385.     mov    37[si], al
  386.     xor    ax, ax
  387.     mov    36[si], al
  388.     mov    34[si], ax
  389.     mov    32[si], ax
  390.     mov    ax, 25[si]
  391.     mov    30[si], ax
  392.     mov    ax, 23[si]
  393.     mov    28[si], ax
  394.     mov    al, 22[si]
  395.     mov    27[si], al
  396.     xor    ax, ax
  397.     mov    26[si], al
  398.     mov    24[si], ax
  399.     mov    22[si], ax
  400.     ret
  401.  
  402. nofunc:    mov    dh, 11
  403.     jmp    bad
  404.  
  405. driver_info:pop    bx
  406.     mov    bx, cs
  407.     mov    ds, bx
  408.     mov    bx, version
  409.     mov    ch, class
  410.     mov    dx, iftype
  411.     xor    cl, cl
  412.     mov    si, offset myname
  413.     mov    al, 6
  414.     jmp    good1
  415.  
  416. access_type:pop    bx
  417.     push    ds
  418.     push    cs
  419.     pop    ds
  420.     cmp    al, class
  421.     jz    access_type1
  422.     mov    dh, 2
  423.     jmp    short access_type5
  424. access_type1:cmp    bx, iftype
  425.     jz    access_type7
  426.     cmp    bx, -1
  427.     jz    access_type7
  428. ;    mov    dh, 3
  429. ;    jmp    short access_type5
  430. access_type7:and    dl, dl
  431.     jz    access_type2
  432.     mov    dh, 4
  433.     jmp    short access_type5
  434. access_type2:cmp    cx, mmatch + 1
  435.     jc    access_type3
  436.     mov    dh, 14
  437.     jmp    short access_type5
  438. access_type3:mov    bx, offset htab
  439. access_type4:cmp    [bx].nmatch, -1
  440.     jz    access_type6
  441.     add    bx, size hinfo
  442.     cmp    bx, offset htabe
  443.     jc    access_type4
  444.     mov    dh, 9
  445. access_type5:pop    ds
  446.     jmp    bad1
  447. access_type6:mov    [bx].nmatch, cx
  448.     mov    [bx].recvo, di
  449.     mov    [bx].recvs, es
  450.     mov    di, ds
  451.     mov    es, di
  452.     lea    di, [bx].match
  453.     pop    ds
  454.     rep    movsb
  455.     mov    ax, bx
  456.     jmp    good1
  457.  
  458. release_type:pop    bx
  459.     mov    cs:[bx].nmatch, -1
  460.     jmp    good1
  461.  
  462. send_pkt:push    ds
  463.     mov    bx, ds
  464.     mov    dx, cs
  465.     mov    ds, dx
  466.     add    stab + 4, 1
  467.     adc    stab + 6, 0
  468.     add    stab + 12, cx
  469.     adc    stab + 14, 0
  470.     mov    word ptr sECB + 48, bx
  471.  
  472.     cmp    cmap, 8
  473. ifdef    nosacca
  474.     jz    armap
  475.     jmp    send_pkt4
  476. armap:
  477. else
  478.     jnz    send_pkt4
  479. endif
  480.     mov    es, bx
  481.     mov    ax, es:[si]
  482.     mov    word ptr sECB + 24, ax
  483.     mov    ax, es:2[si]
  484.     mov    word ptr sECB + 26, ax
  485.     mov    ax, es:4[si]
  486.     mov    word ptr sECB + 28, ax
  487.     mov    ax, word ptr es:12[si]
  488.     mov    sECB + 16 + 5, ah
  489.     cmp    ax, 0608h
  490.     jnz    sndna1
  491.     mov    sECB + 16 + 5, 213
  492.     mov    ax, es:20[si]
  493.     mov    word ptr arcarp + 6, ax
  494.     mov    al, es:27[si]
  495.     mov    arcarp + 8, al
  496.     mov    ax, es:28[si]
  497.     mov    word ptr arcarp + 9, ax
  498.     mov    ax, es:30[si]
  499.     mov    word ptr arcarp + 11, ax
  500.     mov    al, es:37[si]
  501.     mov    arcarp + 13, al
  502.     mov    ax, es:38[si]
  503.     mov    word ptr arcarp + 14, ax
  504.     mov    ax, es:40[si]
  505.     mov    word ptr arcarp + 16, ax
  506.     mov    cx, 18
  507.     mov    si, offset arcarp
  508.     mov    word ptr sECB + 48, cs
  509.     jmp    short send_pkt4
  510. sndna1:
  511. ifdef    nosacca
  512.     cmp    ax, 0caach
  513.     jnz    sndna2
  514.     mov    sECB + 16 + 5, nosacca
  515.     jmp    short send_pkt5
  516. sndna2:
  517. endif
  518.     cmp    ax, 0008h
  519.     jnz    send_pkt5
  520.     mov    sECB + 16 + 5, 212
  521. send_pkt5:add    si, 14
  522.     sub    cx, 14
  523. send_pkt4:
  524.  
  525.     mov    word ptr sECB + 42, cx
  526.     mov    word ptr sECB + 46, si
  527.     mov    word ptr sECB + 50, cx
  528.     xor    bx, bx
  529.     call    psup
  530.     jnz    send_pkt3
  531.     push    si
  532.     mov    di, si
  533.     mov    si, offset sECB
  534.     mov    cx, 26
  535.     rep    movsw
  536.     mov    cx, word ptr sECB + 50
  537.     lds    si, dword ptr sECB + 46
  538.     shr    cx, 1
  539.     rep    movsw
  540.     jnc    send_pkt1
  541.     movsb
  542. send_pkt1:mov    dx, cs
  543.     mov    ds, dx
  544.     pop    si
  545.     lea    ax, 52[si]
  546.     mov    es:46[si], ax
  547.     mov    es:48[si], es
  548.     mov    bx, 12
  549.     call    psup
  550.     sti
  551.     pop    ds
  552.     jmp    good
  553. send_pkt3:add    stab + 20, 1
  554.     adc    stab + 22, 0
  555.     pop    ds
  556.     mov    dh, 12
  557.     jmp    bad
  558.  
  559. terminate:push    ds
  560.     mov    ax, cs
  561.     mov    ds, ax
  562.     mov    cx, nmulti
  563.     jcxz    terminate2
  564.     mov    si, offset mtab
  565. terminate1:push    si
  566.     push    cx
  567.     mov    ax, cs
  568.     mov    es, ax
  569.     mov    ax, Board
  570.     mov    bx, 3
  571.     call    control
  572.     pop    cx
  573.     pop    si
  574.     add    si, alen
  575.     loop    terminate1
  576. terminate2:xor    ax, ax
  577.     mov    es, ax
  578.     mov    bx, myvec
  579.     mov    ax, savpko
  580.     mov    es:[bx], ax
  581.     mov    ax, savpks
  582.     mov    es:2[bx], ax
  583.     mov    ax, Board
  584.     mov    bx, 9
  585.     cmp    chain, 0
  586.     jz    terminate3
  587. ifdef    prescan
  588.     mov    bx, 31
  589. else
  590.     mov    bx, 30
  591. endif
  592.     mov    si, cs
  593.     mov    es, si
  594.     mov    si, offset StkChn
  595. terminate3:call    psup
  596.     mov    ax, cs
  597.     mov    es, ax
  598.     mov    ah, 49h
  599.     int    21h
  600.     pop    ds
  601.     jmp    good
  602.  
  603. get_address:cmp    cx, cs:alen
  604.     jnc    get_address1
  605.     mov    dh, 9
  606.     jmp    bad
  607. get_address1:push    ds
  608.     lds    si, cs:config
  609.     add    si, 28+6
  610.     mov    cx, cs:alen
  611.     sub    si, cx
  612.     rep    movsb
  613.     pop    ds
  614.     mov    cx, cs:alen
  615.     jmp    good
  616.  
  617. reset_interface:mov    dh, 15
  618.     jmp    bad
  619.  
  620. get_parameters:mov    di, cs
  621.     mov    es, di
  622.     mov    di, offset ptab
  623.     jmp    good
  624.  
  625. set_rcv_mode:mov    bx, cx
  626.     dec    bx
  627.     cmp    bx, 6
  628.     jnc    set_rcv_mode1
  629.     shl    bx, 1
  630.     push    cx
  631.     mov    ax, cs:rmmap[bx]
  632.     mov    bx, 4
  633.     mov    cx, -1
  634.     call    cs:control
  635.     pop    cx
  636. ;    jnz    set_rcv_mode1    ; XXX no longer supported by ODI
  637.     mov    cs:rmode, cx
  638.     jmp    good
  639. set_rcv_mode1:mov    dh, 8
  640.     jmp    bad
  641.  
  642. get_rcv_mode:mov    ax, cs:rmode
  643.     jmp    good
  644.  
  645. set_multicast_list:mov    ax, cx
  646.     xor    dx, dx
  647.     mov    bx, cs:alen
  648.     div    bx
  649.     and    dx, dx
  650.     jz    set_multicast_list1
  651.     mov    dh, 14
  652.     jmp    bad
  653. set_multicast_list1:cmp    ax, mmulti + 1
  654.     jc    set_multicast_list6
  655.     mov    dh, 9
  656.     jmp    bad
  657. set_multicast_list6:push    ds
  658.     push    cx
  659.     push    ax
  660.     push    es
  661.     push    di
  662.     mov    ax, cs
  663.     mov    ds, ax
  664.     mov    cx, nmulti
  665.     jcxz    set_multicast_list3
  666.     mov    si, offset mtab
  667. set_multicast_list2:push    si
  668.     push    cx
  669.     mov    ax, cs
  670.     mov    es, ax
  671.     mov    ax, Board
  672.     mov    bx, 3
  673.     call    control
  674.     pop    cx
  675.     pop    si
  676.     add    si, alen
  677.     loop    set_multicast_list2
  678. set_multicast_list3:pop    si
  679.     pop    ds
  680.     pop    ax
  681.     pop    cx
  682.     mov    bx, cs
  683.     mov    es, bx
  684.     mov    di, offset mtab
  685.     cld
  686.     rep    movsb
  687.     mov    bx, cs
  688.     mov    ds, bx
  689.     mov    nmulti, ax
  690.     mov    cx, ax
  691.     jcxz    set_multicast_list5
  692.     mov    si, offset mtab
  693. set_multicast_list4:push    si
  694.     push    cx
  695.     mov    ax, cs
  696.     mov    es, ax
  697.     mov    ax, Board
  698.     mov    bx, 2
  699.     call    control
  700.     pop    cx
  701.     pop    si
  702.     add    si, alen
  703.     loop    set_multicast_list4
  704. set_multicast_list5:pop    ds
  705.     jmp    good
  706.  
  707. get_multicast_list:mov    di, cs
  708.     mov    es, di
  709.     mov    di, offset mtab
  710.     mov    ax, cs:nmulti
  711.     mov    cx, cs:alen
  712.     mul    cx
  713.     mov    cx, ax
  714.     jmp    good
  715.  
  716. get_statistics:mov    si, cs
  717.     mov    ds, si
  718.     mov    si, offset stab
  719.     jmp    good
  720.  
  721. set_address:mov    dh, 13
  722.     jmp    bad
  723.  
  724. funcs    dw    nofunc
  725.     dw    driver_info
  726.     dw    access_type
  727.     dw    release_type
  728.     dw    send_pkt
  729.     dw    terminate
  730.     dw    get_address
  731.     dw    reset_interface
  732.     dw    nofunc
  733.     dw    nofunc
  734.  
  735.     dw    get_parameters
  736.     dw    nofunc
  737.     dw    nofunc
  738.     dw    nofunc
  739.     dw    nofunc
  740.     dw    nofunc
  741.     dw    nofunc
  742.     dw    nofunc
  743.     dw    nofunc
  744.     dw    nofunc
  745.  
  746.     dw    set_rcv_mode
  747.     dw    get_rcv_mode
  748.     dw    set_multicast_list
  749.     dw    get_multicast_list
  750.     dw    get_statistics
  751.     dw    set_address
  752.  
  753. nfuncs    equ    ($ - offset funcs) / 2
  754.  
  755. intpk    proc    far
  756.     jmp    short dopk
  757.     nop
  758. sig    db    'PKT DRVR', 0
  759. dopk:    cli
  760.     cld
  761.     push    bx
  762.     cmp    ah, nfuncs
  763.     jc    dopk1
  764.     jmp    nofunc
  765.  
  766. dopk1:    mov    bl, ah
  767.     xor    bh, bh
  768.     shl    bx, 1
  769.     jmp    cs:funcs[bx]
  770.  
  771. bad:    pop    bx
  772. bad1:    stc
  773.     sti
  774.     ret    2
  775. good:    pop    bx
  776. good1:    clc
  777.     sti
  778.     ret    2
  779. intpk    endp
  780.  
  781. start:    mov    ax, cs
  782.     mov    ds, ax
  783.     cld
  784.  
  785.     mov    dx, offset copyright
  786.     mov    ah, 9
  787.     int    21h
  788.  
  789.     mov    bx, 81h
  790.     call    space
  791.     call    number
  792.     jc    start0
  793.     mov    Board, ax
  794.     call    space
  795.     call    number
  796.     jc    start0
  797.     add    ax, ax
  798.     add    ax, ax
  799.     mov    myvec, ax
  800.  
  801. start0:    xor    ax, ax
  802.     mov    es, ax
  803.     mov    bx, myvec
  804.     les    di, es:[bx]
  805.     add    di, 3
  806.     mov    si, offset sig
  807.     mov    cx, 9
  808.     repe    cmpsb
  809.     jnz    start1
  810.     mov    dx, offset already
  811. pexit:    mov    ah, 9
  812.     int    21h
  813.     int    20h
  814.  
  815. start1:    xor    ax, ax
  816.     mov    es, ax
  817.     xor    bx, bx
  818.     xor    dx, dx
  819.     mov    ah, 0c0h
  820. start11:push    ax
  821.     int    2fh
  822.     cmp    al, 0ffh
  823.     pop    ax
  824.     jz    start13
  825. start12:inc    ah
  826.     jnz    start11
  827.     mov    dx, offset nolsl
  828.     jmp    pexit
  829. start13:mov    cx, dx
  830.     or    cx, bx
  831.     jz    start12
  832.     mov    di, si
  833.     mov    si, offset lslname
  834.     cld
  835.     mov    cx, 8
  836.     repe    cmpsb
  837.     jz    start14
  838.     xor    bx, bx
  839.     xor    dx, dx
  840.     jmp    start12
  841.  
  842. start14:mov    word ptr psup, bx
  843.     mov    word ptr psup + 2, dx
  844.     mov    si, cs
  845.     mov    es, si
  846.     mov    si, offset psup
  847.     mov    bx, 2
  848.     call    psup
  849.     mov    ax, word ptr gsup
  850.     or    ax, word ptr gsup + 2
  851.     jnz    start2
  852.     mov    dx, offset lslfail
  853.     jmp    pexit
  854.  
  855. start2:    mov    bx, 18
  856.     mov    ax, Board
  857.     call    psup
  858.     jz    start3
  859.     mov    dx, offset nocont
  860.     jmp    pexit
  861. start3:    mov    word ptr control, si
  862.     mov    word ptr control + 2, es
  863.     mov    ax, Board
  864.     xor    bx, bx
  865.     call    control
  866.     jz    start4
  867.     mov    dx, offset noconf
  868.     jmp    pexit
  869. start4:    mov    word ptr config, si
  870.     mov    word ptr config + 2, es
  871.     mov    al, es:114[si]
  872.     or    al, al
  873.     jz    trynew
  874.     cmp    al, 16
  875.     jc    oldok
  876. trynew:    mov    al, es:118[si]
  877. oldok:    xor    ah, ah
  878.     cmp    al, 8
  879.     jnc    noloirq
  880.     add    ax, 8
  881.     jmp    short haveirq
  882. noloirq:cmp    al, 16
  883.     jnc    noirq
  884.     add    ax, 70h - 8
  885. haveirq:mov    word ptr ptab + 12, ax
  886. noirq:    mov    ax, es:60[si]
  887.     cmp    ax, 4
  888.     jz    istok
  889.     cmp    ax, 11
  890.     jz    istok
  891.     cmp    ax, 3
  892.     jz    is8023
  893.     cmp    ax, 5
  894.     jz    is8023
  895.     cmp    ax, 10
  896.     jz    is8023
  897.     cmp    ax, 7
  898.     jz    ispcn2
  899.     cmp    ax, 15
  900.     jz    ispcn2
  901.     cmp    ax, 16
  902.     jz    ispcn2
  903.     cmp    ax, 14
  904.     jz    isarc
  905.     mov    dx, offset t_unk
  906.     jmp    short gottype
  907. istok:    mov    dx, offset t_tok
  908.     mov    off, 14
  909.     mov    ax, es:40[si]
  910.     mov    word ptr ptab + 4, ax
  911.     mov    class, 3
  912.     mov    fmin, 14
  913.     jmp    short gottype
  914. ispcn2:    mov    dx, offset t_pcn2
  915.     mov    off, 14
  916.     mov    class, 11
  917.     jmp    short gottype
  918. is8023:    mov    dx, offset t_8023
  919.     mov    off, 14
  920.     mov    class, 11
  921.     jmp    short gottype
  922. isarc:    mov    dx, offset t_arc
  923.     mov    cmap, 8
  924. gottype:mov    ah, 9
  925.     int    21h
  926.  
  927.     mov    word ptr Handler, offset recvcom
  928.     mov    word ptr Handler + 2, cs
  929.     mov    word ptr Cont, offset pcont
  930.     mov    word ptr Cont + 2, cs
  931.  
  932.     cmp    cmap, 8
  933.     jz    nochain
  934.     mov    si, cs
  935.     mov    es, si
  936.     mov    si, offset StkChn
  937. ifdef    prescan
  938.     mov    bx, 28
  939. else
  940.     mov    bx, 27
  941. endif
  942.     call    psup
  943.     cmp    ax, 0
  944.     mov    dx, offset chnmsg1
  945.     jz    usechn
  946.     cmp    ax, 8009h
  947.     jnz    nochain
  948.     mov    Posit, 1
  949.     mov    si, cs
  950.     mov    es, si
  951.     mov    si, offset StkChn
  952.     mov    bx, 27
  953.     call    psup
  954.     cmp    ax, 0
  955.     mov    dx, offset chnmsg2
  956.     jz    usechn
  957.  
  958. nochain:mov    si, cs
  959.     mov    es, si
  960.     mov    si, offset Handler
  961.     mov    ax, Board
  962.     mov    bx, 8
  963.     call    psup
  964.     jz    start5
  965.     mov    dx, offset rfail
  966.     jmp    pexit
  967.  
  968. usechn:    mov    ah, 9
  969.     int    21h
  970.     mov    chain, 1
  971. start5:    mov    word ptr sECB + 10, offset transcom
  972.     mov    word ptr sECB + 12, cs
  973.     mov    word ptr sECB + 14, -1
  974.     mov    ax, Board
  975.     mov    word ptr sECB + 22, ax
  976.     mov    word ptr sECB + 44, 1
  977.  
  978.     xor    ax, ax
  979.     mov    es, ax
  980.     pushf
  981.     cli
  982.     mov    bx, myvec
  983.     mov    ax, es:[bx]
  984.     mov    savpko, ax
  985.     mov    ax, es:2[bx]
  986.     mov    savpks, ax
  987.     mov    es:[bx], offset intpk
  988.     mov    es:2[bx], cs
  989.     popf
  990.  
  991.     mov    dx, offset goodins
  992.     mov    ah, 9
  993.     int    21h
  994.  
  995.     mov    es, ds:[2ch]
  996.     mov    ah, 49h
  997.     int    21h
  998.     mov    word ptr ds:[2ch], 0
  999.  
  1000.     mov    cx, 5
  1001.     xor    bx, bx
  1002. cloop:    mov    ah, 3eh
  1003.     int    21h
  1004.     inc    bx
  1005.     loop    cloop
  1006.  
  1007.     mov    dx, offset start
  1008.     int    27h
  1009.  
  1010. number:    xor    ax, ax
  1011.     mov    cx, -1
  1012.     mov    base, 10
  1013.     cmp    byte ptr [bx], '0'
  1014.     jnz    number1
  1015.     xor    cx, cx
  1016.     mov    base, 8
  1017.     inc    bx
  1018.     cmp    byte ptr [bx], 'x'
  1019.     jz    @f
  1020.     cmp    byte ptr [bx], 'X'
  1021.     jnz    number1
  1022. @@:    mov    base, 16
  1023.     inc    bx
  1024. number1:mov    dl, byte ptr [bx]
  1025.     cmp    dl, '0'
  1026.     jc    @f
  1027.     cmp    dl, '9' + 1
  1028.     jnc    @f
  1029.     sub    dl, '0'
  1030.     jmp    short number2
  1031. @@:    cmp    dl, 'a'
  1032.     jc    @f
  1033.     cmp    dl, 'f' + 1
  1034.     jnc    @f
  1035.     sub    dl, 'a' - 10
  1036.     jmp    short number2
  1037. @@:    cmp    dl, 'A'
  1038.     jc    number3
  1039.     cmp    dl, 'F' + 1
  1040.     jnc    number2
  1041.     sub    dl, 'A' - 10
  1042. number2:xor    dh, dh
  1043.     cmp    dx, base
  1044.     jnc    number3
  1045.     xor    cx, cx
  1046.     push    dx
  1047.     mov    dx, base
  1048.     mul    dx
  1049.     pop    dx
  1050.     add    ax, dx
  1051.     inc    bx
  1052.     jmp    short number1
  1053. number3:add    cx, 1
  1054.     ret
  1055.  
  1056. space:    cmp    byte ptr [bx], ' '
  1057.     jz    space1
  1058.     cmp    byte ptr [bx], 9
  1059.     jz    space1
  1060.     ret
  1061. space1:    inc    bx
  1062.     jmp    short space
  1063.  
  1064. base    dw    10
  1065. lslname    db    'LINKSUP$'
  1066. already    db    'A driver is already installed at this vector.', 13, 10, '$'
  1067. t_unk    db    'Using Ethernet framing, class 1', 13, 10, '$'
  1068. t_tok    db    'Using Token Ring framing, class 3', 13, 10, '$'
  1069. t_pcn2    db    'Using PCN2 framing, class 11', 13, 10, '$'
  1070. t_8023    db    'Using 802.3 framing, class 11', 13, 10, '$'
  1071. t_arc    db    'Using ARCNET framing, class 1', 13, 10, '$'
  1072. goodins    db    'ODIPKT is installed and ready.', 13, 10, '$'
  1073. nolsl    db    'The Link Support Layer is not loaded.', 13, 10, '$'
  1074. lslfail    db    'The Link Support Layer failed to init.', 13, 10, '$'
  1075. nocont    db    'Cannot get MLID control entry', 13, 10, '$'
  1076. noconf    db    'Cannot get MLID configuration', 13, 10, '$'
  1077. rfail    db    'Failed to register protocol stack', 13, 10, '$'
  1078. ifdef    prescan
  1079. chnmsg1    db    'Registered as high priority chained prescan stack', 13, 10, '$'
  1080. chnmsg2    db    'Registered as chained prescan stack', 13, 10, '$'
  1081. else
  1082. chnmsg1    db    'Registered as high priority chained default stack', 13, 10, '$'
  1083. chnmsg2    db    'Registered as chained default stack', 13, 10, '$'
  1084. endif
  1085.  
  1086. CODE    ends
  1087.     end    at100h
  1088.