-
Notifications
You must be signed in to change notification settings - Fork 168
Privileged mode #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What is the status of this? Currently, I am having to write assembly code and create pendSV interrupt manually. I figured that out from here. Is there any better way ? |
It is this you are referring to? https://docs.rs/cortex-m/0.6.0/cortex_m/peripheral/struct.SCB.html#method.set_pendsv |
The true SVC instruction is a bit problematic, as this requires However, if you run the nightly compiler it should be no issue, you can use the functions here for reference https://github.com/rust-embedded/cortex-m/blob/master/src/asm.rs Or if you want stable, create your own
|
Oh yeah, I did come across those nightly compiler features. I guess I have to work with stable, so the second option I guess. Thank you :) |
Hey, also is there any way to Run code in privileged mode. Also is there anyway to make your code use the Main stack pointer instead of the process stack pointer. |
164: Allow writing to the CONTROL register r=adamgreig a=jonas-schievink This allows entering unprivileged mode. Part of #58 Co-authored-by: Jonas Schievink <[email protected]>
@kanishkarj Privileged mode and Main Stack Pointer (MSP) are used by default after reset of Cortex-M processors. The issue title and description are incorrect, I'm assuming it's talking about entering unprivileged mode (and using the Process Stack Pointer instead of MSP). |
Yeah, I realised. I don't have so much experience with embedded programming. I got to know that MSP is used by default recently. Well yes, I would like to know how to change to unprivileged mode ? I assume it is possible to do it with the PR mentioned below. |
It's now possible (as of 0.6.2) to switch to unprivileged mode by writing to the One more nice-to-have for dealing with unprivileged mode is a way to use the I suggest closing this issue, since the APIs the cortex-m provides are pretty much the best it can provide already. |
Since there were no objections, closing as per the comment above. |
There is currently no support for working in privileged mode.
There should at least be
cortex_m::asm::svc(num: u32)
cortex_m::register::control::write(Control)
and perhaps also something in the lines ofcortex_m::register::control::modify(f: F) where f: FnOnce(Control) -> Control
The cortex_m_rt crate seem to already implement the possibility for overriding the SVC handler. So with these changed it should be possible to:
The text was updated successfully, but these errors were encountered: