S32K148 switch to supervisor mode and back

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

S32K148 switch to supervisor mode and back

ソリューションへジャンプ
2,304件の閲覧回数
michael_kirches
Contributor III

Dear NXP community,

I have a question about application modes on the S32K148.

To test some particularities in our current application, it would be helpful to be able to check, if the application is currently running in user or supervisor mode and to switch to supervisor mode if required. These checks are related to CAN and a third party CAN stack we have to integrate.

We want to check, if the CAN stack tries to access registers which may be protected, we want to achieve something similar to this pseudo-code function:

Function ReadFromProtectedRegister(Pointer_To_Address)
VAR content
IF Application in User Mode THEN
   Switch to Supervisor Mode
   content = Content of memory at Pointer_To_Address
   Switch back to User Mode
ELSE
   content = Content of memory at Pointer_To_Address
ENDIF
RETURN content
END‍‍‍‍‍‍‍‍‍‍‍

Could anyone please give us a hint on how to achieve this? Thanks a lot in advance.

Regards,

Michael

1 解決策
2,121件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

Please see this thread:

https://community.nxp.com/thread/480213 

Thanks,

BR, Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
2,122件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

Please see this thread:

https://community.nxp.com/thread/480213 

Thanks,

BR, Daniel

0 件の賞賛
返信
2,121件の閲覧回数
michael_kirches
Contributor III

Hi Daniel,

thanks for the link, but how would I check, if the application currently runs in user or supervisor mode? Unfortunatelly I am not too familiar with assembler instructions.

BR,

Michael

0 件の賞賛
返信
2,121件の閲覧回数
michael_kirches
Contributor III

I solved the question on how to check for privileged/unprivileged mode myself. In case anyone else stumbles accross the same question:

register int r0 __asm__("r0");

__asm__("mrs r0, control"); // nPRIV = 1

printf("R0 is: %d", r0);

This will move co-processor register control to register r0 and print the current value of r0.