spr_access.S 786 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <asm/ppc_asm.h>
  3. /* unsigned long xmon_mfspr(sprn, default_value) */
  4. _GLOBAL(xmon_mfspr)
  5. PPC_LL r5, .Lmfspr_table@got(r2)
  6. b xmon_mxspr
  7. /* void xmon_mtspr(sprn, new_value) */
  8. _GLOBAL(xmon_mtspr)
  9. PPC_LL r5, .Lmtspr_table@got(r2)
  10. b xmon_mxspr
  11. /*
  12. * r3 = sprn
  13. * r4 = default or new value
  14. * r5 = table base
  15. */
  16. xmon_mxspr:
  17. /*
  18. * To index into the table of mxsprs we need:
  19. * i = (sprn & 0x3ff) * 8
  20. * or using rwlinm:
  21. * i = (sprn << 3) & (0x3ff << 3)
  22. */
  23. rlwinm r3, r3, 3, 0x3ff << 3
  24. add r5, r5, r3
  25. mtctr r5
  26. mr r3, r4 /* put default_value in r3 for mfspr */
  27. bctr
  28. .Lmfspr_table:
  29. spr = 0
  30. .rept 1024
  31. mfspr r3, spr
  32. blr
  33. spr = spr + 1
  34. .endr
  35. .Lmtspr_table:
  36. spr = 0
  37. .rept 1024
  38. mtspr spr, r4
  39. blr
  40. spr = spr + 1
  41. .endr