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