0001
0002
0003
0004 #define __stringify_in_c(...) #__VA_ARGS__
0005 #define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
0006
0007
0008
0009
0010
0011 #define ___PPC_RA(a) (((a) & 0x1f) << 16)
0012 #define ___PPC_RB(b) (((b) & 0x1f) << 11)
0013
0014 #define PPC_INST_COPY 0x7c20060c
0015 #define PPC_INST_PASTE 0x7c20070d
0016
0017 #define PPC_COPY(a, b) stringify_in_c(.long PPC_INST_COPY | \
0018 ___PPC_RA(a) | ___PPC_RB(b))
0019 #define PPC_PASTE(a, b) stringify_in_c(.long PPC_INST_PASTE | \
0020 ___PPC_RA(a) | ___PPC_RB(b))
0021 #define CR0_SHIFT 28
0022 #define CR0_MASK 0xF
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 static inline int vas_copy(void *crb, int offset)
0035 {
0036 asm volatile(PPC_COPY(%0, %1)";"
0037 :
0038 : "b" (offset), "b" (crb)
0039 : "memory");
0040
0041 return 0;
0042 }
0043
0044 static inline int vas_paste(void *paste_address, int offset)
0045 {
0046 __u32 cr;
0047
0048 cr = 0;
0049 asm volatile(PPC_PASTE(%1, %2)";"
0050 "mfocrf %0, 0x80;"
0051 : "=r" (cr)
0052 : "b" (offset), "b" (paste_address)
0053 : "memory", "cr0");
0054
0055 return (cr >> CR0_SHIFT) & CR0_MASK;
0056 }