home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / PEN / PENTKT / PENBASE / IDC.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  14KB  |  404 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: IDC.ASM                                    */
  18. ;      /*                                                               */
  19. ;      /*  DESCRIPTIVE NAME: Inter-driver communication routines        */
  20. ;      /*                                                               */
  21. ;      /*                                                               */
  22. ;      /*  STATUS:  Version 1.0                                         */
  23. ;      /*                                                               */
  24. ;      /*  NOTES: IDC routines are provided. The entry point that the   */
  25. ;      /*         pen device driver services calls, as defined by the   */
  26. ;      /*         Devhlp_RegisterDeviceClass, is defined here. The      */
  27. ;      /*         IDC entry point in the device header is available     */
  28. ;      /*         for device dependent use.                             */
  29. ;      /*                                                               */
  30. ;      /*         The configuration and binding protocol is implemented */
  31. ;      /*         here.                                                 */
  32. ;      /*                                                               */
  33. ;      /*         Routines to call the device driver services are       */
  34. ;      /*         provided here.                                        */
  35. ;      /*                                                               */
  36. ;      /*  ENTRY POINTS:                                                */
  37. ;      /*      See public statements                                    */
  38. ;      /*  EXTERNAL REFERENCES:                                         */
  39. ;      /*      See extrn statements                                     */
  40. ;      /*                                                               */
  41. ;      /******************* END  OF  SPECIFICATIONS *********************/
  42. .xlist
  43.   include pensegs.inc
  44.   include pen.inc
  45.   include penidc.inc
  46.   include penei.inc
  47.   include struc.inc
  48. .list
  49.  
  50. .286p
  51.  
  52. ;------------------------------------------------------------------------------
  53. ;  external data references
  54. ;------------------------------------------------------------------------------
  55.  
  56. extrn Device_Help  : dword
  57. extrn dcb0         : byte
  58. extrn RegCaps0     : byte
  59.  
  60. ;------------------------------------------------------------------------------
  61. ;  external routines
  62. ;------------------------------------------------------------------------------
  63.  
  64. extrn Vmc_ReadEnable  : near
  65.  
  66. ;------------------------------------------------------------------------------
  67. ; local data declarations
  68. ;------------------------------------------------------------------------------
  69.  
  70. DSEG segment
  71.  
  72. DevStatus     db     0                 ; idc controls
  73.  
  74. ; bits for DevStatus
  75. RPTENABLED    equ    0001h    ; reporting is enabled
  76. DEVICEENABLED equ    0002h    ; events are enabled
  77.  
  78. ; Inter Driver Communication table for driver entry point
  79. public pen_idc
  80. pen_idc       dw     Idc_invalid         ; by unit commands
  81.               dw     Idc_QueryCaps       ; 1
  82.               dw     Idc_QueryDevConfig  ; 2
  83.               dw     Idc_StartDevice     ; 3
  84.               dw     Idc_invalid         ; 4
  85.               dw     Idc_invalid         ; 5
  86. PENBYUNIT     equ    ($-pen_idc)/2
  87.  
  88.               dw     Idc_ReadEnable      ; 6
  89.               dw     Idc_ReadDisable     ; 7
  90.               dw     Idc_EnableDevice    ; 8
  91.               dw     Idc_DisableDevice   ; 9
  92.               dw     Idc_ActCallBack     ; 10
  93.               dw     Idc_VMChange        ; 11
  94. PENIDCMAX     equ    ($-pen_idc)/2
  95.  
  96.  
  97. DSEG ends
  98.  
  99. CSEG SEGMENT
  100.      ASSUME    CS:CSEG, SS:nothing, ES:nothing, DS:DGROUP
  101.  
  102.  
  103. ;---- OS/2 IDC ENTRY POINT ----------------------------------------------------
  104. ; Handle OS/2 device driver interface commands for pen PM device services
  105. ;  ax    = idc command number
  106. ; returns
  107. ;  cy & ax != 0 for error
  108. ;  nc & ax == 0 for success
  109. ;------------------------------------------------------------------------------
  110. public Idc_DriverEntryPoint
  111. Idc_DriverEntryPoint proc far
  112.  
  113.   .if <ax b  PENBYUNIT>      ; If it a call that passes unit
  114.      mov  si, ax
  115.      shl  si, 1
  116.      CALL_UNIT pen_idc[si],bl
  117.   .elseif <ax b  PENIDCMAX>  ; global call
  118.      lea  bx, dcb0
  119.      mov  si, ax
  120.      shl  si, 1
  121.      call pen_idc[si]
  122.   .else                      ; out of range
  123.      stc
  124.      mov  ax, 1
  125.   .endif
  126.  
  127.   ret                        ; return
  128. Idc_DriverEntryPoint endp
  129.  
  130. ;---- IDC ROUTINES ------------------------------------------------------------
  131. ;
  132. ;------------------------------------------------------------------------------
  133.  
  134. Idc_invalid proc
  135.   PANIC PANIC_INVALID_IDC
  136.   stc
  137.   ret
  138. Idc_invalid endp
  139.  
  140. ;------------------------------------------------------------------------------
  141. ;  Query the capibilities for the logical device
  142. ;    bx = unit
  143. ;    es: di = area to copy registration packet
  144. ;  returns
  145. ;    nc, ax == 0 for success
  146. ;    cy, ax 1= 0 for error
  147. ;------------------------------------------------------------------------------
  148. public Idc_QueryCaps
  149. Idc_QueryCaps proc near     ; request unit registration
  150.   xor  ax,ax
  151.   mov  si,[bx].dcb_@RegCaps        ; si -> registration packet
  152.   mov  cx,[si]                     ; get size
  153.   .if <cx a es:[di]>               ; truncate copy
  154.     mov  cx, es:[di]
  155.     mov  ax,DRV_ERR_BUFF_TRUNC     ; return error, but copy part
  156.   .endif
  157.   rep movsb
  158.   clc
  159.   ret
  160. Idc_QueryCaps endp
  161.  
  162. ;------------------------------------------------------------------------------
  163. ; Get device configuration parameters
  164. ;  bx = dcb
  165. ;  es:di = pointer to buffer to return parameters
  166. ;------------------------------------------------------------------------------
  167. public Idc_QueryDevConfig
  168. Idc_QueryDevConfig  Proc
  169.   mov  si, [bx].dcb_@DeviceData        ; get addr of device data
  170.   .if  <zero si>
  171.      mov  word ptr es:[di],0
  172.   .else
  173.      mov  cx, es:[di].DevData_CfgDataLen ; get length of data requested
  174.      .if <cx gt [si].DevData_CfgDataLen> ; if more than we got
  175.         mov  cx, [si].DevData_CfgDataLen ; limit to what we have
  176.      .endif
  177.      cld                               ; go forward
  178.      rep  movsb                        ; move data to callers data area
  179.   .endif
  180.   xor  ax,ax                           ; clear carry for no error
  181.   ret                                  ; return to IDC router
  182. Idc_QueryDevConfig  EndP
  183.  
  184. ;------------------------------------------------------------------------------
  185. ; Enable reporting of interrupt data to locator driver service
  186. ;  bx = dcb
  187. ;------------------------------------------------------------------------------
  188. public Idc_StartDevice
  189. Idc_StartDevice Proc
  190.  
  191.    UNPANIC  PANIC_DDS     ; we have been contacted
  192.  
  193. ; do level check
  194.  
  195.   .if  <es:[di].sinfo_idc_major lt PEN_DDS_LEV_MAJOR> OR
  196.   .if  <es:[di].sinfo_idc_minor lt PEN_DDS_LEV_MINOR> OR
  197.   .if  <es:[di].sinfo_eif_major lt PEN_EI_LEV_MAJOR> OR
  198.   .if  <es:[di].sinfo_eif_minor lt PEN_EI_LEV_MINOR>
  199.      PANIC PANIC_LEVELS
  200.      mov  ax,DRV_ERR_LEVEL
  201.      stc
  202.      ret
  203.   .endif
  204.  
  205. ; hold stuff from SINFO structure needed to call
  206.  
  207.   mov  ax, es:[di].sinfo_service_ds
  208.   mov  [bx].dcb_service_ds, ax
  209.   mov  ax, word ptr es:[di].sinfo_service_rtn
  210.   mov  word ptr [bx].dcb_service_rtn, ax
  211.   mov  ax, word ptr es:[di].sinfo_service_rtn+2
  212.   mov  word ptr [bx].dcb_service_rtn+2, ax
  213.  
  214. ; register with device service
  215.  
  216.   call Idc_RegisterDevice
  217.  
  218. ; save returned information
  219.  
  220.   .if c
  221.      PANIC PANIC_REG_ERR
  222.      stc
  223.   .else
  224.      mov  di, [bx].dcb_@RegCaps
  225.      mov  al, [di].ccap_device_id
  226.      mov  di, [bx].dcb_@EiEvent
  227.      .if  <nonzero di>
  228.         mov  [di].cev_device_id, al
  229.      .endif
  230.  
  231. ; start up the device
  232.  
  233.      CALL_NZ_OK [bx].dcb_@Dev_Start ; start up the device
  234.   .endif
  235.   ret
  236. Idc_StartDevice EndP
  237.  
  238. ;------------------------------------------------------------------------------
  239. ; Enable reporting of interrupt data to driver services
  240. ; cx:dx = Style/Capabilites bits
  241. ;------------------------------------------------------------------------------
  242. public Idc_ReadEnable
  243. Idc_ReadEnable  Proc
  244.   or   DevStatus, RPTENABLED ; Set flag to enable intrpt reporting
  245.   CALL_NZ_OK [bx].dcb_@Dev_ReadEnable ; Change default Style
  246.   call Vmc_ReadEnable        ; check for video mode overrides
  247.   ret
  248. Idc_ReadEnable  EndP
  249.  
  250. ;------------------------------------------------------------------------------
  251. ; Disable reporting of interrupt data
  252. ;------------------------------------------------------------------------------
  253. public Idc_ReadDisable
  254. Idc_ReadDisable  Proc  Near
  255.   and  DevStatus, NOT RPTENABLED ; set flag to disable data reporting
  256.   CALL_NZ_OK dcb0.dcb_@Dev_ReadDisable
  257.   ret
  258. Idc_ReadDisable  EndP
  259.  
  260. ;------------------------------------------------------------------------------
  261. ;  Disable reporting device interrupts
  262. ;------------------------------------------------------------------------------
  263. public Idc_DisableDevice
  264. Idc_DisableDevice  Proc  Near
  265.   and  DevStatus, NOT DEVICEENABLED
  266.   CALL_NZ_OK dcb0.dcb_@Dev_Disable
  267.   ret
  268. Idc_DisableDevice  EndP
  269.  
  270. ;------------------------------------------------------------------------------
  271. ; Enable reporting device interrupts
  272. ;------------------------------------------------------------------------------
  273. public Idc_EnableDevice
  274. Idc_EnableDevice  Proc  Near
  275.   or   DevStatus, DEVICEENABLED
  276.   CALL_NZ_OK dcb0.dcb_@Dev_Enable
  277.   ret
  278. Idc_EnableDevice  EndP
  279.  
  280. ;------------------------------------------------------------------------------
  281. ; activity call back stub
  282. ;  bx = dcb
  283. ;------------------------------------------------------------------------------
  284. public Idc_ActCallBack
  285. Idc_ActCallBack Proc
  286.   CALL_NZ_OK dcb0.dcb_@Dev_CallBack
  287.   ret                            ; return to IDC router
  288. Idc_ActCallBack EndP
  289.  
  290. ;------------------------------------------------------------------------------
  291. ; Video Mode Notification
  292. ;  bx = dcb
  293. ;------------------------------------------------------------------------------
  294. public Idc_VMChange
  295. Idc_VMChange proc
  296.   CALL_NZ_OK dcb0.dcb_@Dev_VMChange
  297.   ret
  298. Idc_VMChange endp
  299.  
  300. ;------------------------------------------------------------------------------
  301. ; Advance Power Management notification
  302. ;  bx = dcb
  303. ;------------------------------------------------------------------------------
  304. public Idc_APM
  305. Idc_APM proc
  306.   CALL_NZ_OK dcb0.dcb_@Dev_APM
  307.   ret
  308. Idc_APM endp
  309.  
  310. ;-- IDC SUPPORT ROUTINES ------------------------------------------------------
  311. ;
  312. ;------------------------------------------------------------------------------
  313.  
  314. idc_common proc
  315.  
  316. ;------------------------------------------------------------------------------
  317. ; register device
  318. ;  bx = dcb
  319. ;------------------------------------------------------------------------------
  320. public Idc_RegisterDevice
  321. Idc_RegisterDevice:
  322.   mov  ax, REGISTER_DEVICE
  323.   mov  di, [bx].dcb_@RegCaps
  324.   jmp  short common2
  325.  
  326. ;------------------------------------------------------------------------------
  327. ; report event
  328. ;  bx = dcb
  329. ;------------------------------------------------------------------------------
  330. public Idc_ReportEvent
  331. Idc_ReportEvent:
  332.   mov  di, [bx].dcb_@EiEvent   ; Addr of event packet
  333.   mov  ax, REPORT_EVENT
  334.   jmp  short common
  335.  
  336. ;------------------------------------------------------------------------------
  337. ; update capabilities
  338. ;  bx = dcb
  339. ;------------------------------------------------------------------------------
  340. public Idc_UpdateCaps
  341. Idc_UpdateCaps:
  342.   mov  di, [bx].dcb_@RegCaps   ; Addr of caps packet
  343.   mov  ax, UPDATE_CAPS
  344.   jmp  short common
  345.  
  346. ;------------------------------------------------------------------------------
  347. ; request a callback
  348. ;  bx = dcb
  349. ;------------------------------------------------------------------------------
  350. public Idc_RequestCallback
  351. Idc_RequestCallback:
  352.   mov  cl, RegCaps0.ccap_device_id
  353.   mov  ax, REQUEST_CALLBACK
  354.   jmp  short common
  355.  
  356. ;------------------------------------------------------------------------------
  357. ; cancel a callback
  358. ;  bx = dcb
  359. ;------------------------------------------------------------------------------
  360. public Idc_CancelCallback
  361. Idc_CancelCallback:
  362.   mov  cl, RegCaps0.ccap_device_id
  363.   mov  ax, CANCEL_CALLBACK
  364.   jmp  short common
  365.  
  366. ;------------------------------------------------------------------------------
  367. ; suppress stroke
  368. ;  bx = dcb
  369. ;------------------------------------------------------------------------------
  370. public Idc_SuppressStroke
  371. Idc_SuppressStroke:
  372.   mov  cl, RegCaps0.ccap_device_id
  373.   mov  ax, SUPPRESS_STROKE
  374.   jmp  short common
  375.  
  376. ;------------------------------------------------------------------------------
  377. ; request the activity count
  378. ;  bx = dcb
  379. ; returns
  380. ;  edx = activity count
  381. ;------------------------------------------------------------------------------
  382. public Idc_QueryActivity
  383. Idc_QueryActivity:
  384.   mov  ax, QUERY_ACTIVITY
  385.  
  386. common:
  387.   .if <bit DevStatus nz RPTENABLED>
  388. common2:
  389.      push ds
  390.      push bx
  391.  
  392.      push ds
  393.      pop  es
  394.      mov  ds,[bx].dcb_service_ds
  395.      call es:[bx].dcb_service_rtn
  396.      pop  bx
  397.      pop  ds
  398.   .endif
  399.   ret
  400. Idc_Common endp
  401.  
  402. CSEG ends
  403. END
  404.