2 * Copyright (C) ARM Limited 2010-2014. All rights reserved.
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.
12 #include <linux/version.h>
15 #include <linux/list.h>
17 #define GATOR_PERF_SUPPORT LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
18 #define GATOR_PERF_PMU_SUPPORT GATOR_PERF_SUPPORT && defined(CONFIG_PERF_EVENTS) && (!(defined(__arm__) || defined(__aarch64__)) || defined(CONFIG_HW_PERF_EVENTS))
19 #define GATOR_NO_PERF_SUPPORT (!(GATOR_PERF_SUPPORT))
20 #define GATOR_CPU_FREQ_SUPPORT (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)) && defined(CONFIG_CPU_FREQ)
21 #define GATOR_IKS_SUPPORT defined(CONFIG_BL_SWITCHER)
27 #define ARM11MPCORE 0xb02
28 #define CORTEX_A5 0xc05
29 #define CORTEX_A7 0xc07
30 #define CORTEX_A8 0xc08
31 #define CORTEX_A9 0xc09
32 #define CORTEX_A12 0xc0d
33 #define CORTEX_A15 0xc0f
34 #define CORTEX_A17 0xc0e
35 #define SCORPION 0x00f
36 #define SCORPIONMP 0x02d
37 #define KRAITSIM 0x049
39 #define KRAIT_S4_PRO 0x06f
40 #define CORTEX_A53 0xd03
41 #define CORTEX_A57 0xd07
45 #define MAXSIZE_CORE_NAME 32
49 // Human readable name
50 const char core_name[MAXSIZE_CORE_NAME];
51 // gatorfs event and Perf PMU name
52 const char * const pmnc_name;
53 // compatible from Documentation/devicetree/bindings/arm/cpus.txt
54 const char * const dt_name;
55 const int pmnc_counters;
58 const struct gator_cpu *gator_find_cpu_by_cpuid(const u32 cpuid);
59 const struct gator_cpu *gator_find_cpu_by_pmu_name(const char *const name);
61 /******************************************************************************
63 ******************************************************************************/
64 struct dentry *gatorfs_mkdir(struct super_block *sb, struct dentry *root,
67 int gatorfs_create_ulong(struct super_block *sb, struct dentry *root,
68 char const *name, unsigned long *val);
70 int gatorfs_create_ro_ulong(struct super_block *sb, struct dentry *root,
71 char const *name, unsigned long *val);
73 /******************************************************************************
75 ******************************************************************************/
76 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
77 # error Kernels prior to 2.6.32 not supported
78 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
79 # define GATOR_DEFINE_PROBE(probe_name, proto) \
80 static void probe_##probe_name(PARAMS(proto))
81 # define GATOR_REGISTER_TRACE(probe_name) \
82 register_trace_##probe_name(probe_##probe_name)
83 # define GATOR_UNREGISTER_TRACE(probe_name) \
84 unregister_trace_##probe_name(probe_##probe_name)
86 # define GATOR_DEFINE_PROBE(probe_name, proto) \
87 static void probe_##probe_name(void *data, PARAMS(proto))
88 # define GATOR_REGISTER_TRACE(probe_name) \
89 register_trace_##probe_name(probe_##probe_name, NULL)
90 # define GATOR_UNREGISTER_TRACE(probe_name) \
91 unregister_trace_##probe_name(probe_##probe_name, NULL)
94 /******************************************************************************
96 ******************************************************************************/
97 struct gator_interface {
98 void (*shutdown)(void); // Complementary function to init
99 int (*create_files)(struct super_block *sb, struct dentry *root);
101 void (*stop)(void); // Complementary function to start
102 int (*online)(int **buffer, bool migrate);
103 int (*offline)(int **buffer, bool migrate);
104 void (*online_dispatch)(int cpu, bool migrate); // called in process context but may not be running on core 'cpu'
105 void (*offline_dispatch)(int cpu, bool migrate); // called in process context but may not be running on core 'cpu'
106 int (*read)(int **buffer);
107 int (*read64)(long long **buffer);
108 int (*read_proc)(long long **buffer, struct task_struct *);
109 struct list_head list;
112 int gator_events_install(struct gator_interface *interface);
113 int gator_events_get_key(void);
114 u32 gator_cpuid(void);
116 void gator_backtrace_handler(struct pt_regs *const regs);
118 #if !GATOR_IKS_SUPPORT
120 #define get_physical_cpu() smp_processor_id()
121 #define lcpu_to_pcpu(lcpu) lcpu
122 #define pcpu_to_lcpu(pcpu) pcpu
126 #define get_physical_cpu() lcpu_to_pcpu(get_logical_cpu())
127 int lcpu_to_pcpu(const int lcpu);
128 int pcpu_to_lcpu(const int pcpu);
132 #define get_logical_cpu() smp_processor_id()
133 #define on_primary_core() (get_logical_cpu() == 0)