]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/powerpc/oprofile/cell/pr_util.h
Pull osi into release branch
[linux-3.10.git] / arch / powerpc / oprofile / cell / pr_util.h
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
14 #ifndef PR_UTIL_H
15 #define PR_UTIL_H
16
17 #include <linux/cpumask.h>
18 #include <linux/oprofile.h>
19 #include <asm/cell-pmu.h>
20 #include <asm/spu.h>
21
22 #include "../../platforms/cell/cbe_regs.h"
23
24 /* Defines used for sync_start */
25 #define SKIP_GENERIC_SYNC 0
26 #define SYNC_START_ERROR -1
27 #define DO_GENERIC_SYNC 1
28
29 struct spu_overlay_info {       /* map of sections within an SPU overlay */
30         unsigned int vma;       /* SPU virtual memory address from elf */
31         unsigned int size;      /* size of section from elf */
32         unsigned int offset;    /* offset of section into elf file */
33         unsigned int buf;
34 };
35
36 struct vma_to_fileoffset_map {  /* map of sections within an SPU program */
37         struct vma_to_fileoffset_map *next;     /* list pointer */
38         unsigned int vma;       /* SPU virtual memory address from elf */
39         unsigned int size;      /* size of section from elf */
40         unsigned int offset;    /* offset of section into elf file */
41         unsigned int guard_ptr;
42         unsigned int guard_val;
43         /*
44          * The guard pointer is an entry in the _ovly_buf_table,
45          * computed using ovly.buf as the index into the table.  Since
46          * ovly.buf values begin at '1' to reference the first (or 0th)
47          * entry in the _ovly_buf_table, the computation subtracts 1
48          * from ovly.buf.
49          * The guard value is stored in the _ovly_buf_table entry and
50          * is an index (starting at 1) back to the _ovly_table entry
51          * that is pointing at this _ovly_buf_table entry.  So, for
52          * example, for an overlay scenario with one overlay segment
53          * and two overlay sections:
54          *      - Section 1 points to the first entry of the
55          *        _ovly_buf_table, which contains a guard value
56          *        of '1', referencing the first (index=0) entry of
57          *        _ovly_table.
58          *      - Section 2 points to the second entry of the
59          *        _ovly_buf_table, which contains a guard value
60          *        of '2', referencing the second (index=1) entry of
61          *        _ovly_table.
62          */
63
64 };
65
66 /* The three functions below are for maintaining and accessing
67  * the vma-to-fileoffset map.
68  */
69 struct vma_to_fileoffset_map *create_vma_map(const struct spu *spu,
70                                              u64 objectid);
71 unsigned int vma_map_lookup(struct vma_to_fileoffset_map *map,
72                             unsigned int vma, const struct spu *aSpu,
73                             int *grd_val);
74 void vma_map_free(struct vma_to_fileoffset_map *map);
75
76 /*
77  * Entry point for SPU profiling.
78  * cycles_reset is the SPU_CYCLES count value specified by the user.
79  */
80 int start_spu_profiling(unsigned int cycles_reset);
81
82 void stop_spu_profiling(void);
83
84
85 /* add the necessary profiling hooks */
86 int spu_sync_start(void);
87
88 /* remove the hooks */
89 int spu_sync_stop(void);
90
91 /* Record SPU program counter samples to the oprofile event buffer. */
92 void spu_sync_buffer(int spu_num, unsigned int *samples,
93                      int num_samples);
94
95 void set_spu_profiling_frequency(unsigned int freq_khz, unsigned int cycles_reset);
96
97 #endif    /* PR_UTIL_H */