Path: blob/master/arch/powerpc/oprofile/cell/pr_util.h
10818 views
/*1* Cell Broadband Engine OProfile Support2*3* (C) Copyright IBM Corporation 20064*5* Author: Maynard Johnson <[email protected]>6*7* This program is free software; you can redistribute it and/or8* modify it under the terms of the GNU General Public License9* as published by the Free Software Foundation; either version10* 2 of the License, or (at your option) any later version.11*/1213#ifndef PR_UTIL_H14#define PR_UTIL_H1516#include <linux/cpumask.h>17#include <linux/oprofile.h>18#include <asm/cell-pmu.h>19#include <asm/cell-regs.h>20#include <asm/spu.h>2122/* Defines used for sync_start */23#define SKIP_GENERIC_SYNC 024#define SYNC_START_ERROR -125#define DO_GENERIC_SYNC 126#define SPUS_PER_NODE 827#define DEFAULT_TIMER_EXPIRE (HZ / 10)2829extern struct delayed_work spu_work;30extern int spu_prof_running;3132#define TRACE_ARRAY_SIZE 10243334extern spinlock_t oprof_spu_smpl_arry_lck;3536struct spu_overlay_info { /* map of sections within an SPU overlay */37unsigned int vma; /* SPU virtual memory address from elf */38unsigned int size; /* size of section from elf */39unsigned int offset; /* offset of section into elf file */40unsigned int buf;41};4243struct vma_to_fileoffset_map { /* map of sections within an SPU program */44struct vma_to_fileoffset_map *next; /* list pointer */45unsigned int vma; /* SPU virtual memory address from elf */46unsigned int size; /* size of section from elf */47unsigned int offset; /* offset of section into elf file */48unsigned int guard_ptr;49unsigned int guard_val;50/*51* The guard pointer is an entry in the _ovly_buf_table,52* computed using ovly.buf as the index into the table. Since53* ovly.buf values begin at '1' to reference the first (or 0th)54* entry in the _ovly_buf_table, the computation subtracts 155* from ovly.buf.56* The guard value is stored in the _ovly_buf_table entry and57* is an index (starting at 1) back to the _ovly_table entry58* that is pointing at this _ovly_buf_table entry. So, for59* example, for an overlay scenario with one overlay segment60* and two overlay sections:61* - Section 1 points to the first entry of the62* _ovly_buf_table, which contains a guard value63* of '1', referencing the first (index=0) entry of64* _ovly_table.65* - Section 2 points to the second entry of the66* _ovly_buf_table, which contains a guard value67* of '2', referencing the second (index=1) entry of68* _ovly_table.69*/7071};7273struct spu_buffer {74int last_guard_val;75int ctx_sw_seen;76unsigned long *buff;77unsigned int head, tail;78};798081/* The three functions below are for maintaining and accessing82* the vma-to-fileoffset map.83*/84struct vma_to_fileoffset_map *create_vma_map(const struct spu *spu,85unsigned long objectid);86unsigned int vma_map_lookup(struct vma_to_fileoffset_map *map,87unsigned int vma, const struct spu *aSpu,88int *grd_val);89void vma_map_free(struct vma_to_fileoffset_map *map);9091/*92* Entry point for SPU profiling.93* cycles_reset is the SPU_CYCLES count value specified by the user.94*/95int start_spu_profiling_cycles(unsigned int cycles_reset);96void start_spu_profiling_events(void);9798void stop_spu_profiling_cycles(void);99void stop_spu_profiling_events(void);100101/* add the necessary profiling hooks */102int spu_sync_start(void);103104/* remove the hooks */105int spu_sync_stop(void);106107/* Record SPU program counter samples to the oprofile event buffer. */108void spu_sync_buffer(int spu_num, unsigned int *samples,109int num_samples);110111void set_spu_profiling_frequency(unsigned int freq_khz, unsigned int cycles_reset);112113#endif /* PR_UTIL_H */114115116