From: Philippe Elie <phil.el@wanadoo.fr>

From: Zwane Mwaikambo <zwane@arm.linux.org.uk>

This patch adds infrastructure code and enables ARM to utilise the timer
int oprofile driver.  There is PMU code under development for the XScale
but that is still forthcoming.  In the meantime you can use the timer int
driver with an updated Oprofile-CVS userspace (SF is a bit slow, please
allow 24hrs).



---

 25-akpm/arch/arm/Kconfig             |    2 ++
 25-akpm/arch/arm/Makefile            |    1 +
 25-akpm/arch/arm/kernel/time.c       |    3 +++
 25-akpm/arch/arm/oprofile/Kconfig    |   23 +++++++++++++++++++++++
 25-akpm/arch/arm/oprofile/Makefile   |    9 +++++++++
 25-akpm/arch/arm/oprofile/init.c     |   22 ++++++++++++++++++++++
 25-akpm/drivers/oprofile/timer_int.c |    1 -
 7 files changed, 60 insertions(+), 1 deletion(-)

diff -puN arch/arm/Kconfig~oprofile-arm-support arch/arm/Kconfig
--- 25/arch/arm/Kconfig~oprofile-arm-support	Wed Feb 11 16:00:18 2004
+++ 25-akpm/arch/arm/Kconfig	Wed Feb 11 16:00:18 2004
@@ -639,6 +639,8 @@ source "drivers/media/Kconfig"
 
 source "fs/Kconfig"
 
+source "arch/arm/oprofile/Kconfig"
+
 source "drivers/video/Kconfig"
 
 if ARCH_ACORN || ARCH_CLPS7500 || ARCH_TBOX || ARCH_SHARK || ARCH_SA1100 || PCI
diff -puN arch/arm/kernel/time.c~oprofile-arm-support arch/arm/kernel/time.c
--- 25/arch/arm/kernel/time.c~oprofile-arm-support	Wed Feb 11 16:00:18 2004
+++ 25-akpm/arch/arm/kernel/time.c	Wed Feb 11 16:00:18 2004
@@ -83,6 +83,9 @@ unsigned long long sched_clock(void)
  */
 static inline void do_profile(struct pt_regs *regs)
 {
+
+	profile_hook(regs);
+
 	if (!user_mode(regs) &&
 	    prof_buffer &&
 	    current->pid) {
diff -puN arch/arm/Makefile~oprofile-arm-support arch/arm/Makefile
--- 25/arch/arm/Makefile~oprofile-arm-support	Wed Feb 11 16:00:18 2004
+++ 25-akpm/arch/arm/Makefile	Wed Feb 11 16:00:18 2004
@@ -116,6 +116,7 @@ endif
 core-$(CONFIG_FPE_NWFPE)	+= arch/arm/nwfpe/
 core-$(CONFIG_FPE_FASTFPE)	+= $(FASTFPE_OBJ)
 
+drivers-$(CONFIG_OPROFILE)      += arch/arm/oprofile/
 drivers-$(CONFIG_ARCH_CLPS7500)	+= drivers/acorn/char/
 drivers-$(CONFIG_ARCH_L7200)	+= drivers/acorn/char/
 
diff -puN /dev/null arch/arm/oprofile/init.c
--- /dev/null	Thu Apr 11 07:25:15 2002
+++ 25-akpm/arch/arm/oprofile/init.c	Wed Feb 11 16:00:18 2004
@@ -0,0 +1,22 @@
+/**
+ * @file init.c
+ *
+ * @remark Copyright 2004 Oprofile Authors
+ *
+ * @author Zwane Mwaikambo
+ */
+
+#include <linux/oprofile.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+
+int oprofile_arch_init(struct oprofile_operations **ops)
+{
+	int ret = -ENODEV;
+
+	return ret;
+}
+
+void oprofile_arch_exit(void)
+{
+}
diff -puN /dev/null arch/arm/oprofile/Kconfig
--- /dev/null	Thu Apr 11 07:25:15 2002
+++ 25-akpm/arch/arm/oprofile/Kconfig	Wed Feb 11 16:00:18 2004
@@ -0,0 +1,23 @@
+
+menu "Profiling support"
+	depends on EXPERIMENTAL
+
+config PROFILING
+	bool "Profiling support (EXPERIMENTAL)"
+	help
+	  Say Y here to enable the extended profiling support mechanisms used
+	  by profilers such as OProfile.
+
+
+config OPROFILE
+	tristate "OProfile system profiling (EXPERIMENTAL)"
+	depends on PROFILING
+	help
+	  OProfile is a profiling system capable of profiling the
+	  whole system, include the kernel, kernel modules, libraries,
+	  and applications.
+
+	  If unsure, say N.
+
+endmenu
+
diff -puN /dev/null arch/arm/oprofile/Makefile
--- /dev/null	Thu Apr 11 07:25:15 2002
+++ 25-akpm/arch/arm/oprofile/Makefile	Wed Feb 11 16:00:18 2004
@@ -0,0 +1,9 @@
+obj-$(CONFIG_OPROFILE) += oprofile.o
+
+DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
+		oprof.o cpu_buffer.o buffer_sync.o \
+		event_buffer.o oprofile_files.o \
+		oprofilefs.o oprofile_stats.o \
+		timer_int.o )
+
+oprofile-y				:= $(DRIVER_OBJS) init.o
diff -puN drivers/oprofile/timer_int.c~oprofile-arm-support drivers/oprofile/timer_int.c
--- 25/drivers/oprofile/timer_int.c~oprofile-arm-support	Wed Feb 11 16:00:18 2004
+++ 25-akpm/drivers/oprofile/timer_int.c	Wed Feb 11 16:00:18 2004
@@ -10,7 +10,6 @@
 #include <linux/kernel.h>
 #include <linux/notifier.h>
 #include <linux/smp.h>
-#include <linux/irq.h>
 #include <linux/oprofile.h>
 #include <linux/profile.h>
 #include <linux/init.h>

_