privinst.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 1996 Paul Mackerras.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #define GETREG(reg) \
  10. static inline unsigned long get_ ## reg (void) \
  11. { unsigned long ret; asm volatile ("mf" #reg " %0" : "=r" (ret) :); return ret; }
  12. #define SETREG(reg) \
  13. static inline void set_ ## reg (unsigned long val) \
  14. { asm volatile ("mt" #reg " %0" : : "r" (val)); }
  15. GETREG(msr)
  16. SETREG(msrd)
  17. GETREG(cr)
  18. #define GSETSPR(n, name) \
  19. static inline long get_ ## name (void) \
  20. { long ret; asm volatile ("mfspr %0," #n : "=r" (ret) : ); return ret; } \
  21. static inline void set_ ## name (long val) \
  22. { asm volatile ("mtspr " #n ",%0" : : "r" (val)); }
  23. GSETSPR(0, mq)
  24. GSETSPR(1, xer)
  25. GSETSPR(4, rtcu)
  26. GSETSPR(5, rtcl)
  27. GSETSPR(8, lr)
  28. GSETSPR(9, ctr)
  29. GSETSPR(18, dsisr)
  30. GSETSPR(19, dar)
  31. GSETSPR(22, dec)
  32. GSETSPR(25, sdr1)
  33. GSETSPR(26, srr0)
  34. GSETSPR(27, srr1)
  35. GSETSPR(272, sprg0)
  36. GSETSPR(273, sprg1)
  37. GSETSPR(274, sprg2)
  38. GSETSPR(275, sprg3)
  39. GSETSPR(282, ear)
  40. GSETSPR(287, pvr)
  41. GSETSPR(1008, hid0)
  42. GSETSPR(1009, hid1)
  43. GSETSPR(1010, iabr)
  44. GSETSPR(1013, dabr)
  45. GSETSPR(1023, pir)
  46. static inline void store_inst(void *p)
  47. {
  48. asm volatile ("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r" (p));
  49. }
  50. static inline void cflush(void *p)
  51. {
  52. asm volatile ("dcbf 0,%0; icbi 0,%0" : : "r" (p));
  53. }
  54. static inline void cinval(void *p)
  55. {
  56. asm volatile ("dcbi 0,%0; icbi 0,%0" : : "r" (p));
  57. }