1/* 2 * Copyright 2014, General Dynamics C4 Systems 3 * 4 * This software may be distributed and modified according to the terms of 5 * the GNU General Public License version 2. Note that NO WARRANTY is provided. 6 * See "LICENSE_GPLv2.txt" for details. 7 * 8 * @TAG(GD_GPL) 9 */ 10 11/* 12 * Profiler Interface 13 * 14 * 2006 - 2007 David Greenaway 15 * 2007 Ported to seL4 C kernel by Philip Derrin 16 */ 17 18#ifndef __MACHINE__PROFILER_H__ 19#define __MACHINE__PROFILER_H__ 20 21#include <machine/registerset.h> 22#include <machine/hardware.h> 23 24#ifdef PROFILER 25 26/* Approximate number of unique addresses that we can record. 27 * 28 * This value corresponds to the size of a hash table, and needs 29 * to be a prime number to ensure correctness. 30 */ 31//#define MAX_UNIQUE_INSTRUCTIONS ((256 * 1024) + 3) /* 262147 is prime */ 32/* Downsized to fit in the default 1M kernel section - davec */ 33#define MAX_UNIQUE_INSTRUCTIONS 94349 34 35#define MAX_UNIQUE_CHECKPOINTS 2000 36 37/* Record the given program counter */ 38void profiler_record_sample(word_t pc) VISIBLE; 39 40/* Reset all counters */ 41void profiler_reset(void); 42 43/* List the recorded values to stdout */ 44void profiler_list(void); 45 46/* Should we be profiling the system? */ 47extern bool_t profiler_enabled; 48 49/* Set the current status of the profiler */ 50static inline void profiler_set_enabled(bool_t enabled) 51{ 52 profiler_enabled = enabled; 53} 54 55/* Get the current status of the profiler */ 56static inline bool_t profiler_is_enabled(void) 57{ 58 return profiler_enabled; 59} 60 61/* Number of entries the profiler currently keeps track of */ 62extern int profiler_num_entries; 63 64/* Number of instructions the profiler could not record */ 65extern long long profiler_dropped_instructions; 66 67/* The instructions recorded by the profiler */ 68typedef struct { 69 word_t pc; 70 word_t count; 71} profiler_entry_t; 72 73#ifdef CHECKPOINT_PROFILER 74extern volatile unsigned int checkpoint; 75extern profiler_entry_t profiler_entries[MAX_UNIQUE_CHECKPOINTS]; 76#else 77extern profiler_entry_t profiler_entries[MAX_UNIQUE_INSTRUCTIONS]; 78#endif 79 80#endif /* PROFILER */ 81 82#endif /* !__MACHINE__PROFILER_H__ */ 83 84