mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-26 20:00:32 +00:00
Replace some inline ASM with xtensa_lx implementations (#4144)
* Fix incorrect uses of wsr.intset * Also use interrupt::clear * Also replace wsr.vecbase * Remove cause_sw_intr_to_core from C3/S3
This commit is contained in:
parent
e57530c9b5
commit
83105b4dbb
@ -286,7 +286,7 @@ impl<'d> CpuControl<'d> {
|
||||
|
||||
// set vector table and stack pointer
|
||||
unsafe {
|
||||
core::arch::asm!("wsr.vecbase {0}", in(reg) &raw const _init_start, options(nostack));
|
||||
xtensa_lx::set_vecbase(&raw const _init_start);
|
||||
xtensa_lx::set_stack_pointer(APP_CORE_STACK_TOP.load(Ordering::Acquire));
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ impl<'d> CpuControl<'d> {
|
||||
|
||||
// set vector table and stack pointer
|
||||
unsafe {
|
||||
core::arch::asm!("wsr.vecbase {0}", in(reg) &raw const _init_start, options(nostack));
|
||||
xtensa_lx::set_vecbase(&raw const _init_start);
|
||||
xtensa_lx::set_stack_pointer(APP_CORE_STACK_TOP.load(Ordering::Acquire));
|
||||
}
|
||||
|
||||
|
@ -87,14 +87,12 @@ pub(crate) fn setup_multitasking() {
|
||||
#[cfg_attr(not(esp32), unsafe(export_name = "Software0"))]
|
||||
#[cfg_attr(esp32, unsafe(export_name = "Software1"))]
|
||||
fn task_switch_interrupt(context: &mut CpuContext) {
|
||||
let intr = SW_INTERRUPT;
|
||||
unsafe { core::arch::asm!("wsr.intclear {0}", in(reg) intr, options(nostack)) };
|
||||
unsafe { xtensa_lx_rt::xtensa_lx::interrupt::clear(SW_INTERRUPT) };
|
||||
|
||||
SCHEDULER.with(|scheduler| scheduler.switch_task(context));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn yield_task() {
|
||||
let intr = SW_INTERRUPT;
|
||||
unsafe { core::arch::asm!("wsr.intset {0}", in(reg) intr, options(nostack)) };
|
||||
unsafe { xtensa_lx::interrupt::set(SW_INTERRUPT) };
|
||||
}
|
||||
|
@ -192,18 +192,12 @@ unsafe extern "C" fn is_in_isr() -> i32 {
|
||||
crate::is_interrupts_disabled() as i32
|
||||
}
|
||||
|
||||
#[cfg(esp32)]
|
||||
#[ram]
|
||||
unsafe extern "C" fn cause_sw_intr_to_core(_core: i32, _intr_no: i32) -> i32 {
|
||||
#[cfg(any(esp32c3, esp32s3))]
|
||||
todo!("cause_sw_intr_to_core is not implemented for this target");
|
||||
|
||||
#[cfg(esp32)]
|
||||
{
|
||||
trace!("cause_sw_intr_to_core {} {}", _core, _intr_no);
|
||||
let intr = 1 << _intr_no;
|
||||
unsafe { core::arch::asm!("wsr.intset {0}", in(reg) intr, options(nostack)) };
|
||||
0
|
||||
}
|
||||
trace!("cause_sw_intr_to_core {} {}", _core, _intr_no);
|
||||
unsafe { xtensa_lx_rt::xtensa_lx::interrupt::set(1 << _intr_no) };
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
|
@ -117,7 +117,7 @@ pub(super) static G_OSI_FUNCS: osi_funcs_s = osi_funcs_s {
|
||||
task_create: Some(task_create),
|
||||
task_delete: Some(task_delete),
|
||||
is_in_isr: Some(is_in_isr),
|
||||
cause_sw_intr_to_core: Some(cause_sw_intr_to_core),
|
||||
cause_sw_intr_to_core: None,
|
||||
malloc: Some(crate::ble::malloc),
|
||||
malloc_internal: Some(crate::ble::malloc_internal),
|
||||
free: Some(crate::ble::free),
|
||||
|
@ -118,7 +118,7 @@ pub(super) static G_OSI_FUNCS: osi_funcs_s = osi_funcs_s {
|
||||
task_create: Some(task_create),
|
||||
task_delete: Some(task_delete),
|
||||
is_in_isr: Some(is_in_isr),
|
||||
cause_sw_intr_to_core: Some(cause_sw_intr_to_core),
|
||||
cause_sw_intr_to_core: None,
|
||||
malloc: Some(crate::ble::malloc),
|
||||
malloc_internal: Some(crate::ble::malloc_internal),
|
||||
free: Some(crate::ble::free),
|
||||
|
Loading…
x
Reference in New Issue
Block a user