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

Linux/Unix编程

开发平台:

Unix_Linux

  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 BCM1250_TBPROF_H
  19. #if SBPROF_TB_DEBUG
  20. #define DBG(a) a
  21. #else
  22. #define DBG(a)
  23. #endif
  24. #define SBPROF_TB_MAJOR 240
  25. typedef u_int64_t tb_sample_t[6*256];
  26. struct sbprof_tb {
  27. tb_sample_t *sbprof_tbbuf;
  28. int          next_tb_sample;
  29. volatile int tb_enable;
  30. volatile int tb_armed;
  31. wait_queue_head_t tb_sync;
  32. };
  33. #define MAX_SAMPLE_BYTES (24*1024*1024)
  34. #define MAX_TBSAMPLE_BYTES (12*1024*1024)
  35. #define MAX_SAMPLES (MAX_SAMPLE_BYTES/sizeof(u_int32_t))
  36. #define TB_SAMPLE_SIZE (sizeof(tb_sample_t))
  37. #define MAX_TB_SAMPLES (MAX_TBSAMPLE_BYTES/TB_SAMPLE_SIZE)
  38. /***************************************************************************
  39.  * Routines for gathering ZBbus profiles using trace buffer
  40.  ***************************************************************************/
  41. /* Requires: Already called zclk_timer_init with a value that won't
  42.      saturate 40 bits.  No subsequent use of SCD performance counters
  43.      or trace buffer.
  44.    Effect:   Starts gathering random ZBbus profiles using trace buffer. */
  45. static int sbprof_zbprof_start(struct file *filp);
  46. /* Effect: Stops collection of ZBbus profiles */
  47. static int sbprof_zbprof_stop(void);
  48. /***************************************************************************
  49.  * Routines for using 40-bit SCD cycle counter
  50.  *
  51.  * Client responsible for either handling interrupts or making sure
  52.  * the cycles counter never saturates, e.g., by doing
  53.  * zclk_timer_init(0) at least every 2^40 - 1 ZCLKs.
  54.  ***************************************************************************/
  55. /* Configures SCD counter 0 to count ZCLKs starting from val;
  56.    Configures SCD counters1,2,3 to count nothing.
  57.    Must not be called while gathering ZBbus profiles.
  58. unsigned long long val; */
  59. #define zclk_timer_init(val) 
  60.   __asm__ __volatile__ (".set push;" 
  61. ".set mips64;" 
  62. "la   $8, 0xb00204c0;" /* SCD perf_cnt_cfg */ 
  63. "sd   %0, 0x10($8);"   /* write val to counter0 */ 
  64. "sd   %1, 0($8);"      /* config counter0 for zclks*/ 
  65. ".set pop" 
  66. : /* no outputs */ 
  67.      /* enable, counter0 */ 
  68. : /* inputs */ "r"(val), "r" ((1ULL << 33) | 1ULL) 
  69. : /* modifies */ "$8" )
  70. /* Reads SCD counter 0 and puts result in value
  71.    unsigned long long val; */
  72. #define zclk_get(val) 
  73.   __asm__ __volatile__ (".set push;" 
  74. ".set mips64;" 
  75. "la   $8, 0xb00204c0;" /* SCD perf_cnt_cfg */ 
  76. "ld   %0, 0x10($8);"   /* write val to counter0 */ 
  77. ".set pop" 
  78. : /* outputs */ "=r"(val) 
  79. : /* inputs */ 
  80. : /* modifies */ "$8" )
  81. #endif