Problem in entering supervisor mode in MPC5748g

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

Problem in entering supervisor mode in MPC5748g

1,233 次查看
ashishraikar
Contributor I

After triggering the software interrupt 1

INTC.SSCIR[1].B.SET = 1; // to trigger a software interrupt.

I'm using this assembly code inside the interrupt service routine to change the PR bit of the MSR register.

1) to read the current MSR value into variable var

var is declared as:

uint32_t var = 0;

__asm__ __volatile__ ("e_lis %r30, (var)@h");

__asm__ __volatile__("e_ori %r30, %r30, (var)@l");

__asm__ __volatile__("mfmsr %r31");

__asm__ __volatile__("e_stw %r31, 0(%r30)");

But the e_ori instruction is intrepretted as e_mulli instruction in the disassembly, therefore its not loading the lower 16 bits into the r30 register, and returning a IVOR1 exception after executing the e_stw instruction. 

Is this the correct way to do it? please suggest some solution.

标签 (1)
标记 (2)
5 回复数

897 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I am not aware which compiler are you using.

I have used GHS one and bellow core works for me fine:

pastedImage_1.png

Peter

897 次查看
proteusiv
Contributor II

Hi.

Does this code work? The code does not reference var, and the comments mention changing from supervisor to user mode. What about changing from user to supervisor mode?

0 项奖励

897 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

Yes, the code works. Why I would post not working code?

var is defined as global 32-bit variable for me.

Change from user to supervisor is done via system call exception IVOR. (see core reference manual)

Peter

897 次查看
proteusiv
Contributor II

Thanks.  I have tried calling sm("se_sc"); from my code and have set up an IVOR8_Handler.  I have tried masking out the PR bit from the MSR register, but do not know which mnemonic do I use. Please can you expand upon how to change to supervisor mode?  Many thanks.

0 项奖励

897 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

Ok so you want to change from user mode to supervisor mode.

That is always good to know.

pastedImage_1.png

For your usecase:

1. call IVOR8

asm("se_sc");

2. change SRR1 in IVOR8 exception according to picture.

Peter