Skip to content

Commit

Permalink
crates/sel4: Improve types
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Feb 29, 2024
1 parent 0241655 commit 484bb4b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
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

0 comments on commit 484bb4b

Please sign in to comment.