Skip to content

Commit

Permalink
crates/sel4/sys: Support multi-word bitfields in object invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
nspin committed Oct 4, 2023
1 parent 0b118ba commit f64e525
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/sel4/sys/build/xml/invocations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'a> InvocationGenerator<'a> {
});
}
ParameterType::Bitfield => toks.extend(quote! {
self.set_mr_bits(#start..#end, #name.0.inner()[0]);
self.set_mr_bits_from_slice(#start..#end, #name.0.inner());
}),
ParameterType::Struct { members } => {
assert!(self.parameter_types.get(&param.ty).pass_by_reference());
Expand Down
10 changes: 9 additions & 1 deletion crates/sel4/sys/src/ipc_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::mem;
use core::ops::Range;
use core::slice;

use sel4_bitfield_ops::{get_bits, set_bits, PrimInt};
use sel4_bitfield_ops::{get_bits, set_bits, set_bits_from_slice, PrimInt, UnsignedPrimInt};

use crate::{seL4_CPtr, seL4_IPCBuffer, seL4_Word};

Expand Down Expand Up @@ -31,6 +31,14 @@ impl seL4_IPCBuffer {
set_bits(&mut self.msg, range, T::cast_to_unsigned(value))
}

pub(crate) fn set_mr_bits_from_slice<T>(&mut self, range: Range<usize>, value: &[T])
where
T: UnsignedPrimInt,
usize: TryFrom<T>,
{
set_bits_from_slice(&mut self.msg, range, value, 0)
}

pub(crate) fn msg_bytes_mut(&mut self) -> &'static mut [u8] {
let msg = &mut self.msg;
unsafe {
Expand Down

0 comments on commit f64e525

Please sign in to comment.