ppc_save_regs.S 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 1996 Paul Mackerras.
  4. *
  5. * NOTE: assert(sizeof(buf) > 23 * sizeof(long))
  6. */
  7. #include <asm/processor.h>
  8. #include <asm/ppc_asm.h>
  9. #include <asm/asm-offsets.h>
  10. #include <asm/ptrace.h>
  11. #include <asm/asm-compat.h>
  12. /*
  13. * Grab the register values as they are now.
  14. * This won't do a particularly good job because we really
  15. * want our caller's caller's registers, and our caller has
  16. * already executed its prologue.
  17. * ToDo: We could reach back into the caller's save area to do
  18. * a better job of representing the caller's state (note that
  19. * that will be different for 32-bit and 64-bit, because of the
  20. * different ABIs, though).
  21. */
  22. _GLOBAL(ppc_save_regs)
  23. /* This allows stack frame accessor macros and offsets to be used */
  24. subi r3,r3,STACK_FRAME_OVERHEAD
  25. PPC_STL r0,GPR0(r3)
  26. #ifdef CONFIG_PPC32
  27. stmw r2,GPR2(r3)
  28. #else
  29. SAVE_GPRS(2, 31, r3)
  30. lbz r0,PACAIRQSOFTMASK(r13)
  31. PPC_STL r0,SOFTE(r3)
  32. #endif
  33. /* store current SP */
  34. PPC_STL r1,GPR1(r3)
  35. /* get caller's LR */
  36. PPC_LL r4,0(r1)
  37. PPC_LL r0,LRSAVE(r4)
  38. PPC_STL r0,_LINK(r3)
  39. mflr r0
  40. PPC_STL r0,_NIP(r3)
  41. mfmsr r0
  42. PPC_STL r0,_MSR(r3)
  43. mfctr r0
  44. PPC_STL r0,_CTR(r3)
  45. mfxer r0
  46. PPC_STL r0,_XER(r3)
  47. mfcr r0
  48. PPC_STL r0,_CCR(r3)
  49. li r0,0
  50. PPC_STL r0,_TRAP(r3)
  51. PPC_STL r0,ORIG_GPR3(r3)
  52. blr