copy-paste.h 817 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2016-17 IBM Corp.
  4. */
  5. #include <asm/ppc-opcode.h>
  6. #include <asm/reg.h>
  7. /*
  8. * Copy/paste instructions:
  9. *
  10. * copy RA,RB
  11. * Copy contents of address (RA) + effective_address(RB)
  12. * to internal copy-buffer.
  13. *
  14. * paste RA,RB
  15. * Paste contents of internal copy-buffer to the address
  16. * (RA) + effective_address(RB)
  17. */
  18. static inline int vas_copy(void *crb, int offset)
  19. {
  20. asm volatile(PPC_COPY(%0, %1)";"
  21. :
  22. : "b" (offset), "b" (crb)
  23. : "memory");
  24. return 0;
  25. }
  26. static inline int vas_paste(void *paste_address, int offset)
  27. {
  28. u32 cr;
  29. cr = 0;
  30. asm volatile(PPC_PASTE(%1, %2)";"
  31. "mfocrf %0, 0x80;"
  32. : "=r" (cr)
  33. : "b" (offset), "b" (paste_address)
  34. : "memory", "cr0");
  35. /* We mask with 0xE to ignore SO */
  36. return (cr >> CR0_SHIFT) & 0xE;
  37. }