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 /*
9  * Copy/paste instructions:
10  *
11  *	copy RA,RB
12  *		Copy contents of address (RA) + effective_address(RB)
13  *		to internal copy-buffer.
14  *
15  *	paste RA,RB
16  *		Paste contents of internal copy-buffer to the address
17  *		(RA) + effective_address(RB)
18  */
vas_copy(void * crb,int offset)19 static inline int vas_copy(void *crb, int offset)
20 {
21 	asm volatile(PPC_COPY(%0, %1)";"
22 		:
23 		: "b" (offset), "b" (crb)
24 		: "memory");
25 
26 	return 0;
27 }
28 
vas_paste(void * paste_address,int offset)29 static inline int vas_paste(void *paste_address, int offset)
30 {
31 	u32 cr;
32 
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 
40 	/* We mask with 0xE to ignore SO */
41 	return (cr >> CR0_SHIFT) & 0xE;
42 }
43