home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / odipkt / odipkt13.asm < prev    next >
Assembly Source File  |  1997-01-26  |  18KB  |  1,099 lines

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