spr_access.S 747 B

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