linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org, Arnd Bergmann <arnd.bergmann@de.ibm.com>
Subject: [RFC/PATCH 4/9] Prepare for spu disassembly in xmon
Date: Thu, 16 Nov 2006 18:23:22 +1100	[thread overview]
Message-ID: <20061116072325.BCD9167C14@ozlabs.org> (raw)
In-Reply-To: <1163661800.406227.631357998554.qpush@cradle>

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.

---

 arch/powerpc/xmon/ppc-dis.c |    6 +++---
 arch/powerpc/xmon/xmon.c    |   15 ++++++++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)

Index: cell/arch/powerpc/xmon/ppc-dis.c
===================================================================
--- cell.orig/arch/powerpc/xmon/ppc-dis.c
+++ cell/arch/powerpc/xmon/ppc-dis.c
@@ -27,14 +27,14 @@ extern void print_address (unsigned long
 /* Print a PowerPC or POWER instruction.  */
 
 int
-print_insn_powerpc (unsigned long insn, unsigned long memaddr, int dialect)
+print_insn_powerpc (unsigned long insn, unsigned long memaddr)
 {
   const struct powerpc_opcode *opcode;
   const struct powerpc_opcode *opcode_end;
   unsigned long op;
+  int dialect;
 
-  if (dialect == 0)
-    dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON
+  dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON
 	      | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC;
 
   /* Get the major opcode of the instruction.  */
Index: cell/arch/powerpc/xmon/xmon.c
===================================================================
--- cell.orig/arch/powerpc/xmon/xmon.c
+++ cell/arch/powerpc/xmon/xmon.c
@@ -153,7 +153,7 @@ static int do_spu_cmd(void);
 
 int xmon_no_auto_backtrace;
 
-extern int print_insn_powerpc(unsigned long, unsigned long, int);
+extern int print_insn_powerpc(unsigned long insn, unsigned long memaddr);
 
 extern void xmon_enter(void);
 extern void xmon_leave(void);
@@ -2066,8 +2066,11 @@ prdump(unsigned long adrs, long ndump)
 	}
 }
 
+typedef int (*instruction_dump_func)(unsigned long inst, unsigned long addr);
+
 int
-ppc_inst_dump(unsigned long adr, long count, int praddr)
+generic_inst_dump(unsigned long adr, long count, int praddr,
+			instruction_dump_func dump_func)
 {
 	int nr, dotted;
 	unsigned long first_adr;
@@ -2097,12 +2100,18 @@ ppc_inst_dump(unsigned long adr, long co
 		if (praddr)
 			printf(REG"  %.8x", adr, inst);
 		printf("\t");
-		print_insn_powerpc(inst, adr, 0);	/* always returns 4 */
+		dump_func(inst, adr);
 		printf("\n");
 	}
 	return adr - first_adr;
 }
 
+int
+ppc_inst_dump(unsigned long adr, long count, int praddr)
+{
+	return generic_inst_dump(adr, count, praddr, print_insn_powerpc);
+}
+
 void
 print_address(unsigned long addr)
 {

  parent reply	other threads:[~2006-11-16  7:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-16  7:23 [RFC/PATCH 0/9] More xmon cell patches Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 1/9] Fix sparse warning in xmon Cell code Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 3/9] Add a 'sd' command (spu dump) to xmon to dump spu local store Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 2/9] Show state of spus as they're stopped in Cell xmon helper Michael Ellerman
2006-11-16  7:23 ` Michael Ellerman [this message]
2006-11-16  7:23 ` [RFC/PATCH 5/9] Import spu disassembly code into xmon Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 6/9] Add spu disassembly to xmon Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 7/9] Make xmon disassembly optional Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 8/9] Make 64-bit cpu features defined on 32-bit Michael Ellerman
2006-11-16 10:17   ` Stephen Rothwell
2006-11-16 23:03     ` Michael Ellerman
2006-11-16  7:23 ` [RFC/PATCH 9/9] Import updated version of ppc disassembly code for xmon Michael Ellerman
2006-11-16 21:20 ` [RFC/PATCH 0/9] More xmon cell patches Arnd Bergmann
2006-11-20 22:06   ` Paul Mackerras
2006-11-21 10:24 ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061116072325.BCD9167C14@ozlabs.org \
    --to=michael@ellerman.id.au \
    --cc=arnd.bergmann@de.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).