dsp.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) 2005 Mips Technologies
  3. * Author: Chris Dearman, chris@mips.com derived from fpu.h
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #ifndef _ASM_DSP_H
  11. #define _ASM_DSP_H
  12. #include <asm/cpu.h>
  13. #include <asm/cpu-features.h>
  14. #include <asm/hazards.h>
  15. #include <asm/mipsregs.h>
  16. #define DSP_DEFAULT 0x00000000
  17. #define DSP_MASK 0x3f
  18. #define __enable_dsp_hazard() \
  19. do { \
  20. asm("_ehb"); \
  21. } while (0)
  22. static inline void __init_dsp(void)
  23. {
  24. mthi1(0);
  25. mtlo1(0);
  26. mthi2(0);
  27. mtlo2(0);
  28. mthi3(0);
  29. mtlo3(0);
  30. wrdsp(DSP_DEFAULT, DSP_MASK);
  31. }
  32. static inline void init_dsp(void)
  33. {
  34. if (cpu_has_dsp)
  35. __init_dsp();
  36. }
  37. #define __save_dsp(tsk) \
  38. do { \
  39. tsk->thread.dsp.dspr[0] = mfhi1(); \
  40. tsk->thread.dsp.dspr[1] = mflo1(); \
  41. tsk->thread.dsp.dspr[2] = mfhi2(); \
  42. tsk->thread.dsp.dspr[3] = mflo2(); \
  43. tsk->thread.dsp.dspr[4] = mfhi3(); \
  44. tsk->thread.dsp.dspr[5] = mflo3(); \
  45. tsk->thread.dsp.dspcontrol = rddsp(DSP_MASK); \
  46. } while (0)
  47. #define save_dsp(tsk) \
  48. do { \
  49. if (cpu_has_dsp) \
  50. __save_dsp(tsk); \
  51. } while (0)
  52. #define __restore_dsp(tsk) \
  53. do { \
  54. mthi1(tsk->thread.dsp.dspr[0]); \
  55. mtlo1(tsk->thread.dsp.dspr[1]); \
  56. mthi2(tsk->thread.dsp.dspr[2]); \
  57. mtlo2(tsk->thread.dsp.dspr[3]); \
  58. mthi3(tsk->thread.dsp.dspr[4]); \
  59. mtlo3(tsk->thread.dsp.dspr[5]); \
  60. wrdsp(tsk->thread.dsp.dspcontrol, DSP_MASK); \
  61. } while (0)
  62. #define restore_dsp(tsk) \
  63. do { \
  64. if (cpu_has_dsp) \
  65. __restore_dsp(tsk); \
  66. } while (0)
  67. #define __get_dsp_regs(tsk) \
  68. ({ \
  69. if (tsk == current) \
  70. __save_dsp(current); \
  71. \
  72. tsk->thread.dsp.dspr; \
  73. })
  74. #endif /* _ASM_DSP_H */