home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / PEN / PENTKT / PENBASE / GIO.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  31KB  |  961 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  4. ;
  5. ;    The following IBM OS/2 WARP source code is provided to you solely for
  6. ;    the purpose of assisting you in your development of OS/2 WARP device
  7. ;    drivers. You may use this code in accordance with the IBM License
  8. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  9. ;    Copyright statement may not be removed.;
  10. ;*****************************************************************************/
  11. ;      /*****************************************************************/
  12. ;      /*                                                               */
  13. ;      /*                                                               */
  14. ;      /*****************************************************************/
  15. ;      /******************* START OF SPECIFICATIONS *********************/
  16. ;      /*                                                               */
  17. ;      /*  SOURCE FILE NAME: GIO.ASM                                    */
  18. ;      /*                                                               */
  19. ;      /*  DESCRIPTIVE NAME: Generic IOCTL handler                      */
  20. ;      /*                                                               */
  21. ;      /*                                                               */
  22. ;      /*  STATUS:  Version 1.0                                         */
  23. ;      /*                                                               */
  24. ;      /*  NOTES: This module provides routines to service the          */
  25. ;      /*         architected pen IOCTLs. Device dependent IOCTLs       */
  26. ;      /*         are serviced in the device dependent routine.         */
  27. ;      /*                                                               */
  28. ;      /*         A routine can be subclassed, or replaced, by replacing*/
  29. ;      /*         the routine address in the IOCTL branch table.        */
  30. ;      /*                                                               */
  31. ;      /*  ENTRY POINTS:                                                */
  32. ;      /*      See public statements                                    */
  33. ;      /*  EXTERNAL REFERENCES:                                         */
  34. ;      /*      See extrn statements                                     */
  35. ;      /*                                                               */
  36. ;      /******************* END  OF  SPECIFICATIONS *********************/
  37. public Gio_UnPanic,Gio_Panic  ; must occur before emi.inc
  38. public Gio_CallAll
  39. public Gio_CallUnit
  40. public Gio_CallType
  41. .xlist
  42.   include pensegs.inc
  43.   include pen.inc
  44.   include penei.inc
  45.   include penioctl.inc
  46.   include devsym.inc
  47.   include struc.inc
  48. .list
  49.  
  50. .286p
  51.  
  52. ;------------------------------------------------------------------------------
  53. ; external routines
  54. ;------------------------------------------------------------------------------
  55.  
  56. extrn Gio_rtb  : near
  57. extrn Gio_qtts : near
  58. extrn Gio_qtt  : near
  59. extrn Gio_stts : near
  60. extrn But_CalcCaps : near
  61. extrn Idc_UpdateCaps : near
  62. extrn Loc_qlrc       : near
  63. extrn Dsp_SetInactPeriod : near
  64. extrn Dsp_SDS    : near
  65. extrn Dev_IOCTL_rtn  : near
  66.  
  67. ;------------------------------------------------------------------------------
  68. ; external data
  69. ;------------------------------------------------------------------------------
  70.  
  71. extrn RegCaps0 : byte
  72. extrn DDPanic  : dword
  73.  
  74. ;------------------------------------------------------------------------------
  75. ; local data
  76. ;------------------------------------------------------------------------------
  77.  
  78. ERROR_BAD_COMMAND equ 08003h
  79. ERROR_BAD_UNIT    equ 08001h
  80. ERROR_BAD_PARM    equ 08013h
  81.  
  82. DSEG segment
  83.  
  84. public DCB_Anchor
  85. DCB_Anchor    dw 0 ; anchor for dcb list
  86. dataPack      dd 0
  87. paraPack      dd 0
  88.  
  89. FIND_UNIT  equ 01h        ; load DCB before calling
  90. CHECK_TYPE equ 02h        ; check the type before calling
  91. PASS_PARM  equ 04h        ; pass parm packet in fs:di
  92. PASS_DATA  equ 08h        ; pass parm packet in gs:si
  93.  
  94. ; Category table
  95. public ioctl_table,tbl_W_Driver,tbl_R_Driver,tbl_W_Locator,tbl_R_Locator
  96.  
  97.               dw    (ioctl_tableE-ioctl_table)/4 ;category count
  98. ioctl_table   dw    tbl_W_Driver  ; category 90h writes
  99.               dw    tbl_R_Driver  ; category 90h reads
  100.               dw    tbl_W_Locator ; category 91h writes
  101.               dw    tbl_R_Locator ; category 91h reads
  102.               dw    tbl_W_Button  ; category 92h writes
  103.               dw    tbl_R_Button  ; category 92h reads
  104.               dw    tbl_W_Display ; category 93h writes
  105.               dw    tbl_R_Display ; category 93h reads
  106. ioctl_tableE  label byte
  107.  
  108. ; Driver IOCTLs - Category 90h
  109.  
  110.               dw     (tbl_W_DriverE-tbl_W_Driver)/2 ;function count
  111. tbl_W_Driver  dw     Gio_susd     ; 50h Set Unit Specific Data
  112.               db     0            ; no type
  113.               db     FIND_UNIT+PASS_PARM+PASS_DATA
  114.  
  115.               dw     Gio_suv      ; 51h Set Unit Variable
  116.               db     0            ; no type
  117.               db     FIND_UNIT+PASS_PARM
  118.  
  119.               dw     Gio_rtb      ; 52h Reset Trace Buffer
  120.               db     0            ; no type
  121.               db     0            ; 
  122.  
  123.               dw     Gio_stts     ; 53h Set Trace Table Size
  124.               db     0            ; no type
  125.               db     PASS_PARM    ; 
  126. tbl_W_DriverE label  byte
  127.  
  128.               dw     (tbl_R_DriverE-tbl_R_Driver)/2 ;function count
  129. tbl_R_Driver  dw     Gio_qusd     ; 60H Query Unit Specific Data
  130.               db     0            ; no type
  131.               db     FIND_UNIT+PASS_PARM+PASS_DATA
  132.  
  133.               dw     Gio_quv      ; 61H Query Unit Variable
  134.               db     0            ; no type
  135.               db     FIND_UNIT+PASS_PARM
  136.  
  137.               dw     Gio_quc      ; 62H Query Unit Capabilities
  138.               db     0            ; no type
  139.               db     FIND_UNIT+PASS_PARM+PASS_DATA
  140.  
  141.               dw     Gio_qtt      ; 63H Query Trace Table
  142.               db     0            ; no type
  143.               db     PASS_PARM+PASS_DATA
  144.  
  145.               dw     Gio_qtts     ; 64H Query Trace Table Size
  146.               db     0            ; no type
  147.               db     PASS_DATA
  148. tbl_R_DriverE label  byte
  149.  
  150. ; LocatorIOCTLs - Category 91h
  151.  
  152.               dw     (tbl_W_LocatorE-tbl_W_locator)/2 ;function count
  153. tbl_W_Locator dw     Gio_slo      ; 50h Set Locator Offset
  154.               db     DT_LOCATOR
  155.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM
  156.  
  157.               dw     Gio_slpr     ; 51h Set Locator Pass Rate
  158.               db     DT_LOCATOR
  159.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM
  160.  
  161.               dw     Gio_slsr     ; 52h Set Locator Sample Rate
  162.               db     DT_LOCATOR
  163.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM
  164.  
  165. tbl_W_LocatorE label  byte
  166.  
  167.               dw     (tbl_R_LocatorE-tbl_R_Locator)/2 ;function count
  168. tbl_R_Locator dw     Gio_qlv      ; 60H Query Locator Variables
  169.               db     DT_LOCATOR
  170.               db     FIND_UNIT+CHECK_TYPE+PASS_DATA
  171.  
  172.               dw     Gio_qlrc     ; 61H Query Locator Raw Coordinate
  173.               db     DT_LOCATOR
  174.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM+PASS_DATA
  175.  
  176.               dw     Gio_qdle      ; 62H Query Default Locator Extents
  177.               db     DT_LOCATOR    ; no type
  178.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM+PASS_DATA
  179. tbl_R_LocatorE label  byte
  180.  
  181. ; Button IOCTLs - Category 92h
  182.  
  183.               dw     (tbl_W_ButtonE-tbl_W_Button)/2 ;function count
  184. tbl_W_Button  dw     Gio_sba      ; 50h Set Button Assignment
  185.               db     DT_BUTTON
  186.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM
  187.  
  188. tbl_W_ButtonE label  byte
  189.  
  190.               dw     (tbl_R_ButtonE-tbl_R_Button)/2 ;function count
  191. tbl_R_Button  dw     Gio_qba      ; 60H Query Button Assignment
  192.               db     DT_BUTTON
  193.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM+PASS_DATA
  194. tbl_R_ButtonE label  byte
  195.  
  196. ; Display IOCTLs - Category 93h
  197.  
  198.               dw     (tbl_W_DisplayE-tbl_W_Display)/2 ;function count
  199. tbl_W_Display dw     Gio_sds      ; 50h Set Display State
  200.               db     DT_DISPLAY
  201.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM
  202.  
  203.               dw     Gio_sdip     ; 51h Set Display Inactivity Period
  204.               db     DT_DISPLAY
  205.               db     FIND_UNIT+CHECK_TYPE+PASS_PARM
  206. tbl_W_DisplayE label  byte
  207.  
  208.               dw     (tbl_R_DisplayE-tbl_R_Display)/2 ;function count
  209. tbl_R_Display dw     Gio_qds      ; 60H Query Display State
  210.               db     DT_DISPLAY
  211.               db     FIND_UNIT+CHECK_TYPE+PASS_DATA
  212. tbl_R_DisplayE label  byte
  213.  
  214. DSEG ends
  215.  
  216. CSEG SEGMENT
  217.      ASSUME    CS:CSEG, SS:nothing, ES:nothing, DS:DGROUP
  218.  
  219. ;---- OS/2 GENERIC IO ENTRY POINT ---------------------------------------------
  220. ; Handle OS/2 generic IOCTL commands
  221. ;  es:bx = request packet
  222. ;------------------------------------------------------------------------------
  223. public GIO_Entry
  224. GIO_Entry    PROC  NEAR
  225.   push  es
  226.   push  bx
  227.  
  228.   mov   ah, PEN_CAT_DRIVER         ; calculate the last category defined
  229.   add   ah, byte ptr ioctl_table-2 ; (actually one more than)
  230.  
  231.   mov   al, byte ptr es:[bx].GIOCategory
  232.   .if <al b  PEN_CAT_DRIVER> OR      ; its not a defined IOCTL category
  233.   .if <al ae ah>
  234.      call Dev_IOCTL_rtn
  235.   .else near
  236.      xor   ah, ah
  237.      and   al, 0fh
  238.      mov   si, ax
  239.      sal   si, 2
  240.  
  241.      mov   ah, byte ptr es:[bx].GIOFunction
  242.      and   ah, 70h
  243.      .if   <ah ne 50h> AND
  244.      .if   <ah ne 60h>
  245.         mov  ax,ERROR_BAD_COMMAND
  246.      .else  near
  247.         .if <ah eq 60h> ; use read table
  248.            add si, 2
  249.         .endif
  250.         mov  si,[si].ioctl_table    ; get function table
  251.         add  ah, byte ptr [si-2] ; calculate one past highest function
  252.         mov  al, byte ptr es:[bx].GIOFunction
  253.         .if <al ae ah>
  254.            mov   ax, ERROR_BAD_COMMAND
  255.         .else
  256.            and   al, 0Fh
  257.            sal   al, 2
  258.            xor   ah,ah
  259.            add   si,ax
  260.            .386p
  261.            mov   ecx, es:[bx].GIOParaPack  ; get parms
  262.            mov   paraPack,ecx
  263.            mov   ecx, es:[bx].GIODataPack  ; get data
  264.            mov   dataPack,ecx
  265.            mov   dx,[si]          ; get routine to call
  266.            .if   <bit <byte ptr [si+3]> nz FIND_UNIT>
  267.               lfs  di, es:[bx].GIOParaPack  ; get parms
  268.               mov  al, byte ptr fs:[di]     ; get unit number
  269.               mov  bx, DCB_Anchor
  270.               .repeat
  271.                  .if <al eq [bx].dcb_Unit>
  272.                     jmp  short gio_n1
  273.                     clc
  274.                     ret
  275.                  .endif
  276.                  mov  bx, [bx].dcb_Link
  277.               .until <zero bx>
  278.               mov   ax, ERROR_BAD_UNIT
  279.               jmp   gio_exit
  280. gio_n1:
  281.               .if   <bit <byte ptr [si+3]> nz CHECK_TYPE>
  282.                  mov  al,[bx].dcb_DevType
  283.                  .if <al ne [si+2]>
  284.                     mov   ax, ERROR_BAD_UNIT
  285.                     jmp   short gio_exit
  286.                  .endif
  287.               .endif
  288.            .endif
  289.            .if   <bit <byte ptr [si+3]> nz PASS_PARM>
  290.               lfs di,paraPack
  291.            .endif
  292.            .if   <bit <byte ptr [si+3]> nz PASS_DATA>
  293.               lgs si,dataPack
  294.            .endif
  295.            call  dx
  296.            .286p
  297.         .endif
  298.      .endif
  299.   .endif
  300. gio_exit:
  301.   pop   bx
  302.   pop   es
  303.   mov   es:[bx].PktStatus, ax
  304.   ret                              ; Return to Request Handler Rtn.
  305. GIO_Entry ENDP
  306.  
  307. ;---- DRIVER ROUTINES----------------------------------------------------------
  308. ;
  309. ;------------------------------------------------------------------------------
  310.  
  311. ;---- OS/2 GENERIC IO ENTRY POINT ---------------------------------------------
  312. ; Handle OS/2 generic IOCTL commands
  313. ;   fs:di parm packet if requested
  314. ;   gs:si data packet if requested
  315. ;------------------------------------------------------------------------------
  316.  
  317. .386p
  318.  
  319. ;------------------------------------------------------------------------------
  320. ; 50h Set Unit Specific Data
  321. ;   fs:di parm packet
  322. ;   gs:si data packet
  323. ;------------------------------------------------------------------------------
  324. public Gio_susd
  325. Gio_susd proc
  326.   .if <[bx].dcb_DevType eq DT_LOCATOR> AND
  327.   .if <bit [bx].dcb_Xtrans.trn_flags nz STANDARD_USD> AND
  328.   .if <bit [bx].dcb_Ytrans.trn_flags nz STANDARD_USD>
  329.      mov   cx, word ptr fs:[di].pqusd_byteCount
  330.      .if   <cx ge <size SLUSD>>
  331.  
  332.         .if <<word ptr gs:[si].slusd_XmeasuredExtent> eq 0> OR
  333.         .if <<word ptr gs:[si].slusd_YmeasuredExtent> eq 0>
  334.            mov  ax,ERROR_BAD_PARM
  335.            ret
  336.         .endif
  337.  
  338.         mov  eax, dword ptr gs:[si].slusd_Xorigin
  339.         mov  [bx].dcb_Xtrans.trn_org_adj,  eax                  ; doragh
  340.         mov  [bx].dcb_Xtrans.trn_org_calibrated, eax            ; doragh
  341.                                                                 ; doragh
  342.         mov  eax, dword ptr gs:[si].slusd_XmeasuredExtent       ; doragh
  343.         mov  [bx].dcb_Xtrans.trn_ext_adj, eax                   ; doragh
  344.         mov  [bx].dcb_Xtrans.trn_ext_adj_calibrated, eax        ; doragh
  345.                                                                 ; doragh
  346.         mov  eax, dword ptr gs:[si].slusd_Yorigin               ; doragh
  347.         mov  [bx].dcb_Ytrans.trn_org_adj, eax                   ; doragh
  348.         mov  [bx].dcb_Ytrans.trn_org_calibrated, eax            ; doragh
  349.                                                                 ; doragh
  350.         mov  eax, dword ptr gs:[si].slusd_YmeasuredExtent       ; doragh
  351.         mov  [bx].dcb_Ytrans.trn_ext_adj, eax                   ; doragh
  352.         mov  [bx].dcb_Ytrans.trn_ext_adj_calibrated, eax        ; doragh
  353.      .endif
  354.   .endif
  355.   push  gs
  356.   pop   es
  357.   mov   di,si
  358.   CALL_NZ_OK [bx].dcb_@Dev_susd ; Set Unit Specific Data IOCTL rtn
  359.                              ; cx = target byte size
  360.                              ; es:di = target area
  361.   ret
  362. Gio_susd endp
  363.  
  364. ;------------------------------------------------------------------------------
  365. ; 51h Set Unit Variable
  366. ;   fs:di parm packet
  367. ;------------------------------------------------------------------------------
  368. public Gio_suv
  369. Gio_suv proc
  370.   mov  al, byte ptr fs:[di].psuv_index
  371.   mov  si, [bx].dcb_@UVars
  372.   .if <nonzero si>,AND
  373.   .if <al lt <byte ptr [si].uv_numVars>
  374.      push ax
  375.      inc  ax ; skip arrary size
  376.      sal  ax,2
  377.      add  si,ax
  378.      pop  ax
  379.      mov  edx, fs:[di].psuv_value
  380.      CALL_NZ_OK [bx].dcb_@Dev_suv  ; routine can change value before saving
  381.      mov  [si], edx
  382.   .else
  383.      mov  ax, ERROR_BAD_PARM
  384.   .endif
  385.   ret
  386. Gio_suv endp
  387.  
  388. ;------------------------------------------------------------------------------
  389. ; 60H Query Unit Specific Data
  390. ;   fs:di parm packet
  391. ;   gs:si data packet
  392. ;------------------------------------------------------------------------------
  393. public Gio_qusd
  394. Gio_qusd proc
  395.   .if <[bx].dcb_DevType eq DT_LOCATOR> AND NEAR
  396.   .if <bit [bx].dcb_Xtrans.trn_flags nz STANDARD_USD> AND NEAR
  397.   .if <bit [bx].dcb_Ytrans.trn_flags nz STANDARD_USD> NEAR
  398.      mov   cx, word ptr fs:[di].pqusd_byteCount
  399.      .if   <cx ge <size SLUSD>>
  400.         mov  gs:[si].slusd_length,size SLUSD
  401.  
  402.         mov  eax, [bx].dcb_Xtrans.trn_org_default
  403.         mov  gs:[si].slusd_XoriginDefault,eax
  404.  
  405.         mov  eax, [bx].dcb_Xtrans.trn_org_calibrated     ; doragh
  406.         mov  gs:[si].slusd_Xorigin,eax
  407.  
  408.         mov  eax, [bx].dcb_Xtrans.trn_ext_adj_calibrated ; doragh
  409.         mov  gs:[si].slusd_XmeasuredExtent,eax
  410.  
  411.         mov  eax, [bx].dcb_Ytrans.trn_org_default
  412.         mov  gs:[si].slusd_YoriginDefault,eax
  413.  
  414.         mov  eax, [bx].dcb_Ytrans.trn_org_calibrated     ; doragh
  415.         mov  gs:[si].slusd_Yorigin,eax
  416.  
  417.         mov  eax, [bx].dcb_Ytrans.trn_ext_adj_calibrated ; doragh
  418.         mov  gs:[si].slusd_YmeasuredExtent,eax
  419.  
  420.         mov  gs:[di].slusd_length,size SLUSD
  421.         mov  fs:[di].pqusd_RetByteCount,size SLUSD
  422.         mov  fs:[di].pqusd_rc,QUSD_OK
  423.      .elseif   <cx ge 4>
  424.         mov  gs:[di].slusd_length,size SLUSD
  425.         mov  fs:[di].pqusd_RetByteCount,4
  426.         mov  fs:[di].pqusd_rc,QUSD_TRUNC
  427.      .else
  428.         mov  fs:[di].pqusd_RetByteCount,0
  429.         mov  fs:[di].pqusd_rc,QUSD_TRUNC
  430.      .endif
  431.      mov  eax,QUSD_LENGTH+QUSD_STANDARD
  432.      .if  <bit [bx].dcb_Xtrans.trn_flags nz INVERTED_COORD>
  433.         or eax,QUSD_X_INVERT
  434.      .endif
  435.      .if  <bit [bx].dcb_Ytrans.trn_flags nz INVERTED_COORD>
  436.         or eax,QUSD_Y_INVERT
  437.      .endif
  438.      mov  fs:[di].pqusd_Capabilities,eax
  439.   .endif
  440.  
  441. ; The device dependent QUSD routine can overwrite the RetByteCount,Capabilities,
  442. ; and rc field in the parm packet
  443.  
  444.   CALL_NZ_OK [bx].dcb_@Dev_qusd ; Query Unit Specific Data IOCTL rtn
  445.                              ; cx = target byte size
  446.                              ; gs:si = data packet
  447.                              ; fs:di = parm packet
  448.   ret
  449. Gio_qusd endp
  450.  
  451. ;------------------------------------------------------------------------------
  452. ; 61H Query Unit Variable
  453. ;   fs:di parm packet
  454. ;   gs:si data packet
  455. ;------------------------------------------------------------------------------
  456. public Gio_quv
  457. Gio_quv proc
  458.   mov  al, byte ptr fs:[di].pquv_index
  459.   mov  si, [bx].dcb_@UVars
  460.   .if <nonzero si>,AND
  461.   .if <al lt <byte ptr [si].uv_numVars>
  462.      push ax
  463.      inc  ax ; skip array size
  464.      sal  ax,2
  465.      add  si,ax
  466.      mov  edx, [si]
  467.      pop  ax
  468.      push si
  469.      CALL_NZ_OK [bx].dcb_@Dev_quv   ; let him change it
  470.      pop  si
  471.      mov  [si],edx
  472.      lfs  di, dataPack
  473.      mov  fs:[di].dquv_value, edx
  474.   .else
  475.      mov  ax, ERROR_BAD_PARM
  476.   .endif
  477.   ret
  478. Gio_quv endp
  479.  
  480. ;------------------------------------------------------------------------------
  481. ; 62H Query Unit Capabilites
  482. ;   fs:di parm packet
  483. ;   gs:si data packet
  484. ;------------------------------------------------------------------------------
  485. public Gio_quc
  486. Gio_quc proc
  487.  
  488.   push si            ; save destination address
  489.  
  490.   mov  fs:[di].pquc_rc,QUSD_OK
  491.   mov  si, [bx].dcb_@RegCaps ; get capibility packet
  492.   xor  ecx, ecx
  493.   mov  cx, [si]
  494.   .if  <fs:[di].pquc_byteCount lt ecx>
  495.      mov  fs:[di].pquc_rc,QUSD_TRUNC
  496.      mov  ecx,fs:[di].pquc_byteCount
  497.   .endif
  498.   mov  fs:[di].pquc_RetByteCount,ecx
  499.  
  500.   push gs            ; set up for movsb
  501.   pop  es
  502.   pop  di            ; restore destination into destination movsb reg
  503.  
  504.   rep  movsb         ; move it
  505.   xor  ax,ax
  506.   ret
  507. Gio_quc endp
  508.  
  509.  
  510. ;---- LOCATOR IOCTLs ----------------------------------------------------------
  511. ;
  512. ;------------------------------------------------------------------------------
  513.  
  514. ;------------------------------------------------------------------------------
  515. ; 50h Set Locator Offset
  516. ;   fs:di parm packet
  517. ;------------------------------------------------------------------------------
  518. public Gio_slo
  519. Gio_slo proc
  520.   .if <bit fs:[di].pslo_command nz PSLO_SET_X>
  521.      mov ax,word ptr fs:[di].pslo_xOffset
  522.      mov [bx].dcb_Xtrans.trn_offset,ax
  523.   .endif
  524.   .if <bit fs:[di].pslo_command nz PSLO_SET_Y>
  525.      mov ax,word ptr fs:[di].pslo_yOffset
  526.      mov [bx].dcb_Ytrans.trn_offset,ax
  527.   .endif
  528.   xor ax,ax
  529.   ret
  530. Gio_slo endp
  531.  
  532. ;------------------------------------------------------------------------------
  533. ; 51h Set Locator Pass Rate
  534. ;   fs:di parm packet
  535. ;------------------------------------------------------------------------------
  536. public Gio_slpr
  537. Gio_slpr proc
  538.   mov si, [bx].dcb_@RegCaps
  539.   mov al,byte ptr fs:[di].pslpr_passRate
  540.   mov [si].lcap_pass_rate,al
  541.   call IDC_UpdateCaps                ; update caps
  542.   xor ax,ax
  543.   ret
  544. Gio_slpr endp
  545.  
  546. ;------------------------------------------------------------------------------
  547. ; 52h Set Locator Sample Rate
  548. ;   fs:di parm packet
  549. ;------------------------------------------------------------------------------
  550. public Gio_slsr
  551. Gio_slsr proc
  552.   mov si, [bx].dcb_@RegCaps
  553.   mov ax,word ptr fs:[di].pslsr_sampleRate
  554.   .if <zero ax>
  555.      mov ax,[si].lcap_max_sample_rate
  556.   .endif
  557.   mov [si].lcap_sample_rate,ax
  558.   CALL_NZ_OK [bx].dcb_@slsr             ; change rate device
  559.   .if <zero ax>
  560.      call IDC_UpdateCaps                ; update caps
  561.   .endif
  562.   ret
  563. Gio_slsr endp
  564.  
  565. ;------------------------------------------------------------------------------
  566. ; 60H Query Locator Variables
  567. ;   fs:di parm packet
  568. ;   gs:si data packet
  569. ;------------------------------------------------------------------------------
  570. public Gio_qlv
  571. Gio_qlv proc
  572.   mov ax, [bx].dcb_Xtrans.trn_offset
  573.   cwde
  574.   mov gs:[si].dqlv_xOffset,eax
  575.  
  576.   mov ax, [bx].dcb_Ytrans.trn_offset
  577.   cwde
  578.   mov gs:[si].dqlv_yOffset,eax
  579.  
  580.   mov di, [bx].dcb_@RegCaps
  581.   mov ax, [di].lcap_sample_rate
  582.   cwde
  583.   mov gs:[si].dqlv_sampleRate,eax
  584.  
  585.   mov al, [di].lcap_pass_rate
  586.   cbw
  587.   cwde
  588.   mov gs:[si].dqlv_passRate,eax
  589.   xor ax,ax
  590.   ret
  591. Gio_qlv endp
  592.  
  593. ;------------------------------------------------------------------------------
  594. ; 61H Query Locator Raw Coordinate
  595. ;   fs:di parm packet
  596. ;   gs:si data packet
  597. ;------------------------------------------------------------------------------
  598. public Gio_qlrc
  599. Gio_qlrc proc
  600.   mov  edx,fs:[di].pqlrc_timeout
  601.   push gs
  602.   push si
  603.   call Loc_qlrc
  604.   pop  si
  605.   pop  gs
  606.   mov  gs:[si].dqlrc_xRaw,ecx
  607.   mov  gs:[si].dqlrc_yRaw,edx
  608.   mov  gs:[si].dqlrc_rc,eax
  609.  
  610.   xor ax,ax
  611.   ret
  612. Gio_qlrc endp
  613.  
  614. ;------------------------------------------------------------------------------
  615. ; 62H Query Default Locator Extents
  616. ;   fs:di parm packet
  617. ;   gs:si data packet
  618. ;------------------------------------------------------------------------------
  619. public Gio_qdle
  620. Gio_qdle proc
  621.    mov  gs:[si].dqdle_rc, QDLE_FAIL
  622.   .if <bit [bx].dcb_Xtrans.trn_flags nz STANDARD_USD> AND NEAR
  623.   .if <bit [bx].dcb_Ytrans.trn_flags nz STANDARD_USD> NEAR
  624.       mov  eax, [bx].dcb_Xtrans.trn_ext_adj_default
  625.       mov  gs:[si].dqdle_Xdefault,eax
  626.  
  627.       mov  eax, [bx].dcb_Ytrans.trn_ext_adj_default
  628.       mov  gs:[si].dqdle_Ydefault,eax
  629.  
  630.       mov  gs:[si].dqdle_rc, QDLE_OK
  631.   .endif
  632.   ret
  633. Gio_qdle endp
  634. ;---- BUTTON  IOCTLs ----------------------------------------------------------
  635. ;
  636. ;------------------------------------------------------------------------------
  637.  
  638. ;------------------------------------------------------------------------------
  639. ; 50h Set Button Assignment
  640. ;   fs:di parm packet
  641. ;------------------------------------------------------------------------------
  642. public Gio_sba
  643. Gio_sba proc
  644.   mov cx,word ptr fs:[di].psba_buttonIndex
  645.   mov si,[bx].dcb_NumButDefs
  646.   dec si
  647.   .if <cx le si>   ; in range of defined buttons
  648.      mov  ax, 1                            ; make a mask of the index
  649.      shl  ax, cl
  650.      mov  dx, ax
  651.  
  652.      mov  cl,byte ptr fs:[di].psba_action  ; make a mask of the action
  653.      mov  ax, 1
  654.      shl  ax, cl
  655.  
  656. ; see if this assignment is legal for this type of button
  657.  
  658.      mov  si,[bx].dcb_@regCaps
  659.  
  660.      .if <bit [si].bcap_typeMask nz dx >   ; check by button type
  661.         and ax, [si].bcap_barrel           ; check barrel capabilities
  662.      .else
  663.         and ax, [si].bcap_nonbarrel        ; check non-barrel capabilities
  664.      .endif
  665.      jz short sba_error
  666.  
  667. ; its OK, go ahead and assign it
  668.  
  669.      mov  ax,word ptr fs:[di].psba_buttonIndex
  670.      sal  ax,BUT_DEF_SIZE_SHIFT
  671.      mov  si,[bx].dcb_@ButDefArray
  672.      add  si,ax
  673.      mov  al,byte ptr fs:[di].psba_action
  674.      mov  [si].but_action,al
  675.      mov  al,byte ptr fs:[di].psba_value
  676.      mov  [si].but_value,al
  677.      call But_CalcCaps                  ; re-calc the capability packet
  678.      call IDC_UpdateCaps                ; update caps
  679.      xor  ax,ax
  680.   .else
  681. sba_error:
  682.      mov  ax, ERROR_BAD_PARM
  683.   .endif
  684.   ret
  685. Gio_sba endp
  686.  
  687. ;------------------------------------------------------------------------------
  688. ; 60H Query Button Assignment
  689. ;   fs:di parm packet
  690. ;   gs:si data packet
  691. ;------------------------------------------------------------------------------
  692. public Gio_qba
  693. Gio_qba proc
  694.   mov ax,word ptr fs:[di].psba_buttonIndex
  695.   mov cx,[bx].dcb_NumButDefs
  696.   dec cx
  697.   .if <ax le cx>
  698.      sal  ax,BUT_DEF_SIZE_SHIFT
  699.      mov  di,[bx].dcb_@ButDefArray
  700.      add  di,ax
  701.      xor  eax,eax
  702.      mov  al,[di].but_action
  703.      mov  gs:[si].dqba_action,eax
  704.      mov  al,[di].but_value
  705.      mov  gs:[si].dqba_value,eax
  706.      xor  ax,ax
  707.   .else
  708.      mov  ax, ERROR_BAD_PARM
  709.   .endif
  710.   ret
  711. Gio_qba endp
  712.  
  713. ;---- DISPLAY IOCTLs ----------------------------------------------------------
  714. ;
  715. ;------------------------------------------------------------------------------
  716.  
  717. ;------------------------------------------------------------------------------
  718. ; 50h Set Display State
  719. ;   fs:di parm packet
  720. ;------------------------------------------------------------------------------
  721. public Gio_sds
  722. Gio_sds proc
  723.   mov  al, byte ptr fs:[di].psds_command
  724.   call Dsp_SDS
  725.   xor  ax,ax
  726.   ret
  727. Gio_sds endp
  728.  
  729. ;------------------------------------------------------------------------------
  730. ; 51h Set Display Inactivity Period (and automatic processing options)
  731. ;   fs:di parm packet
  732. ;------------------------------------------------------------------------------
  733. public Gio_sdip
  734. Gio_sdip proc
  735.   mov  ax, word ptr fs:[di].psdip_command
  736.  
  737. ; update opaque option
  738.  
  739.  .if  <bit al nz SDIP_EN_OPAQUE>
  740.     or  [bx].dcb_DspFlags,DSP_OPAQUE
  741.  .endif
  742.  .if  <bit al nz SDIP_DI_OPAQUE>
  743.     and [bx].dcb_DspFlags,not DSP_OPAQUE
  744.  .endif
  745.  
  746. ; only allow the following if capabilities permit
  747.  
  748.   mov  si, [bx].dcb_@RegCaps
  749.   .if  <bit [si].dcap_auto_flag nz 1>
  750.  
  751. ;    change the period
  752.  
  753.      .if  <bit ax nz SDIP_PERIOD>
  754.         mov  edx, fs:[di].psdip_period
  755.         mov  [bx].dcb_inactPeriod,edx
  756.      .endif
  757.  
  758. ;    set auto on/off option
  759.  
  760.      .if  <bit al nz SDIP_EN_AUTO>
  761.         or  [bx].dcb_DspFlags,DSP_AUTO_ENABLED
  762.      .endif
  763.      .if  <bit al nz SDIP_DI_AUTO>
  764.         and [bx].dcb_DspFlags,not DSP_AUTO_ENABLED
  765.      .endif
  766.  
  767. ;    set suppress option
  768.  
  769.      .if  <bit ax nz SDIP_EN_SUPPRESS>
  770.         or  [bx].dcb_DspFlags,DSP_SUPPRESS
  771.      .endif
  772.      .if  <bit ax nz SDIP_DI_SUPPRESS>
  773.         and [bx].dcb_DspFlags,not DSP_SUPPRESS
  774.      .endif
  775.  
  776. ;    update state of display engine
  777.  
  778.      call Dsp_SetInactPeriod
  779.  
  780.   .endif
  781.   xor  ax,ax
  782.   ret
  783. Gio_sdip endp
  784.  
  785. ;------------------------------------------------------------------------------
  786. ; 60H Query Display State
  787. ;   fs:di parm packet
  788. ;   gs:si data packet
  789. ;------------------------------------------------------------------------------
  790. public Gio_qds
  791. Gio_qds proc
  792.   xor eax, eax
  793.   .if <bit [bx].dcb_DspFlags nz DSP_STATE_ON>
  794.      mov al, 1
  795.   .endif
  796.   mov gs:[si].dqds_state,eax
  797.  
  798.   xor eax, eax
  799.   mov dx,[bx].dcb_DspFlags
  800.   .if  <bit dx nz DSP_OPAQUE>
  801.      or  ax,SDIP_EN_OPAQUE
  802.   .else
  803.      or  ax,SDIP_DI_OPAQUE
  804.   .endif
  805.   .if <bit dx nz DSP_AUTO_ENABLED>
  806.      or  ax,SDIP_EN_AUTO
  807.   .else
  808.      or  ax,SDIP_DI_AUTO
  809.   .endif
  810.   .if <bit dx nz DSP_SUPPRESS>
  811.      or  ax,SDIP_EN_SUPPRESS
  812.   .else
  813.      or  ax,SDIP_DI_SUPPRESS
  814.   .endif
  815.   mov gs:[si].dqds_automatic,eax
  816.  
  817.   mov eax,[bx].dcb_InactPeriod
  818.   mov gs:[si].dqds_period,eax
  819.  
  820.   xor ax,ax
  821.   ret
  822. Gio_qds endp
  823.  
  824. .286p
  825.  
  826. ;---- MISC   ROUTINES----------------------------------------------------------
  827. ;
  828. ;------------------------------------------------------------------------------
  829.  
  830. ;------------------------------------------------------------------------------
  831. ; panic routine
  832. ; al = panic value
  833. ;------------------------------------------------------------------------------
  834. public GIO_Panic
  835. GIO_Panic proc
  836.   .if <al eq <byte ptr DDPanic>> OR
  837.   .if <al eq <byte ptr DDPanic+1>> OR
  838.   .if <al eq <byte ptr DDPanic+2>> OR
  839.   .if <al eq <byte ptr DDPanic+3>>
  840.      stc
  841.      ret
  842.   .endif
  843.   .if <<byte ptr DDPanic> eq 0>
  844.     mov  byte ptr DDPanic,al
  845.   .elseif <<byte ptr DDPanic+1> eq 0>
  846.     mov  byte ptr DDPanic+1,al
  847.   .elseif <<byte ptr DDPanic+2> eq 0>
  848.     mov  byte ptr DDPanic+2,al
  849.   .elseif <<byte ptr DDPanic+3> eq 0>
  850.     mov  byte ptr DDPanic+3,al
  851.   .endif
  852.   stc
  853.   ret
  854. GIO_Panic endp
  855.  
  856. ;------------------------------------------------------------------------------
  857. ; unpanic routine
  858. ; al = panic value
  859. ;------------------------------------------------------------------------------
  860. public GIO_UnPanic
  861. GIO_UnPanic proc
  862.   .if <<byte ptr DDPanic> eq al>
  863.     mov  byte ptr DDPanic,0
  864.   .elseif <<byte ptr DDPanic+1> eq al>
  865.     mov  byte ptr DDPanic+1,0
  866.   .elseif <<byte ptr DDPanic+2> eq al>
  867.     mov  byte ptr DDPanic+2,0
  868.   .elseif <<byte ptr DDPanic+3> eq al>
  869.     mov  byte ptr DDPanic+3,0
  870.   .endif
  871.   ret
  872. GIO_UnPanic endp
  873.  
  874. ;------------------------------------------------------------------------------
  875. ; Add a dcb to the dcb list and assign unit number
  876. ;  bx = DCB
  877. ;------------------------------------------------------------------------------
  878. public Gio_AddDCB
  879. Gio_AddDCB proc
  880.   mov  si, bx                   ; link DCB
  881.   xchg si, DCB_Anchor
  882.   mov  [bx].dcb_Link,si
  883.  
  884.   mov  al, RegCaps0.ddcap_unitCount     ; assign unit number
  885.   mov  [bx].dcb_Unit,al
  886.   inc  RegCaps0.ddcap_unitCount
  887.   ret
  888. Gio_AddDCB endp
  889.  
  890. ;------------------------------------------------------------------------------
  891. ; Do a passed routine for each DCB on the list
  892. ;  si = routine to call
  893. ; exit
  894. ;  bx = DCB passed to routine that returned NC
  895. ;     = 0 if all routines returned C
  896. ;  NC = a routine returned NC and search stopped
  897. ;  CY = all routines returned CY
  898. ;------------------------------------------------------------------------------
  899. Gio_CallAll  proc
  900.   mov  bx, DCB_Anchor
  901.   .repeat
  902.      push  bx
  903.      call  si
  904.      pop   bx
  905.      .leave nc
  906.      mov  bx, [bx].dcb_Link
  907.   .until <zero bx>
  908.   ret
  909. Gio_CallAll  endp
  910.  
  911. ;------------------------------------------------------------------------------
  912. ; Do a passed routine for each DCB on the list of the requested type
  913. ;  ax = DCB type
  914. ;  si = routine to call
  915. ; exit
  916. ;  nothing
  917. ;------------------------------------------------------------------------------
  918. Gio_CallType proc
  919.   mov  bx, DCB_Anchor
  920.   .repeat
  921.      .if <al eq [bx].dcb_DevType>
  922.         push  ax
  923.         push  bx
  924.         push  si
  925.         call  si
  926.         pop   si
  927.         pop   bx
  928.         pop   ax
  929.      .endif
  930.      mov  bx, [bx].dcb_Link
  931.   .until <zero bx>
  932.   ret
  933. Gio_CallType endp
  934.  
  935. ;------------------------------------------------------------------------------
  936. ; call the dcb by unit number
  937. ;  al = unit
  938. ;  si = rtn to call
  939. ; exit
  940. ;  bx = DCB & NC for success
  941. ;     = DCB & CY for error return
  942. ;     = 0 if not found & CY set
  943. ;------------------------------------------------------------------------------
  944. Gio_CallUnit proc
  945.   mov  bx, DCB_Anchor
  946.   .repeat
  947.      .if <al eq [bx].dcb_Unit>
  948.         call  si
  949.         clc
  950.         ret
  951.      .endif
  952.      mov  bx, [bx].dcb_Link
  953.   .until <zero bx>
  954.   stc
  955.   ret
  956. Gio_CallUnit endp
  957.  
  958. CSEG ends
  959.  
  960. end
  961.