Problem in entering supervisor mode in MPC5748g

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem in entering supervisor mode in MPC5748g

1,206 Views
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.

Labels (1)
Tags (2)
5 Replies

870 Views
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

870 Views
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 Kudos

870 Views
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

870 Views
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 Kudos

870 Views
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