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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,466 次查看
modEmMaik
Contributor I

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:

 

BR,

mike aka modEmMaik

 

modEmMaikUserModeIssue.zip

Message Edited by t.dowe on 2009-10-09 11:02 AM
标签 (1)
0 项奖励
回复
1 回复

720 次查看
aersek
Contributor I

To enable usage of user stack you should enable it in CACR register of processor - bit 4 - EUSP.

 

 

0 项奖励
回复