Skip to content

Commit

Permalink
Add and use TrapFrame::new() in esp-wifi
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Aug 29, 2024
1 parent 6c6cc9b commit 6ea0e56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 56 deletions.
57 changes: 1 addition & 56 deletions esp-wifi/src/preempt/preempt_xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,7 @@ pub struct TaskContext {
}

static mut CTX_TASKS: [TaskContext; MAX_TASK] = [TaskContext {
trap_frame: TrapFrame {
PC: 0,
PS: 0,
A0: 0,
A1: 0,
A2: 0,
A3: 0,
A4: 0,
A5: 0,
A6: 0,
A7: 0,
A8: 0,
A9: 0,
A10: 0,
A11: 0,
A12: 0,
A13: 0,
A14: 0,
A15: 0,
SAR: 0,
EXCCAUSE: 0,
EXCVADDR: 0,
LBEG: 0,
LEND: 0,
LCOUNT: 0,
THREADPTR: 0,
SCOMPARE1: 0,
BR: 0,
ACCLO: 0,
ACCHI: 0,
M0: 0,
M1: 0,
M2: 0,
M3: 0,
F64R_LO: 0,
F64R_HI: 0,
F64S: 0,
FCR: 0,
FSR: 0,
F0: 0,
F1: 0,
F2: 0,
F3: 0,
F4: 0,
F5: 0,
F6: 0,
F7: 0,
F8: 0,
F9: 0,
F10: 0,
F11: 0,
F12: 0,
F13: 0,
F14: 0,
F15: 0,
},
trap_frame: TrapFrame::new(),
}; MAX_TASK];

pub fn task_create(task: extern "C" fn()) {
Expand Down
13 changes: 13 additions & 0 deletions xtensa-lx-rt/src/exception/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ pub struct Context {
pub F15: u32,
}

impl Default for Context {
fn default() -> Self {
Self::new()
}
}

impl Context {
/// Creates a new, zeroed out context.
pub const fn new() -> Self {
unsafe { core::mem::zeroed() }
}
}

extern "Rust" {
/// The exception assembly jumps here once registers have been spilled
fn __exception(cause: ExceptionCause, save_frame: &mut Context);
Expand Down

0 comments on commit 6ea0e56

Please sign in to comment.