home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v1.zip / DDKX86 / H / PERFHOOK.H < prev    next >
C/C++ Source or Header  |  1995-04-14  |  12KB  |  229 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. /*****************************************************************************/
  13. /*static char *SCCSID = "@(#)perfhook.h    6.3 92/05/08";*/
  14. /*      SCCSID = @(#)perfhook.h    6.3 92/05/08                         */
  15. /***************************************************************************/
  16. /*                                                                         */
  17. /*                                                                         */
  18. /***************************************************************************/
  19. /*                                      */
  20. /*    Performance hook include file     */
  21. /*                                      */
  22.  
  23. #define PERFTRACE 1                             /* Set for major code '01' */
  24. #define PERFBIT x040                            /* Bit for major code 1    */
  25.  
  26. /***
  27.  *  Dekko card memory mapped I/O address data area
  28.  */
  29. struct Dekko_Addr
  30. {
  31.     unsigned long   reserved;           /* +0 - not used                   */
  32.     unsigned short  majmin_code;        /* +4 - Major (hi) minor (lo) code */
  33.     unsigned short  start_stop_sync;    /* +6 - not used                   */
  34.     unsigned long   perf_data_4byte;    /* +8 - 4 byte performance data    */
  35.     unsigned short  perf_data;          /* +C - 2 byte performance data    */
  36. };
  37.  
  38. #if defined(MMIOPH)
  39.  
  40. #if defined(PINBALL_MMIOPH)
  41. #define mmptr   far
  42. #else
  43. #define mmptr
  44. #endif
  45.  
  46.  
  47. /***
  48.  *  Local variables used by the performance hook internal macros
  49.  */
  50. static struct Dekko_Addr mmptr  *dekko_addr;
  51. static unsigned char mmptr      *dekko_ptr;
  52. static          short            dekko_idx;
  53. static unsigned long             dekko_quad;
  54.  
  55.  
  56. /***************************************************************************/
  57. /*                                                                         */
  58. /*  TEST_TRACING........... Determines if tracing is active for the given  */
  59. /*                          major code and if the "master" tracing switch  */
  60. /*                          is currently active.                           */
  61. /*                                                                         */
  62. /***************************************************************************/
  63.  
  64. #define TEST_TRACING(RMT,Maj)   \
  65.         (*RMT & 0x40) && (*(RMT+(Maj>>3)) & (0x80>>(Maj&7)))
  66.  
  67.  
  68. /***************************************************************************/
  69. /*                                                                         */
  70. /*  SET_DEKKO_ADDRESS...... Loads the dekko card address into the variable */
  71. /*                          "dekko_addr". Address value is obtained from   */
  72. /*                          the info segment data.                         */
  73. /*                                                                         */
  74. /***************************************************************************/
  75.  
  76. #define SET_DEKKO_ADDRESS(infoseg_ptr) \
  77.     dekko_addr = (struct Dekko_Addr *) infoseg_ptr.SIS_MMIOAddr;
  78.  
  79. #define SET_DEKKO_ADDRESS2(infoseg_ptr) \
  80.     dekko_addr = (struct Dekko_Addr *) infoseg_ptr->SIS_MMIOAddr;
  81.  
  82.  
  83. /***************************************************************************/
  84. /*                                                                         */
  85. /*  FORCE_WRITE............ Macro used to break the optimization of the    */
  86. /*                          C complier. This macro will force it to        */
  87. /*                          generate code for consecutive statements which */
  88. /*                          write to the same memory location. This may    */
  89. /*                          stop working without notice. It should be      */
  90. /*                          checked each time the "C" compiler is changed. */
  91. /*                                                                         */
  92. /***************************************************************************/
  93.  
  94. #define FORCE_WRITE if(dekko_addr!=0);
  95.  
  96.  
  97. /***************************************************************************/
  98. /*                                                                         */
  99. /*  WRITE_MAJ_MNR_CODES.... Writes the given major and minor codes into    */
  100. /*                          the "majmin_code" element of the dekko addr.   */
  101. /*                                                                         */
  102. /***************************************************************************/
  103.  
  104. #define WRITE_MAJMNR_CODES(MajMnr) dekko_addr->majmin_code = MajMnr;
  105.  
  106.  
  107. /***************************************************************************/
  108. /*                                                                         */
  109. /*  WRITE_BYTE_VALUE....... Writes the given byte value at the +C offset   */
  110. /*                          data area of the dekko card. The byte is       */
  111. /*                          written into the high byte of the data area    */
  112. /*                          and the low byte is padded with a zero.        */
  113. /*                                                                         */
  114. /***************************************************************************/
  115.  
  116. #define WRITE_BYTE_VALUE(val) \
  117.     dekko_addr->perf_data=(unsigned short)val; \
  118.     FORCE_WRITE
  119.  
  120.  
  121. /***************************************************************************/
  122. /*                                                                         */
  123. /*  WRITE_WORD_VALUE....... Writes the given word value at the +C offset   */
  124. /*                          data area of the dekko card.                   */
  125. /*                                                                         */
  126. /***************************************************************************/
  127.  
  128. #define WRITE_WORD_VALUE(val) \
  129.     dekko_addr->perf_data=(unsigned short)val; \
  130.     FORCE_WRITE
  131.  
  132.  
  133. /***************************************************************************/
  134. /*                                                                         */
  135. /*  WRITE_DWORD_VALUE...... Writes the double word value at the +8 offset  */
  136. /*                          data area of the dekko card.                   */
  137. /*                                                                         */
  138. /***************************************************************************/
  139.  
  140. #define WRITE_DWORD_VALUE(val) \
  141.     dekko_addr->perf_data_4byte=(unsigned long)val; \
  142.     FORCE_WRITE
  143.  
  144.  
  145. /***************************************************************************/
  146. /*                                                                         */
  147. /*  WRITE_BYTE_STREAM...... Write the stream of bytes indicated by         */
  148. /*                          dekko_ptr and dekko_idx to the +8 offset of    */
  149. /*                          the dekko card as a series of double words.    */
  150. /*                                                                         */
  151. /*  07/09/90 - Fixed extra quad written when last byte of string was on    */
  152. /*             the quad boundry.                                           */
  153. /*                                                                         */
  154. /***************************************************************************/
  155.  
  156. #define WRITE_BYTE_STREAM                    \
  157.         while (dekko_idx > 0) {              \
  158.             dekko_quad = *(long mmptr *)dekko_ptr; \
  159.             WRITE_DWORD_VALUE (dekko_quad)   \
  160.             dekko_ptr += 4; dekko_idx -= 4; }
  161.  
  162.  
  163. /***************************************************************************/
  164. /*                                                                         */
  165. /*  WRITE_ASCIIZ_STRING.... Writes the asciiz string to the dekko card as  */
  166. /*                          a series of double words to the +8 offset. The */
  167. /*                          final "dword" is padded with as many blanks as */
  168. /*                          needed. The null terminator is always written. */
  169. /*                                                                         */
  170. /*  06/21/90 - Modified to check for null string. Write zeros if NULL.     */
  171. /*                                                                         */
  172. /***************************************************************************/
  173.  
  174. #define WRITE_ASCIIZ_STRING(str)              \
  175.         if (str != NULL) {                    \
  176.             dekko_ptr = (unsigned char mmptr *)str; \
  177.             dekko_idx = 1;                    \
  178.             while (*dekko_ptr++) dekko_idx++; \
  179.             dekko_ptr = (unsigned char mmptr *)str; \
  180.             WRITE_BYTE_STREAM  }              \
  181.         else                                  \
  182.             WRITE_DWORD_VALUE(0)
  183.  
  184.  
  185. /***************************************************************************/
  186. /*                                                                         */
  187. /*  WRITE_NUMB_STRING...... Writes the length byte of the string to the +C */
  188. /*                          offset of the dekko card. The data part of the */
  189. /*                          string is then written to the +8 offset as a   */
  190. /*                          series of double words.                        */
  191. /*                                                                         */
  192. /*  06/21/90 - Fixed pointer incrememt problem. Also allowed for fact that */
  193. /*             length byte value includes the length byte.                 */
  194. /*                                                                         */
  195. /***************************************************************************/
  196.  
  197. #define WRITE_NUMB_STRING(str)                \
  198.         if (str != NULL) {                    \
  199.             dekko_ptr = (unsigned char mmptr *)str; \
  200.             dekko_idx = *dekko_ptr - 1;       \
  201.             dekko_ptr++;                      \
  202.             WRITE_WORD_VALUE (dekko_idx)      \
  203.             WRITE_BYTE_STREAM }               \
  204.         else                                  \
  205.             WRITE_DWORD_VALUE(0)
  206.  
  207.  
  208. #if defined(PINBALL_MMIOPH)
  209. /***************************************************************************/
  210. /*                                                                         */
  211. /*  WRITE_CRACKED_PATH..... Writes a cracked path to the dekko card. See   */
  212. /*                          file \drv6\src\pinball\hdrs\misc.h for cracked */
  213. /*                          path structure.                                */
  214. /*                                                                         */
  215. /***************************************************************************/
  216.  
  217. #define WRITE_CRACKED_PATH(pckpth)              \
  218.         {   unsigned char far *p = &(pckpth->sp.c); \
  219.             unsigned char far *ep= p-2;             \
  220.             ep += pckpth->cbPath; ep += *ep;    \
  221.             WRITE_WORD_VALUE (pckpth->hVPB)     \
  222.             WRITE_WORD_VALUE (pckpth->cbPath)   \
  223.             while (p!=ep){WRITE_NUMB_STRING(p) p+=*p;}\
  224.         }
  225. #endif
  226.  
  227.  
  228. #endif
  229.