How to make S32K146 M4 Core user mode and supervisor mode switching?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to make S32K146 M4 Core user mode and supervisor mode switching?

4,294件の閲覧回数
paulzhou
Contributor II

Dear Sir 

      How to make S32K146 M4 Core user mode and supervisor mode switching?

      Do you have demo code for this case? or reference application document ?

      Do S32K146 MCAL must do user mode and supervisor mode switching to meets functional security?

     Thank you!

ラベル(1)
3 返答(返信)

1,441件の閲覧回数
Fatma1234
Contributor I

Hello,

I am workinh with uC S32K144. I am developing two applications that have different access rights, one runs under supervisor mode, the other under user mode for safety reason.

The problem is, the application that runs under user mode has sometimes the need to read some registers and maube write on them, so it gets rejected and SW resets.

For now I developed a patch to switch to the supervisor mode before running the function that access crticial registers. 

Is there another solution for that ? Is there a way to allow limited access for some registers whe we are on user mode ? 

0 件の賞賛
返信

3,838件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,
If you need to switch to User mode, just set the nPRIV bit in CONTROL register

// switch to User (unprivileged) mode
 __asm__("mov r0, #0x01");
 __asm__("msr control, r0"); // nPRIV = 1


And to switch it back, you need to do it in SVC handler

// make a supervisor call (SVC) to transfer control to privileged software
 __asm__("svc #0x00");

void SVC_Handler(void){
 // switch to Supervisor (privileged) mode
 __asm__("mov r0, #0x00");
 __asm__("msr control, r0"); // nPRIV = 0
}

Unfortunately, I’m not familiar with MCAL.
Could you please create a service ticket?

https://community.nxp.com/docs/DOC-329745 

Regards,
Daniel

3,839件の閲覧回数
paulzhou
Contributor II

Dear Daniel
     Thank you for your help and this problem is solved

0 件の賞賛
返信