More xmon cell patches
cover More xmon cell patches
This is an updated series of xmon cell patches, it replaces the series of three I sent earlier (Nov 3rd).
It fixes the xmon sparse warnings, updates 'ss, adds 'sd' and 'sdi' commands to xmon - and incorporates updated disassembly code. Finally we make the disassembly optional for folks looking for a smaller kernel.
I haven't signed-off this series, as I'm not sure whether that's the right thing to do for the binutils code - which I obviously didn't write. When I know, I'll resend with signed-offs or whatever is appropriate.
The update of the ppc-dis.c code is RFC, I just thought I'd do it while I was there. But I haven't tested it thoroughly.
Arnd,
I think you have the first three of these in CVS? The first two should be unchanged, but the third one has changed for the better and should probably be updated if possible.
cheers
PATCH 1/9 Fix sparse warning in xmon Cell code
My patch to add spu helpers to xmon (a898497088f46252e6750405504064e2dce53117) introduced a few sparse warnings, because I was dereferencing an __iomem pointer.
I think the best way to handle it is to actually use the appropriate in_beXX functions. Need to rejigger the DUMP macro a little to accomodate that.
---
arch/powerpc/xmon/xmon.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
arch/powerpc/xmon/xmon.c +15 -7
@@ -2746,13 +2746,13 @@ static void restart_spus(void) }#define DUMP_WIDTH 23 -#define DUMP_FIELD (obj, format, field) \ +#define DUMP_VALUE (format, field, value) \ do { \ if (setjmp(bus_error_jmp) == 0) { \ catch_memory_errors = 1; \ sync(); \ printf(" %-*s = "format"\n", DUMP_WIDTH, \ - #field, obj->field); \ + #field, value); \ sync(); \ __delay(200); \ } else { \
@@ -2763,6 +2763,9 @@ do { \ catch_memory_errors =0 ; \ } while (0) +#define DUMP_FIELD (obj, format, field) \ + DUMP_VALUE(format, field, obj->field) +static void dump_spu_fields (struct spu *spu) {printf ("Dumping spu fields at address %p:\n" , spu);
@@ -2791,13 +2794,18 @@ static void dump_spu_fields(struct spu *DUMP_FIELD (spu,"0x%p" , timestamp);DUMP_FIELD (spu,"0x%lx" , problem_phys);DUMP_FIELD (spu,"0x%p" , problem); -DUMP_FIELD (spu,"0x%x" , problem->spu_runcntl_RW); -DUMP_FIELD (spu,"0x%x" , problem->spu_status_R); -DUMP_FIELD (spu,"0x%x" , problem->spu_npc_RW); +DUMP_VALUE ("0x%x" , problem->spu_runcntl_RW, +in_be32 (&spu->problem->spu_runcntl_RW)); +DUMP_VALUE ("0x%x" , problem->spu_status_R, +in_be32 (&spu->problem->spu_status_R)); +DUMP_VALUE ("0x%x" , problem->spu_npc_RW, +in_be32 (&spu->problem->spu_npc_RW));DUMP_FIELD (spu,"0x%p" , priv1); -if (spu->priv1) -DUMP_FIELD (spu,"0x%lx" , priv1->mfc_sr1_RW); +if (spu->priv1) { +DUMP_VALUE ("0x%lx" , priv1->mfc_sr1_RW, +in_be64 (&spu->priv1->mfc_sr1_RW)); + }DUMP_FIELD (spu,"0x%p" , priv2); }
PATCH 2/9 Show state of spus as they're stopped in Cell xmon helper
In reply to Michael EllermanAfter stopping spus in xmon I often find myself trawling through the field dumps to find out which spus were running. The spu stopping code actually knows what's running, so let's print it out to save the user some futzing.
---
arch/powerpc/xmon/xmon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/xmon/xmon.c +4 -1
@@ -2700,7 +2700,10 @@ static void stop_spus(void)__delay (200 ); spu_info[i].stopped_ok =1 ; -printf ("Stopped spu %.2d\n" , i); + +printf ("Stopped spu %.2d (was %s)\n" , i, + spu_info[i].saved_spu_runcntl_RW ? +"running" :"stopped" ); }else { catch_memory_errors =0 ;printf ("*** Error stopping spu %.2d\n" , i);
PATCH 3/9 Add a 'sd' command (spu dump) to xmon to dump spu local store
In reply to Michael EllermanAdd a command to xmon to dump the memory of a spu's local store. This mimics the 'd' command which dumps regular memory, but does a little hand holding by taking the user supplied address and finding that offset in the local store for the specified spu.
This makes it easy for example to look at what was executing on a spu:
1:mon> ss
...
Stopped spu 04 (was running)
...
1:mon> sf 4
Dumping spu fields at address c0000000019e0a00:
...
problem->spu_npc_RW = 0x228
...
1:mon> sd 4 0x228d000080080318228 01a00c021cffc408 4020007f217ff488 |........@ ..!...|
Aha, 01a00c02, which is of course rdch $2,$ch24 !
--
Updated to only do the setjmp goo around the spu access, and not around prdump because it does its own (via mread).
Also the num variable is now common between sf and sd, so you don't have to keep typing the spu number in if you're repeating commands on the same spu.
---
arch/powerpc/xmon/xmon.c | 60 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-)
arch/powerpc/xmon/xmon.c +55 -5
@@ -217,7 +217,8 @@ Commands:\n\#ifdef CONFIG_PPC_CELL " ss stop execution on all spus\n\ sr restore execution on stopped spus\n\ -sf # dump spu fields for spu # (in hex)\n" +sf # dump spu fields for spu # (in hex)\n\ +sd # dump spu local store for spu # (in hex)\n" #endif" S print special registers\n\ t print backtrace\n\
@@ -2649,6 +2650,7 @@ struct spu_info {struct spu *spu;u64 saved_mfc_sr1_RW;u32 saved_spu_runcntl_RW; +unsigned long dump_addr;u8 stopped_ok; };
@@ -2668,6 +2670,8 @@ void xmon_register_spus(struct list_head spu_info[spu->number].spu = spu; spu_info[spu->number].stopped_ok =0 ; + spu_info[spu->number].dump_addr = (unsigned long ) + spu_info[spu->number].spu->local_store; } }
@@ -2813,9 +2817,43 @@ static void dump_spu_fields(struct spu *DUMP_FIELD (spu,"0x%p" , priv2); } +static void dump_spu_ls (unsigned long num) +{ +unsigned long offset, addr, ls_addr; + +if (setjmp (bus_error_jmp) ==0 ) { + catch_memory_errors =1 ; +sync (); + ls_addr = (unsigned long )spu_info[num].spu->local_store; +sync (); +__delay (200 ); + }else { + catch_memory_errors =0 ; +printf ("*** Error: accessing spu info for spu %d\n" , num); +return ; + } + catch_memory_errors =0 ; + +if (scanhex (&offset)) + addr = ls_addr + offset; +else + addr = spu_info[num].dump_addr; + +if (addr >= ls_addr +LS_SIZE ) { +printf ("*** Error: address outside of local store\n" ); +return ; + } + +prdump (addr,64 ); + addr +=64 ; + last_cmd ="sd\n" ; + + spu_info[num].dump_addr = addr; +} +static int do_spu_cmd (void ) { -unsigned long num =0 ; +static unsigned long num =0 ;int cmd; cmd =inchar ();
@@ -2827,10 +2865,22 @@ static int do_spu_cmd(void)restart_spus ();break ;case 'f' : -if (scanhex (&num) && num <XMON_NUM_SPUS && spu_info[num].spu) -dump_spu_fields (spu_info[num].spu); -else +case 'd' : +scanhex (&num); +if (num >=XMON_NUM_SPUS || !spu_info[num].spu) {printf ("*** Error: invalid spu number\n" ); +return 0 ; + } + +switch (cmd) { +case 'f' : +dump_spu_fields (spu_info[num].spu); +break ; +default : +dump_spu_ls (num); +break ; + } +break ;default :return -1 ;
PATCH 4/9 Prepare for spu disassembly in xmon
In reply to Michael EllermanIn 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(-)
arch/powerpc/xmon/ppc-dis.c +3 -3
@@ -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. */
arch/powerpc/xmon/xmon.c +12 -3
@@ -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 coif (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) {
PATCH 5/9 Import spu disassembly code into xmon
In reply to Michael EllermanThis patch imports and munges the spu disassembly code from binutils.
All files originated from version 1.1 in binutils cvs.
* spu.h, spu-insns.h and spu-opc.c are unchanged except for pathnames.
* spu-dis.c has been edited heavily:
* use printf instead of info->fprintf_func and similar.
* pass the instruction in rather than reading it.
* we have no equivalent to symbol_at_address_func, so we just assume there is never a symbol at the address given.
---
arch/powerpc/xmon/spu-dis.c | 249 +++++++++++++++++++++++++ arch/powerpc/xmon/spu-insns.h | 410 ++++++++++++++++++++++++++++++++++++++++++ arch/powerpc/xmon/spu-opc.c | 44 ++++ arch/powerpc/xmon/spu.h | 126 ++++++++++++ 4 files changed, 829 insertions(+)
arch/powerpc/xmon/spu-dis.c new file +249 -0
@@ -0,0 +1,249 @@ +/* Disassemble SPU instructions + +Copyright 2006 Free Software Foundation, Inc. + +This file is part of GDB, GAS, and the GNU binutils. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include <linux/string.h> +#include "nonstdio.h" +#include "ansidecl.h" +#include "spu.h" + +extern void print_address (unsigned long memaddr); + +/* This file provides a disassembler function which uses +the disassembler interface defined in dis-asm.h. */ + +extern const struct spu_opcode spu_opcodes[]; +extern const int spu_num_opcodes; + +#define SPU_DISASM_TBL_SIZE (1 << 11) +static const struct spu_opcode *spu_disassemble_table[SPU_DISASM_TBL_SIZE ]; + +static void +init_spu_disassemble (void ) +{ +int i; + +/* If two instructions have the same opcode then we prefer the first +* one. In most cases it is just an alternate mnemonic. */ +for (i =0 ; i < spu_num_opcodes; i++) + { +int o = spu_opcodes[i].opcode; +if (o >=SPU_DISASM_TBL_SIZE ) +continue ;/* abort (); */ +if (spu_disassemble_table[o] ==0 ) + spu_disassemble_table[o] = &spu_opcodes[i]; + } +} + +/* Determine the instruction from the 10 least significant bits. */ +static const struct spu_opcode * +get_index_for_opcode (unsigned int insn) +{ +const struct spu_opcode *index; +unsigned int opcode = insn >> (32 -11 ); + +/* Init the table. This assumes that element 0/opcode 0 (currently +* NOP) is always used */ +if (spu_disassemble_table[0 ] ==0 ) +init_spu_disassemble (); + +if ((index = spu_disassemble_table[opcode &0x780 ]) !=0 + && index->insn_type ==RRR ) +return index; + +if ((index = spu_disassemble_table[opcode &0x7f0 ]) !=0 + && (index->insn_type ==RI18 || index->insn_type ==LBT )) +return index; + +if ((index = spu_disassemble_table[opcode &0x7f8 ]) !=0 + && index->insn_type ==RI10 ) +return index; + +if ((index = spu_disassemble_table[opcode &0x7fc ]) !=0 + && (index->insn_type ==RI16 )) +return index; + +if ((index = spu_disassemble_table[opcode &0x7fe ]) !=0 + && (index->insn_type ==RI8 )) +return index; + +if ((index = spu_disassemble_table[opcode &0x7ff ]) !=0 ) +return index; + +return 0 ; +} + +/* Print a Spu instruction. */ + +int +print_insn_spu (unsigned long insn,unsigned long memaddr) +{ +int value; +int hex_value; +const struct spu_opcode *index; +enum spu_insns tag; + + index =get_index_for_opcode (insn); + +if (index ==0 ) + { +printf (".long 0x%x" , insn); + } +else + { +int i; +int paren =0 ; + tag = (enum spu_insns )(index - spu_opcodes); +printf ("%s" , index->mnemonic); +if (tag ==M_BI || tag ==M_BISL || tag ==M_IRET || tag ==M_BISLED + || tag ==M_BIHNZ || tag ==M_BIHZ || tag ==M_BINZ || tag ==M_BIZ + || tag ==M_SYNC || tag ==M_HBR ) + { +int fb = (insn >> (32 -18 )) &0x7f ; +if (fb &0x40 ) +printf (tag ==M_SYNC ?"c" :"p" ); +if (fb &0x20 ) +printf ("d" ); +if (fb &0x10 ) +printf ("e" ); + } +if (index->arg[0 ] !=0 ) +printf ("\t" ); + hex_value =0 ; +for (i =1 ; i <= index->arg[0 ]; i++) + { +int arg = index->arg[i]; +if (arg !=A_P && !paren && i >1 ) +printf ("," ); + +switch (arg) + { +case A_T : +printf ("$%d" , +DECODE_INSN_RT (insn)); +break ; +case A_A : +printf ("$%d" , +DECODE_INSN_RA (insn)); +break ; +case A_B : +printf ("$%d" , +DECODE_INSN_RB (insn)); +break ; +case A_C : +printf ("$%d" , +DECODE_INSN_RC (insn)); +break ; +case A_S : +printf ("$sp%d" , +DECODE_INSN_RA (insn)); +break ; +case A_H : +printf ("$ch%d" , +DECODE_INSN_RA (insn)); +break ; +case A_P : + paren++; +printf ("(" ); +break ; +case A_U7A : +printf ("%d" , +173 -DECODE_INSN_U8 (insn)); +break ; +case A_U7B : +printf ("%d" , +155 -DECODE_INSN_U8 (insn)); +break ; +case A_S3 : +case A_S6 : +case A_S7 : +case A_S7N : +case A_U3 : +case A_U5 : +case A_U6 : +case A_U7 : + hex_value =DECODE_INSN_I7 (insn); +printf ("%d" , hex_value); +break ; +case A_S11 : +print_address (memaddr +DECODE_INSN_I9a (insn) *4 ); +break ; +case A_S11I : +print_address (memaddr +DECODE_INSN_I9b (insn) *4 ); +break ; +case A_S10 : +case A_S10B : + hex_value =DECODE_INSN_I10 (insn); +printf ("%d" , hex_value); +break ; +case A_S14 : + hex_value =DECODE_INSN_I10 (insn) *16 ; +printf ("%d" , hex_value); +break ; +case A_S16 : + hex_value =DECODE_INSN_I16 (insn); +printf ("%d" , hex_value); +break ; +case A_X16 : + hex_value =DECODE_INSN_U16 (insn); +printf ("%u" , hex_value); +break ; +case A_R18 : + value =DECODE_INSN_I16 (insn) *4 ; +if (value ==0 ) +printf ("%d" , value); +else + { + hex_value = memaddr + value; +print_address (hex_value &0x3ffff ); + } +break ; +case A_S18 : + value =DECODE_INSN_U16 (insn) *4 ; +if (value ==0 ) +printf ("%d" , value); +else +print_address (value); +break ; +case A_U18 : + value =DECODE_INSN_U18 (insn); +if (value ==0 ||1 ) + { + hex_value = value; +printf ("%u" , value); + } +else +print_address (value); +break ; +case A_U14 : + hex_value =DECODE_INSN_U14 (insn); +printf ("%u" , hex_value); +break ; + } +if (arg !=A_P && paren) + { +printf (")" ); + paren--; + } + } +if (hex_value >16 ) +printf ("\t# %x" , hex_value); + } +return 4 ; +}
arch/powerpc/xmon/spu-insns.h new file +410 -0
410 lines not on this page · raw message
arch/powerpc/xmon/spu-opc.c new file +44 -0
44 lines not on this page · raw message
arch/powerpc/xmon/spu.h new file +126 -0
126 lines not on this page · raw message
PATCH 6/9 Add spu disassembly to xmon
In reply to Michael EllermanThis patch adds a "sdi" command to xmon, to disassemble the contents of an spu's local store.
---
arch/powerpc/xmon/Makefile | 1 + arch/powerpc/xmon/xmon.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-)
arch/powerpc/xmon/Makefile +1 -0
@@ -5,3 +5,4 @@ EXTRA_CFLAGS += -mno-minimal-toc endif obj-y += xmon.o ppc-dis.o ppc-opc.o setjmp.o start.o \ nonstdio.o +obj-$(CONFIG_PPC_CELL) += spu-dis.o spu-opc.o
arch/powerpc/xmon/xmon.c +27 -8
@@ -154,6 +154,7 @@ static int do_spu_cmd(void);int xmon_no_auto_backtrace;extern int print_insn_powerpc (unsigned long insn,unsigned long memaddr); +extern int print_insn_spu (unsigned long insn,unsigned long memaddr);extern void xmon_enter (void );extern void xmon_leave (void );
@@ -218,7 +219,8 @@ Commands:\n\" ss stop execution on all spus\n\ sr restore execution on stopped spus\n\ sf # dump spu fields for spu # (in hex)\n\ -sd # dump spu local store for spu # (in hex)\n" +sd # dump spu local store for spu # (in hex)\ +sdi # disassemble spu local store for spu # (in hex)\n" #endif" S print special registers\n\ t print backtrace\n\
@@ -2826,7 +2828,13 @@ static void dump_spu_fields(struct spu *DUMP_FIELD (spu,"0x%p" , priv2); } -static void dump_spu_ls (unsigned long num) +int +spu_inst_dump (unsigned long adr,long count,int praddr) +{ +return generic_inst_dump (adr, count, praddr, print_insn_spu); +} + +static void dump_spu_ls (unsigned long num,int subcmd) {unsigned long offset, addr, ls_addr;
@@ -2853,9 +2861,17 @@ static void dump_spu_ls(unsigned long nureturn ; } -prdump (addr,64 ); - addr +=64 ; - last_cmd ="sd\n" ; +switch (subcmd) { +case 'i' : + addr +=spu_inst_dump (addr,16 ,1 ); + last_cmd ="sdi\n" ; +break ; +default : +prdump (addr,64 ); + addr +=64 ; + last_cmd ="sd\n" ; +break ; + } spu_info[num].dump_addr = addr; }
@@ -2863,7 +2879,7 @@ static void dump_spu_ls(unsigned long nustatic int do_spu_cmd (void ) {static unsigned long num =0 ; -int cmd; +int cmd, subcmd =0 ; cmd =inchar ();switch (cmd) {
@@ -2873,8 +2889,11 @@ static int do_spu_cmd(void)case 'r' :restart_spus ();break ; -case 'f' :case 'd' : + subcmd =inchar (); +if (isxdigit (subcmd) || subcmd =='\n' ) + termch = subcmd; +case 'f' :scanhex (&num);if (num >=XMON_NUM_SPUS || !spu_info[num].spu) {printf ("*** Error: invalid spu number\n" );
@@ -2886,7 +2905,7 @@ static int do_spu_cmd(void)dump_spu_fields (spu_info[num].spu);break ;default : -dump_spu_ls (num); +dump_spu_ls (num, subcmd);break ; }
PATCH 7/9 Make xmon disassembly optional
In reply to Michael EllermanWhile adding spu disassembly support it struck me that we're actually carrying quite a lot of code around, just to do disassembly in the case of a crash.
While on large systems it's not an issue, on smaller ones it might be nice to have xmon - but without the weight of the disassembly support. For a Cell build this saves ~230KB (!), and for pSeries ~195KB.
We still support the 'di' and 'sdi' commands, however they just dump the instruction in hex.
Move the definitions into a header to clean xmon.c just a tiny bit.
---
arch/powerpc/Kconfig.debug | 9 +++++++++ arch/powerpc/xmon/Makefile | 8 ++++++-- arch/powerpc/xmon/dis-asm.h | 31 +++++++++++++++++++++++++++++++ arch/powerpc/xmon/ppc-dis.c | 3 +-- arch/powerpc/xmon/spu-dis.c | 3 +-- arch/powerpc/xmon/xmon.c | 5 +---- 6 files changed, 49 insertions(+), 10 deletions(-)
arch/powerpc/Kconfig.debug +9 -0
@@ -98,6 +98,15 @@ config XMON_DEFAULT xmon is normally disabled unless booted with 'xmon=on'. Use 'xmon=off' to disable xmon init during runtime. +config XMON_DISASSEMBLY + bool "Include disassembly support in xmon" + depends on XMON + default y + help + Include support for disassembling in xmon. You probably want + to say Y here, unless you're building for a memory-constrained + system. + config IRQSTACKS bool "Use separate kernel stacks when processing interrupts" depends on PPC64
arch/powerpc/xmon/Makefile +6 -2
@@ -3,6 +3,10 @@ ifdef CONFIG_PPC64 EXTRA_CFLAGS += -mno-minimal-toc endif -obj-y += xmon.o ppc-dis.o ppc-opc.o setjmp.o start.o \ - nonstdio.o + +obj-y += xmon.o setjmp.o start.o nonstdio.o + +ifdef CONFIG_XMON_DISASSEMBLY +obj-y += ppc-dis.o ppc-opc.o obj-$(CONFIG_PPC_CELL) += spu-dis.o spu-opc.o +endif
arch/powerpc/xmon/dis-asm.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef _POWERPC_XMON_DIS_ASM_H +#define _POWERPC_XMON_DIS_ASM_H +/* +* Copyright (C) 2006 Michael Ellerman, IBM Corporation. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +extern void print_address (unsigned long memaddr); + +#ifdef CONFIG_XMON_DISASSEMBLY +extern int print_insn_powerpc (unsigned long insn,unsigned long memaddr); +extern int print_insn_spu (unsigned long insn,unsigned long memaddr); +#else +static inline int print_insn_powerpc (unsigned long insn,unsigned long memaddr) +{ +printf ("%.8x" , insn); +return 0 ; +} + +static inline int print_insn_spu (unsigned long insn,unsigned long memaddr) +{ +printf ("%.8x" , insn); +return 0 ; +} +#endif + +#endif /* _POWERPC_XMON_DIS_ASM_H */
arch/powerpc/xmon/ppc-dis.c +1 -2
@@ -21,8 +21,7 @@ Software Foundation, 59 Temple Place - S#include "nonstdio.h" #include "ansidecl.h" #include "ppc.h" - -extern void print_address (unsigned long memaddr); +#include "dis-asm.h" /* Print a PowerPC or POWER instruction. */
arch/powerpc/xmon/spu-dis.c +1 -2
@@ -22,8 +22,7 @@#include "nonstdio.h" #include "ansidecl.h" #include "spu.h" - -extern void print_address (unsigned long memaddr); +#include "dis-asm.h" /* This file provides a disassembler function which uses the disassembler interface defined in dis-asm.h. */
arch/powerpc/xmon/xmon.c +1 -4
@@ -46,6 +46,7 @@#endif #include "nonstdio.h" +#include "dis-asm.h" #define scanhex xmon_scanhex#define skipbl xmon_skipbl
@@ -109,7 +110,6 @@ static int bsesc(void);static void dump (void );static void prdump (unsigned long ,long );static int ppc_inst_dump (unsigned long ,long ,int ); -void print_address (unsigned long );static void backtrace (struct pt_regs *);static void excprint (struct pt_regs *);static void prregs (struct pt_regs *);
@@ -153,9 +153,6 @@ static int do_spu_cmd(void);int xmon_no_auto_backtrace; -extern int print_insn_powerpc (unsigned long insn,unsigned long memaddr); -extern int print_insn_spu (unsigned long insn,unsigned long memaddr); -extern void xmon_enter (void );extern void xmon_leave (void );
PATCH 8/9 Make 64-bit cpu features defined on 32-bit
In reply to Michael EllermanIt saves #ifdef'ing in callers if we at least define the 64-bit cpu features for 32-bit also.
---
include/asm-powerpc/cputable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-powerpc/cputable.h +2 -2
@@ -311,7 +311,8 @@ extern void do_feature_fixups(unsigned l#define CPU_FTRS_E500_2 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ CPU_FTR_BIG_PHYS | CPU_FTR_NODSISRALIGN)#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN) -#ifdef __powerpc64__ + +/* 64-bit CPUs */ #define CPU_FTRS_POWER3 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ CPU_FTR_HPTE_TABLE | CPU_FTR_IABR | CPU_FTR_PPC_LE)#define CPU_FTRS_RS64 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
@@ -343,7 +344,6 @@ extern void do_feature_fixups(unsigned l CPU_FTR_PURR | CPU_FTR_REAL_LE)#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2) -#endif #ifdef __powerpc64__#define CPU_FTRS_POSSIBLE \
Re: [RFC/PATCH 8/9] Make 64-bit cpu features defined on 32-bit
Quoted 3 lines · On Thu, 16 Nov 2006 18:23:27 +1100 Michael Ellerman <[email protected]>…
It saves #ifdef'ing in callers if we at least define the 64-bit cpu features for 32-bit also.
Does it matter that some of the 64 bit feature bit defines are 0 on 32 bit?
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/
Re: [RFC/PATCH 8/9] Make 64-bit cpu features defined on 32-bit
Quoted 7 lines · Stephen Rothwell
Quoted 3 lines · On Thu, 16 Nov 2006 18:23:27 +1100 Michael Ellerman <[email protected]>…
It saves #ifdef'ing in callers if we at least define the 64-bit cpu features for 32-bit also.
Does it matter that some of the 64 bit feature bit defines are 0 on 32 bit?
Not for me, I just want to be able to call cpu_has_feature() on it. If the feature is 0 it'll always return false.
cheers
Signature · 8 lines
Michael Ellerman OzLabs, IBM Australia Development Lab wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
PATCH 9/9 Import updated version of ppc disassembly code for xmon
In reply to Michael EllermanThis includes:
* version 1.24 of ppc-dis.c
* version 1.88 of ppc-opc.c
* version 1.23 of ppc.h
I can't vouch for the accuracy etc. of these changes, but it brings us into line with binutils - and from a cursory test appears to work fine.
---
arch/powerpc/xmon/ppc-dis.c | 20 - arch/powerpc/xmon/ppc-opc.c | 778 ++++++++++++++++++++++++++++++++------------ arch/powerpc/xmon/ppc.h | 39 +- 3 files changed, 618 insertions(+), 219 deletions(-)
arch/powerpc/xmon/ppc-dis.c +16 -4
@@ -1,5 +1,6 @@/* ppc-dis.c -- Disassemble PowerPC instructions -Copyright 1994 Free Software Foundation, Inc. +Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support This file is part of GDB, GAS, and the GNU binutils.
@@ -16,8 +17,9 @@ the GNU General Public License for moreYou should have received a copy of the GNU General Public License along with this file; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <asm/cputable.h> #include "nonstdio.h" #include "ansidecl.h" #include "ppc.h"
@@ -36,6 +38,15 @@ print_insn_powerpc (unsigned long insn, dialect =PPC_OPCODE_PPC |PPC_OPCODE_CLASSIC |PPC_OPCODE_COMMON |PPC_OPCODE_64 |PPC_OPCODE_POWER4 |PPC_OPCODE_ALTIVEC ; +if (cpu_has_feature (CPU_FTRS_POWER5 )) + dialect |=PPC_OPCODE_POWER5 ; + +if (cpu_has_feature (CPU_FTRS_CELL )) + dialect |=PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ; + +if (cpu_has_feature (CPU_FTRS_POWER6 )) + dialect |=PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ; +/* Get the major opcode of the instruction. */ op =PPC_OP (insn);
@@ -120,7 +131,8 @@ print_insn_powerpc (unsigned long insn, }/* Print the operand as directed by the flags. */ -if ((operand->flags &PPC_OPERAND_GPR ) !=0 ) +if ((operand->flags &PPC_OPERAND_GPR ) !=0 + || ((operand->flags &PPC_OPERAND_GPR_0 ) !=0 && value !=0 ))printf ("r%ld" , value);else if ((operand->flags &PPC_OPERAND_FPR ) !=0 )printf ("f%ld" , value);
@@ -136,7 +148,7 @@ print_insn_powerpc (unsigned long insn,else {if (operand->bits ==3 ) -printf ("cr%d" , value); +printf ("cr%ld" , value);else {static const char *cbnames[4 ] = {"lt" ,"gt" ,"eq" ,"so" };
arch/powerpc/xmon/ppc-opc.c +575 -203
1,664 lines not on this page · raw message
arch/powerpc/xmon/ppc.h +27 -12
@@ -1,5 +1,5 @@ /* ppc.h -- Header file for PowerPC opcode table - Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003 + Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support
@@ -17,7 +17,7 @@ the GNU General Public License for more You should have received a copy of the GNU General Public License along with this file; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PPC_H #define PPC_H
@@ -134,6 +134,18 @@ extern const int powerpc_num_opcodes; /* Opcode is supported by machine check APU. */ #define PPC_OPCODE_RFMCI 0x800000 +/* Opcode is only supported by Power5 architecture. */ +#define PPC_OPCODE_POWER5 0x1000000 + +/* Opcode is supported by PowerPC e300 family. */ +#define PPC_OPCODE_E300 0x2000000 + +/* Opcode is only supported by Power6 architecture. */ +#define PPC_OPCODE_POWER6 0x4000000 + +/* Opcode is only supported by PowerPC Cell family. */ +#define PPC_OPCODE_CELL 0x8000000 + /* A macro to extract the major opcode from an instruction. */ #define PPC_OP(i) (((i) >> 26) & 0x3f)
@@ -233,25 +245,28 @@ extern const struct powerpc_operand powe register names with a leading 'r'. */ #define PPC_OPERAND_GPR (040) +/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */ +#define PPC_OPERAND_GPR_0 (0100) + /* This operand names a floating point register. The disassembler prints these with a leading 'f'. */ -#define PPC_OPERAND_FPR (0100) +#define PPC_OPERAND_FPR (0200) /* This operand is a relative branch displacement. The disassembler prints these symbolically if possible. */ -#define PPC_OPERAND_RELATIVE (0200) +#define PPC_OPERAND_RELATIVE (0400) /* This operand is an absolute branch address. The disassembler prints these symbolically if possible. */ -#define PPC_OPERAND_ABSOLUTE (0400) +#define PPC_OPERAND_ABSOLUTE (01000) /* This operand is optional, and is zero if omitted. This is used for - the optional BF and L fields in the comparison instructions. The + example, in the optional BF field in the comparison instructions. The assembler must count the number of operands remaining on the line, and the number of operands remaining for the opcode, and decide whether this operand is present or not. The disassembler should print this operand out only if it is not zero. */ -#define PPC_OPERAND_OPTIONAL (01000) +#define PPC_OPERAND_OPTIONAL (02000) /* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand is omitted, then for the next operand use this operand value plus
@@ -259,24 +274,24 @@ extern const struct powerpc_operand powe hack is needed because the Power rotate instructions can take either 4 or 5 operands. The disassembler should print this operand out regardless of the PPC_OPERAND_OPTIONAL field. */ -#define PPC_OPERAND_NEXT (02000) +#define PPC_OPERAND_NEXT (04000) /* This operand should be regarded as a negative number for the purposes of overflow checking (i.e., the normal most negative number is disallowed and one more than the normal most positive number is allowed). This flag will only be set for a signed operand. */ -#define PPC_OPERAND_NEGATIVE (04000) +#define PPC_OPERAND_NEGATIVE (010000) /* This operand names a vector unit register. The disassembler prints these with a leading 'v'. */ -#define PPC_OPERAND_VR (010000) +#define PPC_OPERAND_VR (020000) /* This operand is for the DS field in a DS form instruction. */ -#define PPC_OPERAND_DS (020000) +#define PPC_OPERAND_DS (040000) /* This operand is for the DQ field in a DQ form instruction. */ -#define PPC_OPERAND_DQ (040000) +#define PPC_OPERAND_DQ (0100000) /* The POWER and PowerPC assemblers use a few macros. We keep them with the operands table for simplicity. The macro table is an
Quoted 7 lines · Michael Ellerman
This is an updated series of xmon cell patches, it replaces the series of three I sent earlier (Nov 3rd).
It fixes the xmon sparse warnings, updates 'ss, adds 'sd' and 'sdi' commands to xmon - and incorporates updated disassembly code. Finally we make the disassembly optional for folks looking for a smaller kernel.
Quoted 6 lines
I haven't signed-off this series, as I'm not sure whether that's the right thing to do for the binutils code - which I obviously didn't write. When I know, I'll resend with signed-offs or whatever is appropriate.
The update of the
ppc-dis.ccode is RFC, I just thought I'd do it while I was there. But I haven't tested it thoroughly.
Thanks for the update. I'll put them into my 2.6.19-rc based tree, but I won't backport them to 2.6.18, in case anyone is wondering.
Quoted 3 lines
I think you have the first three of these in CVS? The first two should be unchanged, but the third one has changed for the better and should probably be updated if possible.
I would prefer if you didn't do this, as it breaks my scripts when dealing with multiple trees containing the same patches. Please either change the subject of the replacement patch, or put the update into another patch on top of it. It's no problem if your patches go right into powerpc.git, but if you want me to forward them, I'd rather fold the patches myself.
Paul, are you taking these patches directly, or should I repost them to you along with my other stuff for 2.6.20?
Arnd <><
Quoted 2 lines · Arnd Bergmann
Paul, are you taking these patches directly, or should I repost them to you along with my other stuff for 2.6.20?
Whichever you prefer - if you ack them on the mailing list I'll put them in powerpc.git, or if you resend them with your signed-off-by I'll put them in.
Paul.
Quoted 6 lines · Michael Ellerman
This is an updated series of xmon cell patches, it replaces the series of three I sent earlier (Nov 3rd).
It fixes the xmon sparse warnings, updates 'ss, adds 'sd' and 'sdi' commands to xmon - and incorporates updated disassembly code. Finally we make the disassembly optional for folks looking for a smaller kernel.
All 9 patches look good to me. Paul, please include in powerpc.git.
Arnd <><