VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / linux / oprofile.h
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 <linux/spinlock.h>
18 #include <asm/atomic.h>
19  
20 struct super_block;
21 struct dentry;
22 struct file_operations;
23  
24 /* Operations structure to be filled in */
25 struct 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         /* CPU identification string. */
38         char * cpu_type;
39 };
40
41 /**
42  * One-time initialisation. *ops must be set to a filled-in
43  * operations structure. This is called even in timer interrupt
44  * mode.
45  *
46  * Return 0 on success.
47  */
48 int oprofile_arch_init(struct oprofile_operations ** ops);
49  
50 /**
51  * One-time exit/cleanup for the arch.
52  */
53 void oprofile_arch_exit(void);
54
55 /**
56  * Add a sample. This may be called from any context. Pass
57  * smp_processor_id() as cpu.
58  */
59 extern void oprofile_add_sample(unsigned long eip, unsigned int is_kernel, 
60         unsigned long event, int cpu);
61
62 /**
63  * Create a file of the given name as a child of the given root, with
64  * the specified file operations.
65  */
66 int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
67         char const * name, struct file_operations * fops);
68
69 int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
70         char const * name, struct file_operations * fops, int perm);
71  
72 /** Create a file for read/write access to an unsigned long. */
73 int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
74         char const * name, ulong * val);
75  
76 /** Create a file for read-only access to an unsigned long. */
77 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
78         char const * name, ulong * val);
79  
80 /** Create a file for read-only access to an atomic_t. */
81 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
82         char const * name, atomic_t * val);
83  
84 /** create a directory */
85 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
86         char const * name);
87
88 /**
89  * Write the given asciz string to the given user buffer @buf, updating *offset
90  * appropriately. Returns bytes written or -EFAULT.
91  */
92 ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
93
94 /**
95  * Convert an unsigned long value into ASCII and copy it to the user buffer @buf,
96  * updating *offset appropriately. Returns bytes written or -EFAULT.
97  */
98 ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
99
100 /**
101  * Read an ASCII string for a number from a userspace buffer and fill *val on success.
102  * Returns 0 on success, < 0 on error.
103  */
104 int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
105
106 /** lock for read/write safety */
107 extern spinlock_t oprofilefs_lock;
108  
109 #endif /* OPROFILE_H */