Require float-save-restore in esp-wifi (#2322)

* Add failing test case

* Make sure task contexts are properly initialised

* Require float-save-restore for esp-wifi
This commit is contained in:
Dániel Buga 2024-10-10 10:24:50 +02:00 committed by GitHub
parent 0142703112
commit ba8daafb0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 4 deletions

View File

@ -44,6 +44,8 @@ portable_atomic_enum = { version = "0.3.1", features = ["portable-atomic"] }
bt-hci = { version = "0.1.1", optional = true }
esp-config = { version = "0.1.0", path = "../esp-config" }
xtensa-lx-rt = { version = "0.17.1", path = "../xtensa-lx-rt", optional = true }
[build-dependencies]
esp-build = { version = "0.1.0", path = "../esp-build" }
esp-config = { version = "0.1.0", path = "../esp-config", features = ["build"] }
@ -83,16 +85,19 @@ esp32h2 = [
esp32 = [
"esp-hal/esp32",
"esp-wifi-sys/esp32",
"xtensa-lx-rt/float-save-restore",
]
# Target the ESP32-S2.
esp32s2 = [
"esp-hal/esp32s2",
"esp-wifi-sys/esp32s2",
"xtensa-lx-rt/float-save-restore",
]
# Target the ESP32-S3.
esp32s3 = [
"esp-hal/esp32s3",
"esp-wifi-sys/esp32s3",
"xtensa-lx-rt/float-save-restore",
]
## Enable Async support

View File

@ -22,7 +22,7 @@ pub fn allocate_main_task() -> *mut Context {
}
let ptr = malloc(size_of::<Context>() as u32) as *mut Context;
core::ptr::write_bytes(ptr, 0, 1);
core::ptr::write(ptr, Context::new());
(*ptr).next = ptr;
*ctx_now = ptr;
ptr
@ -37,7 +37,7 @@ fn allocate_task() -> *mut Context {
}
let ptr = malloc(size_of::<Context>() as u32) as *mut Context;
core::ptr::write_bytes(ptr, 0, 1);
core::ptr::write(ptr, Context::new());
(*ptr).next = (**ctx_now).next;
(**ctx_now).next = ptr;
ptr

View File

@ -11,6 +11,17 @@ pub struct Context {
pub allocated_stack: *const u8,
}
impl Context {
pub fn new() -> Self {
Context {
trap_frame: TrapFrame::default(),
thread_semaphore: 0,
next: core::ptr::null_mut(),
allocated_stack: core::ptr::null(),
}
}
}
pub fn task_create(
task: extern "C" fn(*mut c_types::c_void),
param: *mut c_types::c_void,

View File

@ -11,6 +11,17 @@ pub struct Context {
pub allocated_stack: *const u8,
}
impl Context {
pub fn new() -> Self {
Context {
trap_frame: TrapFrame::new(),
thread_semaphore: 0,
next: core::ptr::null_mut(),
allocated_stack: core::ptr::null(),
}
}
}
pub fn task_create(
task: extern "C" fn(*mut c_types::c_void),
param: *mut c_types::c_void,
@ -28,7 +39,7 @@ pub fn task_create(
// stack must be aligned by 16
let task_stack_ptr = stack as usize + task_stack_size;
let stack_ptr = task_stack_ptr - (task_stack_ptr % 0x10);
let stack_ptr = task_stack_ptr - (task_stack_ptr % 16);
(*ctx).trap_frame.A1 = stack_ptr as u32;
(*ctx).trap_frame.PS = 0x00040000 | (1 & 3) << 16; // For windowed ABI set WOE and CALLINC (pretend task was 'call4'd).

View File

@ -249,18 +249,21 @@ esp32c3 = [
"esp-hal/esp32c3",
"esp-hal-embassy/esp32c3",
"esp-wifi?/esp32c3",
"esp-wifi?/phy-enable-usb",
]
esp32c6 = [
"esp-backtrace/esp32c6",
"esp-hal/esp32c6",
"esp-hal-embassy/esp32c6",
"esp-wifi?/esp32c6",
"esp-wifi?/phy-enable-usb",
]
esp32h2 = [
"esp-backtrace/esp32h2",
"esp-hal/esp32h2",
"esp-hal-embassy/esp32h2",
"esp-wifi?/esp32h2",
"esp-wifi?/phy-enable-usb",
]
esp32s2 = [
"embedded-test/xtensa-semihosting",
@ -275,6 +278,7 @@ esp32s3 = [
"esp-hal/esp32s3",
"esp-hal-embassy/esp32s3",
"esp-wifi?/esp32s3",
"esp-wifi?/phy-enable-usb",
]
# Async & Embassy:
embassy = [

View File

@ -2,7 +2,6 @@
//% CHIPS: esp32 esp32s2 esp32s3
//% FEATURES: esp-wifi esp-alloc
//% FEATURES: esp-wifi esp-alloc xtensa-lx-rt/float-save-restore
#![no_std]
#![no_main]