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

Improve parameter types for sel4::UserContext methods #102

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/examples/root-task/spawn-thread/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn create_user_context(f: SecondaryThreadFn) -> sel4::UserContext {
ctx
}

fn user_context_arg_mut(ctx: &mut sel4::UserContext, i: sel4::Word) -> &mut sel4::Word {
fn user_context_arg_mut(ctx: &mut sel4::UserContext, i: usize) -> &mut sel4::Word {
cfg_if! {
if #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] {
ctx.gpr_a_mut(i)
Expand Down
6 changes: 3 additions & 3 deletions crates/sel4-capdl-initializer/core/src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod imp {
*regs.pc_mut() = extra.ip;
*regs.sp_mut() = extra.sp;
for (i, value) in extra.gprs.iter().enumerate() {
*regs.gpr_mut(i.try_into().unwrap()) = *value;
*regs.gpr_mut(i) = *value;
}
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ mod imp {
*regs.pc_mut() = extra.ip;
*regs.sp_mut() = extra.sp;
for (i, value) in extra.gprs.iter().enumerate() {
*regs.gpr_a_mut(i.try_into().unwrap()) = *value;
*regs.gpr_a_mut(i) = *value;
}
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ mod imp {
*regs.pc_mut() = extra.ip;
*regs.sp_mut() = extra.sp;
for (i, value) in extra.gprs.iter().enumerate() {
*regs.gpr_mut(i.try_into().unwrap()) = *value;
*regs.gpr_mut(i) = *value;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4/src/arch/arm/arch/aarch32/user_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl UserContext {
&mut self.0.cpsr
}

pub fn gpr(&self, ix: Word) -> &Word {
pub fn gpr(&self, ix: usize) -> &Word {
match ix {
0 => &self.inner().r0,
1 => &self.inner().r1,
Expand All @@ -57,7 +57,7 @@ impl UserContext {
}
}

pub fn gpr_mut(&mut self, ix: Word) -> &mut Word {
pub fn gpr_mut(&mut self, ix: usize) -> &mut Word {
match ix {
0 => &mut self.inner_mut().r0,
1 => &mut self.inner_mut().r1,
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4/src/arch/arm/arch/aarch64/user_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl UserContext {
&mut self.0.spsr
}

pub fn gpr(&self, ix: Word) -> &Word {
pub fn gpr(&self, ix: usize) -> &Word {
match ix {
0 => &self.inner().x0,
1 => &self.inner().x1,
Expand Down Expand Up @@ -75,7 +75,7 @@ impl UserContext {
}
}

pub fn gpr_mut(&mut self, ix: Word) -> &mut Word {
pub fn gpr_mut(&mut self, ix: usize) -> &mut Word {
match ix {
0 => &mut self.inner_mut().x0,
1 => &mut self.inner_mut().x1,
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4/src/arch/riscv/user_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl UserContext {
&mut self.0.sp
}

pub fn gpr_a(&self, ix: Word) -> &Word {
pub fn gpr_a(&self, ix: usize) -> &Word {
match ix {
0 => &self.inner().a0,
1 => &self.inner().a1,
Expand All @@ -43,7 +43,7 @@ impl UserContext {
}
}

pub fn gpr_a_mut(&mut self, ix: Word) -> &mut Word {
pub fn gpr_a_mut(&mut self, ix: usize) -> &mut Word {
match ix {
0 => &mut self.inner_mut().a0,
1 => &mut self.inner_mut().a1,
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4/src/arch/x86/arch/x64/user_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl UserContext {
&mut self.0.rsp
}

pub fn gpr(&self, ix: Word) -> &Word {
pub fn gpr(&self, ix: usize) -> &Word {
// TODO
match ix {
0 => &self.inner().rdi,
Expand All @@ -41,7 +41,7 @@ impl UserContext {
}
}

pub fn gpr_mut(&mut self, ix: Word) -> &mut Word {
pub fn gpr_mut(&mut self, ix: usize) -> &mut Word {
match ix {
0 => &mut self.inner_mut().rdi,
1 => &mut self.inner_mut().rsi,
Expand Down
Loading