diff options
author | Hollis Blanchard <hollisb@us.ibm.com> | 2008-11-05 10:36:15 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:52:21 -0500 |
commit | c381a04313e7c0fb04246b1ff711e0b5726de6c0 (patch) | |
tree | d487c0a99510854eb1763329cb4b25182a2ef8c9 /arch/powerpc | |
parent | 9dd921cfea734409a931ccc6eafd7f09850311e9 (diff) |
ppc: Create disassemble.h to extract instruction fields
This is used in a couple places in KVM, but isn't KVM-specific.
However, this patch doesn't modify other in-kernel emulation code:
- xmon uses a direct copy of ppc_opc.c from binutils
- emulate_instruction() doesn't need it because it can use a series
of mask tests.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/disassemble.h | 80 | ||||
-rw-r--r-- | arch/powerpc/kvm/emulate.c | 57 |
2 files changed, 81 insertions, 56 deletions
diff --git a/arch/powerpc/include/asm/disassemble.h b/arch/powerpc/include/asm/disassemble.h new file mode 100644 index 000000000000..9b198d1b3b2b --- /dev/null +++ b/arch/powerpc/include/asm/disassemble.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License, version 2, as | ||
4 | * published by the Free Software Foundation. | ||
5 | * | ||
6 | * This program is distributed in the hope that it will be useful, | ||
7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
9 | * GNU General Public License for more details. | ||
10 | * | ||
11 | * You should have received a copy of the GNU General Public License | ||
12 | * along with this program; if not, write to the Free Software | ||
13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
14 | * | ||
15 | * Copyright IBM Corp. 2008 | ||
16 | * | ||
17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | ||
18 | */ | ||
19 | |||
20 | #ifndef __ASM_PPC_DISASSEMBLE_H__ | ||
21 | #define __ASM_PPC_DISASSEMBLE_H__ | ||
22 | |||
23 | #include <linux/types.h> | ||
24 | |||
25 | static inline unsigned int get_op(u32 inst) | ||
26 | { | ||
27 | return inst >> 26; | ||
28 | } | ||
29 | |||
30 | static inline unsigned int get_xop(u32 inst) | ||
31 | { | ||
32 | return (inst >> 1) & 0x3ff; | ||
33 | } | ||
34 | |||
35 | static inline unsigned int get_sprn(u32 inst) | ||
36 | { | ||
37 | return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0); | ||
38 | } | ||
39 | |||
40 | static inline unsigned int get_dcrn(u32 inst) | ||
41 | { | ||
42 | return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0); | ||
43 | } | ||
44 | |||
45 | static inline unsigned int get_rt(u32 inst) | ||
46 | { | ||
47 | return (inst >> 21) & 0x1f; | ||
48 | } | ||
49 | |||
50 | static inline unsigned int get_rs(u32 inst) | ||
51 | { | ||
52 | return (inst >> 21) & 0x1f; | ||
53 | } | ||
54 | |||
55 | static inline unsigned int get_ra(u32 inst) | ||
56 | { | ||
57 | return (inst >> 16) & 0x1f; | ||
58 | } | ||
59 | |||
60 | static inline unsigned int get_rb(u32 inst) | ||
61 | { | ||
62 | return (inst >> 11) & 0x1f; | ||
63 | } | ||
64 | |||
65 | static inline unsigned int get_rc(u32 inst) | ||
66 | { | ||
67 | return inst & 0x1; | ||
68 | } | ||
69 | |||
70 | static inline unsigned int get_ws(u32 inst) | ||
71 | { | ||
72 | return (inst >> 11) & 0x1f; | ||
73 | } | ||
74 | |||
75 | static inline unsigned int get_d(u32 inst) | ||
76 | { | ||
77 | return inst & 0xffff; | ||
78 | } | ||
79 | |||
80 | #endif /* __ASM_PPC_DISASSEMBLE_H__ */ | ||
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c index c5d2bfcf567a..5fd9cf779be5 100644 --- a/arch/powerpc/kvm/emulate.c +++ b/arch/powerpc/kvm/emulate.c | |||
@@ -28,62 +28,7 @@ | |||
28 | #include <asm/time.h> | 28 | #include <asm/time.h> |
29 | #include <asm/byteorder.h> | 29 | #include <asm/byteorder.h> |
30 | #include <asm/kvm_ppc.h> | 30 | #include <asm/kvm_ppc.h> |
31 | 31 | #include <asm/disassemble.h> | |
32 | /* Instruction decoding */ | ||
33 | static inline unsigned int get_op(u32 inst) | ||
34 | { | ||
35 | return inst >> 26; | ||
36 | } | ||
37 | |||
38 | static inline unsigned int get_xop(u32 inst) | ||
39 | { | ||
40 | return (inst >> 1) & 0x3ff; | ||
41 | } | ||
42 | |||
43 | static inline unsigned int get_sprn(u32 inst) | ||
44 | { | ||
45 | return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0); | ||
46 | } | ||
47 | |||
48 | static inline unsigned int get_dcrn(u32 inst) | ||
49 | { | ||
50 | return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0); | ||
51 | } | ||
52 | |||
53 | static inline unsigned int get_rt(u32 inst) | ||
54 | { | ||
55 | return (inst >> 21) & 0x1f; | ||
56 | } | ||
57 | |||
58 | static inline unsigned int get_rs(u32 inst) | ||
59 | { | ||
60 | return (inst >> 21) & 0x1f; | ||
61 | } | ||
62 | |||
63 | static inline unsigned int get_ra(u32 inst) | ||
64 | { | ||
65 | return (inst >> 16) & 0x1f; | ||
66 | } | ||
67 | |||
68 | static inline unsigned int get_rb(u32 inst) | ||
69 | { | ||
70 | return (inst >> 11) & 0x1f; | ||
71 | } | ||
72 | |||
73 | static inline unsigned int get_rc(u32 inst) | ||
74 | { | ||
75 | return inst & 0x1; | ||
76 | } | ||
77 | |||
78 | static inline unsigned int get_ws(u32 inst) | ||
79 | { | ||
80 | return (inst >> 11) & 0x1f; | ||
81 | } | ||
82 | |||
83 | static inline unsigned int get_d(u32 inst) | ||
84 | { | ||
85 | return inst & 0xffff; | ||
86 | } | ||
87 | 32 | ||
88 | static void kvmppc_emulate_dec(struct kvm_vcpu *vcpu) | 33 | static void kvmppc_emulate_dec(struct kvm_vcpu *vcpu) |
89 | { | 34 | { |