spr_access.S 814 B

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