uwb: add the UWB stack (debug support)
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / oprofile.h
blob041bb31100f48fd780b9505cf21842be36cdb68f
1 /**
2 * @file oprofile.h
4 * API for machine-specific interrupts to interface
5 * to oprofile.
7 * @remark Copyright 2002 OProfile authors
8 * @remark Read the file COPYING
10 * @author John Levon <levon@movementarian.org>
13 #ifndef OPROFILE_H
14 #define OPROFILE_H
16 #include <linux/types.h>
17 #include <linux/spinlock.h>
18 #include <asm/atomic.h>
20 /* Each escaped entry is prefixed by ESCAPE_CODE
21 * then one of the following codes, then the
22 * relevant data.
23 * These #defines live in this file so that arch-specific
24 * buffer sync'ing code can access them.
26 #define ESCAPE_CODE ~0UL
27 #define CTX_SWITCH_CODE 1
28 #define CPU_SWITCH_CODE 2
29 #define COOKIE_SWITCH_CODE 3
30 #define KERNEL_ENTER_SWITCH_CODE 4
31 #define KERNEL_EXIT_SWITCH_CODE 5
32 #define MODULE_LOADED_CODE 6
33 #define CTX_TGID_CODE 7
34 #define TRACE_BEGIN_CODE 8
35 #define TRACE_END_CODE 9
36 #define XEN_ENTER_SWITCH_CODE 10
37 #define SPU_PROFILING_CODE 11
38 #define SPU_CTX_SWITCH_CODE 12
40 struct super_block;
41 struct dentry;
42 struct file_operations;
43 struct pt_regs;
45 /* Operations structure to be filled in */
46 struct oprofile_operations {
47 /* create any necessary configuration files in the oprofile fs.
48 * Optional. */
49 int (*create_files)(struct super_block * sb, struct dentry * root);
50 /* Do any necessary interrupt setup. Optional. */
51 int (*setup)(void);
52 /* Do any necessary interrupt shutdown. Optional. */
53 void (*shutdown)(void);
54 /* Start delivering interrupts. */
55 int (*start)(void);
56 /* Stop delivering interrupts. */
57 void (*stop)(void);
58 /* Arch-specific buffer sync functions.
59 * Return value = 0: Success
60 * Return value = -1: Failure
61 * Return value = 1: Run generic sync function
63 int (*sync_start)(void);
64 int (*sync_stop)(void);
66 /* Initiate a stack backtrace. Optional. */
67 void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
68 /* CPU identification string. */
69 char * cpu_type;
72 /**
73 * One-time initialisation. *ops must be set to a filled-in
74 * operations structure. This is called even in timer interrupt
75 * mode so an arch can set a backtrace callback.
77 * If an error occurs, the fields should be left untouched.
79 int oprofile_arch_init(struct oprofile_operations * ops);
81 /**
82 * One-time exit/cleanup for the arch.
84 void oprofile_arch_exit(void);
86 /**
87 * Add data to the event buffer.
88 * The data passed is free-form, but typically consists of
89 * file offsets, dcookies, context information, and ESCAPE codes.
91 void add_event_entry(unsigned long data);
93 /**
94 * Add a sample. This may be called from any context. Pass
95 * smp_processor_id() as cpu.
97 void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
99 /**
100 * Add an extended sample. Use this when the PC is not from the regs, and
101 * we cannot determine if we're in kernel mode from the regs.
103 * This function does perform a backtrace.
106 void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
107 unsigned long event, int is_kernel);
109 /* Use this instead when the PC value is not from the regs. Doesn't
110 * backtrace. */
111 void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
113 /* add a backtrace entry, to be called from the ->backtrace callback */
114 void oprofile_add_trace(unsigned long eip);
118 * Create a file of the given name as a child of the given root, with
119 * the specified file operations.
121 int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
122 char const * name, const struct file_operations * fops);
124 int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
125 char const * name, const struct file_operations * fops, int perm);
127 /** Create a file for read/write access to an unsigned long. */
128 int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
129 char const * name, ulong * val);
131 /** Create a file for read-only access to an unsigned long. */
132 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
133 char const * name, ulong * val);
135 /** Create a file for read-only access to an atomic_t. */
136 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
137 char const * name, atomic_t * val);
139 /** create a directory */
140 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
141 char const * name);
144 * Write the given asciz string to the given user buffer @buf, updating *offset
145 * appropriately. Returns bytes written or -EFAULT.
147 ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
150 * Convert an unsigned long value into ASCII and copy it to the user buffer @buf,
151 * updating *offset appropriately. Returns bytes written or -EFAULT.
153 ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
156 * Read an ASCII string for a number from a userspace buffer and fill *val on success.
157 * Returns 0 on success, < 0 on error.
159 int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
161 /** lock for read/write safety */
162 extern spinlock_t oprofilefs_lock;
164 #endif /* OPROFILE_H */