home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / CLOCK / PTVDM.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  6KB  |  276 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 = @(#)ptvdm.asm    6.1 91/02/18
  13.     PAGE    ,132
  14.     NAME    PTIMER
  15.     TITLE    Physical Timer Device Driver
  16.  
  17. ;***    Physical Clock Device Driver (PTD)
  18. ;
  19. ;    SCCSID = @(#)ptvdm.asm 1.00 90/10/10
  20. ;
  21. ;
  22. ;
  23. ;
  24. ;    PTD-VTD Communication Interface
  25. ;
  26. ;    DESCRIPTION
  27. ;        This module contains all the PTD-VTD communication
  28. ;        interface procedures.
  29. ;
  30. ;    MODIFICATION HISTORY
  31. ;    10/10/90 MTS    Created.
  32.  
  33.  
  34.     .xlist
  35. INCL_MI EQU    1
  36.     include mvdm.inc    ;mvdm definitions for dos macros
  37.     include vtdptd.inc    ;definitions common to both timer VDD and PDD
  38.     include clkseg.inc    ;segment definitions
  39.     include clkdata.inc
  40.     .list
  41.  
  42.     .386p
  43.  
  44.  
  45. ClkData SEGMENT
  46.     extrn    selClkData:word
  47.     extrn    fsPTFlags:word
  48.     extrn    fpfnVTProc:fword
  49. ClkData ENDS
  50.  
  51.  
  52. ClkCode SEGMENT
  53.  
  54.     extrn    PTT0Close:near
  55.     extrn    PTBeepClose:near
  56.  
  57. EVEN                    ;make sure it's word aligned
  58. PTFuncTable label word
  59.     dw    offset ClkCode:PTRegister    ;PTDCMD_REGISTER
  60.     dw    offset ClkCode:PTDeRegister    ;PTDCMD_DEREGISTER
  61.     dw    offset ClkCode:PTEnableTick    ;PTDCMD_ENABLETICK
  62.     dw    offset ClkCode:PTDisableTick    ;PTDCMD_DISABLETICK
  63. PTMaxFunc    EQU    ($-PTFuncTable)/2-1
  64.  
  65.  
  66. ;***LP    PTVDMProc(ulFunc, ul1, ul2) - VDD request router
  67. ;
  68. ;    This subroutine is registered by the PDD during system initialization
  69. ;    via DevHlp_RegisterPDD, and is called by the VDD to perform various
  70. ;    services.  See all the PTDCMD_* equates for a brief list of those
  71. ;    services.
  72. ;
  73. ;    ENTRY
  74. ;        [sp+ 8] = ul2
  75. ;        [sp+12] = ul1
  76. ;        [sp+16] = ulFunc
  77. ;
  78. ;        Refer to vtdptd.h for details of ul1 and ul2.
  79. ;
  80. ;    EXIT-SUCCESS
  81. ;        (eax) = TRUE
  82. ;    EXIT-FAILURE
  83. ;        (eax) = FALSE
  84. ;
  85. ;    USES
  86. ;        All except bx,si,di,bp,ds,es
  87. ;
  88. ;    CONTEXT
  89. ;        VDD Init-time
  90. ;        VDM Task-time
  91. ;
  92. ;    PCODE
  93. ;        route to appropriate PT* worker function;
  94. ;
  95. ;    NOTE
  96. ;        Assume function code can be used as direct function table index.
  97.  
  98.     ASSUME    CS:ClkCode,DS:NOTHING,ES:NOTHING,SS:NOTHING
  99. Procedure PTVDMProc,far
  100.  
  101.     ?abase    = 8 + 2         ;%%% ret. addr. is 8 bytes, bp 2 bytes
  102.     ArgVar    ul2,ULONG        ;BUGBUG Procedure, EndProc should
  103.     ArgVar    ul1,ULONG        ;    be changed to support 16:32
  104.     ArgVar    ulFunc,ULONG        ;    type of procedure calling.
  105.  
  106.     EnterProc
  107.     SaveReg <bx,si,di,ds,es>
  108.  
  109.     mov    ds,cs:[selClkData]
  110.     ASSUME    DS:ClkData
  111.  
  112.     sub    eax,eax         ;assume failure
  113.  
  114.     mov    bx,WORD PTR [ulFunc]    ;(bx)=ulFunc
  115.     sub    bx,PTDCMD_REGISTER    ;don't make assumptions on register equ
  116.     cmp    bx,PTMaxFunc        ;is it a valid function?
  117.     ja    ptvx            ;NO, goto error exit
  118.  
  119.     shl    bx,1            ;adjust bx as word index
  120.  
  121.     mov    cx,WORD PTR [ul1+2]
  122.     mov    si,WORD PTR [ul1]    ;(cx:si)=ul1
  123.     mov    dx,WORD PTR [ul2+2]
  124.     mov    di,WORD PTR [ul2]    ;(dx:di)=ul2
  125.  
  126.     call    cs:PTFuncTable[bx]    ;process requested function
  127.  
  128. ptvx:    RestoreReg <es,ds,di,si,bx>
  129.     ASSUME    DS:NOTHING
  130.  
  131.     LeaveProc
  132.  
  133.     retfd    ?aframe         ;%%%
  134.  
  135. EndProc PTVDMProc
  136.  
  137.  
  138. ;***LP    PTRegister() - VDD registration
  139. ;
  140. ;    Record the entry point being registered for the VDD.  This is in
  141. ;    respond to PTDCMD_REGISTER and is invoked by the VDM manager
  142. ;    in VDHOpenPDD.
  143. ;
  144. ;    ENTRY
  145. ;        (si:dx,di) = VDD entry point
  146. ;
  147. ;    EXIT
  148. ;        (eax) = TRUE     //always successful
  149. ;
  150. ;    USES
  151. ;        None
  152. ;
  153. ;    CONTEXT
  154. ;        VDD Init-time
  155. ;
  156. ;    PCODE
  157. ;        store the VDD entry point;
  158. ;        release T0 and T2 ownership to vtimer;
  159.  
  160.     ASSUME    CS:ClkCode,DS:ClkData,ES:NOTHING,SS:NOTHING
  161. Procedure PTRegister,near
  162.  
  163.     mov    word ptr [fpfnVTProc],di    ;offset low word
  164.     mov    word ptr [fpfnVTProc+2],dx    ;offset high word
  165.     mov    word ptr [fpfnVTProc+4],si    ;selector
  166.  
  167.     call    PTT0Close            ;release T0 ownership
  168.     call    PTBeepClose            ;release T2 ownership
  169.  
  170.     mov    eax,CTRUE            ;return success
  171.  
  172.     ret
  173.  
  174. EndProc PTRegister
  175.  
  176.  
  177. ;***LP    PTDeRegister() - VDD de-registration
  178. ;
  179. ;    Zero the VDD entry point.  This is in respond to PTDCMD_DEREGISTER.
  180. ;
  181. ;    ENTRY
  182. ;        None
  183. ;
  184. ;    EXIT
  185. ;        (eax) = TRUE     //always successful
  186. ;
  187. ;    USES
  188. ;        None
  189. ;
  190. ;    CONTEXT
  191. ;        Task-time
  192. ;
  193. ;    PCODE
  194. ;        zero the VDD entry point;
  195. ;        make sure ptimer now owns both T0 and T2;
  196.  
  197.     ASSUME    CS:ClkCode,DS:ClkData,ES:NOTHING,SS:NOTHING
  198. Procedure PTDeRegister,near
  199.  
  200.     xor    eax,eax
  201.     mov    dword ptr [fpfnVTProc],eax    ;offset
  202.     mov    word ptr [fpfnVTProc+4],ax    ;selector
  203.  
  204.     mov    [fsPTFlags],PTF_OWNT0+PTF_OWNT2 ;reset ptimer flags
  205.  
  206.     mov    eax,CTRUE            ;return success
  207.  
  208.     ret
  209.  
  210. EndProc PTDeRegister
  211.  
  212.  
  213. ;***LP    PTEnableTick() - VDD request enable timer tick
  214. ;
  215. ;    Enable tick delivery to timer VDD.
  216. ;
  217. ;    ENTRY
  218. ;        None
  219. ;
  220. ;    EXIT
  221. ;        (eax) = TRUE     //always successful
  222. ;
  223. ;    USES
  224. ;        None
  225. ;
  226. ;    CONTEXT
  227. ;        VDM Task-time
  228. ;
  229. ;    PCODE
  230. ;        indicate VDD needs tick;
  231.  
  232.     ASSUME    CS:ClkCode,DS:ClkData,ES:NOTHING,SS:NOTHING
  233. Procedure PTEnableTick,near
  234.  
  235.     or    fsPTFlags,PTF_TICKENABLE
  236.     mov    eax,CTRUE            ;return success
  237.  
  238.     ret
  239.  
  240. EndProc PTEnableTick
  241.  
  242.  
  243. ;***LP    PTDisableTick() - VDD request disable timer tick
  244. ;
  245. ;    Disable tick delivery to timer VDD.
  246. ;
  247. ;    ENTRY
  248. ;        None
  249. ;
  250. ;    EXIT
  251. ;        (eax) = TRUE     //always successful
  252. ;
  253. ;    USES
  254. ;        None
  255. ;
  256. ;    CONTEXT
  257. ;        VDM Task-time
  258. ;
  259. ;    PCODE
  260. ;        indicate VDD does not need tick;
  261.  
  262.     ASSUME    CS:ClkCode,DS:ClkData,ES:NOTHING,SS:NOTHING
  263. Procedure PTDisableTick,near
  264.  
  265.     and    fsPTFlags,NOT PTF_TICKENABLE
  266.     mov    eax,CTRUE            ;return success
  267.  
  268.     ret
  269.  
  270. EndProc PTDisableTick
  271.  
  272. ClkCode ENDS
  273.  
  274.  
  275.     END
  276.