copy-paste.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2016-17 IBM Corp.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <asm/ppc-opcode.h>
  10. #include <asm/reg.h>
  11. /*
  12. * Copy/paste instructions:
  13. *
  14. * copy RA,RB
  15. * Copy contents of address (RA) + effective_address(RB)
  16. * to internal copy-buffer.
  17. *
  18. * paste RA,RB
  19. * Paste contents of internal copy-buffer to the address
  20. * (RA) + effective_address(RB)
  21. */
  22. static inline int vas_copy(void *crb, int offset)
  23. {
  24. asm volatile(PPC_COPY(%0, %1)";"
  25. :
  26. : "b" (offset), "b" (crb)
  27. : "memory");
  28. return 0;
  29. }
  30. static inline int vas_paste(void *paste_address, int offset)
  31. {
  32. u32 cr;
  33. cr = 0;
  34. asm volatile(PPC_PASTE(%1, %2)";"
  35. "mfocrf %0, 0x80;"
  36. : "=r" (cr)
  37. : "b" (offset), "b" (paste_address)
  38. : "memory", "cr0");
  39. /* We mask with 0xE to ignore SO */
  40. return (cr >> CR0_SHIFT) & 0xE;
  41. }