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

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