1 /**
2 * Copyright (C) ARM Limited 2010-2011. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #ifndef GATOR_H_
10 #define GATOR_H_
12 #include <linux/version.h>
13 #include <linux/fs.h>
14 #include <linux/mm.h>
15 #include <linux/list.h>
17 // cpu ids
18 #define ARM1136 0xb36
19 #define ARM1156 0xb56
20 #define ARM1176 0xb76
21 #define ARM11MPCORE 0xb02
22 #define CORTEX_A5 0xc05
23 #define CORTEX_A8 0xc08
24 #define CORTEX_A9 0xc09
25 #define CORTEX_A15 0xc0f
27 /******************************************************************************
28 * Filesystem
29 ******************************************************************************/
30 int gatorfs_create_file_perm(struct super_block *sb, struct dentry *root,
31 char const *name, const struct file_operations *fops, int perm);
33 struct dentry *gatorfs_mkdir(struct super_block *sb,
34 struct dentry *root, char const *name);
36 int gatorfs_create_ulong(struct super_block *sb, struct dentry *root,
37 char const *name, unsigned long *val);
39 int gatorfs_create_ro_ulong(struct super_block *sb, struct dentry *root,
40 char const *name, unsigned long *val);
42 void gator_op_create_files(struct super_block *sb, struct dentry *root);
44 /******************************************************************************
45 * Tracepoints
46 ******************************************************************************/
47 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
48 # error Kernels prior to 2.6.32 not supported
49 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
50 # define GATOR_DEFINE_PROBE(probe_name, proto) \
51 static void probe_##probe_name(PARAMS(proto))
52 # define GATOR_REGISTER_TRACE(probe_name) \
53 register_trace_##probe_name(probe_##probe_name)
54 # define GATOR_UNREGISTER_TRACE(probe_name) \
55 unregister_trace_##probe_name(probe_##probe_name)
56 #else
57 # define GATOR_DEFINE_PROBE(probe_name, proto) \
58 static void probe_##probe_name(void *data, PARAMS(proto))
59 # define GATOR_REGISTER_TRACE(probe_name) \
60 register_trace_##probe_name(probe_##probe_name, NULL)
61 # define GATOR_UNREGISTER_TRACE(probe_name) \
62 unregister_trace_##probe_name(probe_##probe_name, NULL)
63 #endif
65 /******************************************************************************
66 * Events
67 ******************************************************************************/
68 struct gator_interface {
69 int (*create_files)(struct super_block *sb, struct dentry *root);
70 int (*start)(void);
71 void (*stop)(void);
72 void (*online)(void);
73 void (*offline)(void);
74 int (*read)(int **buffer);
75 int (*read64)(long long **buffer);
76 struct list_head list;
77 };
79 #define gator_events_init(initfn) \
80 static inline int __gator_events_init_test(void) \
81 { return initfn(); }
83 int gator_events_install(struct gator_interface *interface);
84 int gator_events_get_key(void);
85 extern u32 gator_cpuid(void);
87 extern unsigned long gator_net_traffic;
89 #endif // GATOR_H_