This source file includes following definitions.
- copy
- copy_first
- paste
- paste_last
1
2 #ifndef _SELFTESTS_POWERPC_INSTRUCTIONS_H
3 #define _SELFTESTS_POWERPC_INSTRUCTIONS_H
4
5 #include <stdio.h>
6 #include <stdlib.h>
7
8
9 #define __COPY(RA, RB, L) \
10 (0x7c00060c | (RA) << (31-15) | (RB) << (31-20) | (L) << (31-10))
11 #define COPY(RA, RB, L) \
12 .long __COPY((RA), (RB), (L))
13
14 static inline void copy(void *i)
15 {
16 asm volatile(str(COPY(0, %0, 0))";"
17 :
18 : "b" (i)
19 : "memory"
20 );
21 }
22
23 static inline void copy_first(void *i)
24 {
25 asm volatile(str(COPY(0, %0, 1))";"
26 :
27 : "b" (i)
28 : "memory"
29 );
30 }
31
32
33 #define __PASTE(RA, RB, L, RC) \
34 (0x7c00070c | (RA) << (31-15) | (RB) << (31-20) | (L) << (31-10) | (RC) << (31-31))
35 #define PASTE(RA, RB, L, RC) \
36 .long __PASTE((RA), (RB), (L), (RC))
37
38 static inline int paste(void *i)
39 {
40 int cr;
41
42 asm volatile(str(PASTE(0, %1, 0, 0))";"
43 "mfcr %0;"
44 : "=r" (cr)
45 : "b" (i)
46 : "memory"
47 );
48 return cr;
49 }
50
51 static inline int paste_last(void *i)
52 {
53 int cr;
54
55 asm volatile(str(PASTE(0, %1, 1, 1))";"
56 "mfcr %0;"
57 : "=r" (cr)
58 : "b" (i)
59 : "memory"
60 );
61 return cr;
62 }
63
64 #define PPC_INST_COPY __COPY(0, 0, 0)
65 #define PPC_INST_COPY_FIRST __COPY(0, 0, 1)
66 #define PPC_INST_PASTE __PASTE(0, 0, 0, 0)
67 #define PPC_INST_PASTE_LAST __PASTE(0, 0, 1, 1)
68
69 #endif