fpu.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* MN10300 FPU definitions
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. * Derived from include/asm-i386/i387.h: Copyright (C) 1994 Linus Torvalds
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public Licence
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the Licence, or (at your option) any later version.
  11. */
  12. #ifndef _ASM_FPU_H
  13. #define _ASM_FPU_H
  14. #include <asm/processor.h>
  15. #include <asm/sigcontext.h>
  16. #include <asm/user.h>
  17. #ifdef __KERNEL__
  18. /* the task that owns the FPU state */
  19. extern struct task_struct *fpu_state_owner;
  20. #define set_using_fpu(tsk) \
  21. do { \
  22. (tsk)->thread.fpu_flags |= THREAD_USING_FPU; \
  23. } while (0)
  24. #define clear_using_fpu(tsk) \
  25. do { \
  26. (tsk)->thread.fpu_flags &= ~THREAD_USING_FPU; \
  27. } while (0)
  28. #define is_using_fpu(tsk) ((tsk)->thread.fpu_flags & THREAD_USING_FPU)
  29. #define unlazy_fpu(tsk) \
  30. do { \
  31. preempt_disable(); \
  32. if (fpu_state_owner == (tsk)) \
  33. fpu_save(&tsk->thread.fpu_state); \
  34. preempt_enable(); \
  35. } while (0)
  36. #define exit_fpu() \
  37. do { \
  38. struct task_struct *__tsk = current; \
  39. preempt_disable(); \
  40. if (fpu_state_owner == __tsk) \
  41. fpu_state_owner = NULL; \
  42. preempt_enable(); \
  43. } while (0)
  44. #define flush_fpu() \
  45. do { \
  46. struct task_struct *__tsk = current; \
  47. preempt_disable(); \
  48. if (fpu_state_owner == __tsk) { \
  49. fpu_state_owner = NULL; \
  50. __tsk->thread.uregs->epsw &= ~EPSW_FE; \
  51. } \
  52. preempt_enable(); \
  53. clear_using_fpu(__tsk); \
  54. } while (0)
  55. extern asmlinkage void fpu_init_state(void);
  56. extern asmlinkage void fpu_kill_state(struct task_struct *);
  57. extern asmlinkage void fpu_disabled(struct pt_regs *, enum exception_code);
  58. extern asmlinkage void fpu_exception(struct pt_regs *, enum exception_code);
  59. #ifdef CONFIG_FPU
  60. extern asmlinkage void fpu_save(struct fpu_state_struct *);
  61. extern asmlinkage void fpu_restore(struct fpu_state_struct *);
  62. #else
  63. #define fpu_save(a)
  64. #define fpu_restore(a)
  65. #endif /* CONFIG_FPU */
  66. /*
  67. * signal frame handlers
  68. */
  69. extern int fpu_setup_sigcontext(struct fpucontext *buf);
  70. extern int fpu_restore_sigcontext(struct fpucontext *buf);
  71. #endif /* __KERNEL__ */
  72. #endif /* _ASM_FPU_H */