Mike Hayn

M52259demo Usermode Stack issue (still uses the supervisor mode stack)

Discussion created by Mike Hayn on Oct 9, 2009
Latest reply on Nov 5, 2009 by Andrija Ersek

Hi all,


I am actually preparing some exercises on a M52259Demo and encountered an issue for the user mode demonstration program.


The complete program simulates a user mode operating system trap call, using the user stack for parameter passing. So I set up a code like this to create an user stack an switch to user mode:


asm {
       // Init for the application (user mode)
       lea      userStack[10], a0    // UserStackPointer init
       move.l   a0, usp
       // switch to user mode
       move.w    sr,d1
       andi.l   #0xdfff, d1
       move.w    d1,sr  
       pea  counter // Still pushes it to supervisor stack...

The code warrior register panel reflects 0x0704 as SR register value, which should be the non-supervisor mode, plus the correct address pointing to my user stack as OTHER_A7. But when I push the pointer to "counter" via the pea command, it pushes it onto the supervisor stack.


I verified the user mode, via the following putchar commands. Those are blocked in the user mode after reset state and perform correct using MCF_SCM_PACR2 |= 0x60, so I guess the switch to user mode performs correct.


I received the code from an old example (target processor 68030 embedded system, so I guess the code performed correct on the old system.


The simplified project, including the code example should be attached to this post.


Any help would be very much appreciated :smileyhappy:



mike aka modEmMaik



Message Edited by t.dowe on 2009-10-09 11:02 AM