Running PSIM (PowerPC simulator) under GDB

Sorry if this is a bit of a clueless newbie question, but here goes. Running under Cygwin, with GDB and the embedded PowerPC simulator, PSIM. I can load the code OK, but when I try to run it, I get Type 7 ("Program") exceptions. This occurs even if interrupts are disabled by setting MSR=0. As I understand, Exception 7 originates from certain floating-point problems, which should not apply in this case (straight out of reset).

Can anyone suggest what might be causing these exceptions? TIA

================================================ == Transcript (setup files follow):

$ powerpc-unknown-eabi-gdb GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-cygwin

--target=powerpc-unknown-eabi" .

Reading .gdbinit Connected to the simulator. Breakpoint 1 at 0x3014: file main.c, line 490. (gdb) disass $pc Dump of assembler code for function _start: // Code is as expected

0x00002000 : mtspr 81,r0 0x00002004 : lis r1,48 0x00002008 : addi r1,r1,-30736 0x0000200c : lis r13,64 0x00002010 : addi r13,r13,-32436 0x00002014 : lis r2,0 0x00002018 : addi r2,r2,13404 0x0000201c : addi r1,r1,-4 0x00002020 : lis r0,0 0x00002024 : stw r0,0(r1) 0x00002028 : stwu r1,-64(r1) 0x0000202c : mfmsr r3 0x00002030 : ori r3,r3,4096 0x00002034 : mtmsr r3 0x00002038 : bl 0x30bc 0x0000203c : b 0x2000 End of assembler dump. (gdb) run Starting program: main.elf cpu 1, cia 0x700: double interrupt - MSR[RI] bit clear when attempting to deliver interrupt, cia=0x700, msr=0x0; srr0=0x2000(cia), srr1=0x80002(msr); trap-vector=0x700, trap-msr=0x0

Program terminated with signal ?, Unknown signal. The program no longer exists. [Switching to process 0] (gdb)

================================================ .gdbinit

file main.elf target sim -f psim.init set output-radix 16 load main.elf set $pc=0x2000 set $msr=0 break main

================================================ psim.init

/#address-cells 0x1 /aliases /options /options/little-endian? false /chosen /chosen/stdin */openprom/pal /chosen/stdout !/chosen/stdin /chosen/memory */memory /packages /cpus /cpus/cpu@0 /cpus/cpu@0/cpu-nr 0x0 /openprom /openprom/init /openprom/init/register /openprom/init/register/0.pc 0x100 /openprom/init/register/sp 0x3feff0 /openprom/init/register/msr 0x02 /openprom/init/stack /openprom/init/stack/stack-type "ppc-elf" /openprom/options /openprom/options/oea-memory-size 0x400000 /openprom/options/oea-interrupt-prefix 0x1 /openprom/options/smp 0x1 /openprom/options/env "oea" /openprom/options/os-emul "bug" /openprom/options/strict-alignment? false /openprom/options/floating-point? true /openprom/options/use-stdio? true /openprom/options/model "604" /openprom/options/model-issue 0xffffffff /openprom/pal /memory@0 /memory@0/reg 0 0x400000 /memory@0/available 0x3000 0x3fd000

Reply to
David R Brooks
Loading thread data ...

What is supposed spr81 to be ? I guess you want to do mtlr r0 but lr is spr8, not 81. Should check this...

Reply to
no_spam

Just so! I am targetting the MPC563, in which Special Register 81 is "Interrupt Disable" (a shorthand for clearing 2 bits in the MSR). This is not emulated by PSIM, which models the 604-series CPUs. Odd though, the PowerPC spec. says that un-implemented instructions (specifically including invalid Special registers) should hit Exception 10, not Exception 7. Life's little mystery #46...

Replaced with an instruction which explicitly sets the MSR, all OK. Thanks for drawing my attention to this code line :-)

no_spam wrote:

:On Tue, 26 Oct 2004 19:32:44 +0800, David R Brooks wrote: : :> Sorry if this is a bit of a clueless newbie question, but here goes. :> Running under Cygwin, with GDB and the embedded PowerPC simulator, :> PSIM. :> I can load the code OK, but when I try to run it, I get Type 7 :> ("Program") exceptions. This occurs even if interrupts are disabled by :> setting MSR=0. :> As I understand, Exception 7 originates from certain floating-point :> problems, which should not apply in this case (straight out of reset). :> :> Can anyone suggest what might be causing these exceptions? :> TIA :> :> ================================================ :> == Transcript (setup files follow): :> :> $ powerpc-unknown-eabi-gdb :> GNU gdb 6.0 :> Copyright 2003 Free Software Foundation, Inc. :> GDB is free software, covered by the GNU General Public License, and :> you are :> welcome to change it and/or distribute copies of it under certain :> conditions. :> Type "show copying" to see the conditions. :> There is absolutely no warranty for GDB. Type "show warranty" for :> details. :> This GDB was configured as "--host=i686-pc-cygwin :> --target=powerpc-unknown-eabi" :> . :> :> Reading .gdbinit :> Connected to the simulator. :> Breakpoint 1 at 0x3014: file main.c, line 490. :> (gdb) disass $pc :> Dump of assembler code for function _start: // Code is as expected :> 0x00002000 : mtspr 81,r0 : :What is supposed spr81 to be ? :I guess you want to do mtlr r0 but lr is spr8, not 81. :Should check this...

Reply to
David R Brooks

The standard PPC specifications say that invalid special register should hit program exception (7). Exception 10 is implementation specific, not in the core PPC spec, so if the MPC563 is not emulated in PSIM, the way it acts is all right for main stream PPC cores.

My pleasure.

Reply to
no_spam

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.