Skip to content

Add enter_unprivileged() function #594

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinbube
Copy link

This adds a function to switch to program stack and unprivileged mode.

Fixes #583

This adds a function to switch to program stack and unprivileged mode.

Fixes rust-embedded#583
@kevinbube kevinbube force-pushed the new/enter_unprivileged_fn branch from 93ae33a to 89152c5 Compare April 25, 2025 16:36
/// code, respectively.
#[cfg(cortex_m)]
#[inline(always)]
pub fn enter_unprivileged(psp: &u32, entry: fn() -> !) -> ! {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PSP should be either a raw pointer, or a new type that requires appropriate alignment. Conceptually this is similar to https://docs.rs/rp2040-hal/latest/rp2040_hal/multicore/struct.Core.html#method.spawn and we could borrow the StackAllocation idea.

Unfortunately I don't immediately recall if PSP needs to be 4 or 8 byte aligned. We should check, and document.

The function also needs to be marked unsafe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard fault on debug compilation
2 participants