special_insns.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Port on Texas Instruments TMS320C6x architecture
  3. *
  4. * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
  5. * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _ASM_C6X_SPECIAL_INSNS_H
  12. #define _ASM_C6X_SPECIAL_INSNS_H
  13. #define get_creg(reg) \
  14. ({ unsigned int __x; \
  15. asm volatile ("mvc .s2 " #reg ",%0\n" : "=b"(__x)); __x; })
  16. #define set_creg(reg, v) \
  17. do { unsigned int __x = (unsigned int)(v); \
  18. asm volatile ("mvc .s2 %0," #reg "\n" : : "b"(__x)); \
  19. } while (0)
  20. #define or_creg(reg, n) \
  21. do { unsigned __x, __n = (unsigned)(n); \
  22. asm volatile ("mvc .s2 " #reg ",%0\n" \
  23. "or .l2 %1,%0,%0\n" \
  24. "mvc .s2 %0," #reg "\n" \
  25. "nop\n" \
  26. : "=&b"(__x) : "b"(__n)); \
  27. } while (0)
  28. #define and_creg(reg, n) \
  29. do { unsigned __x, __n = (unsigned)(n); \
  30. asm volatile ("mvc .s2 " #reg ",%0\n" \
  31. "and .l2 %1,%0,%0\n" \
  32. "mvc .s2 %0," #reg "\n" \
  33. "nop\n" \
  34. : "=&b"(__x) : "b"(__n)); \
  35. } while (0)
  36. #define get_coreid() (get_creg(DNUM) & 0xff)
  37. /* Set/get IST */
  38. #define set_ist(x) set_creg(ISTP, x)
  39. #define get_ist() get_creg(ISTP)
  40. /*
  41. * Exception management
  42. */
  43. #define disable_exception()
  44. #define get_except_type() get_creg(EFR)
  45. #define ack_exception(type) set_creg(ECR, 1 << (type))
  46. #define get_iexcept() get_creg(IERR)
  47. #define set_iexcept(mask) set_creg(IERR, (mask))
  48. #define _extu(x, s, e) \
  49. ({ unsigned int __x; \
  50. asm volatile ("extu .S2 %3,%1,%2,%0\n" : \
  51. "=b"(__x) : "n"(s), "n"(e), "b"(x)); \
  52. __x; })
  53. #endif /* _ASM_C6X_SPECIAL_INSNS_H */