]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/powerpc/oprofile/cell/pr_util.h
Merge branch 'bkl/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic...
[mirror_ubuntu-bionic-kernel.git] / arch / powerpc / oprofile / cell / pr_util.h
CommitLineData
1474855d
BN
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>
eef686a0 20#include <asm/cell-regs.h>
1474855d
BN
21#include <asm/spu.h>
22
1474855d
BN
23/* Defines used for sync_start */
24#define SKIP_GENERIC_SYNC 0
25#define SYNC_START_ERROR -1
26#define DO_GENERIC_SYNC 1
a5598ca0
CL
27#define SPUS_PER_NODE 8
28#define DEFAULT_TIMER_EXPIRE (HZ / 10)
29
30extern struct delayed_work spu_work;
31extern int spu_prof_running;
1474855d 32
88382329
CL
33#define TRACE_ARRAY_SIZE 1024
34
35extern spinlock_t oprof_spu_smpl_arry_lck;
36
1474855d
BN
37struct spu_overlay_info { /* map of sections within an SPU overlay */
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 buf;
42};
43
44struct vma_to_fileoffset_map { /* map of sections within an SPU program */
45 struct vma_to_fileoffset_map *next; /* list pointer */
46 unsigned int vma; /* SPU virtual memory address from elf */
47 unsigned int size; /* size of section from elf */
48 unsigned int offset; /* offset of section into elf file */
49 unsigned int guard_ptr;
50 unsigned int guard_val;
51 /*
52 * The guard pointer is an entry in the _ovly_buf_table,
53 * computed using ovly.buf as the index into the table. Since
54 * ovly.buf values begin at '1' to reference the first (or 0th)
55 * entry in the _ovly_buf_table, the computation subtracts 1
56 * from ovly.buf.
57 * The guard value is stored in the _ovly_buf_table entry and
58 * is an index (starting at 1) back to the _ovly_table entry
59 * that is pointing at this _ovly_buf_table entry. So, for
60 * example, for an overlay scenario with one overlay segment
61 * and two overlay sections:
62 * - Section 1 points to the first entry of the
63 * _ovly_buf_table, which contains a guard value
64 * of '1', referencing the first (index=0) entry of
65 * _ovly_table.
66 * - Section 2 points to the second entry of the
67 * _ovly_buf_table, which contains a guard value
68 * of '2', referencing the second (index=1) entry of
69 * _ovly_table.
70 */
71
72};
73
a5598ca0
CL
74struct spu_buffer {
75 int last_guard_val;
76 int ctx_sw_seen;
77 unsigned long *buff;
78 unsigned int head, tail;
79};
80
81
1474855d
BN
82/* The three functions below are for maintaining and accessing
83 * the vma-to-fileoffset map.
84 */
85struct vma_to_fileoffset_map *create_vma_map(const struct spu *spu,
9b635642 86 unsigned long objectid);
1474855d
BN
87unsigned int vma_map_lookup(struct vma_to_fileoffset_map *map,
88 unsigned int vma, const struct spu *aSpu,
89 int *grd_val);
90void vma_map_free(struct vma_to_fileoffset_map *map);
91
92/*
93 * Entry point for SPU profiling.
94 * cycles_reset is the SPU_CYCLES count value specified by the user.
95 */
014cef91 96int start_spu_profiling_cycles(unsigned int cycles_reset);
88382329 97void start_spu_profiling_events(void);
1474855d 98
014cef91 99void stop_spu_profiling_cycles(void);
88382329 100void stop_spu_profiling_events(void);
1474855d
BN
101
102/* add the necessary profiling hooks */
103int spu_sync_start(void);
104
105/* remove the hooks */
106int spu_sync_stop(void);
107
108/* Record SPU program counter samples to the oprofile event buffer. */
109void spu_sync_buffer(int spu_num, unsigned int *samples,
110 int num_samples);
111
112void set_spu_profiling_frequency(unsigned int freq_khz, unsigned int cycles_reset);
113
114#endif /* PR_UTIL_H */