summaryrefslogtreecommitdiffstats
path: root/arch/mips/cavium-octeon/cpu.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2009-11-24 01:24:58 +0000
committerRalf Baechle <ralf@linux-mips.org>2009-12-17 01:57:30 +0000
commit69f3a7de1f1ec935924b1b13f83812f8b30e92ce (patch)
treea5f8a71b9cb3026a44ae7a1564488de8c3d8d2a9 /arch/mips/cavium-octeon/cpu.c
parent4dd92e15b316d1a782772f16074571a70ceb9184 (diff)
downloadop-kernel-dev-69f3a7de1f1ec935924b1b13f83812f8b30e92ce.zip
op-kernel-dev-69f3a7de1f1ec935924b1b13f83812f8b30e92ce.tar.gz
MIPS: Modularize COP2 handling
Away with the daemons of ifdef; get ready for future COP2 users. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Patchwork: http://patchwork.linux-mips.org/patch/708/
Diffstat (limited to 'arch/mips/cavium-octeon/cpu.c')
-rw-r--r--arch/mips/cavium-octeon/cpu.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/mips/cavium-octeon/cpu.c b/arch/mips/cavium-octeon/cpu.c
new file mode 100644
index 0000000..b6df538
--- /dev/null
+++ b/arch/mips/cavium-octeon/cpu.c
@@ -0,0 +1,52 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2009 Wind River Systems,
+ * written by Ralf Baechle <ralf@linux-mips.org>
+ */
+#include <linux/init.h>
+#include <linux/irqflags.h>
+#include <linux/notifier.h>
+#include <linux/prefetch.h>
+#include <linux/sched.h>
+
+#include <asm/cop2.h>
+#include <asm/current.h>
+#include <asm/mipsregs.h>
+#include <asm/page.h>
+#include <asm/octeon/octeon.h>
+
+static int cnmips_cu2_call(struct notifier_block *nfb, unsigned long action,
+ void *data)
+{
+ unsigned long flags;
+ unsigned int status;
+
+ switch (action) {
+ case CU2_EXCEPTION:
+ prefetch(&current->thread.cp2);
+ local_irq_save(flags);
+ KSTK_STATUS(current) |= ST0_CU2;
+ status = read_c0_status();
+ write_c0_status(status | ST0_CU2);
+ octeon_cop2_restore(&(current->thread.cp2));
+ write_c0_status(status & ~ST0_CU2);
+ local_irq_restore(flags);
+
+ return NOTIFY_BAD; /* Don't call default notifier */
+ }
+
+ return NOTIFY_OK; /* Let default notifier send signals */
+}
+
+static struct notifier_block cnmips_cu2_notifier = {
+ .notifier_call = cnmips_cu2_call,
+};
+
+static int cnmips_cu2_setup(void)
+{
+ return register_cu2_notifier(&cnmips_cu2_notifier);
+}
+early_initcall(cnmips_cu2_setup);
OpenPOWER on IntegriCloud