psr.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * psr.h: This file holds the macros for masking off various parts of
  3. * the processor status register on the Sparc. This is valid
  4. * for Version 8. On the V9 this is renamed to the PSTATE
  5. * register and its members are accessed as fields like
  6. * PSTATE.PRIV for the current CPU privilege level.
  7. *
  8. * Copyright (C) 1994 David S. Miller ([email protected])
  9. */
  10. #ifndef __LINUX_SPARC_PSR_H
  11. #define __LINUX_SPARC_PSR_H
  12. #include <uapi/asm/psr.h>
  13. #ifndef __ASSEMBLY__
  14. /* Get the %psr register. */
  15. static inline unsigned int get_psr(void)
  16. {
  17. unsigned int psr;
  18. __asm__ __volatile__(
  19. "rd %%psr, %0\n\t"
  20. "nop\n\t"
  21. "nop\n\t"
  22. "nop\n\t"
  23. : "=r" (psr)
  24. : /* no inputs */
  25. : "memory");
  26. return psr;
  27. }
  28. static inline void put_psr(unsigned int new_psr)
  29. {
  30. __asm__ __volatile__(
  31. "wr %0, 0x0, %%psr\n\t"
  32. "nop\n\t"
  33. "nop\n\t"
  34. "nop\n\t"
  35. : /* no outputs */
  36. : "r" (new_psr)
  37. : "memory", "cc");
  38. }
  39. /* Get the %fsr register. Be careful, make sure the floating point
  40. * enable bit is set in the %psr when you execute this or you will
  41. * incur a trap.
  42. */
  43. extern unsigned int fsr_storage;
  44. static inline unsigned int get_fsr(void)
  45. {
  46. unsigned int fsr = 0;
  47. __asm__ __volatile__(
  48. "st %%fsr, %1\n\t"
  49. "ld %1, %0\n\t"
  50. : "=r" (fsr)
  51. : "m" (fsr_storage));
  52. return fsr;
  53. }
  54. #endif /* !(__ASSEMBLY__) */
  55. #endif /* !(__LINUX_SPARC_PSR_H) */