trace_prof.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2001 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #ifndef __ASM_SIBYTE_TRACE_PROF_H
  19. #define __ASM_SIBYTE_TRACE_PROF_H
  20. #undef DBG
  21. #if SBPROF_TB_DEBUG
  22. #define DBG(a) a
  23. #else
  24. #define DBG(a)
  25. #endif
  26. #define SBPROF_TB_MAJOR 240
  27. #define DEVNAME "bcm1250_tbprof"
  28. typedef u_int64_t tb_sample_t[6*256];
  29. struct sbprof_tb {
  30. int open;
  31. tb_sample_t *sbprof_tbbuf;
  32. int next_tb_sample;
  33. volatile int tb_enable;
  34. volatile int tb_armed;
  35. wait_queue_head_t tb_sync;
  36. wait_queue_head_t tb_read;
  37. };
  38. #define MAX_SAMPLE_BYTES (24*1024*1024)
  39. #define MAX_TBSAMPLE_BYTES (12*1024*1024)
  40. #define MAX_SAMPLES (MAX_SAMPLE_BYTES/sizeof(u_int32_t))
  41. #define TB_SAMPLE_SIZE (sizeof(tb_sample_t))
  42. #define MAX_TB_SAMPLES (MAX_TBSAMPLE_BYTES/TB_SAMPLE_SIZE)
  43. /* IOCTLs */
  44. #define SBPROF_ZBSTART _IOW('s', 0, int)
  45. #define SBPROF_ZBSTOP _IOW('s', 1, int)
  46. #define SBPROF_ZBWAITFULL _IOW('s', 2, int)
  47. /***************************************************************************
  48. * Routines for gathering ZBbus profiles using trace buffer
  49. ***************************************************************************/
  50. /* Requires: Already called zclk_timer_init with a value that won't
  51. saturate 40 bits. No subsequent use of SCD performance counters
  52. or trace buffer.
  53. Effect: Starts gathering random ZBbus profiles using trace buffer. */
  54. extern int sbprof_zbprof_start(struct file *filp);
  55. /* Effect: Stops collection of ZBbus profiles */
  56. extern int sbprof_zbprof_stop(void);
  57. /***************************************************************************
  58. * Routines for using 40-bit SCD cycle counter
  59. *
  60. * Client responsible for either handling interrupts or making sure
  61. * the cycles counter never saturates, e.g., by doing
  62. * zclk_timer_init(0) at least every 2^40 - 1 ZCLKs.
  63. ***************************************************************************/
  64. /* Configures SCD counter 0 to count ZCLKs starting from val;
  65. Configures SCD counters1,2,3 to count nothing.
  66. Must not be called while gathering ZBbus profiles.
  67. unsigned long long val; */
  68. #define zclk_timer_init(val) \
  69. __asm__ __volatile__ (".set push;" \
  70. ".set mips64;" \
  71. "la $8, 0xb00204c0;" /* SCD perf_cnt_cfg */ \
  72. "sd %0, 0x10($8);" /* write val to counter0 */ \
  73. "sd %1, 0($8);" /* config counter0 for zclks*/ \
  74. ".set pop" \
  75. : /* no outputs */ \
  76. /* enable, counter0 */ \
  77. : /* inputs */ "r"(val), "r" ((1ULL << 33) | 1ULL) \
  78. : /* modifies */ "$8" )
  79. /* Reads SCD counter 0 and puts result in value
  80. unsigned long long val; */
  81. #define zclk_get(val) \
  82. __asm__ __volatile__ (".set push;" \
  83. ".set mips64;" \
  84. "la $8, 0xb00204c0;" /* SCD perf_cnt_cfg */ \
  85. "ld %0, 0x10($8);" /* write val to counter0 */ \
  86. ".set pop" \
  87. : /* outputs */ "=r"(val) \
  88. : /* inputs */ \
  89. : /* modifies */ "$8" )
  90. #endif /* __ASM_SIBYTE_TRACE_PROF_H */