pr_util.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Cell Broadband Engine OProfile Support
  3. *
  4. * (C) Copyright IBM Corporation 2006
  5. *
  6. * Author: Maynard Johnson <maynardj@us.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #ifndef PR_UTIL_H
  14. #define PR_UTIL_H
  15. #include <linux/cpumask.h>
  16. #include <linux/oprofile.h>
  17. #include <asm/cell-pmu.h>
  18. #include <asm/cell-regs.h>
  19. #include <asm/spu.h>
  20. /* Defines used for sync_start */
  21. #define SKIP_GENERIC_SYNC 0
  22. #define SYNC_START_ERROR -1
  23. #define DO_GENERIC_SYNC 1
  24. #define SPUS_PER_NODE 8
  25. #define DEFAULT_TIMER_EXPIRE (HZ / 10)
  26. extern struct delayed_work spu_work;
  27. extern int spu_prof_running;
  28. struct spu_overlay_info { /* map of sections within an SPU overlay */
  29. unsigned int vma; /* SPU virtual memory address from elf */
  30. unsigned int size; /* size of section from elf */
  31. unsigned int offset; /* offset of section into elf file */
  32. unsigned int buf;
  33. };
  34. struct vma_to_fileoffset_map { /* map of sections within an SPU program */
  35. struct vma_to_fileoffset_map *next; /* list pointer */
  36. unsigned int vma; /* SPU virtual memory address from elf */
  37. unsigned int size; /* size of section from elf */
  38. unsigned int offset; /* offset of section into elf file */
  39. unsigned int guard_ptr;
  40. unsigned int guard_val;
  41. /*
  42. * The guard pointer is an entry in the _ovly_buf_table,
  43. * computed using ovly.buf as the index into the table. Since
  44. * ovly.buf values begin at '1' to reference the first (or 0th)
  45. * entry in the _ovly_buf_table, the computation subtracts 1
  46. * from ovly.buf.
  47. * The guard value is stored in the _ovly_buf_table entry and
  48. * is an index (starting at 1) back to the _ovly_table entry
  49. * that is pointing at this _ovly_buf_table entry. So, for
  50. * example, for an overlay scenario with one overlay segment
  51. * and two overlay sections:
  52. * - Section 1 points to the first entry of the
  53. * _ovly_buf_table, which contains a guard value
  54. * of '1', referencing the first (index=0) entry of
  55. * _ovly_table.
  56. * - Section 2 points to the second entry of the
  57. * _ovly_buf_table, which contains a guard value
  58. * of '2', referencing the second (index=1) entry of
  59. * _ovly_table.
  60. */
  61. };
  62. struct spu_buffer {
  63. int last_guard_val;
  64. int ctx_sw_seen;
  65. unsigned long *buff;
  66. unsigned int head, tail;
  67. };
  68. /* The three functions below are for maintaining and accessing
  69. * the vma-to-fileoffset map.
  70. */
  71. struct vma_to_fileoffset_map *create_vma_map(const struct spu *spu,
  72. u64 objectid);
  73. unsigned int vma_map_lookup(struct vma_to_fileoffset_map *map,
  74. unsigned int vma, const struct spu *aSpu,
  75. int *grd_val);
  76. void vma_map_free(struct vma_to_fileoffset_map *map);
  77. /*
  78. * Entry point for SPU profiling.
  79. * cycles_reset is the SPU_CYCLES count value specified by the user.
  80. */
  81. int start_spu_profiling(unsigned int cycles_reset);
  82. void stop_spu_profiling(void);
  83. /* add the necessary profiling hooks */
  84. int spu_sync_start(void);
  85. /* remove the hooks */
  86. int spu_sync_stop(void);
  87. /* Record SPU program counter samples to the oprofile event buffer. */
  88. void spu_sync_buffer(int spu_num, unsigned int *samples,
  89. int num_samples);
  90. void set_spu_profiling_frequency(unsigned int freq_khz, unsigned int cycles_reset);
  91. #endif /* PR_UTIL_H */