Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Prepare for spu disassembly in xmon

In order to do disassembly of spu binaries in xmon, we need to abstract
the disassembly function from ppc_inst_dump.

We do this by making the actual disassembly function a function pointer
that we pass to ppc_inst_dump(). To save updating all the callers, we
turn ppc_inst_dump() into generic_inst_dump() and make ppc_inst_dump()
a wrapper which always uses print_insn_powerpc().

Currently we pass the dialect into print_insn_powerpc(), but we always
pass 0 - so just make it a local.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>

authored by

Michael Ellerman and committed by
Paul Mackerras
4c4c8723 24a24c85

+15 -6
+3 -3
arch/powerpc/xmon/ppc-dis.c
··· 27 27 /* Print a PowerPC or POWER instruction. */ 28 28 29 29 int 30 - print_insn_powerpc (unsigned long insn, unsigned long memaddr, int dialect) 30 + print_insn_powerpc (unsigned long insn, unsigned long memaddr) 31 31 { 32 32 const struct powerpc_opcode *opcode; 33 33 const struct powerpc_opcode *opcode_end; 34 34 unsigned long op; 35 + int dialect; 35 36 36 - if (dialect == 0) 37 - dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON 37 + dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON 38 38 | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC; 39 39 40 40 /* Get the major opcode of the instruction. */
+12 -3
arch/powerpc/xmon/xmon.c
··· 154 154 155 155 int xmon_no_auto_backtrace; 156 156 157 - extern int print_insn_powerpc(unsigned long, unsigned long, int); 157 + extern int print_insn_powerpc(unsigned long insn, unsigned long memaddr); 158 158 159 159 extern void xmon_enter(void); 160 160 extern void xmon_leave(void); ··· 2068 2068 } 2069 2069 } 2070 2070 2071 + typedef int (*instruction_dump_func)(unsigned long inst, unsigned long addr); 2072 + 2071 2073 int 2072 - ppc_inst_dump(unsigned long adr, long count, int praddr) 2074 + generic_inst_dump(unsigned long adr, long count, int praddr, 2075 + instruction_dump_func dump_func) 2073 2076 { 2074 2077 int nr, dotted; 2075 2078 unsigned long first_adr; ··· 2102 2099 if (praddr) 2103 2100 printf(REG" %.8x", adr, inst); 2104 2101 printf("\t"); 2105 - print_insn_powerpc(inst, adr, 0); /* always returns 4 */ 2102 + dump_func(inst, adr); 2106 2103 printf("\n"); 2107 2104 } 2108 2105 return adr - first_adr; 2106 + } 2107 + 2108 + int 2109 + ppc_inst_dump(unsigned long adr, long count, int praddr) 2110 + { 2111 + return generic_inst_dump(adr, count, praddr, print_insn_powerpc); 2109 2112 } 2110 2113 2111 2114 void