home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / perf.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  11.1 KB  |  305 lines

  1. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  2.  
  3. /*****************************************************************************
  4.  *
  5.  *   (C) Copyright MICROSOFT Corp., 1988-1990
  6.  *
  7.  *   Title:     PERF.H - Include file for perf monitor
  8.  *
  9.  *   Version:   1.00
  10.  *
  11.  *   Date:
  12.  *
  13.  *   Author:    FCF
  14.  *
  15.  *-----------------------------------------------------------------------------
  16.  *
  17.  *   Change log:
  18.  *
  19.  *   DATE        REV DESCRIPTION
  20.  *   ----------- --- -----------------------------------------------------------
  21.  */
  22.  
  23. /*  See dos\dos386\vxd\perf\example for a sample VxD that registers as */
  24. /*  a perf server.                                                     */
  25.  
  26. /* defines */
  27.  
  28. #define MAXNAMELEN            50    /* maximum number of characters in
  29.                                    service name, stat name, or key names */
  30. #define MAXCOMPLEXSUBSTAT    8    /* maximum number of stats making
  31.                                    up a complex stat */
  32.     
  33. /* structures and flags used for the ring-0 interface */
  34.  
  35. struct perf_server_0 {
  36.     unsigned long    psrv0_Level;    /* Must be zero for this level */
  37.     unsigned long    psrv0_Flags;
  38.     char            *psrv0_pszServerName;
  39.     char           *psrv0_pszServerNodeName;
  40.     void           *psrv0_pControlFunc;
  41. };
  42.  
  43. struct perf_stat_0 {
  44.     unsigned long    pst0_Level;    /* Must be zero for this level */
  45.     unsigned long    pst0_Flags;
  46.     char           *pst0_pszStatName;
  47.     char           *pst0_pszStatNodeName;
  48.     char           *pst0_pszStatUnitName;
  49.     char           *pst0_pszStatDescription;
  50.     void           *pst0_pStatFunc;
  51. };
  52.  
  53. /* Values for psrv0_Flags follow */
  54.  
  55. /* Values for pst0_Flags follow */
  56.  
  57. /* pst0_pStatFunc points either directly to data (always a DWORD for now) */
  58. /* or, if PSTF_FUNCPTR_BIT is set, to a _cdecl function.  This function   */
  59. /* accepts a stat handle as it's argument and returns the stat in eax     */
  60.  
  61. #define PSTF_FUNCPTR        0x00000001
  62.  
  63. /* The data referenced by this stat is always a counter, e.g. number of   */
  64. /* bytes read.  It is up to the client to differentiate this into a rate. */
  65. /* If PSTF_RATE is set, then the text associated with this stat assumes   */
  66. /* that the stat will be differentiated with respect to time.  It's       */
  67. /* possible that two stats will refer to the same data - one with this    */
  68. /* bit set and one without, with help text appropriate for each.          */
  69.  
  70. #define PSTF_COUNT        0x00000000
  71. #define PSTF_RATE        0x00000002
  72.  
  73. /* A recommendation as to the frequency of update.  Bytes read/second     */
  74. /* can change quite rapidly, but updating # of shares will not change     */
  75. /* as often, and (currently) vcache cache size is static.  Perf clients   */
  76. /* are free to ignore these values, and free to define update frequency.  */
  77.  
  78. #define PSTF_FREQ_HIGH        0x00000000
  79. #define PSTF_FREQ_LOW        0x00000004
  80. #define PSTF_FREQ_STATIC    0x00000008
  81. #define PSTF_FREQ_MASK        (PSTF_FREQ_STATIC | PSTF_FREQ_LOW |    \
  82.                  PSTF_FREQ_HIGH)
  83.  
  84.  
  85. /* A recommendation as to the scale type.  Bytes read/second may be more  */
  86. /* appropriately displayed on a log10 scale, while memory available might */
  87. /* be better on a linear scale.  Perf clients are free to ignore this.    */
  88.  
  89. #define PSTF_SCALE_LINEAR    0x00000000
  90. #define PSTF_SCALE_LOG10    0x00000010
  91. #define PSTF_SCALE_LOG2        0x00000020
  92. #define PSTF_SCALE_MASK        (PSTF_SCALE_LINEAR | PSTF_SCALE_LOG10 | \
  93.                  PSTF_SCALE_LOG2)
  94.  
  95. /* XLATOFF */
  96.  
  97. unsigned long PERF_Server_Register( struct perf_server_0 * );
  98. void PERF_Server_Deregister( unsigned long hReg );
  99. unsigned long PERF_Server_Add_Stat( unsigned long hReg, struct perf_stat_0 );
  100. void PERF_Server_Remove_Stat( unsigned long hStat );
  101.  
  102. /* XLATON */
  103.  
  104. /* Control messages sent to perf server's control function.  The control */
  105. /* function is optional, set it to NULL if you don't want any control    */
  106. /* messages.  Perf servers are free to ignore any messages they want.    */
  107. /* Control functions take two DWORD parameters; a message (dwMsg) and a  */
  108. /* DWORD of message-dependent data (dwData).                              */
  109.  
  110. /* The following defines are values for dwMsg:                             */
  111. #define PMSG_START_STAT                0x11
  112. #define PMSG_STOP_STAT                0x12
  113.  
  114. /* PMSG_START_STAT: Notifies that a perf client is going to start        */
  115. /*     watching this stat.  dwData contains the stat handle.             */
  116. /* PMSG_STOP_STAT: Notifies that a perf client is no longer              */
  117. /*     watching this stat.  dwData contains the stat handle.             */
  118. /* Stats which are expensive to maintain should only be kept while some- */
  119. /* one is watching them.  Note that there can be more than one stat      */
  120. /* client, so don't just stop keeping track of a stat if you receive     */
  121. /* a PMSG_STOP_STAT.  The server should keep a counter of the number     */
  122. /* of PMSG_START_STAT's it receives for a particular counter, decrement  */
  123. /* it for each PMSG_STOP_STAT and stop keeping track of the stat when the*/
  124. /* counter reaches zero.                                                 */
  125. /* Most stats are trivial to maintain and just involve incrementing a    */
  126. /* counter.  For stats like these, perf servers should always increment  */
  127. /* the counter and ignore messages to start and stop.                    */
  128.  
  129.  
  130. /* IOCTL apis understood by perf (from ring 3 client) */
  131.  
  132. #define IOCTL_PERF_GET_STATS        0x10
  133. #define IOCTL_PERF_START_STAT        0x11
  134. #define IOCTL_PERF_STOP_STAT        0x12
  135. /* On entry to the IOCTL_PERF_GET_STATS ioctl:
  136.     lpvInBuffer     pointer to array of DWORD stat handles
  137.     cbInBuffer        size of array, in bytes
  138.     lpvOutBuffer    pointer to result array (can be same as lpvInBuffer)
  139.     cbOutBuffer        size of destination array
  140. */
  141.  
  142. /* ASM
  143.  
  144. ; Ring-0 macros to aid stat registration
  145.  
  146. Reg_Perf_Srv MACRO level:REQ, flags:REQ, servername:REQ, nodename:REQ, controlfunc:REQ
  147.     local    nothere
  148.     VxDcall    PERF_Get_Version
  149.     or    eax, eax
  150.     jz    nothere
  151.  
  152.     IF (OPATTR(controlfunc)) AND 00010000y     ;; register
  153.         push    controlfunc
  154.     ELSE
  155.         push    OFFSET32 controlfunc
  156.     ENDIF
  157.  
  158.     IF (OPATTR(nodename)) AND 00010000y        ;; register
  159.         push    nodename
  160.     ELSE
  161.         push    OFFSET32 nodename
  162.     ENDIF
  163.  
  164.     IF (OPATTR(servername)) AND 00010000y        ;; register
  165.         push    servername
  166.     ELSE
  167.         push    OFFSET32 servername
  168.     ENDIF
  169.     
  170.     push    flags
  171.         push    level
  172.     push    esp
  173.     VxDcall    PERF_Server_Register
  174.     add    esp, 6*4
  175. nothere:
  176.     ENDM
  177.  
  178. Reg_Perf_Stat MACRO srvhandle:REQ, level:REQ, flags:REQ, name:REQ, nodename:REQ, unitname:REQ, desc:REQ, func:REQ
  179.     IF (OPATTR(func)) AND 00010000y        ;; register
  180.         push    func
  181.     ELSE
  182.         push    OFFSET32 func
  183.     ENDIF
  184.  
  185.     IF (OPATTR(desc)) AND 00010000y        ;; register
  186.         push    desc
  187.     ELSE
  188.         push    OFFSET32 desc
  189.     ENDIF
  190.  
  191.     IF (OPATTR(unitname)) AND 00010000y    ;; register
  192.         push    unitname
  193.     ELSE
  194.         push    OFFSET32 unitname
  195.     ENDIF
  196.  
  197.     IF (OPATTR(nodename)) AND 00010000y    ;; register
  198.         push    nodename
  199.     ELSE
  200.         push    OFFSET32 nodename
  201.     ENDIF
  202.  
  203.     IF (OPATTR(name)) AND 00010000y        ;; register
  204.         push    name
  205.     ELSE
  206.         push    OFFSET32 name
  207.     ENDIF
  208.     
  209.     push    flags
  210.     push    level
  211.     push    esp
  212.     push    srvhandle
  213.     VxDcall    PERF_Server_Add_Stat
  214.     add    esp, 9*4
  215.     ENDM
  216.  
  217. Begin_Service_Table PERF
  218. PERF_Service PERF_Get_Version, LOCAL
  219. PERF_Service PERF_Server_Register, LOCAL
  220. PERF_Service PERF_Server_Deregister, LOCAL
  221. PERF_Service PERF_Server_Add_Stat, LOCAL
  222. PERF_Service PERF_Server_Remove_Stat, LOCAL
  223. End_Service_Table PERF
  224.  
  225. */
  226.  
  227. /* Registry constants follow.  A sample perf registry tree might look like
  228.    this:
  229.  
  230. HKEY_LOCAL_MACHINE\STATS\VFAT            
  231.               NAME="32-bit file system"
  232.                  \READS
  233.                +---    NAME="Reads per second"
  234.                |       HANDLE=<4 byte binary value>
  235.           Required |       DESCRIPTION="The number of file read requests
  236.                |                    per second"
  237.                |       VALUE=<some dynamic registry identifier>
  238.                +---    DIFFERENTIATE="TRUE"
  239.  
  240.                +---    MIBID="1.3.4.7.3"
  241.                |       STARTSCALE=1000
  242.           Optional |       FREQUENCY="HIGH"
  243.                +---    SCALETYPE="LOG10"
  244.  
  245. */
  246.  
  247. #define HKEY_PERF_ROOT            HKEY_LOCAL_MACHINE
  248. #define PERF_REG_KEY            "STATS"
  249. #define PERF_REG_NAME_SRV_NAME        "NAME"
  250. #define PERF_REG_NAME_STAT_NAME        "NAME"
  251. #define PERF_REG_NAME_STAT_FREQ        "FREQUENCY"
  252. #define PERF_REG_NAME_STAT_HANDLE    "HANDLE"
  253. #define PERF_REG_NAME_STAT_DESC        "DESCRIPTION"
  254. #define PERF_REG_NAME_STAT_VALUE    "VALUE"
  255. #define PERF_REG_NAME_STAT_DIFF        "DIFFERENTIATE"
  256. #define PERF_REG_NAME_STAT_SCALETYPE    "SCALETYPE"
  257. #define PERF_REG_NAME_STAT_STARTSCALE    "STARTSCALE"
  258.  
  259. #define PERF_REG_VAL_STAT_TRUE        "TRUE"
  260. #define PERF_REG_VAL_STAT_FALSE        "FALSE"
  261. #define PERF_REG_VAL_STAT_HIGH        "HIGH"
  262. #define PERF_REG_VAL_STAT_LOW        "LOW"
  263. #define PERF_REG_VAL_STAT_LINEAR    "LINEAR"
  264. #define PERF_REG_VAL_STAT_LOG10        "LOG10"
  265. #define PERF_STAT_PREFIX            "STAT"
  266.  
  267. /* complex stat defines */
  268.  
  269. #define PSTF_INT_COMPLEX    0x00000010
  270. #define PSTF_EXT_COMPLEX    0x00000020
  271. /* A complex statistic has no data value of its own-- it just defines two */
  272. /* or more regular stats that may be added together to appear as a single */
  273. /* value in the UI.  For example: VFAT->bytes written/sec and VFAT->bytes */
  274. /* read/sec are simplex (normal) stats that each have a data counter.     */
  275. /* VFAT->total bytes/sec is a complex stat made up of those two simplex   */
  276. /* stats.  When the UI wants to display a complex stat's value, it gets   */
  277. /* the data value for the simplex stats contained in it and adds those    */
  278. /* values together.  To define a complex stat, set either PSTF_INT_COMPLEX*/
  279. /* or PSTF_EXT_COMPLEX when registering the stat.  The pst0_pStatFunc     */
  280. /* member should be set to point at a table of pointers to strings        */
  281. /* containing the registry key names of the simplex stats.  The pointer   */
  282. /* table should be null-terminated.  If PSTF_INT_COMPLEX is set, all      */
  283. /* stats must be internal to the VxD.  If PST_EXT_COMPLEX, the stats can  */
  284. /* be from other VxDs (including the one registering the complex stat).   */
  285. /* For internal complex stats, the key names in the table are the same      */
  286. /* as the key names used to register the stat.  For example: VFAT         */
  287. /* registers itself with the "VFAT" key name, and registers two simple    */
  288. /* stats with "BReadSec" and "BWriteSec" key names.  It then registers a  */
  289. /* complex stat with a "BTotSec" key name, where the pst0_pStatFunc          */
  290. /* points to a table of pointers; the first pointer would point to        */
  291. /* "BReadSec", the next pointer in the table would point to "BWriteSec",  */
  292. /* and the next pointer would be NULL to signifiy the end of the list.    */
  293. /* This is convenient because the "BReadSec" string already exists.  If   */
  294. /* PSTF_EXT_COMPLEX is set, the strings that the pointer table points to  */
  295. /* also have to contain the registry key name of the VxD which registered */
  296. /* them.  In the above example, if VFAT were to set the PSTF_EXT_COMPLEX  */
  297. /* flag the strings pointed to by the table would have to be              */
  298. /* "VFAT\BReadSec" and "VFAT\BWriteSec".  The advantage of setting this   */
  299. /* flag is that you can specify external stats, like "NDIS\PacketsSec".   */
  300.  
  301. /* This is complicated to explain, but very easy to do.                   */
  302. /* See dos\dos386\vxd\perf\example\example.asm for an example of how to   */
  303. /* register a complex stat.                                               */
  304. #pragma option pop /*P_O_Pop*/
  305.