home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / ATCOM / ATCOM.INC < prev    next >
Text File  |  1995-04-14  |  56KB  |  1,440 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12. ;       SCCSID = @(#)atcom.inc  6.13 92/02/22
  13. ; ***************************************************************************
  14. ; *
  15. ; *
  16. ; *
  17. ; ***************************************************************************
  18. ;
  19. ;       Macros, structures and constants for the COM device driver.
  20. ;       Some of the constants are dependent on the 16450 serial
  21. ;       communications chip.
  22.  
  23. ;       Modification History
  24. ;
  25. ;       JGT     05/10/88        Remove baud rate table (p587-cpd12)
  26. ;
  27. ;       YN      05/25/89        MVDM Support - @VDM
  28. ;
  29. ;       ACW     04/16/91        @PVW Added perfview counters/timers
  30. ;
  31. ;       YN      08/13/91        CP20D1390 - Bulletin Board Support
  32. ;
  33. ;       MF      02/21/92        PB732220 - Procom Plus host mode fix (@0001)
  34. ;
  35. ;       WDM     04/20/94        D82467 - add pvwxport.inc to resolve pvdbh_s
  36.  
  37. ;.xlist
  38.  include pvwxport.inc           ; 82467
  39. ;.list
  40.  
  41. HSEG SEGMENT DWORD PUBLIC 'RESDATA'              ; resident data segment
  42. HSEG ENDS
  43.  
  44. RSEG SEGMENT DWORD PUBLIC 'RESCODE'              ; resident code segment
  45. RSEG ENDS
  46.  
  47. DSEG SEGMENT DWORD PUBLIC 'DATA'                 ; swappable data segment
  48. DSEG ENDS
  49.  
  50. _DATA SEGMENT DWORD PUBLIC 'DATA'
  51. _DATA ENDS
  52.  
  53. CONST SEGMENT DWORD PUBLIC 'CONST'
  54. CONST ENDS
  55.  
  56. _BSS  SEGMENT DWORD PUBLIC 'BSS'
  57. _BSS  ENDS
  58.  
  59. CSEG SEGMENT DWORD PUBLIC 'CODE'              ; swappable code segment
  60. CSEG ENDS
  61.  
  62. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  63. _TEXT ENDS
  64.  
  65. DGROUP  GROUP   DSEG,_DATA,CONST,_BSS
  66. CGROUP  GROUP   RSEG
  67. C2GROUP GROUP   CSEG,_TEXT
  68.  
  69.  
  70. MAXCOMPORTS     EQU     4
  71.  
  72. lhlen           equ     12 ; lock handle length (from pgexport.inc)
  73.  
  74. ;**     ALLSTRICT - turn on all strict checking
  75.  
  76. IFDEF ALLSTRICT
  77.     CISTRICT    EQU     1       ; cominfo
  78.     RPLSTRICT   EQU     1       ; request packet list
  79.     RPTSTRICT   EQU     1       ; request packet type
  80.     RPSTRICT    EQU     1       ; request packet pointer
  81. ENDIF
  82.  
  83. ;**     SIGNATURE assertion check constant
  84. ;
  85. ;       SIGNATURE is used throughout the com driver in order to
  86. ;       perform run time assertion checking.
  87. ;
  88.  
  89. SIGNATURE       EQU     'dg'
  90.  
  91.  
  92. ;**     min - in with IODELAY
  93. ;
  94.  
  95. min     MACRO   a,b
  96. ;       DevIODelay
  97.         IODELAY
  98.         in      a,b
  99. ENDM
  100.  
  101.  
  102. ;**     mout - out with IODELAY
  103. ;
  104.  
  105. mout    MACRO   a,b
  106. ;       DevIODelay
  107.         IODELAY
  108.         out     a,b
  109. ENDM
  110.  
  111.  
  112. ;**     POPFF - special version of pop flags for i286
  113. ;
  114. ;       This avoids the pitfalls of the 286 POPF instruction
  115. ;       which will sometimes allow an interrupt to come in
  116. ;       even if IF is off in both the old and new flags.
  117.  
  118. POPFF   MACRO
  119. ;;LOCAL a
  120. ;;      push    cs
  121. ;;      push    offset cs:a
  122. ;;      iret
  123. ;;a:
  124.         popf            ; assume we're running on a 386 with no erratum
  125. ENDM
  126.  
  127. ;**     ReadLSR - read LSR and save in lsrshadow
  128. ;
  129. ;       moves value into lsrshadow if there was an overrun error,
  130. ;       otherwise just 'or' the value into lsrshadow so that errors are
  131. ;       not lost.
  132. ;
  133. ;       INPUT   (ds:si) -> ComInfo
  134. ;
  135. ;       OUTPUT  (al) = LSR
  136. ;
  137. ;       USES    al dx
  138. ;
  139. ;       NOTE    must be called with interupts disabled so we don't get
  140. ;               a receive interrupt during lsrshadow update.
  141.  
  142. ReadLSR MACRO
  143. LOCAL   a
  144.         mov     dx,[si].ci_port
  145.         add     dx,R_LINES              ; (dx) -> LSR
  146.         in      al,dx                   ; (al) =  LSR
  147.         or      [si].ci_lsrshadow,al    ; shadow the contents of the LSR.
  148.                                 ; use 'or' so previous errors are not lost
  149.  
  150.         test    al,LS_OERR
  151.         jz      a                       ; not overrun
  152.         mov     [si].ci_lsrshadow,al    ; shadow the contents of the LSR.
  153.                                 ; use 'mov' because the overrun lost any
  154.                                 ; previous characters.
  155. a:
  156. ENDM
  157.  
  158.  
  159. ;**     ComErr - internal error macro for com driver
  160. ;
  161. ComErr  MACRO   string,near_or_far
  162. LOCAL   a
  163.  
  164.         IFB     <string>
  165.                 %OUT ComError : missing error string
  166.                 .ERR
  167.         ENDIF
  168.  
  169.  
  170.         IFDEF   COMDEBUG
  171.                 MESSAGES EQU 1          ; debug version always has messages
  172.         ENDIF
  173.  
  174.         IFDEF   MESSAGES
  175.                 DSEG SEGMENT
  176.                         a       DB      '&string'       ; allocate message
  177.                 DSEG ENDS
  178.  
  179.                 push    OFFSET DSEG:a           ; push message offset
  180.         ELSE
  181.                 push    0                       ; push null message offset
  182.         ENDIF
  183.  
  184.         IFDEF   COMDEBUG
  185.                 int     3
  186.         ENDIF
  187.         if2
  188.             ifndef ComError
  189.                 ifb <near_or_far>
  190.                 extrn ComError:near
  191.                 else
  192.                         EXTRNFAR ComError
  193.             endif
  194.         endif
  195.         endif
  196.         ifb <near_or_far>
  197.         call    ComError
  198.         else
  199.                 CALLFAR ComError
  200.         endif
  201. ENDM
  202.  
  203.  
  204. ;**     DevHelp - macro to call [DevHlp]
  205. ;
  206. DevHelp MACRO
  207.  
  208.         IFDEF   DDEVHELP
  209.                 int     3
  210.         ENDIF
  211.         call    [DevHlp]
  212.  
  213. ENDM
  214.  
  215.  
  216. ;**     ProcReady - macro to add a request packet to the end of the Ready list
  217. ;
  218. ;       This code is written as a macro because putting RPs on
  219. ;       the Ready list is often done at interrupt time.
  220. ;
  221. ProcReady       MACRO   near_or_far
  222.  
  223.         SaveReg         <si>
  224.         mov     si,OFFSET Ready
  225.         if2
  226.             ifndef LinkRP
  227.                 ifb <near_or_far>
  228.                 extrn LinkRP:near
  229.                 else
  230.                         EXTRNFAR LinkRP
  231.             endif
  232.         endif
  233.         endif
  234.         ifb <near_or_far>
  235.         call    LinkRP
  236.         else
  237.                 CALLFAR LinkRP
  238.         endif
  239.         RestoreReg      <si>
  240. ENDM
  241.  
  242.  
  243. ;**     ChkComInfoPtr - check the validity of the ComInfo pointer
  244. ;
  245. ;       ChkComInfoPtr is a macro which conditionally assembles
  246. ;       to a call if CISTRICT is defined.
  247. ;
  248. ChkComInfoPtr   MACRO
  249.         IFDEF   CISTRICT
  250.             if2
  251.                 ifndef CheckComInfoPtr
  252.                     extrn CheckComInfoPtr:near
  253.                 endif
  254.             endif
  255.             call CheckComInfoPtr
  256.         ENDIF   ; CISTRICT
  257. ENDM
  258.  
  259.  
  260. ;**     ChkRPType - check the request packet for the type we expect
  261. ;
  262. ;       ChkRPType is a macro which conditionally assembles
  263. ;       to a call if RPTSTRICT is defined.
  264. ;
  265. ChkRPType       MACRO   type
  266. LOCAL   a
  267.  
  268.         IFB     <type>
  269.                 %OUT ChkRPType : missing type
  270.                 .ERR
  271.         ENDIF
  272.  
  273.         IFDEF   RPTSTRICT
  274.                 pushf
  275.                 cmp     es:[di].PktCmd,&type
  276.                 je      a
  277.  
  278.                 ComErr  <ChkRPType : unexpected request packet type>
  279.  
  280.         a:      popf
  281.         ENDIF   ; RPTSTRICT
  282. ENDM
  283.  
  284.  
  285. ;**     ChkRPPtr - check the validity of the request packet pointer
  286. ;
  287. ;       ChkRPPtr is a macro which conditionally assembles
  288. ;       to a call if RPSTRICT is defined.
  289. ;
  290. ChkRPPtr        MACRO
  291.         IFDEF   RPSTRICT
  292.             if2
  293.                 ifndef CheckRPPtr
  294.                     extrn CheckRPPtr:near
  295.                 endif
  296.             endif
  297.             call CheckRPPtr
  298.         ENDIF   ; RPSTRICT
  299. ENDM
  300.  
  301.  
  302. ;**     ChkRPLPtr - check the validity of the RP_List pointer
  303. ;
  304. ;       ChkRPLPtr is a macro which conditionally assembles
  305. ;       to a call if RPLSTRICT is defined.
  306. ;
  307. ChkRPLPtr       MACRO
  308.         IFDEF   RPLSTRICT
  309.             if2
  310.                 ifndef CheckRPLPtr
  311.                     extrn CheckRPLPtr:near
  312.                 endif
  313.             endif
  314.             call CheckRPLPtr
  315.         ENDIF   ; RPLSTRICT
  316. ENDM
  317.  
  318. ;**     Call_Strat - Calls the correct strategy routine based on SI
  319. ;
  320. ;       USES    nothing
  321. ;
  322. Call_Strat      MACRO
  323.         local   try2
  324.         local   try3
  325.         local   try4
  326.         local   combine
  327.  
  328.         push    si
  329.         cmp     si,Com1
  330.         jne      try2
  331.         call    Com1Strat
  332.         jmp     short   combine
  333. try2:
  334.         cmp     si, Com2
  335.         jne     try3
  336.         call    Com2Strat
  337.         jmp     short   combine
  338.  
  339. try3:
  340.         cmp     si, Com3
  341.         jne     try4
  342.         call    Com3Strat
  343.         jmp     short   combine
  344.  
  345. try4:   call    Com4Strat
  346.  
  347. combine:
  348.         pop     si
  349. ENDM
  350.  
  351. ;**     FlushQueue - flush an IO_Queue
  352. ;
  353. ;       USES    ax
  354. ;
  355. FlushQueue      MACRO   IOQ
  356.         IFB     <ioq>
  357.                 %OUT "FlushQueue invoked without a queue"
  358.                 .ERR
  359.         ENDIF
  360.  
  361.         ChkComInfoPtr
  362.  
  363.         mov     ax,[si].&IOQ.ioq_base
  364.         mov     [si].&IOQ.ioq_in,ax
  365.         mov     [si].&IOQ.ioq_out,ax
  366.         mov     [si].&IOQ.ioq_count,0
  367. ENDM
  368.  
  369.  
  370. XONequ                  = 11h           ; DC1 ^Q
  371. XOFFequ                 = 13h           ; DC3 ^S
  372.  
  373. PhysAddr struc
  374.         _lo     dw      (?)     ; low word of a 32-bit pointer
  375.         _hi     dw      (?)     ; high word of a 32-bit pointer
  376. PhysAddr ends
  377.  
  378.  
  379. ;**     RP_List - definition of a request packet list
  380. ;
  381. RP_List STRUC
  382.         rpl_head        DD      0       ; pointer to head of list
  383.         rpl_tail        DD      0       ; pointer to tail of list
  384.         rpl_signature   DW      SIGNATURE
  385. RP_List ENDS
  386.  
  387.  
  388. ;**     Fill_IOCTL - fills in the IOCTL packet for passing to the strat
  389. ;
  390. ;       USES    nothing
  391. ;
  392. Fill_IOCTL      MACRO dseg,doff,pseg,poff
  393.         mov     [si].ci_req_pack.GIODataPack._hi,dseg
  394.         mov     [si].ci_req_pack.GIODataPack._lo,doff
  395.         mov     [si].ci_req_pack.GIOParaPack._hi,pseg
  396.         mov     [si].ci_req_pack.GIOParaPack._lo,poff
  397.         mov     [si].ci_req_pack.GIOCategory,1
  398.         mov     [si].ci_req_pack.GIOFunction,al
  399.         mov     [si].ci_req_pack.IPcommand,IOCTL_Command
  400.         mov     [si].ci_req_pack.IPlen,size IOCTLPacket
  401. ENDM
  402.  
  403. ;**     Set_Data - Set the data packet address
  404. ;
  405. ;       USES    nothing
  406. ;
  407. Set_Data        MACRO dataseg,dataoff
  408.         mov     [si].ci_req_pack.GIODataPack._hi,dataseg
  409.         mov     [si].ci_req_pack.GIODataPack._lo,dataoff
  410. ENDM
  411.  
  412. ;**     Set_Para - Set the parameter packet address
  413. ;
  414. ;       USES    nothing
  415. ;
  416. Set_Para        MACRO pseg,poff
  417.         mov     [si].ci_req_pack.GIOParaPack._hi,pseg
  418.         mov     [si].ci_req_pack.GIOParaPack._lo,poff
  419. ENDM
  420.  
  421.  
  422.  
  423. ;**     INT_Notify - calls the INT notify routines if COM in use by VDM
  424. ;
  425. ;       USES    nothing
  426. ;
  427. INT_NOTIFY      MACRO
  428.         local   no_vdm
  429.         test    [si].ci_vdm_flag,VDM_Flag_InUse
  430.         jz      no_vdm
  431.  
  432.         SaveReg <ax,bx,dx>
  433.         mov     dl,[si].ci_port_number
  434.         call    Rx_Notify
  435.         call    Tx_Notify
  436.         call    MS_Notify
  437.         RestoreReg <dx,bx,ax>
  438. no_vdm:
  439. ENDM
  440.  
  441. ;**     SET - sets bit(s) in "var" according to bit-mask "bits"
  442. ;
  443. ;       USES    nothing
  444. ;
  445. SET     MACRO   var,bits
  446.         or      var,bits
  447. ENDM
  448.  
  449. ;**     CLR - clear bit(s) in "var" according to bit-mask "bits"
  450. ;
  451. ;       USES    nothing
  452. ;
  453. CLR     MACRO   var,bits
  454.         and     var,NOT bits
  455. ENDM
  456.  
  457. ;**     setDS - sets DS to segname, does ASSUME DS=segname
  458. ;
  459. ;       USES    nothing
  460. ;
  461. setDS   MACRO   segname
  462.         push    ax
  463.         mov     ax,segname
  464.         mov     ds,ax
  465.         pop     ax
  466.         ASSUME  ds:segname
  467.         endm
  468.  
  469. ;**     setES - sets ES to segname, does ASSUME ES=segname
  470. ;
  471. ;       USES    nothing
  472. ;
  473. setES   MACRO   segname
  474.         push    ax
  475.         mov     ax,segname
  476.         mov     es,ax
  477.         pop     ax
  478.         ASSUME  es:segname
  479.         endm
  480.  
  481.  
  482. IOCTLPacket     STRUC
  483.         IPlen           DB      ?
  484.         IPunit          DB      ?
  485.         IPcommand       DB      ?
  486.         IPstatus        DW      ?
  487.         IPreserved      DD      ?
  488.         IPQlink         DD      ?
  489.         IPcategory      DB      ?
  490.         IPfunction      DB      ?
  491.         IP@parameter    DD      ?
  492.         IP@data         DD      ?
  493.         IPsfn           DW      ?
  494. IOCTLPacket     ENDS
  495.  
  496. Flat_Pointer    struc
  497.         fp_offlo        DW      ?
  498.         fp_offhi        DW      ?
  499.         fp_sel          DW      ?
  500. Flat_Pointer    ends
  501.  
  502. Stack_Data      struc
  503.         old_bp  dw      ?
  504.         old_cs  dd      ?
  505.         old_ip  dd      ?
  506.         ul2     dd      ?
  507.         ul1     dd      ?
  508.         uFunc   dd      ?
  509. Stack_Data      ends
  510.  
  511. Device_dependant_VCOM_data      struc
  512.         ret_len dw      ?
  513.         num_com dw      ?
  514.         @com1   dw      ?
  515.         @com2   dw      ?
  516.         @com3   dw      ?
  517.         @com4   dw      ?
  518.         @cm1irq dw      ?
  519.         @cm2irq dw      ?
  520.         @cm3irq dw      ?
  521.         @cm4irq dw      ?
  522. Device_dependant_VCOM_data      ends
  523.  
  524. IDC_Packet      struc
  525.         Command_Flag    dw      ?
  526.         Com_Port_Num    dw      ?
  527.         Com_Port_Addr   dw      ?
  528.         Com_Port_IRQ    dw      ?
  529.         Return_Code     dw      ?
  530. IDC_Packet       ends
  531.  
  532. ;**     Machine Identifiers
  533. ;
  534. ;       ABIOS_COM          -   Identifies a ABIOS machine
  535. ;       NON_ABIOS_COM      -   Identifies a non ABIOS machine
  536. ;
  537. ;
  538.  
  539. NON_ABIOS_COM   EQU     1
  540. ABIOS_COM       EQU     0
  541.  
  542. ;**     ESP Adapter specific equates
  543. ;
  544.  
  545. SPACE           EQU     20h
  546. ESPSIG          EQU     0AAh
  547. NULL            EQU     00h
  548.  
  549. Ad     STRUC
  550.     _address1   DW      0
  551.     _address2   DW      0
  552.     _interrupt1 DB      0
  553.     _interrupt2 DB      0
  554.     _dma1       DB      0
  555.     _dma2       DB      0
  556.     _port1      DW      -1
  557.     _port2      DW      -1
  558.     _port3      DW      -1
  559.     _port4      DW      -1
  560. Ad     ENDS
  561.  
  562. BUS_MCA         EQU     0
  563. BUS_AT          EQU     1
  564.  
  565. ;**     Queue manifests, sizes and hi/lo water marks
  566. ;
  567. ;       Due to the implementation of the character queues, they
  568. ;       must be declared to be one byte greater than their
  569. ;       actual usable size.
  570. ;
  571. QI_SIZE         EQU     5121                    ; input  queue size
  572. QO_SIZE         EQU     2049    ;before = 513   ; output queue size
  573. QI_SIZE_EVEN    EQU     QI_SIZE + 1 AND NOT 1   ; even size for word alignment
  574. QO_SIZE_EVEN    EQU     QO_SIZE + 1 AND NOT 1
  575.  
  576. ; high/low water marks for when to send handshake
  577. ; when input queue goes above high water, send XOFF and/or drop hardware lines
  578. ; when input queue goes below low  water, send XON and/or raise hardware lines
  579. RX_HIGH_HS      EQU     (QI_SIZE-1)-2048 ; RX queue high water mark
  580. RX_LOW_HS       EQU     (QI_SIZE-1)/2    ; RX queue low water mark
  581.  
  582. ; when input queue goes up to this, move data to user buffer
  583. RX_MOVE_PROT    EQU     200             ; protect mode or below 1 meg
  584. RX_MOVE_REAL    EQU     256             ; real   mode and above 1 meg
  585.  
  586. ; when output queue goes down to this, move data from user buffer
  587. TX_MOVE_PROT    EQU     64              ; protect mode or below 1 meg
  588. TX_MOVE_REAL    EQU     0               ; real   mode and above 1 meg
  589.  
  590. RX_STATE_HOLDING        EQU     1       ; isr has no more room in buffer
  591.                                         ; until consumer removes rx data
  592. RX_STATE_OK             EQU     2       ; isr has room in buffer for rx data
  593.  
  594. ;**     ComInfo.ci_dcb_flags1 definitions
  595. ;
  596. F1_DTR_MASK     EQU     00000011b       ; DTR control mask
  597. F1_DTR_DISABLE  EQU     00000000b       ; DTR disable
  598. F1_DTR_ENABLE   EQU     00000001b       ; DTR enable
  599. F1_DTR_FLOW     EQU     00000010b       ; DTR input handshaking
  600. F1_DTR_INVALID  EQU     00000011b       ; DTR invalid mode
  601. F1_OUT_FLOW     EQU     00111000b       ; output handshaking mask
  602. F1_OUT_CTS_FLOW EQU     00001000b       ; output handshaking using CTS
  603. F1_OUT_DSR_FLOW EQU     00010000b       ; output handshaking using DSR
  604. F1_OUT_DCD_FLOW EQU     00100000b       ; output handshaking using DCD
  605.  
  606. F1_IN_DSR_SENSE EQU     01000000b       ; input  sensitivity using DSR
  607. F1_RESERVED     EQU     10000100b       ; reserved
  608.  
  609.  
  610. ;**     ComInfo.ci_dcb_flags2 definitions
  611. ;
  612. F2_OUT_XO       EQU     00000001b       ; output XON/XOFF
  613. F2_IN_XO        EQU     00000010b       ; input  XON/XOFF
  614.  
  615. F2_ERR_CHAR     EQU     00000100b       ; error replacement char
  616. F2_NULL_STRIP   EQU     00001000b       ; null stripping
  617. F2_BRK_CHAR     EQU     00010000b       ; break replacement char
  618. F2_FULL_DUP     EQU     00100000b       ; full duplex auto flow control
  619.                                         ; (send data after sending XOFF)
  620.  
  621. F2_RTS_MASK     EQU     11000000b       ; RTS control mask
  622. F2_RTS_DISABLE  EQU     00000000b       ; RTS disable
  623. F2_RTS_ENABLE   EQU     01000000b       ; RTS enable
  624. F2_RTS_FLOW     EQU     10000000b       ; RTS input handshaking
  625. F2_RTS_TOGGLE   EQU     11000000b       ; RTS toggle on transmit
  626.  
  627.  
  628. ;**     ComInfo.ci_dcb_flags3 definitions
  629. ;
  630. F3_W_INF_TO     EQU     00000001b       ; write infinite timeout
  631.  
  632. F3_READ_TO_MASK EQU     00000110b       ; read timeout mask
  633. F3_READ_TO_BAD  EQU     00000000b       ; read timeout bad
  634. F3_READ_TO_NORM EQU     00000010b       ; read timeout normal
  635. F3_READ_TO_WFS  EQU     00000100b       ; read timeout wait for something
  636. F3_READ_TO_NW   EQU     00000110b       ; read timeout no wait
  637.  
  638. F3_FIFO_MASK    EQU     00011000b       ; FIFO mask
  639. F3_FIFO_NA      EQU     00000000b       ; FIFO not available
  640. F3_FIFO_OFF     EQU     00001000b       ; FIFO disabled
  641. F3_FIFO_ON      EQU     00010000b       ; FIFO enabled
  642. F3_FIFO_APO     EQU     00011000b       ; FIFO auto priority override
  643. F3_FIFO_HW_ON   EQU     00010000b       ; FIFO HW is on (either ON or APO)
  644.  
  645. F3_RX_MASK      EQU     01100000b       ; receive trigger level mask
  646. F3_RX_1         EQU     00000000b       ; receive trigger level 1
  647. F3_RX_4         EQU     00100000b       ; receive trigger level 4
  648. F3_RX_8         EQU     01000000b        ; receive trigger level 8
  649. F3_RX_14        EQU     01100000b       ; receive trigger level 14
  650.  
  651. F3_TX_16        EQU     10000000b       ; transmit buffer load count = 16
  652.  
  653. F3_FIFO_ALL     EQU     11111000b       ; all the fifo bits
  654.  
  655. ;**** MVDM Support Equates
  656. VDM_Flag_InUse                  EQU     00000001b
  657. VDM_Flag_notify_the_VCOM_RX     EQU     00000010b
  658. VDM_Flag_notify_the_VCOM_TX     EQU     00000100b
  659. VDM_Flag_Blocked_IOCTL          EQU     00001000b
  660. VDM_Flag_InOut_Handshake_Init   EQU     00010000b
  661. VDM_Flag_No_IRQ_Open            EQU     00100000b
  662.  
  663. VDM_Max_Tx_Count                EQU     16
  664. VDM_Max_Rx_Count                EQU     16
  665.  
  666. VDM_Delta_QO_SIZE               EQU     QO_SIZE-VDM_Max_Tx_Count
  667.  
  668. VDM_TERM_TIMEOUT                EQU     15000 ; 15 sec timeout for termination
  669.  
  670.  
  671. ;**     ComInfo.ci_hsflag values
  672. ;
  673. HS_XOFF_PENDING         EQU     00000001b       ; XOFF needs to be sent
  674. HS_FLOW_OFF_LOCAL       EQU     00000010b
  675. HS_XON_PENDING          EQU     00000100b       ; XON needs to be sent
  676. HS_XOFF_RECEIVED        EQU     00001000b       ; XOFF character received
  677. HS_XOFF_SENT            EQU     00010000b       ; XOFF has been sent
  678. HS_BREAK_SET            EQU     01000000b       ; break has been set
  679. HS_TX_IMMED             EQU     10000000b       ; TxImmed character pending
  680.  
  681.  
  682. ;**     IOCTL com status definitions
  683. ;
  684. ; Note: TX_IMMED is maintained in ci_hsflag.  All the other fields are
  685. ; calculated only when IOCTL Return Com Status is called.
  686. ;
  687. CST_CTS_HOLD    EQU     00000001b       ; TX waiting for CTS to be asserted?
  688. CST_DSR_HOLD    EQU     00000010b       ; TX waiting for DSR to be asserted?
  689. CST_DCD_HOLD    EQU     00000100b       ; TX waiting for DCD to be asserted?
  690. CST_XOFF_HOLD   EQU     00001000b       ; TX waiting, XOff received?
  691. CST_XOFF_SENT   EQU     00010000b       ; TX waiting, XOff transmitted?
  692. CST_BREAK_HOLD  EQU     00100000b       ; TX waiting, break being transmitted?
  693. CST_TX_IMMED    EQU     01000000b       ; char waiting to be transmitted immed?
  694. CST_RX_DSR_HOLD EQU     10000000b       ; RX waiting for DSR to be asserted?
  695.  
  696.  
  697. ;**     ComInfo.ci_comerr (IOCTL com error) definitions
  698. ;
  699. CE_SW_OVERRUN   EQU     00000001b       ; receive SW queue overrun error
  700. CE_HW_OVERRUN   EQU     00000010b       ; receive HW overrun error
  701. CE_RX_PARITY    EQU     00000100b       ; receive parity error
  702. CE_FRAME        EQU     00001000b       ; receive framing error
  703.  
  704.  
  705. ;**     ComInfo.ci_event (IOCTL com event) definitions
  706. ;
  707. EV_RX_CHAR      EQU     00000001b       ; set when any character is received
  708.                                         ; and placed in the input queue.
  709. EV_RESERVED     EQU     00000010b       ; reserved
  710. EV_TX_EMPTY     EQU     00000100b       ; set when the last char in the
  711.                                         ; transmit queue is transmitted
  712. EV_CTS          EQU     00001000b       ; set when the CTS signal changes state
  713. EV_DSR          EQU     00010000b       ; set when the DSR signal changes state
  714. EV_DCD          EQU     00100000b       ; set when the DCD signal changes state
  715. EV_BREAK        EQU     01000000b       ; set when a Break is detected on input
  716. EV_ERR          EQU     10000000b       ; set when an error occurs
  717.                                         ; (parity, framing or HW or SW overrun)
  718. EV_RING         EQU    100000000b       ; set when Ring Indicator is detected
  719.  
  720.  
  721. ;**     ComInfo.ci_flagx definitions
  722. ;
  723. FX_DATA_MOVED           EQU     00000001b       ; data moved (PhysToVirt) in
  724.                                                 ; TxInt, so don't move Rx data
  725.                                                 ; this interrupt
  726. FX_LAST_CLOSE           EQU     00000010b       ; last close in progress,
  727.                                                 ; so discard received data
  728. FX_RTS_DROP_PENDING     EQU     00000100b       ; drop RTS at the first timer
  729.                                                 ; tick where the THR and TSR
  730.                                                 ; are empty
  731. FX_WAITING_TX_EMPTY     EQU     00001000b
  732. FX_INT_NESTED           EQU     00010000b       ; nested interrupt occured
  733. FX_IN_DSR_OK            EQU     00100000b       ; input DSR mode is off OR
  734.                                                 ; DSR was high OR DSR is high
  735.                                         ; this bit MUST be the same as MS_DSR
  736.  
  737. FX_CHIP_MASK            EQU     11000000b       ; chip type 8250, 16450, 16550A
  738. FX_8250                 EQU     00000000b       ; 8250x (PC chip)
  739. FX_16450                EQU     01000000b       ; 16450 or 16550 (bad FIFO)
  740. FX_16550A               EQU     10000000b       ; 16550A (good FIFO)
  741.  
  742.  
  743. ;**     ComInfo.ci_flagx definitions
  744. ;
  745. FX_XO_FOUND             EQU     00100000b       ; flag used in TxFlowDetect
  746. FX_TX_IN_PROG           EQU     01000000b       ; flag used for Tx'ing
  747. FX_INT_TIME             EQU     10000000b       ; flag used mode switching
  748.  
  749.  
  750. ;**     ComInfo.ci_Flagx1 definitions
  751. ;
  752. FX1_FLUSH_TX_IP  EQU     00000001b       ;;MF flag for TX Flush in progress
  753. FX1_FLUSH_RX_IP  EQU     00000010b       ;;MF flag for RX Flush in progress
  754. FX1_SET_BAUD_IP  EQU     00000100b       ; flag for set baud IOCTL in progress
  755. FX1_PCMCIA_MODEM EQU     00001000b       ; flag to show this is pcmcia modem
  756.  
  757. ;**     ComInfo.ci_eflags definitions
  758. ;
  759. ; NOTE: bit positions must match SetEnhancedParmeters IOCtl (54H)
  760. ;       parameter packet format
  761. EF_POSSIBLE_ENHANCED    EQU     00000001b       ; port CAN run in enhanced mode
  762. EF_MODE_ENHANCED        EQU     00000010b       ; port is NOW in enhanced mode
  763. EF_RX_REQUEST_NOT_PIO   EQU     00000100b       ; port NOT in rx PIO mode
  764. EF_RX_REQUEST_DEF_DMA   EQU     00001000b       ; port DEFINITELY in rx DMA mode
  765. EF_RX_REQUEST_MASK      EQU     00001100b       ; 
  766. EF_TX_REQUEST_NOT_PIO   EQU     00010000b       ; port NOT in rx PIO mode
  767. EF_TX_REQUEST_DEF_DMA   EQU     00100000b       ; port DEFINITELY in rx DMA mode
  768. EF_TX_REQUEST_MASK      EQU     00110000b       ; 
  769. EF_LAST_RX_WAS_DMA      EQU     01000000b       ; most recent receive for
  770.                                                 ; this port was in DMA mode
  771. EF_LAST_TX_WAS_DMA      EQU     10000000b       ; most recent transmit for
  772.                                                 ; this port was in DMA mode
  773. EF_GET_MASK             EQU     11000001b
  774.  
  775. DMA_REQ_DISABLE         EQU     0       ; don't use DMA, use PIO
  776. DMA_REQ_AUTO            EQU     1       ; maybe use DMA
  777. DMA_REQ_DEDICATE        EQU     2       ; definitely use DMA
  778.  
  779. ;**     Cominfo.ci_depth definitions
  780. ;
  781. ; NOTE: D_BAD is zero so you don't have to test it after incrementing it
  782.  
  783. D_NONE  EQU     0FDh                    ; no          interrupts in progress
  784. D_FIRST EQU     0FEh                    ; first level interrupt  in progress
  785. D_NEST  EQU     0FFh                    ; nested      interrupt  in progress
  786. D_BAD   EQU     000h                    ; too many    interrupts in progress
  787.  
  788. ;**     ESPInfo.pi_flags values
  789. PIF_CI_NULL     EQU     00000001b       ; ISR found a null ComInfo pointer
  790. PIF_NOT_OPEN    EQU     00000010b       ; ISR got interrupt but port not open
  791. PIF_INSTALLED   EQU     00000100b       ; Pecan already set up
  792. PIF_PECAN_BUSY  EQU     00001000b       ; Pecan busy doing something, don't bother
  793. PIF_DMA_READ    EQU     00010000b
  794. PIF_RESET_MASK  EQU     00100000b
  795. PIF_ONE_HAS_IRQ EQU     01000000b       ; Enhanced port is registered for IRQ
  796. PIF_INT_NESTED  EQU     10000000b       ; ESP is processing nested interrupt
  797.  
  798. ;**     Flags values
  799. F_SHUT_DOWN     EQU     00000001b       ; driver shut down due to internal err
  800. F_ESP_CODE_LOCKED       EQU     00000010b
  801. F_LOCK_CONTIGUOUS       EQU     00000100b
  802.  
  803. DEV_IDC            EQU  0100000000000000b
  804. INSTALL_CMD        EQU  001h
  805. DEINSTALL_CMD      EQU  000h
  806.  
  807. ;****   Generic Alert Flag values   ************************************
  808. FGA_WRITE_TO_CTS   EQU  0000000000000001b  ; flag write TO event causes
  809. FGA_WRITE_TO_DSR   EQU  0000000000000010b
  810. FGA_WRITE_TO_DCD   EQU  0000000000000100b
  811. FGA_WRITE_TO_XOFF  EQU  0000000000001000b
  812. FGA_RESERVED       EQU  1111111111110000b  ; reserved GA flags
  813.  
  814. GAS_FLAG_MAX    EQU     8               ; max bit value of allowed GAS flags
  815.  
  816. ;**     Valid baud range and default
  817. ;
  818. MINBAUD         EQU     2
  819. MAX_SBAUD       EQU     57600
  820. MAX_EBAUD       EQU     57600
  821. DEFAULT_BAUD    EQU     1200
  822.  
  823. ;**     Hardware clock speed
  824. ;
  825. ; clock = 115200 = 1C200h
  826. ;
  827. CLOCK_RATEHI    EQU     1               ; MSW of clock rate
  828. CLOCK_RATELO    EQU     0C200h          ; LSW of clock rate
  829. ; The bit rate must be within +-.01% of the requested rate.
  830. ; so the maximum allowable remainder is 11 (11/115200 = .000095)
  831. MAXREM          EQU     11
  832.  
  833.  
  834.  ;**    I/O queue structure
  835. ;
  836. IO_Queue        STRUC
  837.         ioq_phys        DB      SIZE PhysAddr DUP (?)
  838.         ioq_page        DW      (?)
  839.         ioq_base        DW      (?)
  840.         ioq_end         DW      (?)
  841.         ioq_in          DW      (?)
  842.         ioq_out         DW      (?)
  843.         ioq_count       DW      (?)
  844. IO_Queue        ENDS
  845.  
  846. Com1Minor       EQU     0
  847. Com2Minor       EQU     1
  848. Com3Minor       EQU     2
  849. Com4Minor       EQU     3
  850.  
  851. ;**     8250,16450,16550A Serial I/O Chip Port Equates
  852. ;
  853.  
  854. ;**     Port addresses
  855. ;
  856. R_DATA          EQU     0               ; RX/TX data
  857. R_BAUDL         EQU     R_DATA          ; low byte baud rate divisor
  858. R_BAUDH         EQU     R_DATA+1        ; high byte baud rate divisor
  859. R_INTEN         EQU     1               ; interrupt enable
  860. R_INTID         EQU     2               ; interrupt identification (read only)
  861. R_FIFOC         EQU     2               ; FIFO control (write only)
  862. R_LINEC         EQU     3               ; line control
  863. R_MODMC         EQU     4               ; modem control
  864. R_LINES         EQU     5               ; line status
  865. R_MODMS         EQU     6               ; modem status
  866. R_SCRATCH       EQU     7               ; scratch register
  867.  
  868. ;**     Interrupt enable masks
  869. ;
  870. IE_RX           EQU     00000001b       ; read data available
  871. IE_TX           EQU     00000010b       ; transmit buffer empty
  872. IE_LX           EQU     00000100b       ; line status change
  873. IE_MX           EQU     00001000b       ; modem status change
  874.  
  875. ;**     Interrupt identification masks (read only)
  876. ;
  877. ;       NOTE: The values used for II_*X are encoded so that they
  878. ;       can be used as an index to a jump table. They are not used
  879. ;       directly but there values are relevant.
  880. ;
  881. II_NONE         EQU     00000001b       ; no interrupts pending
  882. II_MASK         EQU     00000110b       ; mask of bits for table jump
  883. II_MX           EQU     00000000b       ; modem status interrupt pending
  884. II_TX           EQU     00000010b       ; TX interrupt pending
  885. II_RX           EQU     00000100b       ; RX interrupt pending
  886. II_LX           EQU     00000110b       ; line status interrupt pending
  887. II_RX_TO        EQU     00001000b       ; RX FIFO timeout
  888.  
  889. II_RESERVED     EQU     00110000b       ; reserved
  890.  
  891. II_16550A       EQU     11000000b       ; 16550A indentifier
  892.  
  893. ;**     FIFO Control masks (write only)
  894. ;
  895. FF_ENABLE       EQU     00000001b       ; enable FIFO (both rx and tx)
  896. FF_CLEAR_RX     EQU     00000010b       ; clear RX FIFO
  897. FF_CLEAR_TX     EQU     00000100b       ; clear TX FIFO
  898. FF_DMA          EQU     00001000b       ; DMA
  899. FF_RESERVED     EQU     00110000b       ; RESERVED
  900. FF_RX_MASK      EQU     11000000b       ; RX FIFO trigger level mask
  901. FF_RX_1         EQU     00000000b       ; RX FIFO trigger level 1
  902. FF_RX_4         EQU     01000000b       ; RX FIFO trigger level 4
  903. FF_RX_8         EQU     10000000b       ; RX FIFO trigger level 8
  904. FF_RX_14        EQU     11000000b       ; RX FIFO trigger level 14
  905.  
  906. ;**     Line control masks
  907. ;
  908. LC_BMASK        EQU     00000011b       ; data bits mask
  909. LC_BITS5        EQU     00000000b       ; 5 data bits
  910. LC_BITS6        EQU     00000001b       ; 6 data bits
  911. LC_BITS7        EQU     00000010b       ; 7 data bits
  912. LC_BITS8        EQU     00000011b       ; 8 data bits
  913.  
  914. LC_SMASK        EQU     00000100b       ; stop bits mask
  915. LC_STOP1        EQU     00000000b       ; 1 stop bit
  916. LC_STOP2        EQU     00000100b       ; 2 stop bits (1.5 if 5 data bits)
  917.  
  918. LC_PMASK        EQU     00111000b       ; parity mask
  919. LC_PNONE        EQU     00000000b       ; none parity
  920. LC_PODD         EQU     00001000b       ; odd parity
  921. LC_PEVEN        EQU     00011000b       ; even parity
  922. LC_PMARK        EQU     00101000b       ; mark parity
  923. LC_PSPACE       EQU     00111000b       ; space parity
  924.  
  925. LC_BREAK        EQU     01000000b       ; transmit break
  926. LC_DLAB         EQU     10000000b       ; divisor latch access bit
  927. LC_MASK         EQU     01111111b       ; documented line control register bits
  928.  
  929. ;**     Values for parity
  930. ;
  931. NO_PARITY       EQU     0
  932. ODD_PARITY      EQU     1
  933. EVEN_PARITY     EQU     2
  934. MARK_PARITY     EQU     3
  935. SPACE_PARITY    EQU     4
  936. DEFAULT_PARITY  EQU     EVEN_PARITY
  937.  
  938. ;**     Values for stop bits
  939. ;
  940. ONE_STOP_BIT            EQU     0
  941. ONE_5_STOP_BITS         EQU     1
  942. TWO_STOP_BITS           EQU     2
  943. DEFAULT_STOPBITS        EQU     ONE_STOP_BIT
  944.  
  945. ;**     Values for byte sizes
  946. ;
  947. CHAR_5_MASK             EQU     00011111b
  948. CHAR_6_MASK             EQU     00111111b
  949. CHAR_7_MASK             EQU     01111111b
  950. CHAR_8_MASK             EQU     11111111b
  951. DEFAULT_CHAR_MASK       EQU     CHAR_7_MASK
  952. DEFAULT_BYTESIZE        EQU     7
  953.  
  954. ;**     Modem control register masks
  955. ;
  956. MC_DTR          EQU     00000001b       ; data terminal ready
  957. MC_RTS          EQU     00000010b       ; request to send
  958. MC_OUT1         EQU     00000100b       ; output 1
  959. MC_OUT2         EQU     00001000b       ; output 2
  960. MC_LOOP         EQU     00010000b       ; loopback mode
  961.  
  962. ;**     Line status register masks
  963. ;
  964. LS_DR           EQU     00000001b       ; data ready
  965. LS_OERR         EQU     00000010b       ; overrun error
  966. LS_PERR         EQU     00000100b       ; parity error
  967. LS_FERR         EQU     00001000b       ; framing error
  968. LS_BI           EQU     00010000b       ; break interrupt
  969. LS_THRE         EQU     00100000b       ; TX holding register empty
  970. LS_TSRE         EQU     01000000b       ; TX shift register empty
  971.  
  972. ;**     Modem status register definitions:
  973. ;
  974. MS_DCTS         EQU     00000001b       ; delta clear to send
  975. MS_DDSR         EQU     00000010b       ; delta data set ready
  976. MS_TERI         EQU     00000100b       ; trailing edge of ring indicator
  977. MS_DDCD         EQU     00001000b       ; delta receiver line signal detect
  978. MS_CTS          EQU     00010000b       ; clear to send
  979. MS_DSR          EQU     00100000b       ; data set ready
  980. MS_RI           EQU     01000000b       ; ring indicator
  981. MS_DCD          EQU     10000000b       ; receiver line signal detect
  982. MS_DELTAS       EQU     00001111b       ; deltas, not current values
  983.  
  984. .errnz FX_IN_DSR_OK - MS_DSR
  985.  
  986. COM_SEG         EQU     40h             ; ROM data segment for COM ports
  987. COM1_PORT       EQU     3f8h            ; port for COM1
  988. COM1_VEC        EQU     4               ; IRQ for COM1
  989. COM2_PORT       EQU     2f8h            ; port for COM2
  990. COM2_VEC        EQU     3               ; IRQ for COM2
  991.  
  992. DEVICE_ID       EQU     6               ; ABIOS device ID number (to get LID)
  993.  
  994. BAD_MAX         EQU     1000            ; Maximum number of     interrupt
  995.                                         ; that can be tolarated
  996. DEINSTALL       EQU     0000h           ; Deinstall the driver if     int
  997. POST_ERROR      EQU     0001h           ; Post error if     int
  998. IGNORE_ERROR    EQU     0002h           ; Ignore error even if     int
  999. AF_RTNLIDPARMS  EQU     01h     ; Return LID Parameter
  1000. AF_READDEVPARMS EQU     03h     ; Read Device Parameters
  1001. DEVICE_ID       EQU     06h     ; Device ID Number
  1002. DEVICE_UNIT     EQU     00h     ; Device Unit Number
  1003. RB_LEN          EQU     20h     ; Length of Request Block
  1004. CANCEL_ALL_INTS EQU     0EFh            ; Cancel flag for CANCEL fcn
  1005. FF_FIFO_SUPPORT EQU     00001000b       ; fifo supported and device present
  1006. F_FLAG          EQU     0FFFFh          ; ffffh flag
  1007. RC_COMPLETE     EQU     0000h           ; Operation Completed Successfully
  1008. PCMCIA_SYSTEM   EQU     01h             ; PCMCIA System
  1009. PCMCIA_TEMP_AD1 EQU     0FFF0h          ; ffffh flag
  1010. PCMCIA_TEMP_AD2 EQU     0FFF1h          ; ffffh flag
  1011. PCMCIA_TEMP_AD3 EQU     0FFF2h          ; ffffh flag
  1012. PCMCIA_TEMP_AD4 EQU     0FFF3h          ; ffffh flag
  1013.  
  1014. Open_Command    EQU     0Dh     ; command code for open strategy routine
  1015. Close_Command   EQU     0Eh     ; command code for close strategy routine
  1016. IOCTL_Command   EQU     10h     ; command code for IOCTL strategy routine
  1017. req_header      equ     13      ; size of a request block header
  1018. NULL            EQU     0
  1019.  
  1020. PORT_STANDARD   EQU     0
  1021. PORT_ENHANCED   EQU     1
  1022.  
  1023. parms   STRUC
  1024. cmd_code        db      ?
  1025. num_writes      db      ?
  1026. num_reads       db      ?
  1027. writes          db      5 DUP (?)
  1028. reads           db      2 DUP (?)
  1029. parms   ENDS
  1030.  
  1031. ;**     COM information structure
  1032. ;
  1033. ;       ComInfo contains all of the information pertaining
  1034. ;       to a single port.
  1035. ;
  1036. ; Initial values for flags:
  1037. ;
  1038. F1_INIT         EQU     F1_DTR_ENABLE
  1039. F2_INIT         EQU     F2_RTS_ENABLE
  1040. F3_INIT         EQU     F3_READ_TO_NORM
  1041.  
  1042. WRITE_TO_INIT   EQU     6000            ; 60 seconds
  1043. READ_TO_INIT    EQU     6000            ; 60 seconds
  1044.  
  1045. SPACE           EQU     20H
  1046. NULL            EQU     00H
  1047. ESPSIG          EQU     0AAh                 ; ESP adapter signature
  1048.  
  1049. ComInfo STRUC
  1050. ;**      start of device control block info
  1051. ;
  1052. ; WARNING: this must at the top of the ComInfo structure.
  1053. ; WARNING: this must match the DCB structure exactly.
  1054.  
  1055.         ci_dcb_writeto  DW      WRITE_TO_INIT   ; write timeout
  1056.         ci_dcb_readto   DW      READ_TO_INIT    ; read  timeout
  1057.         ci_dcb_flags1   DB      F1_INIT         ; first  flags byte
  1058.         ci_dcb_flags2   DB      F2_INIT         ; second flags byte
  1059.         ci_dcb_flags3   DB      F3_INIT         ; third  flags byte
  1060.         ci_dcb_ErrChar  DB      0               ; error replacement char
  1061.         ci_dcb_BrkChar  DB      0               ; break replacement char
  1062.         ci_dcb_XonChar  DB      xonequ          ; XON  character
  1063.         ci_dcb_XoffChar DB      xoffequ         ; XOFF character
  1064.  
  1065. ; end of device control block info
  1066.  
  1067.         ci_ier          DB      0               ; word align rest of struc
  1068.  
  1069.         ci_signature    DW      SIGNATURE       ; signature ID word
  1070.         ci_port         DW      0               ; I/O port, 0 if non-existant
  1071.         ci_baud         DW      DEFAULT_BAUD    ; baud rate
  1072.  
  1073.         ci_linec        DB      0               ; line control
  1074.         ci_bytesize     DB      DEFAULT_BYTESIZE; TX/RX byte size
  1075.         ci_parity       DB      DEFAULT_PARITY  ; parity
  1076.         ci_stopbits     DB      DEFAULT_STOPBITS; stop bits
  1077.         ci_cmask        DB      DEFAULT_CHAR_MASK ; received character mask
  1078.         ci_tximm        DB      0               ; transmit immediate character
  1079.  
  1080.         ci_irq          DB      0               ; interrupt number
  1081.         ci_depth        DB      D_NONE          ; interrupt depth
  1082.         ci_isr          DW      (?)             ; interrupt service routine
  1083.         ci_visr         DW      (?)             ; vdm interrupt service routine
  1084.         ci_badmax       DW      BAD_MAX         ;     interrupt maximum
  1085.  
  1086.         ci_nopens       DW      0               ; number of outstanding opens
  1087.         ci_nvdmopens    DW      0               ; number of outstanding vdm opens CP20D1390
  1088.         ci_oci_sem      DD      0               ; open/close/ioctl exclusion sem
  1089.         ci_oci_sem_own  DD      0               ; oci_sem owner RP address
  1090.         ci_comerr       DW      0               ; I/O error
  1091.         ci_event        DW      0               ; event flags
  1092.  
  1093.         ci_GDTSelRead   DW      0               ; GDT selectors for the user buffer
  1094.         ci_GDTSelWrite  DW      0               ; for use in the interrupt routines
  1095.  
  1096.         ci_hAdapter     DD      0
  1097.         ci_hLDev        DD      0
  1098.         ci_hSysName     DD      0
  1099.  
  1100.         ci_flagx        DB      0               ; extra flags
  1101.         ci_flagx1       DB      0               ; extra flags
  1102.         ci_hsflag       DB      0               ; handshake flag
  1103.         ci_hhslines     DB      0               ; DTR/RTS bits for handshaking
  1104.         ci_outhhslines  DB      0               ; output handshake lines
  1105.  
  1106.         ci_lsrshadow    DB      0               ; line  status register shadow
  1107.         ci_msrshadow    DB      0               ; modem status register shadow
  1108.         ci_port_number  DB      0               ; VDM port number of this CIDA
  1109.         ci_LID          DW      0               ; to remember LID on PS/2s
  1110.         ci_flagGA       DW      0               ; Log Facility Alert conditons
  1111.                                                 ; read request packet list
  1112.         ci_r_rpl        DD      0               ; head
  1113.                         DD      0               ; tail
  1114.                         DW      SIGNATURE
  1115.  
  1116.                                                 ; write request packet list
  1117.         ci_w_rpl        DD      0               ; head
  1118.                         DD      0               ; tail
  1119.                         DW      SIGNATURE
  1120.  
  1121.         ci_r_rp         DD      0               ; current read request
  1122.         ci_w_rp         DD      0               ; current write request
  1123.         ci_r_to_move    DW      0               ; bytes to move to satisfy r_rp
  1124.         ci_w_to_move    DW      0               ; bytes to move to satisfy w_rp
  1125.  
  1126.         ci_r_to         DW      0               ; r_rp time out
  1127.         ci_w_to         DW      0               ; w_rp time out
  1128.         ci_r_to_start   DW      0               ; r_rp time out start value
  1129.         ci_w_to_start   DW      0               ; w_rp time out start value
  1130.  
  1131.         ci_vdm_flag     DB     0                ;VDM information flag
  1132.                                                 ;VDM BIT 0 - InUse by VDM
  1133.                                                 ;VDM BIT 1 - notify the VCOM Rx
  1134.                                                 ;VDM BIT 2 - notify the VCOM Tx
  1135.                                                 ;VDM BIT 3 - Blocked IOCTL
  1136.                                                 ;VDM BIT 4-7 RESERVED, set to 0
  1137.  
  1138.         ci_vdm_Rx_State DB     0                ;VDM BIT 0&1 - Rx_State
  1139.                                                 ;VDM BIT 2-7 RESERVED, set to 0
  1140.  
  1141.         ci_vdm_Tx_State DB     0                ;VDM BIT 0&1 - Tx_State
  1142.                                                 ;VDM BIT 2-7 RESERVED, set to 0
  1143.  
  1144.         ci_vdm_Rx_Count DB     0                ;VDM count of chars put in Tx
  1145.                                                 ;VDM Queue since XOFF given to
  1146.                                                 ;VDM DOS APP
  1147.  
  1148.         ci_vdm_Tx_Count DB     0                ;VDM count of chars put in Rx
  1149.                                                 ;VDM Queue since XOFF sent to
  1150.                                                 ;VDM device
  1151.  
  1152.         ci_vdm_LastMSR  DB     0                ;VDM last MSR given to DOS App
  1153.         ci_vdm_LastLSR  DB     0                ;VDM LSR to give to DOS app
  1154.  
  1155.         ci_dummy3       DB     0                ;mw put on word boundaries
  1156.  
  1157.         ci_qin          DB      SIZE IO_Queue dup (?)
  1158.         ci_qin_q        DB      QI_SIZE_EVEN dup (0)
  1159.  
  1160.         ci_qout         DB      SIZE IO_Queue dup (?)
  1161.         ci_qout_q       DB      QO_SIZE_EVEN dup (0)
  1162.  
  1163.         ci_fifobaud     DW     0                ;mw store baud latch values
  1164.  
  1165.         ci_sid          DW     0                ;VDM App's Session ID CP20D1390
  1166.  
  1167.         ci_vdm_OpenError DW    0                ;VDM Type of error to return to
  1168.                                                 ;VDM VCOM from Open
  1169.  
  1170.         ci_vdm_Blocked_IOCTL DD    0            ;VDM IOCTL/Tx Queue
  1171.                                                 ;VDM serialization mechanism
  1172.  
  1173.                                                 ;VDM IOCTL request packet
  1174.         ci_req_pack      DB      size IOCTLPacket dup (0)
  1175.  
  1176.         ci_qstat         DB      QI_SIZE dup (0)  ;VDM LSRQ
  1177.         ci_int_sharing   DB      0               ;supports int. sharing
  1178.         ci_int_data      DW      0               ;offset of SharedIntData
  1179.         ci_next_COM      DW      0               ;ComInfo of next COM on
  1180.                                                 ; this IRQ line
  1181.         ci_mult_COMs_IRQ DB     0               ;other COM ports are on
  1182.                                                 ; this IRQ line
  1183.  
  1184.  
  1185.         ci_eflags       DB      0
  1186.  
  1187.         dummy           DB      0
  1188.         ci_rx_request   DB      DMA_REQ_AUTO
  1189.         ci_tx_request   DB      DMA_REQ_AUTO
  1190.         ;*************************************************************@PVW
  1191.         ;************                                     ************@PVW
  1192.         ;******          Perfview Data Block                    ******@PVW
  1193.         ;**************                                   ************@PVW                 ;@PVW
  1194. ifdef PERFVIEW
  1195.         ci_Data_Block   DB      SIZE pvdbh_s dup (0)
  1196.         ci_Read_Time    dd      0                                    ;@PVW
  1197.                         dd      0                                    ;@PVW
  1198.         ci_Write_Time   dd      0                                    ;@PVW
  1199.                         dd      0                                    ;@PVW
  1200.         ci_Num_Reads    dd      0                                    ;@PVW
  1201.         ci_Read_Bytes   dd      0                                    ;@PVW
  1202.         ci_Num_Writes   dd      0                                    ;@PVW
  1203.         ci_Write_Bytes  dd      0                                    ;@PVW
  1204.         ci_HW_Overruns  dd      0                                    ;@PVW
  1205.         ci_SW_Overruns  dd      0            ;@PVW last item!!! used at init
  1206.                                              ;@PVW time to find data_block len
  1207.  
  1208.         ;************                                     ************@PVW
  1209.         ;*******  If Adding Counters or Timers then see the     ******@PVW
  1210.         ;*******  Number_Tmrs_Ctrs EQU. And change Procedure    ******@PVW
  1211.         ;*******  Initialize_PerfView_Data to reference last    ******@PVW
  1212.         ;*******  data item                                     ******@PVW
  1213.         ;*************************************************************@PVW                 ;@PVW
  1214. endif ; PERFVIEW
  1215. ComInfo ENDS
  1216.  
  1217. SharedIntData struc
  1218.         si_entry        dw      0               ; offset of IRQ handler
  1219.         si_count        db      0               ; number of COM ports on this IRQ
  1220.         si_irq          db      0               ; IRQ line
  1221.         si_opens        db      0               ; number of open COMs on this IRQ
  1222.         si_firstCOM     dw      0               ; ptr. to ComInfo struc
  1223. SharedIntData ENDS
  1224.  
  1225.  
  1226. ;----------------------------------------------------------------------------
  1227. ;                     ABIOS Request Block   structure
  1228. ;----------------------------------------------------------------------------
  1229. RequestBlock struc
  1230.  
  1231.   RBLength        dw      0    ; 00H Length of Request Block
  1232.   LogicalID       dw      0    ; 02H Addr of Logical ID
  1233.   Unit_ab         dw      0    ; 04H Device Unit Value
  1234.   Function_ab     dw      0    ; 06H Function Value
  1235.   RBFlags         dw      0    ; 08H ABIOS to ABIOS Call
  1236.                   dw      0    ; 0AH Reserved area
  1237.   ReturnCode      dw      0    ; 0CH Return Code
  1238.   TimeOut_ab      dw      0    ; 0EH Time to wait in seconds
  1239.   IntLev          dw      0    ; 10H INT Level/ARB Level
  1240.                   dw      0    ; 12H Transmit Buffer Offset
  1241.                   dw      0    ; 14H Transmit Buffer Segment
  1242.   AddOpStat       dw      0    ; 16H Additional Open Status
  1243.   Enhanced_18H    dw      0    ; 18H Enhance Function control
  1244.                   db      0    ; 1AH Comp char match 1
  1245.                   db      0    ; 1BH Comp char function 1
  1246.   EnhArbLev       db      0    ; 1CH Comp char match 2
  1247.                   db      0    ; 1DH Comp char function 2
  1248.                   db      0    ; 1EH Comp char match 3
  1249.                   db      0    ; 1FH Comp char function 3
  1250.                   dw      0    ; 20H Reserved Area 20H
  1251.                                ; 
  1252.                   dw      0    ; 22H Receive Buffer Offset
  1253.                   dw      0    ; 24H Receive BUffer Segment
  1254.                   dw      0    ; 26H Reserved Area
  1255.                                ; 
  1256.   AsyncByte_1     db      0    ; 28H General Data Area Byte 1
  1257.   AsyncByte_2     db      0    ; 29H General Data Area Byte 2
  1258.   AsyncByte_3     db      0    ; 2AH General Data Area Byte 3
  1259.   AsyncByte_4     db      0    ; 2BH General Data Area Byte 4
  1260.                                ; 
  1261.                   dw      0    ; 2CH
  1262.                   dw      0    ; 2EH
  1263.                   dw      0    ; 30H
  1264.                   dw      0    ; 32H
  1265.                   dw      0    ; 34H
  1266.                   dw      0    ; 36H
  1267.                   dw      0    ; 38H
  1268.                   dw      0    ; 3AH
  1269.                   dw      0    ; 3CH
  1270.                   dw      0    ; 3EH
  1271.   BinBaudRate     dd      0    ; 40H Binary baud rate
  1272.                                ;(if Byte44=0FFH )
  1273.   BaudRate        db      0    ; 44H Baud Rate
  1274.   Parity          db      0    ; 45H Parity Bit
  1275.   StopBits        db      0    ; 46H Stop Bits
  1276.   WordLength      db      0    ; 47H Word Length
  1277.   BreakI          db      0    ; 48H Break Indicator
  1278.   LineStatus      db      0    ; 49H Line Status Register
  1279.   ModemStatus     db      0    ; 4AH Modem Status Register
  1280.                                ; 
  1281.   ReturnStat      dw      0    ; 4BH Return Status
  1282.   SaveStat        dw      0    ; 4DH Return Status for
  1283.                                ;     previous operation
  1284.                                ;     when attention interrupt
  1285.                   dw      0    ; 4FH Return Code for
  1286.                                ;     previous operation
  1287.                                ;     when attent interrupt
  1288.   CancelFlag      db      0    ; 51H flag for CANCEL ABIOS
  1289.                   dw      20 dup(?) ; Work Area
  1290.  
  1291. RequestBlock      ends
  1292.  
  1293.  
  1294. DCB_SIZE        EQU     ci_dcb_XoffChar-ci_dcb_writeto+1
  1295. SELECTOR_MASK   EQU     0FFF8h
  1296.  
  1297. LocINFOseg      EQU     2     ;Local Info Seg value for Dev_Hlp CP20D1390
  1298.  
  1299. .errnz ci_dcb_writeto
  1300. .errnz ci_dcb_XoffChar-10
  1301.  
  1302. .errnz rpl_head
  1303. .errnz rpl_tail-4
  1304. .errnz rpl_signature-8
  1305.  
  1306.  
  1307. ESPInfo STRUC
  1308.         pi_address      DW      0
  1309.         pi_DMA_chan     DB      0
  1310.         pi_irq          DB      0
  1311.         pi_isr          DW      0
  1312.         pi_sid          db      0
  1313.         pi_rrindex      db      0
  1314.         pi_svcmask      db      0
  1315.        pi_flagx        DB      0
  1316.        pi_port1        DW      -1
  1317.        pi_port2        DW      -1
  1318.        pi_DMA_outstanding DW      0
  1319.        pi_xfer_count   DW      0
  1320.        pi_depth        DB      D_NONE          ; interrupt depth
  1321. ESPInfo ENDS
  1322.  
  1323.  
  1324.  
  1325. pvw_HW_Overrun  MACRO                               ;@PVW
  1326.       LOCAL   exit                                  ;@PVW
  1327. .386
  1328.       test    ds:[si].ci_Data_Block.dbh_flFlags,RPC_FL_CONFIG ;@PVW PERFVIEW ACTIVE?
  1329.       jz      exit                                  ;@PVW NO, EXIT
  1330.       inc     ds:[si].ci_HW_Overruns                ;@PVW inc perfview cntr
  1331. exit:                                               ;@PVW
  1332. .286C                                               ;@PVW
  1333.       ENDM ;pvw_HW_Overrun                          ;@PVW
  1334.  
  1335. pvw_SW_Overrun  MACRO                               ;@PVW
  1336.       LOCAL   exit                                  ;@PVW
  1337. .386
  1338.       test    ds:[si].ci_Data_Block.dbh_flFlags,RPC_FL_CONFIG ;@PVW PERFVIEW ACTIVE?
  1339.       jz      exit                                  ;@PVW NO, EXIT
  1340.       inc     ds:[si].ci_SW_Overruns                ;@PVW inc perfview cntr
  1341. exit:                                               ;@PVW
  1342. .286C                                               ;@PVW
  1343.       ENDM ;pvw_SW_Overrun                          ;@PVW
  1344.  
  1345.  
  1346. pvw_Read  MACRO   STARTSTOP,CNTRFLAG
  1347.         LOCAL   exit
  1348. .386
  1349.        IFB     <STARTSTOP>                          ;@PVW Flag Blank
  1350.            %out Error: Not enough parameters in macro pvw_Read
  1351.            .err                                     ;@PVW error
  1352.        ENDIF
  1353.        test    ds:[si].ci_Data_Block.dbh_flFlags,RPC_FL_CONFIG ;@PVW Active?
  1354.        jz      exit                                 ;@PVW no, Exit
  1355.        pusha
  1356.        push    DS                                   ;@PVW Push Seg of timer
  1357.        lea     dx, ds:[si].ci_Read_Time            ;@PVW Push Off of timer
  1358.        push    dx                                   ;@PVW
  1359.        inc     ds:[si].ci_Data_Block.dbh_ulSem      ;@PVW Indicate timer update
  1360.        IFIDN   <STARTSTOP>,<START>                  ;@PVW Req to start timer?
  1361.           call  ds:[si].ci_Data_Block.dbh_pfnTmrSub ;@PVW call add Routine
  1362.        ELSEIFIDN <STARTSTOP>,<STOP>                 ;@PVW Req to stop timer?
  1363.           call  ds:[si].ci_Data_Block.dbh_pfnTmrAdd ;@PVW call stop routine
  1364.           IFIDN <CNTRFLAG>,<DOCOUNTERS>             ;@PVW strategy entry?
  1365.              xor   edx,edx                          ;@PVW clear edx
  1366.              mov   dx,es:[di].IOCount               ;@PVW get bytes read
  1367.              add   ds:[si].ci_Read_Bytes,edx        ;@PVW add bytes to total
  1368.              inc   ds:[si].ci_Num_Reads             ;@PVW inc number of reads
  1369.           ELSEIFIDN <CNTRFLAG>,<VDMCOUNTERS>        ;@PVW VCOM entry
  1370.              inc   ds:[si].ci_Read_Bytes            ;@PVW inc bytes read
  1371.              inc   ds:[si].ci_Num_Reads             ;@PVW inc number of reads
  1372.           ELSEIFNB <CNTRFLAG>                       ;@PVW     parameter
  1373.              %out Error: Bad parameter in macro pvw_Read
  1374.              .err                                   ;@PVW error
  1375.           ENDIF                                     ;@PVW
  1376.        ELSE                                         ;@PVW oops
  1377.           %out Error: Bad parameter in macro pvw_Read
  1378.           .err                                      ;@PVW error
  1379.        ENDIF                                        ;@PVW
  1380.        dec     ds:[si].ci_Data_Block.dbh_ulSem      ;@PVW indicate update done
  1381.        popa
  1382. exit:                                               ;@PVW
  1383. .286C                                               ;@PVW
  1384.         ENDM ;pvw_Read                              ;@PVW
  1385.  
  1386.  
  1387. pvw_Write MACRO   STARTSTOP,CNTRFLAG
  1388.         LOCAL   exit
  1389. .386
  1390.        IFB     <STARTSTOP>                          ;@PVW Flag Blank
  1391.            %out Error: Not enough parameters in macro pvw_Write
  1392.            .err                                     ;@PVW error
  1393.        ENDIF
  1394.        test    ds:[si].ci_Data_Block.dbh_flFlags,RPC_FL_CONFIG ;@PVW Active?
  1395.        jz      exit                                 ;@PVW no, Exit
  1396.        pusha                                        ;@PVW save register we use
  1397.        push    DS                                   ;@PVW Push Seg of timer
  1398.        lea     dx, ds:[si].ci_Write_Time            ;@PVW Push Off of timer
  1399.        push    dx                                   ;@PVW
  1400.        inc     ds:[si].ci_Data_Block.dbh_ulSem      ;@PVW Indicate timer update
  1401.        IFIDN   <STARTSTOP>,<START>                  ;@PVW Req to start timer?
  1402.           call  ds:[si].ci_Data_Block.dbh_pfnTmrSub ;@PVW call add Routine
  1403.        ELSEIFIDN <STARTSTOP>,<STOP>                 ;@PVW Req to stop timer?
  1404.           call  ds:[si].ci_Data_Block.dbh_pfnTmrAdd ;@PVW call stop routine
  1405.           IFIDN <CNTRFLAG>,<DOCOUNTERS>             ;@PVW
  1406.              xor   edx,edx                          ;@PVW clear edx
  1407.              mov   dx,es:[di].IOCount               ;@PVW get bytes written
  1408.              add   ds:[si].ci_Write_Bytes,edx       ;@PVW add bytes to total
  1409.              inc   ds:[si].ci_Num_Writes            ;@PVW inc number of writes
  1410.           ELSEIFIDN <CNTRFLAG>,<VDMCOUNTERS>        ;@PVW
  1411.              inc   ds:[si].ci_Write_Bytes           ;@PVW inc bytes written
  1412.              inc   ds:[si].ci_Num_Writes            ;@PVW inc number of writes
  1413.           ELSEIFNB <CNTRFLAG>                       ;@PVW     parameter
  1414.              %out Error: Bad parameter in macro pvw_Write
  1415.              .err                                   ;@PVW error
  1416.           ENDIF                                     ;@PVW
  1417.        ELSE                                         ;@PVW oops
  1418.           %out Error: Bad parameter in macro pvw_Write
  1419.           .err                                      ;@PVW error
  1420.        ENDIF                                        ;@PVW
  1421.        dec     ds:[si].ci_Data_Block.dbh_ulSem      ;@PVW indicate update done
  1422.        popa                                         ;@PVW restore scratch reg
  1423. exit:                                               ;@PVW
  1424. .286C                                               ;@PVW
  1425.         ENDM ;pvw_Write                             ;@PVW
  1426.  
  1427.  
  1428. ;/*------------------------------------------*/
  1429. ;/*  Error codes for FailFree                */
  1430. ;/*------------------------------------------*/
  1431.  
  1432. FFF_INITEVERY     EQU   1
  1433. FFF_ABIOSLID      EQU   2
  1434. FFF_EISACONFIG    EQU   3
  1435. FFF_ISAMCACONFIG  EQU   4
  1436. FFF_GETPORTS      EQU   5
  1437. FFF_CHECKIRQ      EQU   6
  1438. FFF_GETGDT        EQU   7
  1439. FFF_ASSIGNIRQ     EQU   8
  1440.