psr.h 1.4 KB

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