Skip to content
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

aarch64 current_task_ptr use sp_el0 #148

Open
lhw2002426 opened this issue Nov 30, 2024 · 0 comments
Open

aarch64 current_task_ptr use sp_el0 #148

lhw2002426 opened this issue Nov 30, 2024 · 0 comments
Assignees

Comments

@lhw2002426
Copy link
Contributor

When I looked at the code of ruxos task ,I found in modules/ruxhal/src/cpu.rs,ruxos seems use sp_el0 to save current cpu ptr in aarch64. I think it is not reasonable.Why? I guess it may be a mistake.

/// Sets the pointer to the current task with preemption-safety.
///
/// Preemption may be enabled when calling this function. This function will
/// guarantee the correctness even the current task is preempted.
///
/// # Safety
///
/// The given `ptr` must be pointed to a valid task structure.
#[inline]
pub unsafe fn set_current_task_ptr<T>(ptr: *const T) {
   #[cfg(target_arch = "x86_64")]
   {
       CURRENT_TASK_PTR.write_current_raw(ptr as usize)
   }
   #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
   {
       let _guard = kernel_guard::IrqSave::new();
       CURRENT_TASK_PTR.write_current_raw(ptr as usize)
   }
   #[cfg(target_arch = "aarch64")]
   {
       use tock_registers::interfaces::Writeable;
       aarch64_cpu::registers::SP_EL0.set(ptr as u64)
   }
}
   ```
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

No branches or pull requests

2 participants