home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / CLOCK / PTT0.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  4KB  |  213 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 = @(#)ptt0.asm    6.1 91/02/18
  13.     PAGE    ,132
  14.     NAME    PTD
  15.     TITLE    Physical Timer Device Driver
  16.  
  17.  
  18. ;***    Physical Timer Device Driver (PTD)
  19. ;
  20. ;    SCCSID = @(#)ptt0.asm    1.00 90/10/13
  21. ;
  22. ;    DESCRIPTION
  23. ;    This module contains the PTD's timer 0 ownership arbitration
  24. ;    services.
  25. ;
  26. ;    MODIFICATION HISTORY
  27. ;    10/13/90 MTS    Created.
  28.  
  29.  
  30.     .xlist
  31. INCL_MI     EQU    1
  32.     include mvdm.inc    ;mvdm definitions for dos macros
  33.     include ptimer.inc    ;ptimer service public constants
  34.     include timer.inc    ;timer hardware constants
  35.     include vtdptd.inc
  36. INCL_ERRORS    EQU    1
  37.     include bseerr.inc    ;error numbers
  38.     include clkseg.inc    ;segment definitions
  39.     include clkdata.inc
  40.     .list
  41.  
  42.     .386p
  43.  
  44. ;***    Exports
  45. ;
  46.  
  47. ClkData SEGMENT
  48.  
  49. ;***    Imports
  50. ;
  51.     EXTRN    selClkData:WORD
  52.     EXTRN    fpfnVTProc:FWORD
  53.     EXTRN    fsPTFlags:WORD
  54.  
  55. ClkData ENDS
  56.  
  57.  
  58. ClkCode SEGMENT
  59.  
  60. T0FuncTable label word
  61.     dw    offset ClkCode:PTT0Open
  62.     dw    offset ClkCode:PTT0Close
  63. T0MaxFunc    EQU    ($-T0FuncTable)/2-1
  64.  
  65.  
  66. ;***EP    PTTimer0(ulFunc) - Timer 0 Arbitration Services router
  67. ;
  68. ;   PTTimer0 provides the timer 0 arbitration services for
  69. ;   the kernel components.
  70. ;
  71. ;   ENTRY
  72. ;    ulFunc    = Timer 0 arbitration services: PTT0_OPEN, PTT0_CLOSE
  73. ;   EXIT-SUCCESS
  74. ;    (eax) = 0
  75. ;   EXIT-FAILURE
  76. ;    (eax) = error code - ERROR_INVALID_FUNCTION
  77. ;
  78. ;   USES
  79. ;    All
  80. ;
  81. ;   CONTEXT
  82. ;    Task
  83. ;
  84. ;   PCODE
  85. ;    route to appropriate worker routines;
  86.  
  87.     ASSUME    CS:ClkCode,DS:NOTHING,ES:NOTHING,SS:NOTHING
  88. Procedure PTTimer0,FAR
  89.  
  90.     ?abase    = 8 + 2         ;%%% ret. addr. is 8 bytes, bp 2 bytes
  91.     ArgVar    ulFunc,ULONG        ; changed to support 16:32 type of
  92.                     ; procedure calling.
  93.     EnterProc
  94.  
  95.     mov    si,WORD PTR [ulFunc]    ;(si)=ulFunc
  96.  
  97.     cmp    si,T0MaxFunc        ;is it a valid function?
  98.     ja    pte            ;NO, goto error exit
  99.  
  100.     shl    si,1            ;adjust si as word index
  101.     call    cs:T0FuncTable[si]    ;process requested function
  102.  
  103.     xor    eax,eax         ;(eax)=ERROR_NONE
  104. ptx:    LeaveProc
  105.  
  106.     retfd    ?aframe         ;%%%
  107.  
  108. pte:    mov    eax,ERROR_INVALID_FUNCTION
  109.     jmp    short ptx
  110.  
  111. EndProc PTTimer0
  112.  
  113.  
  114. ;***LP    PTT0Open() - Get timer 0 access
  115. ;
  116. ;   This routine is call to request access to the timer 0 hardware.
  117. ;   This is currently used by the profiler to program the profiling
  118. ;   tick rate.
  119. ;
  120. ;   ENTRY
  121. ;    None
  122. ;   EXIT
  123. ;    None
  124. ;
  125. ;   USES
  126. ;    All except ds,es
  127. ;
  128. ;   CONTEXT
  129. ;    Task
  130. ;
  131. ;   PCODE
  132. ;    if vtimer has the timer0 ownership
  133. ;        call vtimer to get it;
  134.  
  135.     ASSUME    CS:ClkCode,DS:NOTHING,ES:NOTHING,SS:NOTHING
  136. Procedure PTT0Open,NEAR
  137.  
  138.     SaveReg <ds,es>
  139.     mov    ds,cs:[selClkData]
  140.     ASSUME    DS:ClkData
  141.  
  142.     test    fsPTFlags,PTF_OWNT0    ;ptimer already has the ownership?
  143.     jnz    ptox            ;YES, exit
  144.  
  145.     or    fsPTFlags,PTF_OWNT0
  146.     xor    eax,eax
  147.     push    DWORD PTR VTDCMD_PREEMPTT0    ;(TOS+8)=VTDCMD_PREEMPTT0
  148.     push    eax                ;(TOS+4)=0
  149.     push    eax                ;(TOS)=0
  150.  
  151.     ;Should ASSERTNONZERO(fpfnVTProc)
  152.     call    FWORD PTR [fpfnVTProc]
  153.  
  154. ptox:    RestoreReg <es,ds>
  155.     ASSUME    DS:NOTHING
  156.  
  157.     ret
  158.  
  159. EndProc PTT0Open
  160.  
  161.  
  162. ;***LP    PTT0Close() - Release timer 0 access
  163. ;
  164. ;   If ptimer has the timer0 ownership, call vtimer to release
  165. ;   the speaker.
  166. ;
  167. ;   ENTRY
  168. ;    None
  169. ;   EXIT
  170. ;    None
  171. ;
  172. ;   USES
  173. ;    All except ds,es
  174. ;
  175. ;   CONTEXT
  176. ;    Task
  177. ;
  178. ;   PCODE
  179. ;    if ptimer has the timer0 ownership and there is a vtimer
  180. ;        call vtimer to release ownership;
  181.  
  182.     ASSUME    CS:ClkCode,DS:NOTHING,ES:NOTHING,SS:NOTHING
  183. Procedure PTT0Close,NEAR
  184.  
  185.     SaveReg <ds,es>
  186.     mov    ds,cs:[selClkData]
  187.     ASSUME    DS:ClkData
  188.  
  189.     test    fsPTFlags,PTF_OWNT0    ;ptimer has the ownership?
  190.     jz    ptcx            ;NO, exit
  191.  
  192.     cmp    DWORD PTR fpfnVTProc,0    ;vtimer exist?
  193.     je    ptcx            ;NO, exit
  194.  
  195.     and    fsPTFlags,NOT PTF_OWNT0
  196.     xor    eax,eax
  197.     push    DWORD PTR VTDCMD_RELEASET0;(TOS+8)=VTDCMD_RELEASET0
  198.     push    eax            ;(TOS+4)=0
  199.     push    eax            ;(TOS)=0
  200.  
  201.     call    FWORD PTR [fpfnVTProc]
  202.  
  203. ptcx:    RestoreReg <es,ds>
  204.  
  205.     ret
  206.  
  207. EndProc PTT0Close
  208.  
  209. ClkCode ENDS
  210.  
  211.  
  212.     END
  213.