Reply by no_spam October 27, 20042004-10-27
On Wed, 27 Oct 2004 17:22:25 +0800, David R Brooks wrote:

> 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...
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.
> Replaced with an instruction which explicitly sets the MSR, all OK. > Thanks for drawing my attention to this code line :-)
My pleasure.
> no_spam <l_indien_no_more_spams@magic.fr> 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 <_start+0>: 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 by David R Brooks October 27, 20042004-10-27
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 <l_indien_no_more_spams@magic.fr> 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 <_start+0>:  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 by no_spam October 26, 20042004-10-26
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 <_start+0>: 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 by David R Brooks October 26, 20042004-10-26
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 <_start+0>:  mtspr   81,r0
0x00002004 <_start+4>:  lis     r1,48
0x00002008 <_start+8>:  addi    r1,r1,-30736
0x0000200c <_start+12>: lis     r13,64
0x00002010 <_start+16>: addi    r13,r13,-32436
0x00002014 <_start+20>: lis     r2,0
0x00002018 <_start+24>: addi    r2,r2,13404
0x0000201c <_start+28>: addi    r1,r1,-4
0x00002020 <_start+32>: lis     r0,0
0x00002024 <_start+36>: stw     r0,0(r1)
0x00002028 <_start+40>: stwu    r1,-64(r1)
0x0000202c <_start+44>: mfmsr   r3
0x00002030 <_start+48>: ori     r3,r3,4096
0x00002034 <_start+52>: mtmsr   r3
0x00002038 <_start+56>: bl      0x30bc <__init>
0x0000203c <_start+60>: b       0x2000 <_start>
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