source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/oprofile.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 3.6 KB
Line 
1/**
2 * @file oprofile.h
3 *
4 * API for machine-specific interrupts to interface
5 * to oprofile.
6 *
7 * @remark Copyright 2002 OProfile authors
8 * @remark Read the file COPYING
9 *
10 * @author John Levon <levon@movementarian.org>
11 */
12
13#ifndef OPROFILE_H
14#define OPROFILE_H
15
16#include <linux/types.h>
17#include <asm/atomic.h>
18 
19struct super_block;
20struct dentry;
21struct file_operations;
22struct pt_regs;
23 
24/* Operations structure to be filled in */
25struct oprofile_operations {
26        /* create any necessary configuration files in the oprofile fs.
27         * Optional. */
28        int (*create_files)(struct super_block * sb, struct dentry * root);
29        /* Do any necessary interrupt setup. Optional. */
30        int (*setup)(void);
31        /* Do any necessary interrupt shutdown. Optional. */
32        void (*shutdown)(void);
33        /* Start delivering interrupts. */
34        int (*start)(void);
35        /* Stop delivering interrupts. */
36        void (*stop)(void);
37        /* Initiate a stack backtrace. Optional. */
38        void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
39        /* CPU identification string. */
40        char * cpu_type;
41};
42
43/**
44 * One-time initialisation. *ops must be set to a filled-in
45 * operations structure. This is called even in timer interrupt
46 * mode so an arch can set a backtrace callback.
47 *
48 * If an error occurs, the fields should be left untouched.
49 */
50int oprofile_arch_init(struct oprofile_operations * ops);
51 
52/**
53 * One-time exit/cleanup for the arch.
54 */
55void oprofile_arch_exit(void);
56
57/**
58 * Add a sample. This may be called from any context. Pass
59 * smp_processor_id() as cpu.
60 */
61void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
62
63/* Use this instead when the PC value is not from the regs. Doesn't
64 * backtrace. */
65void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
66
67/* add a backtrace entry, to be called from the ->backtrace callback */
68void oprofile_add_trace(unsigned long eip);
69
70
71/**
72 * Create a file of the given name as a child of the given root, with
73 * the specified file operations.
74 */
75int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
76        char const * name, struct file_operations * fops);
77
78int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
79        char const * name, struct file_operations * fops, int perm);
80 
81/** Create a file for read/write access to an unsigned long. */
82int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
83        char const * name, ulong * val);
84 
85/** Create a file for read-only access to an unsigned long. */
86int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
87        char const * name, ulong * val);
88 
89/** Create a file for read-only access to an atomic_t. */
90int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
91        char const * name, atomic_t * val);
92 
93/** create a directory */
94struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
95        char const * name);
96
97/**
98 * Write the given asciz string to the given user buffer @buf, updating *offset
99 * appropriately. Returns bytes written or -EFAULT.
100 */
101ssize_t oprofilefs_str_to_user(char const * str, char * buf, size_t count, loff_t * offset);
102
103/**
104 * Convert an unsigned long value into ASCII and copy it to the user buffer @buf,
105 * updating *offset appropriately. Returns bytes written or -EFAULT.
106 */
107ssize_t oprofilefs_ulong_to_user(unsigned long val, char * buf, size_t count, loff_t * offset);
108
109/**
110 * Read an ASCII string for a number from a userspace buffer and fill *val on success.
111 * Returns 0 on success, < 0 on error.
112 */
113int oprofilefs_ulong_from_user(unsigned long * val, char const * buf, size_t count);
114
115/** lock for read/write safety */
116extern spinlock_t oprofilefs_lock;
117 
118#endif /* OPROFILE_H */
Note: See TracBrowser for help on using the repository browser.