home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / CLOCK / CLKVDM.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  6KB  |  251 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 = @(#)clkvdm.asm    6.6 91/10/22
  13.     PAGE    ,132
  14.     NAME    CLOCK
  15.     TITLE    Physical Clock Device Driver
  16.  
  17. ;***    Physical Clock Device Driver (CLK)
  18. ;
  19. ;    SCCSID = @(#)clkvdm.asm    6.6 91/10/22
  20. ;
  21. ;
  22. ;
  23. ;
  24. ;    CLK-VCMS Communication Interface
  25. ;
  26. ;    DESCRIPTION
  27. ;        This module contains all the CLK-VCMOS communication
  28. ;        interface procedures.
  29. ;
  30. ;    MODIFICATION HISTORY
  31. ;    02/02/90 MTS    Created.
  32.  
  33.  
  34.     .xlist
  35. INCL_MI EQU    1
  36.     include mvdm.inc    ;mvdm definitions for dos macros
  37.     include cmos.inc    ;cmos hardware constants
  38.     include vcmospdd.inc    ;definitions common to both cmos VDD and PDD
  39.     include clkseg.inc    ;segment definitions
  40.     .list
  41.  
  42.     .386p
  43.  
  44. ClkCode SEGMENT
  45.  
  46.     PUBLIC    selClkData        ;%%% BUGBUG loader should resolve
  47. selClkData  dw    0            ;%%% instead of storing ds away
  48.  
  49. EVEN                    ;make sure it's word aligned
  50. ClkFuncTable label word
  51.     dw    offset ClkCode:ClkRegister
  52.     dw    offset ClkCode:ClkReadCMOS
  53. ClkMaxFunc    EQU    ($-ClkFuncTable)/2-1
  54.  
  55.  
  56. ;***LP    ClkVDDProc(ulFunc, ul1, ul2) - VDD request router
  57. ;
  58. ;    This subroutine is registered by the PDD during system initialization
  59. ;    via DevHlp_RegisterPDD, and is called by the VDD to perform various
  60. ;    services.  See all the CLKCMD_* equates for a brief list of those
  61. ;    services.
  62. ;
  63. ;    ENTRY
  64. ;        (TOS+8) = ulFunc
  65. ;        (TOS+4) = ul1
  66. ;        (TOS)   = ul2
  67. ;
  68. ;        Refer to vcmospdd.h for details of ul1 and ul2.
  69. ;
  70. ;    EXIT
  71. ;        SUCCESS
  72. ;        (eax) = TRUE
  73. ;        FAILURE
  74. ;        (eax) = FALSE
  75. ;
  76. ;    USES
  77. ;        All except bx,si,di,bp,ds,es
  78. ;
  79. ;    CONTEXT
  80. ;        VDD Init-time
  81. ;        VDM Task-time
  82. ;
  83. ;    PSEUDOCODE
  84. ;        route to appropriate Clk* worker function;
  85. ;
  86. ;    NOTE
  87. ;        Assume function code can be used as direct function table index.
  88.  
  89.     ASSUME    CS:ClkCode,DS:NOTHING,ES:NOTHING,SS:NOTHING
  90. Procedure ClkVDDProc,far
  91.  
  92.     ?abase    = 8 + 2         ;%%% ret. addr. is 8 bytes, bp 2 bytes
  93.     ArgVar    ul2,ULONG        ;BUGBUG Procedure, EndProc should
  94.     ArgVar    ul1,ULONG        ;    be changed to support 16:32
  95.     ArgVar    ulFunc,ULONG        ;    type of procedure calling.
  96.  
  97.     EnterProc
  98.     SaveReg <bx,si,di,ds,es>
  99.  
  100.     mov    ds,cs:[selClkData]
  101.     ASSUME    DS:ClkData
  102.  
  103.     sub    eax,eax         ;assume failure
  104.  
  105.     mov    bx,WORD PTR [ulFunc]    ;(bx)=ulFunc
  106.     sub    bx,CLKCMD_REGISTER    ;don't make assumptions on register equ
  107.     cmp    bx,ClkMaxFunc        ;is it a valid function?
  108.     ja    cvpx            ;NO, goto error exit
  109.  
  110.     shl    bx,1            ;adjust bx as word index
  111.  
  112.     mov    cx,WORD PTR [ul1+2]
  113.     mov    si,WORD PTR [ul1]    ;(cx:si)=ul1
  114.     mov    dx,WORD PTR [ul2+2]
  115.     mov    di,WORD PTR [ul2]    ;(dx:di)=ul2
  116.  
  117.     call    cs:ClkFuncTable[bx]    ;process requested function
  118.  
  119. cvpx:    RestoreReg <es,ds,di,si,bx>
  120.     ASSUME    DS:NOTHING
  121.  
  122.     LeaveProc
  123.  
  124.     retfd    ?aframe         ;%%%
  125.  
  126. EndProc ClkVDDProc
  127.  
  128.  
  129. ;***LP    ClkRegister() - VDD registration
  130. ;
  131. ;    Record the entry point being registered for the VDD.  This is in
  132. ;    response to CLKCMD_REGISTER and is invoked by the VDM manager
  133. ;    in VDHOpenPDD.
  134. ;
  135. ;    ENTRY
  136. ;        (si:dx,di) = NULL -> VDD entry point
  137. ;
  138. ;    EXIT
  139. ;        SUCCESS
  140. ;           (eax) = TRUE    //always successful
  141. ;
  142. ;    USES
  143. ;        None
  144. ;
  145. ;    CONTEXT
  146. ;        VDD Init-time
  147. ;
  148. ;    NOTE
  149. ;        Currently, we don't need a VCMOS entry point.
  150. ;        So we just store it and forget about it.  This routine
  151. ;        must be present because VDM manager will call us no matter
  152. ;        we have a valid entry point or not.
  153. ;
  154. ;    PSEUDO-CODE
  155.  
  156.     ASSUME    CS:ClkCode,DS:ClkData,ES:NOTHING,SS:NOTHING
  157. Procedure ClkRegister,near
  158.  
  159.     mov    eax,CTRUE            ;return success
  160.  
  161.     ret
  162.  
  163. EndProc ClkRegister
  164.  
  165.  
  166. ;***LP    ClkReadCMOS() - VDD Read CMOS
  167. ;
  168. ;    The VDD call this procedure to read the CMOS locations.
  169. ;
  170. ;    ENTRY
  171. ;        (cx:si) -> ReadReq
  172. ;        (dx:di) -> CMOSArray
  173. ;
  174. ;    EXIT
  175. ;        SUCCESS
  176. ;        (eax) = TRUE
  177. ;
  178. ;    USES
  179. ;        All
  180. ;
  181. ;    CONTEXT
  182. ;        VDM Task
  183. ;
  184. ;    NOTE
  185. ;        This function always succeeds because we will enforce a
  186. ;        valid CMOS address range by masking the extra address bits.
  187. ;
  188. ;    PSEUDOCODE
  189. ;        fChanged = FALSE;
  190. ;        do {
  191. ;        for each byte in the range specified {
  192. ;            read CMOS;
  193. ;            if it has been changed since the last iteration {
  194. ;            fChanged = TRUE;
  195. ;            store the new value;
  196. ;            }
  197. ;        }
  198. ;        } while (fChanged);
  199.  
  200.     ASSUME    CS:ClkCode,DS:ClkData,ES:NOTHING,SS:NOTHING
  201. Procedure ClkReadCMOS,hybrid                        
  202.  
  203.     mov    ds,cx            ;(ds:si)->ReadReq packet
  204.     mov    es,dx            ;(es:di)->CMOS array
  205.  
  206. crc10:    mov    bx,di            ;(es:bx)->CMOS array
  207.     mov    al,[si].rdrq_CMOSAddr    ;(al)=start CMOS address
  208.     and    al,ADDR_MASK        ;make sure address within range
  209.     xor    ch,ch
  210.     mov    cl,[si].rdrq_nbCMOS    ;(cx)=number of bytes to read
  211.     xor    dx,dx            ;(dx)=fChanged=FALSE
  212.  
  213. crc20:  pushf                                
  214.     cli                                
  215.     out    PORT_ADDRLATCH,al    ;set port address        
  216.     inc    al            ;(al)=next port
  217.     xchg    al,ah            ;(ah)=next port address
  218.     IODelay
  219.     in    al,PORT_DATALATCH    ;(al)=value of CMOS location
  220.     popf                                
  221.     cmp    al,es:[bx]        ;is this byte the same as before?
  222.     je    crc30            ;YES, continue
  223.  
  224.     inc    dx            ;set fChanged flag
  225.     mov    es:[bx],al        ;store new value
  226.  
  227. crc30:    inc    bx            ;increment buffer pointer
  228.     xchg    ah,al            ;(al)=next port address
  229.     loop    crc20            ;read next byte if we are not done yet
  230.  
  231.     cmp    dx,0            ;have CMOS values changed?
  232.     jne    crc10            ;YES, try again
  233.  
  234.     mov    al,ADDR_DIAGS+ADDR_NMIENABLE;re-enable NMI
  235.     pushf                                
  236.     cli                                
  237.     out    PORT_ADDRLATCH,al
  238.     IODelay
  239.     in    al,PORT_DATALATCH    ;dummy read
  240.     popf                                
  241.  
  242.     mov    eax,CTRUE        ;return TRUE
  243.     ret
  244.  
  245. EndProc ClkReadCMOS
  246.  
  247. ClkCode ENDS
  248.  
  249.  
  250.     END
  251.