supp_reg.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __SUPP_REG_H__
  2. #define __SUPP_REG_H__
  3. /* Macros for reading and writing support/special registers. */
  4. #ifndef STRINGIFYFY
  5. #define STRINGIFYFY(i) #i
  6. #endif
  7. #ifndef STRINGIFY
  8. #define STRINGIFY(i) STRINGIFYFY(i)
  9. #endif
  10. #define SPEC_REG_BZ "BZ"
  11. #define SPEC_REG_VR "VR"
  12. #define SPEC_REG_PID "PID"
  13. #define SPEC_REG_SRS "SRS"
  14. #define SPEC_REG_WZ "WZ"
  15. #define SPEC_REG_EXS "EXS"
  16. #define SPEC_REG_EDA "EDA"
  17. #define SPEC_REG_MOF "MOF"
  18. #define SPEC_REG_DZ "DZ"
  19. #define SPEC_REG_EBP "EBP"
  20. #define SPEC_REG_ERP "ERP"
  21. #define SPEC_REG_SRP "SRP"
  22. #define SPEC_REG_NRP "NRP"
  23. #define SPEC_REG_CCS "CCS"
  24. #define SPEC_REG_USP "USP"
  25. #define SPEC_REG_SPC "SPC"
  26. #define RW_MM_CFG 0
  27. #define RW_MM_KBASE_LO 1
  28. #define RW_MM_KBASE_HI 2
  29. #define RW_MM_CAUSE 3
  30. #define RW_MM_TLB_SEL 4
  31. #define RW_MM_TLB_LO 5
  32. #define RW_MM_TLB_HI 6
  33. #define RW_MM_TLB_PGD 7
  34. #define BANK_GC 0
  35. #define BANK_IM 1
  36. #define BANK_DM 2
  37. #define BANK_BP 3
  38. #define RW_GC_CFG 0
  39. #define RW_GC_CCS 1
  40. #define RW_GC_SRS 2
  41. #define RW_GC_NRP 3
  42. #define RW_GC_EXS 4
  43. #define RW_GC_R0 8
  44. #define RW_GC_R1 9
  45. #define SPEC_REG_WR(r,v) \
  46. __asm__ __volatile__ ("move %0, $" r : : "r" (v));
  47. #define SPEC_REG_RD(r,v) \
  48. __asm__ __volatile__ ("move $" r ",%0" : "=r" (v));
  49. #define NOP() \
  50. __asm__ __volatile__ ("nop");
  51. #define SUPP_BANK_SEL(b) \
  52. SPEC_REG_WR(SPEC_REG_SRS,b); \
  53. NOP(); \
  54. NOP(); \
  55. NOP();
  56. #define SUPP_REG_WR(r,v) \
  57. __asm__ __volatile__ ("move %0, $S" STRINGIFYFY(r) "\n\t" \
  58. "nop\n\t" \
  59. "nop\n\t" \
  60. "nop\n\t" \
  61. : : "r" (v));
  62. #define SUPP_REG_RD(r,v) \
  63. __asm__ __volatile__ ("move $S" STRINGIFYFY(r) ",%0" : "=r" (v));
  64. #endif /* __SUPP_REG_H__ */