spr.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * OpenRISC Linux
  3. *
  4. * Linux architectural port borrowing liberally from similar works of
  5. * others. All original copyrights apply as per the original source
  6. * declaration.
  7. *
  8. * OpenRISC implementation:
  9. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. */
  16. #ifndef __ASM_OPENRISC_SPR_H
  17. #define __ASM_OPENRISC_SPR_H
  18. #define mtspr(_spr, _val) __asm__ __volatile__ ( \
  19. "l.mtspr r0,%1,%0" \
  20. : : "K" (_spr), "r" (_val))
  21. #define mtspr_off(_spr, _off, _val) __asm__ __volatile__ ( \
  22. "l.mtspr %0,%1,%2" \
  23. : : "r" (_off), "r" (_val), "K" (_spr))
  24. static inline unsigned long mfspr(unsigned long add)
  25. {
  26. unsigned long ret;
  27. __asm__ __volatile__ ("l.mfspr %0,r0,%1" : "=r" (ret) : "K" (add));
  28. return ret;
  29. }
  30. static inline unsigned long mfspr_off(unsigned long add, unsigned long offset)
  31. {
  32. unsigned long ret;
  33. __asm__ __volatile__ ("l.mfspr %0,%1,%2" : "=r" (ret)
  34. : "r" (offset), "K" (add));
  35. return ret;
  36. }
  37. #endif