169f3a7deSRalf Baechle /* 269f3a7deSRalf Baechle * This file is subject to the terms and conditions of the GNU General Public 369f3a7deSRalf Baechle * License. See the file "COPYING" in the main directory of this archive 469f3a7deSRalf Baechle * for more details. 569f3a7deSRalf Baechle * 669f3a7deSRalf Baechle * Copyright (C) 2009 Wind River Systems, 769f3a7deSRalf Baechle * written by Ralf Baechle <ralf@linux-mips.org> 869f3a7deSRalf Baechle */ 969f3a7deSRalf Baechle #include <linux/init.h> 1069f3a7deSRalf Baechle #include <linux/irqflags.h> 1169f3a7deSRalf Baechle #include <linux/notifier.h> 1269f3a7deSRalf Baechle #include <linux/prefetch.h> 13fc69910fSArnd Bergmann #include <linux/ptrace.h> 1469f3a7deSRalf Baechle #include <linux/sched.h> 15fc69910fSArnd Bergmann #include <linux/sched/task_stack.h> 1669f3a7deSRalf Baechle 1769f3a7deSRalf Baechle #include <asm/cop2.h> 1869f3a7deSRalf Baechle #include <asm/current.h> 1969f3a7deSRalf Baechle #include <asm/mipsregs.h> 2069f3a7deSRalf Baechle #include <asm/page.h> 2169f3a7deSRalf Baechle #include <asm/octeon/octeon.h> 2269f3a7deSRalf Baechle cnmips_cu2_call(struct notifier_block * nfb,unsigned long action,void * data)2369f3a7deSRalf Baechlestatic int cnmips_cu2_call(struct notifier_block *nfb, unsigned long action, 2469f3a7deSRalf Baechle void *data) 2569f3a7deSRalf Baechle { 2669f3a7deSRalf Baechle unsigned long flags; 2769f3a7deSRalf Baechle unsigned int status; 2869f3a7deSRalf Baechle 2969f3a7deSRalf Baechle switch (action) { 3069f3a7deSRalf Baechle case CU2_EXCEPTION: 3169f3a7deSRalf Baechle prefetch(¤t->thread.cp2); 3269f3a7deSRalf Baechle local_irq_save(flags); 3369f3a7deSRalf Baechle KSTK_STATUS(current) |= ST0_CU2; 3469f3a7deSRalf Baechle status = read_c0_status(); 3569f3a7deSRalf Baechle write_c0_status(status | ST0_CU2); 3669f3a7deSRalf Baechle octeon_cop2_restore(&(current->thread.cp2)); 3769f3a7deSRalf Baechle write_c0_status(status & ~ST0_CU2); 3869f3a7deSRalf Baechle local_irq_restore(flags); 3969f3a7deSRalf Baechle 4069f3a7deSRalf Baechle return NOTIFY_BAD; /* Don't call default notifier */ 4169f3a7deSRalf Baechle } 4269f3a7deSRalf Baechle 4369f3a7deSRalf Baechle return NOTIFY_OK; /* Let default notifier send signals */ 4469f3a7deSRalf Baechle } 4569f3a7deSRalf Baechle cnmips_cu2_setup(void)46158d6742SDavid Daneystatic int __init cnmips_cu2_setup(void) 4769f3a7deSRalf Baechle { 484483b159SRalf Baechle return cu2_notifier(cnmips_cu2_call, 0); 4969f3a7deSRalf Baechle } 5069f3a7deSRalf Baechle early_initcall(cnmips_cu2_setup); 51