4 * API for machine-specific interrupts to interface
7 * @remark Copyright 2002 OProfile authors
8 * @remark Read the file COPYING
10 * @author John Levon <levon@movementarian.org>
16 #include <linux/types.h>
17 #include <linux/spinlock.h>
18 #include <asm/atomic.h>
21 #include <xen/interface/xenoprof.h>
26 struct file_operations;
29 /* Operations structure to be filled in */
30 struct oprofile_operations {
31 /* create any necessary configuration files in the oprofile fs.
33 int (*create_files)(struct super_block * sb, struct dentry * root);
34 /* setup active domains with Xen */
35 int (*set_active)(int *active_domains, unsigned int adomains);
36 /* setup passive domains with Xen */
37 int (*set_passive)(int *passive_domains, unsigned int pdomains);
39 /* Do any necessary interrupt setup. Optional. */
41 /* Do any necessary interrupt shutdown. Optional. */
42 void (*shutdown)(void);
43 /* Start delivering interrupts. */
45 /* Stop delivering interrupts. */
47 /* Initiate a stack backtrace. Optional. */
48 void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
49 /* CPU identification string. */
54 * One-time initialisation. *ops must be set to a filled-in
55 * operations structure. This is called even in timer interrupt
56 * mode so an arch can set a backtrace callback.
58 * If an error occurs, the fields should be left untouched.
60 int oprofile_arch_init(struct oprofile_operations * ops);
63 * One-time exit/cleanup for the arch.
65 void oprofile_arch_exit(void);
68 * Add a sample. This may be called from any context. Pass
69 * smp_processor_id() as cpu.
71 void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
74 * Add an extended sample. Use this when the PC is not from the regs, and
75 * we cannot determine if we're in kernel mode from the regs.
77 * This function does perform a backtrace.
80 void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
81 unsigned long event, int is_kernel);
83 /* Use this instead when the PC value is not from the regs. Doesn't
85 void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
87 /* add a backtrace entry, to be called from the ->backtrace callback */
88 void oprofile_add_trace(unsigned long eip);
90 /* add a domain switch entry */
91 int oprofile_add_domain_switch(int32_t domain_id);
94 * Create a file of the given name as a child of the given root, with
95 * the specified file operations.
97 int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
98 char const * name, const struct file_operations * fops);
100 int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
101 char const * name, const struct file_operations * fops, int perm);
103 /** Create a file for read/write access to an unsigned long. */
104 int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
105 char const * name, ulong * val);
107 /** Create a file for read-only access to an unsigned long. */
108 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
109 char const * name, ulong * val);
111 /** Create a file for read-only access to an atomic_t. */
112 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
113 char const * name, atomic_t * val);
115 /** create a directory */
116 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
120 * Write the given asciz string to the given user buffer @buf, updating *offset
121 * appropriately. Returns bytes written or -EFAULT.
123 ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
126 * Convert an unsigned long value into ASCII and copy it to the user buffer @buf,
127 * updating *offset appropriately. Returns bytes written or -EFAULT.
129 ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
132 * Read an ASCII string for a number from a userspace buffer and fill *val on success.
133 * Returns 0 on success, < 0 on error.
135 int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
137 /** lock for read/write safety */
138 extern spinlock_t oprofilefs_lock;
140 #endif /* OPROFILE_H */