perfmon.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * This file contains the code to configure and utilize the ppc64 pmc hardware
  3.  * Copyright (C) 2002 David Engebretsen <engebret@us.ibm.com>
  4.  */
  5. #ifndef __KERNEL__
  6. #define INLINE_SYSCALL(arg1, arg2)       
  7.   ({                                            
  8.     register long r0 __asm__ ("r0");     
  9.     register long r3 __asm__ ("r3"); 
  10.     register long r4 __asm__ ("r4"); 
  11.     long ret, err;                              
  12.     r0 = 208; 
  13.     r3 = (long) (arg1); 
  14.     r4 = (long) (arg2); 
  15.     __asm__ ("scnt"                           
  16.              "mfcr      %1nt"                 
  17.              : "=r" (r3), "=r" (err)            
  18.              : "r" (r0), "r" (r3), "r" (r4) 
  19.              : "cc", "memory");                 
  20.     ret = r3;                                   
  21.   })
  22. #endif
  23. #ifndef __ASSEMBLY__
  24. struct perfmon_base_struct {
  25. u64 profile_buffer;
  26. u64 profile_length;
  27. u64 trace_buffer;
  28. u64 trace_length;
  29. u64 trace_end;
  30. u64 state;
  31. };
  32. struct pmc_header {
  33. int type;
  34. int pid;
  35. int resv[30];
  36. };
  37. struct pmc_struct {
  38.         int pmc[11];
  39. };
  40. struct pmc_info_struct {
  41. unsigned int mode, cpu;
  42. unsigned int  pmc_base[11];
  43. unsigned long pmc_cumulative[8];
  44. };
  45. struct perfmon_struct {
  46. struct pmc_header header;
  47. union {
  48. struct pmc_struct      pmc;
  49. struct pmc_info_struct pmc_info;
  50.   } vdata;
  51. };
  52. enum {
  53. PMC_OP_ALLOC         = 1,
  54. PMC_OP_FREE          = 2,
  55. PMC_OP_CLEAR         = 4,
  56. PMC_OP_DUMP          = 5,
  57. PMC_OP_DUMP_HARDWARE = 6,
  58. PMC_OP_DECR_PROFILE  = 20,
  59. PMC_OP_PMC_PROFILE   = 21,
  60. PMC_OP_SET           = 30,
  61. PMC_OP_SET_USER      = 31,
  62. PMC_OP_END           = 30
  63. };
  64. #define PMC_TRACE_CMD 0xFF
  65. enum {
  66. PMC_TYPE_DERC_PROFILE  = 1,
  67. PMC_TYPE_CYCLE         = 2,
  68. PMC_TYPE_PROFILE       = 3,
  69. PMC_TYPE_DCACHE        = 4,
  70. PMC_TYPE_L2_MISS       = 5,
  71. PMC_TYPE_LWARCX        = 6,
  72. PMC_TYPE_END           = 6
  73. };
  74. #endif
  75. #define PMC_STATE_INITIAL         0x00
  76. #define PMC_STATE_READY           0x01
  77. #define PMC_STATE_DECR_PROFILE    0x10
  78. #define PMC_STATE_PROFILE_KERN    0x11
  79. #define PMC_STATE_TRACE_KERN      0x20
  80. #define PMC_STATE_TRACE_USER      0x21