cpu.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2009 Wind River Systems,
  7. * written by Ralf Baechle <ralf@linux-mips.org>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/irqflags.h>
  11. #include <linux/notifier.h>
  12. #include <linux/prefetch.h>
  13. #include <linux/ptrace.h>
  14. #include <linux/sched.h>
  15. #include <linux/sched/task_stack.h>
  16. #include <asm/cop2.h>
  17. #include <asm/current.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/page.h>
  20. #include <asm/octeon/octeon.h>
  21. static int cnmips_cu2_call(struct notifier_block *nfb, unsigned long action,
  22. void *data)
  23. {
  24. unsigned long flags;
  25. unsigned int status;
  26. switch (action) {
  27. case CU2_EXCEPTION:
  28. prefetch(&current->thread.cp2);
  29. local_irq_save(flags);
  30. KSTK_STATUS(current) |= ST0_CU2;
  31. status = read_c0_status();
  32. write_c0_status(status | ST0_CU2);
  33. octeon_cop2_restore(&(current->thread.cp2));
  34. write_c0_status(status & ~ST0_CU2);
  35. local_irq_restore(flags);
  36. return NOTIFY_BAD; /* Don't call default notifier */
  37. }
  38. return NOTIFY_OK; /* Let default notifier send signals */
  39. }
  40. static int __init cnmips_cu2_setup(void)
  41. {
  42. return cu2_notifier(cnmips_cu2_call, 0);
  43. }
  44. early_initcall(cnmips_cu2_setup);