Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 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
/** Create a file for read/write access to an unsigned long. */
70
int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71
        char const * name, ulong * val);
72
 
73
/** Create a file for read-only access to an unsigned long. */
74
int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75
        char const * name, ulong * val);
76
 
77
/** Create a file for read-only access to an atomic_t. */
78
int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
79
        char const * name, atomic_t * val);
80
 
81
/** create a directory */
82
struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
83
        char const * name);
84
 
85
/**
86
 * Write the given asciz string to the given user buffer @buf, updating *offset
87
 * appropriately. Returns bytes written or -EFAULT.
88
 */
89
ssize_t oprofilefs_str_to_user(char const * str, char * buf, size_t count, loff_t * offset);
90
 
91
/**
92
 * Convert an unsigned long value into ASCII and copy it to the user buffer @buf,
93
 * updating *offset appropriately. Returns bytes written or -EFAULT.
94
 */
95
ssize_t oprofilefs_ulong_to_user(unsigned long val, char * buf, size_t count, loff_t * offset);
96
 
97
/**
98
 * Read an ASCII string for a number from a userspace buffer and fill *val on success.
99
 * Returns 0 on success, < 0 on error.
100
 */
101
int oprofilefs_ulong_from_user(unsigned long * val, char const * buf, size_t count);
102
 
103
/** lock for read/write safety */
104
extern spinlock_t oprofilefs_lock;
105
 
106
#endif /* OPROFILE_H */