diff --git a/apps/system/components/DebugConsole/kata-io/src/lib.rs b/apps/system/components/DebugConsole/kata-io/src/lib.rs index e753b49..351cacb 100644 --- a/apps/system/components/DebugConsole/kata-io/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-io/src/lib.rs @@ -188,9 +188,7 @@ impl<'a, T: ?Sized> Read for &'a mut T where T: Read, { - fn read(&mut self, buf: &mut [u8]) -> Result { - (**self).read(buf) - } + fn read(&mut self, buf: &mut [u8]) -> Result { (**self).read(buf) } } /// Forwarding implementation of BufRead for &mut @@ -198,13 +196,9 @@ impl<'a, T: ?Sized> BufRead for &'a mut T where T: BufRead, { - fn fill_buf(&mut self) -> Result<&[u8]> { - (**self).fill_buf() - } + fn fill_buf(&mut self) -> Result<&[u8]> { (**self).fill_buf() } - fn consume(&mut self, amt: usize) { - (**self).consume(amt) - } + fn consume(&mut self, amt: usize) { (**self).consume(amt) } } /// Forwarding implementation of Write for &mut @@ -212,11 +206,7 @@ impl<'a, T: ?Sized> Write for &'a mut T where T: Write, { - fn write(&mut self, buf: &[u8]) -> Result { - (**self).write(buf) - } + fn write(&mut self, buf: &[u8]) -> Result { (**self).write(buf) } - fn flush(&mut self) -> Result<()> { - (**self).flush() - } + fn flush(&mut self) -> Result<()> { (**self).flush() } } diff --git a/apps/system/components/DebugConsole/kata-line-reader/src/lib.rs b/apps/system/components/DebugConsole/kata-line-reader/src/lib.rs index 19bb949..9882fec 100644 --- a/apps/system/components/DebugConsole/kata-line-reader/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-line-reader/src/lib.rs @@ -13,15 +13,11 @@ pub enum LineReadError { } impl From for LineReadError { - fn from(err: io::Error) -> LineReadError { - LineReadError::IO(err) - } + fn from(err: io::Error) -> LineReadError { LineReadError::IO(err) } } impl From for LineReadError { - fn from(err: core::str::Utf8Error) -> LineReadError { - LineReadError::Encoding(err) - } + fn from(err: core::str::Utf8Error) -> LineReadError { LineReadError::Encoding(err) } } impl fmt::Display for LineReadError { @@ -39,9 +35,7 @@ pub struct LineReader { buf: [u8; LINE_MAX], } impl Default for LineReader { - fn default() -> Self { - Self::new() - } + fn default() -> Self { Self::new() } } fn get_u8(reader: &mut dyn io::Read) -> io::Result { diff --git a/apps/system/components/DebugConsole/kata-shell/src/lib.rs b/apps/system/components/DebugConsole/kata-shell/src/lib.rs index 0165b93..eb697c3 100644 --- a/apps/system/components/DebugConsole/kata-shell/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-shell/src/lib.rs @@ -73,33 +73,23 @@ impl fmt::Display for CommandError { } impl From for CommandError { - fn from(_err: core::num::ParseIntError) -> CommandError { - CommandError::BadArgs - } + fn from(_err: core::num::ParseIntError) -> CommandError { CommandError::BadArgs } } impl From for CommandError { - fn from(_err: core::num::ParseFloatError) -> CommandError { - CommandError::BadArgs - } + fn from(_err: core::num::ParseFloatError) -> CommandError { CommandError::BadArgs } } impl From for CommandError { - fn from(_err: core::str::ParseBoolError) -> CommandError { - CommandError::BadArgs - } + fn from(_err: core::str::ParseBoolError) -> CommandError { CommandError::BadArgs } } impl From for CommandError { - fn from(err: fmt::Error) -> CommandError { - CommandError::Formatter(err) - } + fn from(err: fmt::Error) -> CommandError { CommandError::Formatter(err) } } impl From for CommandError { - fn from(_err: io::Error) -> CommandError { - CommandError::IO - } + fn from(_err: io::Error) -> CommandError { CommandError::IO } } type CmdFn = fn( diff --git a/apps/system/components/DebugConsole/kata-shell/src/rz.rs b/apps/system/components/DebugConsole/kata-shell/src/rz.rs index 6052239..205b2fe 100644 --- a/apps/system/components/DebugConsole/kata-shell/src/rz.rs +++ b/apps/system/components/DebugConsole/kata-shell/src/rz.rs @@ -26,9 +26,7 @@ enum UploadError { MallocFailed, } impl From for io::Error { - fn from(_err: UploadError) -> io::Error { - io::Error - } + fn from(_err: UploadError) -> io::Error { io::Error } } // TODO(sleffler): use ObjDesc::size_bytes @@ -63,18 +61,12 @@ impl Upload { next_free: 0, } } - pub fn crc32(&self) -> u32 { - self.digest.sum32() - } + pub fn crc32(&self) -> u32 { self.digest.sum32() } pub fn len(&self) -> usize { (self.frames.count() * PAGE_SIZE) - (self.mapped_bytes - self.next_free) } - pub fn finish(&mut self) { - self.unmap_current_frame().expect("finish"); - } - pub fn frames(&self) -> &ObjDescBundle { - &self.frames - } + pub fn finish(&mut self) { self.unmap_current_frame().expect("finish"); } + pub fn frames(&self) -> &ObjDescBundle { &self.frames } // Unmap the current page and reset state. fn unmap_current_frame(&mut self) -> Result<(), UploadError> { @@ -119,9 +111,7 @@ impl Upload { } } impl Drop for Upload { - fn drop(&mut self) { - self.finish(); - } + fn drop(&mut self) { self.finish(); } } impl io::Write for Upload { @@ -161,9 +151,7 @@ impl io::Write for Upload { Ok(buf.len()) } - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } + fn flush(&mut self) -> io::Result<()> { Ok(()) } } /// Receives using ZMODEM and wraps the result as an Upload. diff --git a/apps/system/components/DebugConsole/kata-shell/src/test_memory_manager.rs b/apps/system/components/DebugConsole/kata-shell/src/test_memory_manager.rs index 1513fe1..49214d1 100644 --- a/apps/system/components/DebugConsole/kata-shell/src/test_memory_manager.rs +++ b/apps/system/components/DebugConsole/kata-shell/src/test_memory_manager.rs @@ -50,11 +50,7 @@ fn bootinfo_command( #[cfg(feature = "CONFIG_DEBUG_BUILD")] for ut in bootinfo_ref.untyped.start..bootinfo_ref.untyped.end { let cap_tag = unsafe { kata_os_common::sel4_sys::seL4_DebugCapIdentify(ut) }; - assert_eq!( - cap_tag, 2, - "expected untyped (2), got {} for cap at {}", - cap_tag, ut - ); + assert_eq!(cap_tag, 2, "expected untyped (2), got {} for cap at {}", cap_tag, ut); } Ok(()) } diff --git a/apps/system/components/DebugConsole/kata-shell/src/test_ml_coordinator.rs b/apps/system/components/DebugConsole/kata-shell/src/test_ml_coordinator.rs index 08d5759..943dea6 100644 --- a/apps/system/components/DebugConsole/kata-shell/src/test_ml_coordinator.rs +++ b/apps/system/components/DebugConsole/kata-shell/src/test_ml_coordinator.rs @@ -45,11 +45,7 @@ fn mlexecute_command( let model_id = args.next().ok_or(CommandError::BadArgs)?; if let Err(e) = kata_mlcoord_oneshot(bundle_id, model_id) { - writeln!( - output, - "Execute {:?} {:?} err: {:?}", - bundle_id, model_id, e - )?; + writeln!(output, "Execute {:?} {:?} err: {:?}", bundle_id, model_id, e)?; } Ok(()) @@ -68,11 +64,7 @@ fn mlperiodic_command( let rate_in_ms = rate_str.parse::()?; if let Err(e) = kata_mlcoord_periodic(bundle_id, model_id, rate_in_ms) { - writeln!( - output, - "Periodic {:?} {:?} err: {:?}", - bundle_id, model_id, e - )?; + writeln!(output, "Periodic {:?} {:?} err: {:?}", bundle_id, model_id, e)?; } Ok(()) diff --git a/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs b/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs index a4fa951..7504823 100644 --- a/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs @@ -29,9 +29,7 @@ pub struct Rx { dataport: &'static [u8], } impl Default for Rx { - fn default() -> Self { - Self::new() - } + fn default() -> Self { Self::new() } } impl Rx { @@ -65,9 +63,7 @@ pub struct Tx { dataport: &'static mut [u8], } impl Default for Tx { - fn default() -> Self { - Self::new() - } + fn default() -> Self { Self::new() } } impl Tx { diff --git a/apps/system/components/DebugConsole/zmodem/src/frame.rs b/apps/system/components/DebugConsole/zmodem/src/frame.rs index c2d139f..3c17440 100644 --- a/apps/system/components/DebugConsole/zmodem/src/frame.rs +++ b/apps/system/components/DebugConsole/zmodem/src/frame.rs @@ -82,13 +82,9 @@ impl Frame { out } - pub fn get_frame_type(&self) -> u8 { - self.ftype - } + pub fn get_frame_type(&self) -> u8 { self.ftype } - pub fn get_header(&self) -> u8 { - self.header - } + pub fn get_header(&self) -> u8 { self.header } } fn get_crc(header: u8, buf: &[u8]) -> Vec { diff --git a/apps/system/components/DebugConsole/zmodem/src/proto.rs b/apps/system/components/DebugConsole/zmodem/src/proto.rs index e8e135a..285a035 100644 --- a/apps/system/components/DebugConsole/zmodem/src/proto.rs +++ b/apps/system/components/DebugConsole/zmodem/src/proto.rs @@ -209,9 +209,7 @@ fn unescape(escaped_byte: u8) -> u8 { } } -fn is_escaped(byte: u8) -> bool { - !matches!(byte, ZCRCE | ZCRCG | ZCRCQ | ZCRCW) -} +fn is_escaped(byte: u8) -> bool { !matches!(byte, ZCRCE | ZCRCG | ZCRCQ | ZCRCW) } /// Reads out one byte fn read_byte(r: &mut R) -> io::Result @@ -454,18 +452,12 @@ mod tests { fn test_recv_zlde_frame() { let i = vec![ZLDE, ZCRCE, 237, 174]; let mut v = vec![]; - assert_eq!( - recv_zlde_frame(ZBIN, &mut i.as_slice(), &mut v).unwrap(), - Some(ZCRCE) - ); + assert_eq!(recv_zlde_frame(ZBIN, &mut i.as_slice(), &mut v).unwrap(), Some(ZCRCE)); assert_eq!(&v[..], []); let i = vec![ZLDE, 0x00, ZLDE, ZCRCW, 221, 205]; let mut v = vec![]; - assert_eq!( - recv_zlde_frame(ZBIN, &mut i.as_slice(), &mut v).unwrap(), - Some(ZCRCW) - ); + assert_eq!(recv_zlde_frame(ZBIN, &mut i.as_slice(), &mut v).unwrap(), Some(ZCRCW)); assert_eq!(&v[..], [0x00]); let i = vec![ diff --git a/apps/system/components/DebugConsole/zmodem/src/recv.rs b/apps/system/components/DebugConsole/zmodem/src/recv.rs index 96a15e9..66e09ce 100644 --- a/apps/system/components/DebugConsole/zmodem/src/recv.rs +++ b/apps/system/components/DebugConsole/zmodem/src/recv.rs @@ -26,9 +26,7 @@ enum State { } impl State { - fn new() -> State { - State::SendingZRINIT - } + fn new() -> State { State::SendingZRINIT } fn next(self, frame: &Frame) -> State { match (self, frame.get_frame_type()) { diff --git a/apps/system/components/DebugConsole/zmodem/src/send.rs b/apps/system/components/DebugConsole/zmodem/src/send.rs index 8319e37..f8f42d0 100644 --- a/apps/system/components/DebugConsole/zmodem/src/send.rs +++ b/apps/system/components/DebugConsole/zmodem/src/send.rs @@ -32,9 +32,7 @@ enum State { } impl State { - fn new() -> State { - State::WaitingInit - } + fn new() -> State { State::WaitingInit } fn next(self, frame: &Frame) -> State { match (self, frame.get_frame_type()) { diff --git a/apps/system/components/DebugConsole/zmodem/tests/lib.rs b/apps/system/components/DebugConsole/zmodem/tests/lib.rs index 331c8e2..78fc187 100644 --- a/apps/system/components/DebugConsole/zmodem/tests/lib.rs +++ b/apps/system/components/DebugConsole/zmodem/tests/lib.rs @@ -14,9 +14,7 @@ use std::time::*; extern crate kata_io; -fn forget_err(_e: std::io::Error) -> kata_io::Error { - kata_io::Error {} -} +fn forget_err(_e: std::io::Error) -> kata_io::Error { kata_io::Error {} } struct ReadWrapper { r: R, @@ -37,9 +35,7 @@ impl kata_io::Write for WriteWrapper { self.w.write(buf).map_err(forget_err) } - fn flush(&mut self) -> kata_io::Result<()> { - self.w.flush().map_err(forget_err) - } + fn flush(&mut self) -> kata_io::Result<()> { self.w.flush().map_err(forget_err) } } struct SendInput { diff --git a/apps/system/components/MailboxDriver/mailbox-driver/src/lib.rs b/apps/system/components/MailboxDriver/mailbox-driver/src/lib.rs index 1ee264a..eeda8cc 100644 --- a/apps/system/components/MailboxDriver/mailbox-driver/src/lib.rs +++ b/apps/system/components/MailboxDriver/mailbox-driver/src/lib.rs @@ -83,67 +83,27 @@ extern "C" { //------------------------------------------------------------------------------ // Directly manipulate the mailbox registers. -unsafe fn get_intr_state() -> u32 { - mailbox_mmio.offset(0).read_volatile() -} -unsafe fn get_INTR_ENABLE() -> u32 { - mailbox_mmio.offset(1).read_volatile() -} -unsafe fn get_INTR_TEST() -> u32 { - mailbox_mmio.offset(2).read_volatile() -} -unsafe fn get_MBOXW() -> u32 { - mailbox_mmio.offset(3).read_volatile() -} -unsafe fn get_MBOXR() -> u32 { - mailbox_mmio.offset(4).read_volatile() -} -unsafe fn get_STATUS() -> u32 { - mailbox_mmio.offset(5).read_volatile() -} -unsafe fn get_ERROR() -> u32 { - mailbox_mmio.offset(6).read_volatile() -} -unsafe fn get_WIRQT() -> u32 { - mailbox_mmio.offset(7).read_volatile() -} -unsafe fn get_RIRQT() -> u32 { - mailbox_mmio.offset(8).read_volatile() -} -unsafe fn get_CTRL() -> u32 { - mailbox_mmio.offset(9).read_volatile() -} +unsafe fn get_intr_state() -> u32 { mailbox_mmio.offset(0).read_volatile() } +unsafe fn get_INTR_ENABLE() -> u32 { mailbox_mmio.offset(1).read_volatile() } +unsafe fn get_INTR_TEST() -> u32 { mailbox_mmio.offset(2).read_volatile() } +unsafe fn get_MBOXW() -> u32 { mailbox_mmio.offset(3).read_volatile() } +unsafe fn get_MBOXR() -> u32 { mailbox_mmio.offset(4).read_volatile() } +unsafe fn get_STATUS() -> u32 { mailbox_mmio.offset(5).read_volatile() } +unsafe fn get_ERROR() -> u32 { mailbox_mmio.offset(6).read_volatile() } +unsafe fn get_WIRQT() -> u32 { mailbox_mmio.offset(7).read_volatile() } +unsafe fn get_RIRQT() -> u32 { mailbox_mmio.offset(8).read_volatile() } +unsafe fn get_CTRL() -> u32 { mailbox_mmio.offset(9).read_volatile() } -unsafe fn set_INTR_STATE(x: u32) { - mailbox_mmio.offset(0).write_volatile(x); -} -unsafe fn set_INTR_ENABLE(x: u32) { - mailbox_mmio.offset(1).write_volatile(x); -} -unsafe fn set_INTR_TEST(x: u32) { - mailbox_mmio.offset(2).write_volatile(x); -} -unsafe fn set_MBOXW(x: u32) { - mailbox_mmio.offset(3).write_volatile(x); -} -unsafe fn set_MBOXR(x: u32) { - mailbox_mmio.offset(4).write_volatile(x); -} -unsafe fn set_STATUS(x: u32) { - mailbox_mmio.offset(5).write_volatile(x); -} -unsafe fn set_ERROR(x: u32) { - mailbox_mmio.offset(6).write_volatile(x); -} -unsafe fn set_WIRQT(x: u32) { - mailbox_mmio.offset(7).write_volatile(x); -} -unsafe fn set_RIRQT(x: u32) { - mailbox_mmio.offset(8).write_volatile(x); -} -unsafe fn set_CTRL(x: u32) { - mailbox_mmio.offset(9).write_volatile(x); -} +unsafe fn set_INTR_STATE(x: u32) { mailbox_mmio.offset(0).write_volatile(x); } +unsafe fn set_INTR_ENABLE(x: u32) { mailbox_mmio.offset(1).write_volatile(x); } +unsafe fn set_INTR_TEST(x: u32) { mailbox_mmio.offset(2).write_volatile(x); } +unsafe fn set_MBOXW(x: u32) { mailbox_mmio.offset(3).write_volatile(x); } +unsafe fn set_MBOXR(x: u32) { mailbox_mmio.offset(4).write_volatile(x); } +unsafe fn set_STATUS(x: u32) { mailbox_mmio.offset(5).write_volatile(x); } +unsafe fn set_ERROR(x: u32) { mailbox_mmio.offset(6).write_volatile(x); } +unsafe fn set_WIRQT(x: u32) { mailbox_mmio.offset(7).write_volatile(x); } +unsafe fn set_RIRQT(x: u32) { mailbox_mmio.offset(8).write_volatile(x); } +unsafe fn set_CTRL(x: u32) { mailbox_mmio.offset(9).write_volatile(x); } //------------------------------------------------------------------------------ // Directly manipulate the hardware FIFOs. Synchronous and busy-waits. Not diff --git a/apps/system/components/MemoryManager/kata-memory-interface/src/lib.rs b/apps/system/components/MemoryManager/kata-memory-interface/src/lib.rs index 185e12f..c4a2c17 100644 --- a/apps/system/components/MemoryManager/kata-memory-interface/src/lib.rs +++ b/apps/system/components/MemoryManager/kata-memory-interface/src/lib.rs @@ -138,14 +138,10 @@ impl ObjDescBundle { } // Returns whether there are any object descriptors. - pub fn is_empty(&self) -> bool { - self.objs.len() == 0 - } + pub fn is_empty(&self) -> bool { self.objs.len() == 0 } // Returns the number of object descriptors. - pub fn len(&self) -> usize { - self.objs.len() - } + pub fn len(&self) -> usize { self.objs.len() } // Returns the count of objects specified by the object descriptors. pub fn count(&self) -> usize { @@ -357,9 +353,7 @@ impl From for MemoryManagerError { } impl From> for MemoryManagerError { fn from(result: Result<(), MemoryError>) -> MemoryManagerError { - result.map_or_else(MemoryManagerError::from, |_v| { - MemoryManagerError::MmeSuccess - }) + result.map_or_else(MemoryManagerError::from, |_v| MemoryManagerError::MmeSuccess) } } impl From for Result<(), MemoryManagerError> { @@ -405,11 +399,8 @@ pub fn kata_object_alloc_in_toplevel( objs: Vec, ) -> Result { // Request the objects using the dedicated MemoryManager container. - let mut request = ObjDescBundle::new( - unsafe { MEMORY_RECV_CNODE }, - unsafe { MEMORY_RECV_CNODE_DEPTH }, - objs, - ); + let mut request = + ObjDescBundle::new(unsafe { MEMORY_RECV_CNODE }, unsafe { MEMORY_RECV_CNODE_DEPTH }, objs); kata_object_alloc(&request)?; match request.move_objects_to_toplevel() { Err(_) => { @@ -558,9 +549,7 @@ pub fn kata_reply_alloc() -> Result { // Wrapper for allocating 4K pages. #[inline] pub fn kata_frame_alloc(space_bytes: usize) -> Result { - fn howmany(value: usize, unit: usize) -> usize { - (value + (unit - 1)) / unit - } + fn howmany(value: usize, unit: usize) -> usize { (value + (unit - 1)) / unit } // NB: always allocate 4K pages let mut objs = ObjDescBundle::new( unsafe { MEMORY_RECV_CNODE }, @@ -581,9 +570,7 @@ pub fn kata_frame_alloc(space_bytes: usize) -> Result Result { - fn howmany(value: usize, unit: usize) -> usize { - (value + (unit - 1)) / unit - } + fn howmany(value: usize, unit: usize) -> usize { (value + (unit - 1)) / unit } // NB: always allocate 4K pages let npages = howmany(space_bytes, 1 << seL4_PageBits); // XXX horrible band-aid to workaround Retype "fanout" limit of 256 @@ -596,11 +583,7 @@ pub fn kata_frame_alloc_in_cnode(space_bytes: usize) -> Result Result { self.manager.lock().as_ref().unwrap().stats() } - fn debug(&self) -> Result<(), MemoryError> { - self.manager.lock().as_ref().unwrap().debug() - } + fn debug(&self) -> Result<(), MemoryError> { self.manager.lock().as_ref().unwrap().debug() } } diff --git a/apps/system/components/MemoryManager/kata-memory-manager/src/memory_manager/mod.rs b/apps/system/components/MemoryManager/kata-memory-manager/src/memory_manager/mod.rs index f2024ff..01ce374 100644 --- a/apps/system/components/MemoryManager/kata-memory-manager/src/memory_manager/mod.rs +++ b/apps/system/components/MemoryManager/kata-memory-manager/src/memory_manager/mod.rs @@ -66,12 +66,8 @@ impl UntypedSlab { _next_paddr: ut.paddr, } } - fn _size(&self) -> usize { - l2tob(self.size_bits) - } - fn size_bits(&self) -> usize { - self.size_bits - } + fn _size(&self) -> usize { l2tob(self.size_bits) } + fn size_bits(&self) -> usize { self.size_bits } } pub struct MemoryManager { untypeds: SmallVec<[UntypedSlab; UNTYPED_SLAB_CAPACITY]>, @@ -95,17 +91,11 @@ pub struct MemoryManager { out_of_memory: usize, } -fn _howmany(value: usize, unit: usize) -> usize { - value + (unit - 1) / unit -} -fn _round_up(value: usize, align: usize) -> usize { - _howmany(value, align) * align -} +fn _howmany(value: usize, unit: usize) -> usize { value + (unit - 1) / unit } +fn _round_up(value: usize, align: usize) -> usize { _howmany(value, align) * align } // Log2 bits to bytes. -fn l2tob(size_bits: usize) -> usize { - 1 << size_bits -} +fn l2tob(size_bits: usize) -> usize { 1 << size_bits } impl MemoryManager { // Creates a new MemoryManager instance. The allocator is seeded @@ -161,41 +151,23 @@ impl MemoryManager { } // Total available space. - pub fn total_available_space(&self) -> usize { - self.total_bytes - } + pub fn total_available_space(&self) -> usize { self.total_bytes } // Current allocated space - pub fn allocated_space(&self) -> usize { - self.allocated_bytes - } + pub fn allocated_space(&self) -> usize { self.allocated_bytes } // Current free space. - pub fn free_space(&self) -> usize { - self.total_bytes - self.allocated_bytes - } + pub fn free_space(&self) -> usize { self.total_bytes - self.allocated_bytes } // Total space allocated over time - pub fn total_requested_space(&self) -> usize { - self.requested_bytes - } + pub fn total_requested_space(&self) -> usize { self.requested_bytes } // Current allocated space out of our control. - pub fn overhead_space(&self) -> usize { - self.overhead_bytes - } + pub fn overhead_space(&self) -> usize { self.overhead_bytes } // Current allocated objects - pub fn allocated_objs(&self) -> usize { - self.allocated_objs - } + pub fn allocated_objs(&self) -> usize { self.allocated_objs } // Total objects allocated over time - pub fn total_requested_objs(&self) -> usize { - self.requested_objs - } + pub fn total_requested_objs(&self) -> usize { self.requested_objs } - pub fn untyped_slab_too_small(&self) -> usize { - self.untyped_slab_too_small - } - pub fn out_of_memory(&self) -> usize { - self.out_of_memory - } + pub fn untyped_slab_too_small(&self) -> usize { self.untyped_slab_too_small } + pub fn out_of_memory(&self) -> usize { self.out_of_memory } fn retype_untyped(free_untyped: seL4_CPtr, root: seL4_CPtr, obj: &ObjDesc) -> seL4_Result { unsafe { diff --git a/apps/system/components/MlCoordinator/fake-vec-core/src/lib.rs b/apps/system/components/MlCoordinator/fake-vec-core/src/lib.rs index 1dc03e6..a07bddf 100644 --- a/apps/system/components/MlCoordinator/fake-vec-core/src/lib.rs +++ b/apps/system/components/MlCoordinator/fake-vec-core/src/lib.rs @@ -34,10 +34,6 @@ pub fn clear_data_fault() {} pub fn clear_tcm() {} -pub fn get_return_code() -> u32 { - 0 -} +pub fn get_return_code() -> u32 { 0 } -pub fn get_fault_register() -> u32 { - 0 -} +pub fn get_fault_register() -> u32 { 0 } diff --git a/apps/system/components/MlCoordinator/kata-ml-component/src/run.rs b/apps/system/components/MlCoordinator/kata-ml-component/src/run.rs index 9f7fbf4..ca52d26 100644 --- a/apps/system/components/MlCoordinator/kata-ml-component/src/run.rs +++ b/apps/system/components/MlCoordinator/kata-ml-component/src/run.rs @@ -23,9 +23,7 @@ pub unsafe extern "C" fn pre_init() { } #[no_mangle] -pub unsafe extern "C" fn mlcoord__init() { - ML_COORD.lock().init(); -} +pub unsafe extern "C" fn mlcoord__init() { ML_COORD.lock().init(); } #[no_mangle] pub unsafe extern "C" fn run() { @@ -109,14 +107,10 @@ pub unsafe extern "C" fn mlcoord_cancel( } #[no_mangle] -pub unsafe extern "C" fn host_req_handle() { - ML_COORD.lock().handle_host_req_interrupt(); -} +pub unsafe extern "C" fn host_req_handle() { ML_COORD.lock().handle_host_req_interrupt(); } #[no_mangle] -pub unsafe extern "C" fn finish_handle() { - ML_COORD.lock().handle_return_interrupt(); -} +pub unsafe extern "C" fn finish_handle() { ML_COORD.lock().handle_return_interrupt(); } #[no_mangle] pub unsafe extern "C" fn instruction_fault_handle() { @@ -124,16 +118,10 @@ pub unsafe extern "C" fn instruction_fault_handle() { } #[no_mangle] -pub unsafe extern "C" fn data_fault_handle() { - ML_COORD.lock().handle_data_fault_interrupt(); -} +pub unsafe extern "C" fn data_fault_handle() { ML_COORD.lock().handle_data_fault_interrupt(); } #[no_mangle] -pub unsafe extern "C" fn mlcoord_debug_state() { - ML_COORD.lock().debug_state(); -} +pub unsafe extern "C" fn mlcoord_debug_state() { ML_COORD.lock().debug_state(); } #[no_mangle] -pub unsafe extern "C" fn mlcoord_capscan() { - let _ = Camkes::capscan(); -} +pub unsafe extern "C" fn mlcoord_capscan() { let _ = Camkes::capscan(); } diff --git a/apps/system/components/MlCoordinator/kata-ml-coordinator/src/lib.rs b/apps/system/components/MlCoordinator/kata-ml-coordinator/src/lib.rs index 5c52a9e..f226455 100644 --- a/apps/system/components/MlCoordinator/kata-ml-coordinator/src/lib.rs +++ b/apps/system/components/MlCoordinator/kata-ml-coordinator/src/lib.rs @@ -96,10 +96,7 @@ impl MLCoordinator { container_slot.release(); // NB: take ownership let ret_status = match MlCore::load_image(&model_frames) { Err(e) => { - error!( - "Load of {}:{} failed: {:?}", - &model.bundle_id, &model.model_id, e - ); + error!("Load of {}:{} failed: {:?}", &model.bundle_id, &model.model_id, e); // May have corrupted TCM. self.loaded_model = None; self.statistics.load_failures += 1; diff --git a/apps/system/components/MlCoordinator/kata-ml-support/src/image_manager.rs b/apps/system/components/MlCoordinator/kata-ml-support/src/image_manager.rs index fd4bcb7..c36fc3f 100644 --- a/apps/system/components/MlCoordinator/kata-ml-support/src/image_manager.rs +++ b/apps/system/components/MlCoordinator/kata-ml-support/src/image_manager.rs @@ -146,17 +146,11 @@ impl ImageManager { ret } - fn tcm_top_size(&self) -> usize { - self.tcm_top - TCM_PADDR - } + fn tcm_top_size(&self) -> usize { self.tcm_top - TCM_PADDR } - fn tcm_bottom_size(&self) -> usize { - TCM_PADDR + TCM_SIZE - self.tcm_bottom - } + fn tcm_bottom_size(&self) -> usize { TCM_PADDR + TCM_SIZE - self.tcm_bottom } - fn tcm_free_space(&self) -> usize { - TCM_SIZE - self.tcm_top_size() - self.tcm_bottom_size() - } + fn tcm_free_space(&self) -> usize { TCM_SIZE - self.tcm_top_size() - self.tcm_bottom_size() } // Returns the size of the largest temporary data block of loaded images. fn required_temporary_data(&self) -> usize { @@ -266,9 +260,7 @@ impl ImageManager { } // Returns true if the image is currently loaded in the TCM. - pub fn is_loaded(&mut self, id: &ImageId) -> bool { - self.get_image_index(id).is_some() - } + pub fn is_loaded(&mut self, id: &ImageId) -> bool { self.get_image_index(id).is_some() } // Loads an |image| onto the Vector Core's TCM, evicting models as // necessary. |on_flash_sizes| represents the on-disk sizes (ie fsize) @@ -281,10 +273,7 @@ impl ImageManager { on_flash_sizes: ImageSizes, unpacked_sizes: ImageSizes, ) -> Result<(), &'static str> { - self.make_space( - unpacked_sizes.data_top_size(), - unpacked_sizes.temporary_data, - ); + self.make_space(unpacked_sizes.data_top_size(), unpacked_sizes.temporary_data); let mut temp_top = self.tcm_top; MlCore::write_image_part(image, temp_top, on_flash_sizes.text, unpacked_sizes.text)?; @@ -380,20 +369,14 @@ mod test { struct FakeImage; impl Read for FakeImage { - fn read(&mut self, _buf: &mut [u8]) -> Result { - Ok(0) - } + fn read(&mut self, _buf: &mut [u8]) -> Result { Ok(0) } } - fn fake_image() -> Box { - Box::new(FakeImage {}) - } + fn fake_image() -> Box { Box::new(FakeImage {}) } // The on_flash_sizes are only used when writing the image to memory. For // these tests we want to ignore this, so just use zeroed sizes. - fn ignore_on_flash_sizes() -> ImageSizes { - ImageSizes::default() - } + fn ignore_on_flash_sizes() -> ImageSizes { ImageSizes::default() } fn constant_image_size(size: usize) -> ImageSizes { ImageSizes { @@ -413,9 +396,7 @@ mod test { } } - fn default_id() -> ImageId { - make_id(1) - } + fn default_id() -> ImageId { make_id(1) } fn load_image(image_manager: &mut ImageManager, id: ImageId, unpacked_sizes: ImageSizes) { // fake_vec_core can't fail to load. @@ -431,11 +412,7 @@ mod test { #[test] fn load_unload() { let mut image_manager = ImageManager::default(); - load_image( - &mut image_manager, - default_id(), - constant_image_size(0x1000), - ); + load_image(&mut image_manager, default_id(), constant_image_size(0x1000)); let id = default_id(); diff --git a/apps/system/components/MlCoordinator/kata-vec-core/src/vc_top.rs b/apps/system/components/MlCoordinator/kata-vec-core/src/vc_top.rs index 04d8b6c..7f1c148 100644 --- a/apps/system/components/MlCoordinator/kata-vec-core/src/vc_top.rs +++ b/apps/system/components/MlCoordinator/kata-vec-core/src/vc_top.rs @@ -120,9 +120,7 @@ pub fn set_intr_test(intr_test: IntrTest) { } } -pub fn get_ctrl() -> Ctrl { - unsafe { Ctrl::from_bytes(ptr::read_volatile(CSR)[3].to_ne_bytes()) } -} +pub fn get_ctrl() -> Ctrl { unsafe { Ctrl::from_bytes(ptr::read_volatile(CSR)[3].to_ne_bytes()) } } pub fn set_ctrl(ctrl: Ctrl) { unsafe { diff --git a/apps/system/components/ProcessManager/kata-proc-component/src/run.rs b/apps/system/components/ProcessManager/kata-proc-component/src/run.rs index ed93c10..a0f728b 100644 --- a/apps/system/components/ProcessManager/kata-proc-component/src/run.rs +++ b/apps/system/components/ProcessManager/kata-proc-component/src/run.rs @@ -30,10 +30,7 @@ pub unsafe extern "C" fn pre_init() { // Complete KATA_PROC setup now that Global allocator is setup. KATA_PROC.init(); - trace!( - "ProcessManager has capacity for {} bundles", - KATA_PROC.capacity() - ); + trace!("ProcessManager has capacity for {} bundles", KATA_PROC.capacity()); PKG_MGMT_RECV_SLOT = KATA_CSPACE_SLOTS.alloc(1).unwrap(); } @@ -143,9 +140,7 @@ pub unsafe extern "C" fn proc_ctrl_get_running_bundles( } #[no_mangle] -pub unsafe extern "C" fn proc_ctrl_capscan() { - let _ = Camkes::capscan(); -} +pub unsafe extern "C" fn proc_ctrl_capscan() { let _ = Camkes::capscan(); } #[no_mangle] pub unsafe extern "C" fn proc_ctrl_capscan_bundle( diff --git a/apps/system/components/ProcessManager/kata-proc-interface/src/bundle_image.rs b/apps/system/components/ProcessManager/kata-proc-interface/src/bundle_image.rs index 6d540f9..03f948d 100644 --- a/apps/system/components/ProcessManager/kata-proc-interface/src/bundle_image.rs +++ b/apps/system/components/ProcessManager/kata-proc-interface/src/bundle_image.rs @@ -41,9 +41,7 @@ enum BundleImageError { BadSectionIO, } impl From for BundleImageError { - fn from(_err: seL4_Error) -> BundleImageError { - BundleImageError::CapMoveFailed - } + fn from(_err: seL4_Error) -> BundleImageError { BundleImageError::CapMoveFailed } } // On-disk header format. @@ -79,15 +77,9 @@ pub struct BundleImageSection { pub vaddr: usize, } impl BundleImageSection { - pub fn is_read(&self) -> bool { - (self.flags & SECTION_READ) != 0 - } - pub fn is_write(&self) -> bool { - (self.flags & SECTION_WRITE) != 0 - } - pub fn is_exec(&self) -> bool { - (self.flags & SECTION_EXEC) != 0 - } + pub fn is_read(&self) -> bool { (self.flags & SECTION_READ) != 0 } + pub fn is_write(&self) -> bool { (self.flags & SECTION_WRITE) != 0 } + pub fn is_exec(&self) -> bool { (self.flags & SECTION_EXEC) != 0 } pub fn get_rights(&self) -> seL4_CapRights { seL4_CapRights::new( /*grantreply=*/ 0, @@ -96,12 +88,8 @@ impl BundleImageSection { /*write=*/ self.is_write() as usize, ) } - pub fn data_range(&self) -> Range { - 0..self.fsize - } - pub fn zero_range(&self) -> Range { - self.fsize..self.msize - } + pub fn data_range(&self) -> Range { 0..self.fsize } + pub fn zero_range(&self) -> Range { self.fsize..self.msize } } // BundleImage is a loadable image that backs a Bundle. There are images @@ -142,9 +130,7 @@ impl<'a> BundleImage<'a> { } } - pub fn finish(&mut self) { - self.unmap_current_frame().expect("finish"); - } + pub fn finish(&mut self) { self.unmap_current_frame().expect("finish"); } // Read the current section header and setup to advance to the next // section on the next call. This is used in lieu of an iterator to @@ -260,9 +246,7 @@ impl<'a> BundleImage<'a> { } } impl<'a> Drop for BundleImage<'a> { - fn drop(&mut self) { - self.finish(); - } + fn drop(&mut self) { self.finish(); } } impl<'a> io::Seek for BundleImage<'a> { fn seek(&mut self, pos: io::SeekFrom) -> io::Result { diff --git a/apps/system/components/ProcessManager/kata-proc-manager/src/lib.rs b/apps/system/components/ProcessManager/kata-proc-manager/src/lib.rs index ef84f2e..e239fad 100644 --- a/apps/system/components/ProcessManager/kata-proc-manager/src/lib.rs +++ b/apps/system/components/ProcessManager/kata-proc-manager/src/lib.rs @@ -49,14 +49,10 @@ impl KataProcManager { } // Finishes the setup started by empty(): - pub fn init(&self) { - *self.manager.lock() = Some(ProcessManager::new(KataManagerInterface)); - } + pub fn init(&self) { *self.manager.lock() = Some(ProcessManager::new(KataManagerInterface)); } // Returns the bundle capacity. - pub fn capacity(&self) -> usize { - self.manager.lock().as_ref().unwrap().capacity() - } + pub fn capacity(&self) -> usize { self.manager.lock().as_ref().unwrap().capacity() } } // These just lock accesses and handle the necessary indirection. impl PackageManagementInterface for KataProcManager { @@ -85,10 +81,7 @@ impl ProcessControlInterface for KataProcManager { struct KataManagerInterface; impl ProcessManagerInterface for KataManagerInterface { fn install(&mut self, pkg_contents: &ObjDescBundle) -> Result { - trace!( - "ProcessManagerInterface::install pkg_contents {}", - pkg_contents - ); + trace!("ProcessManagerInterface::install pkg_contents {}", pkg_contents); // Package contains: application manifest, application binary, and // (optional) ML workload binary to run on vector core. diff --git a/apps/system/components/ProcessManager/kata-proc-manager/src/proc_manager/mod.rs b/apps/system/components/ProcessManager/kata-proc-manager/src/proc_manager/mod.rs index acc6734..d97751d 100644 --- a/apps/system/components/ProcessManager/kata-proc-manager/src/proc_manager/mod.rs +++ b/apps/system/components/ProcessManager/kata-proc-manager/src/proc_manager/mod.rs @@ -65,9 +65,7 @@ impl ProcessManager { } } - pub fn capacity(&self) -> usize { - self.bundles.capacity() - } + pub fn capacity(&self) -> usize { self.bundles.capacity() } } impl PackageManagementInterface for ProcessManager { @@ -200,21 +198,11 @@ mod tests { } struct FakeBundleImpl {} impl<'a> BundleImplInterface for FakeBundleImpl<'a> { - fn start(&mut self) -> Result<(), ProcessManagerError> { - Ok(()) - } - fn stop(&mut self) -> Result<(), ProcessManagerError> { - Ok(()) - } - fn resume(&self) -> Result<(), ProcessManagerError> { - Ok(()) - } - fn suspend(&self) -> Result<(), ProcessManagerError> { - Ok(()) - } - fn capscan(&self) -> Result<(), ProcessManagerError> { - Ok(()) - } + fn start(&mut self) -> Result<(), ProcessManagerError> { Ok(()) } + fn stop(&mut self) -> Result<(), ProcessManagerError> { Ok(()) } + fn resume(&self) -> Result<(), ProcessManagerError> { Ok(()) } + fn suspend(&self) -> Result<(), ProcessManagerError> { Ok(()) } + fn capscan(&self) -> Result<(), ProcessManagerError> { Ok(()) } } impl ProcessManagerInterface for FakeManager { fn install(&mut self, pkg_buffer: *const u8, pkg_buffer_size: u32) -> Result { @@ -235,9 +223,7 @@ mod tests { assert!(self.bundles.contains_key(&bundle.app_id)); Ok(Box::new(FakeBundleImpl)) } - fn stop(&mut self, bundle_impl: &mut dyn BundleImplInterface) -> Result<(), pme> { - Ok(()) - } + fn stop(&mut self, bundle_impl: &mut dyn BundleImplInterface) -> Result<(), pme> { Ok(()) } fn capscan(&mut self, bundle_impl: &mut dyn BundleImplInterface) -> Result<(), pme> { Ok(()) } diff --git a/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/arch/riscv.rs b/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/arch/riscv.rs index 12db1dd..fe6c6a4 100644 --- a/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/arch/riscv.rs +++ b/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/arch/riscv.rs @@ -17,15 +17,11 @@ pub const PAGE_SIZE: usize = 4096; // Base/small page size pub const STACK_ALIGNMENT_BYTES: usize = 16; pub const REG_ARGS: seL4_Word = 4; // Number of regs for passing thread args -fn MASK(pow2_bits: usize) -> usize { - (1 << pow2_bits) - 1 -} +fn MASK(pow2_bits: usize) -> usize { (1 << pow2_bits) - 1 } // NB: used to setup copy_addr_pt pub fn PD_SLOT(vaddr: usize) -> usize { (vaddr >> (seL4_PageTableIndexBits + seL4_PageBits)) & MASK(seL4_PageDirIndexBits) } // NB: used by tcb_args::maybe_spill_tcb_args -pub fn PT_SLOT(vaddr: usize) -> usize { - (vaddr >> seL4_PageBits) & MASK(seL4_PageTableIndexBits) -} +pub fn PT_SLOT(vaddr: usize) -> usize { (vaddr >> seL4_PageBits) & MASK(seL4_PageTableIndexBits) } diff --git a/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/feature/no_smp.rs b/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/feature/no_smp.rs index 0ca09fe..0008463 100644 --- a/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/feature/no_smp.rs +++ b/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/feature/no_smp.rs @@ -9,6 +9,4 @@ use sel4_sys::seL4_Word; use static_assertions::assert_cfg; assert_cfg!(not(feature = "CONFIG_SMP_SUPPORT")); -pub fn TCB_SetAffinity(_sel4_tcb: seL4_Word, _affinity: seL4_Word) -> seL4_Result { - Ok(()) -} +pub fn TCB_SetAffinity(_sel4_tcb: seL4_Word, _affinity: seL4_Word) -> seL4_Result { Ok(()) } diff --git a/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/mod.rs b/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/mod.rs index d5248da..3799641 100644 --- a/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/mod.rs +++ b/apps/system/components/ProcessManager/kata-proc-manager/src/sel4bundle/mod.rs @@ -109,9 +109,7 @@ fn make_guard(guard_bits: seL4_Word, guard_size: seL4_Word) -> seL4_Word { ((guard_bits) & ((1 << 18) - 1)) | ((guard_size << 18) | ((1 << 4) - 1)) } -fn roundup(a: usize, b: usize) -> usize { - ((a + b - 1) / b) * b -} +fn roundup(a: usize, b: usize) -> usize { ((a + b - 1) / b) * b } #[allow(dead_code)] fn is_path_empty((root, index, depth): (seL4_CPtr, seL4_CPtr, u8)) -> bool { @@ -199,11 +197,7 @@ impl seL4BundleImpl { bundle: &Bundle, bundle_frames: &ObjDescBundle, ) -> Result { - trace!( - "seL4BundleImpl::new {:?} bundle_frames {}", - bundle, - bundle_frames - ); + trace!("seL4BundleImpl::new {:?} bundle_frames {}", bundle, bundle_frames); sel4_sys::debug_assert_slot_cnode!(bundle_frames.cnode); @@ -247,11 +241,7 @@ impl seL4BundleImpl { ObjDesc::new(seL4_EndpointObject, 1, SDK_EP_SLOT), ObjDesc::new(seL4_ReplyObject, 1, SDK_REPLY_SLOT), // SchedContext for main thread - ObjDesc::new( - seL4_SchedContextObject, - seL4_MinSchedContextBits, - SCHED_CONTEXT_SLOT, - ), + ObjDesc::new(seL4_SchedContextObject, seL4_MinSchedContextBits, SCHED_CONTEXT_SLOT), // VSpace root (PD) ObjDesc::new(seL4_PageTableObject, 1, PD_SLOT), // VSpace page table (PT) @@ -408,12 +398,7 @@ impl seL4BundleImpl { // Frame is now setup, map it into the VSpace at the // page-aligned virtual address. - trace!( - "map slot {} vaddr 0x{:x} {:?}", - frame.cptr, - frame_vaddr, - rights - ); + trace!("map slot {} vaddr 0x{:x} {:?}", frame.cptr, frame_vaddr, rights); arch::map_page(frame, pd, frame_vaddr, *rights, vm_attribs)?; vaddr += frame.size_bytes().unwrap(); } @@ -468,12 +453,7 @@ impl seL4BundleImpl { self.stack_base = vaddr; for index in 0..stack_frames.retype_count() { let frame = &stack_frames.new_at(index); - trace!( - "map stack slot {} vaddr 0x{:x} {:?}", - frame.cptr, - vaddr, - rights_rwn - ); + trace!("map stack slot {} vaddr 0x{:x} {:?}", frame.cptr, vaddr, rights_rwn); arch::map_page(frame, pd, vaddr, rights_rwn, vm_attribs)?; vaddr += frame.size_bytes().unwrap(); } @@ -549,11 +529,7 @@ impl seL4BundleImpl { } let mut sp = self.tcb_sp; - assert_eq!( - sp % arch::STACK_ALIGNMENT_BYTES, - 0, - "TCB stack pointer mis-aligned" - ); + assert_eq!(sp % arch::STACK_ALIGNMENT_BYTES, 0, "TCB stack pointer mis-aligned"); // XXX nonsense values for testing let argv: &[seL4_Word] = &[0x11112222, 0x22223333, 0x44445555]; diff --git a/apps/system/components/SecurityCoordinator/kata-security-component/src/run.rs b/apps/system/components/SecurityCoordinator/kata-security-component/src/run.rs index a538ff8..8492af2 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-component/src/run.rs +++ b/apps/system/components/SecurityCoordinator/kata-security-component/src/run.rs @@ -194,11 +194,7 @@ fn read_key_request( let request = postcard::from_bytes::(request_buffer).map_err(deserialize_failure)?; - trace!( - "READ KEY bundle_id {} key {}", - request.bundle_id, - request.key - ); + trace!("READ KEY bundle_id {} key {}", request.bundle_id, request.key); let value = unsafe { KATA_SECURITY.read_key(request.bundle_id, request.key) }?; let _ = postcard::to_slice(&ReadKeyResponse { value }, reply_buffer).map_err(serialize_failure); Ok(()) @@ -230,11 +226,7 @@ fn delete_key_request( let request = postcard::from_bytes::(request_buffer).map_err(deserialize_failure)?; - trace!( - "DELETE KEY bundle_id {} key {}", - request.bundle_id, - request.key - ); + trace!("DELETE KEY bundle_id {} key {}", request.bundle_id, request.key); unsafe { KATA_SECURITY.delete_key(request.bundle_id, request.key) } } diff --git a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs index 8351806..5cc02a4 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs +++ b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs @@ -60,18 +60,14 @@ Required=1 } } impl Drop for BundleData { - fn drop(&mut self) { - let _ = kata_object_free_in_cnode(&self.pkg_contents); - } + fn drop(&mut self) { let _ = kata_object_free_in_cnode(&self.pkg_contents); } } pub struct FakeSecurityCoordinator { bundles: HashMap, } impl Default for FakeSecurityCoordinator { - fn default() -> Self { - Self::new() - } + fn default() -> Self { Self::new() } } impl FakeSecurityCoordinator { pub fn new() -> Self { @@ -249,18 +245,12 @@ impl SecurityCoordinatorInterface for FakeSecurityCoordinator { // Send the _physical_ address of the message buffer to the security // core. let paddr = seL4_Page_GetAddress(frame_bundle.objs[0].cptr); - mailbox_api_send( - paddr.paddr as u32, - (MESSAGE_SIZE_DWORDS * size_of::()) as u32, - ); + mailbox_api_send(paddr.paddr as u32, (MESSAGE_SIZE_DWORDS * size_of::()) as u32); // Wait for the response to arrive. let mut response_paddr: u32 = 0; let mut response_size: u32 = 0; - mailbox_api_receive( - &mut response_paddr as *mut u32, - &mut response_size as *mut u32, - ); + mailbox_api_receive(&mut response_paddr as *mut u32, &mut response_size as *mut u32); // The security core should have replaced the first and last dwords // with 0x12345678 and 0x87654321. diff --git a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/impl.rs b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/impl.rs index a4c2dcb..42aa8c5 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/impl.rs +++ b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/impl.rs @@ -23,9 +23,7 @@ pub struct SeL4SecurityCoordinator { // TODO(sleffler): mailbox ipc state } impl SeL4SecurityCoordinator { - pub fn new() -> Self { - SeL4SecurityCoordinator {} - } + pub fn new() -> Self { SeL4SecurityCoordinator {} } } pub type KataSecurityCoordinatorInterface = SeL4SecurityCoordinator; @@ -112,11 +110,7 @@ impl SecurityCoordinatorInterface for SeL4SecurityCoordinator { SecurityRequest::SrReadKey => { let request = postcard::from_bytes::(&request_buffer[..]) .map_err(deserialize_failure)?; - trace!( - "READ KEY bundle_id {} key {}", - request.bundle_id, - request.key, - ); + trace!("READ KEY bundle_id {} key {}", request.bundle_id, request.key,); // TODO(sleffler): fill-in Err(SreReadFailed) } @@ -135,11 +129,7 @@ impl SecurityCoordinatorInterface for SeL4SecurityCoordinator { SecurityRequest::SrDeleteKey => { let request = postcard::from_bytes::(&request_buffer[..]) .map_err(deserialize_failure)?; - trace!( - "DELETE KEY bundle_id {} key {}", - request.bundle_id, - request.key, - ); + trace!("DELETE KEY bundle_id {} key {}", request.bundle_id, request.key,); // TODO(sleffler): fill-in Err(SreDeleteFailed) } diff --git a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/lib.rs b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/lib.rs index 9256244..edbb031 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/lib.rs +++ b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/lib.rs @@ -33,9 +33,7 @@ pub struct KataSecurityCoordinator { impl KataSecurityCoordinator { // Constructs a partially-initialized instance; to complete call init(). // This is needed because we need a const fn for static setup. - const fn empty() -> KataSecurityCoordinator { - KataSecurityCoordinator { manager: None } - } + const fn empty() -> KataSecurityCoordinator { KataSecurityCoordinator { manager: None } } pub fn init(&mut self) { self.manager = Some(Box::new(KataSecurityCoordinatorInterface::new())); diff --git a/apps/system/components/SecurityCoordinator/kata-security-interface/src/lib.rs b/apps/system/components/SecurityCoordinator/kata-security-interface/src/lib.rs index 59ebab1..0c172c4 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-interface/src/lib.rs +++ b/apps/system/components/SecurityCoordinator/kata-security-interface/src/lib.rs @@ -36,9 +36,7 @@ pub type SecurityReplyData = [u8; SECURITY_REPLY_DATA_SIZE]; // Interface to any seL4 caapbility associated with the request. pub trait SecurityCapability { - fn get_container_cap(&self) -> Option { - None - } + fn get_container_cap(&self) -> Option { None } // TODO(sleffler): assert/log where no cap fn set_container_cap(&mut self, _cap: seL4_CPtr) {} } @@ -57,12 +55,8 @@ pub struct InstallRequest { pub pkg_contents: ObjDescBundle, } impl SecurityCapability for InstallRequest { - fn get_container_cap(&self) -> Option { - Some(self.pkg_contents.cnode) - } - fn set_container_cap(&mut self, cap: seL4_CPtr) { - self.pkg_contents.cnode = cap; - } + fn get_container_cap(&self) -> Option { Some(self.pkg_contents.cnode) } + fn set_container_cap(&mut self, cap: seL4_CPtr) { self.pkg_contents.cnode = cap; } } #[derive(Debug, Serialize, Deserialize)] @@ -118,12 +112,8 @@ pub struct LoadApplicationResponse { pub bundle_frames: ObjDescBundle, } impl SecurityCapability for LoadApplicationResponse { - fn get_container_cap(&self) -> Option { - Some(self.bundle_frames.cnode) - } - fn set_container_cap(&mut self, cap: seL4_CPtr) { - self.bundle_frames.cnode = cap; - } + fn get_container_cap(&self) -> Option { Some(self.bundle_frames.cnode) } + fn set_container_cap(&mut self, cap: seL4_CPtr) { self.bundle_frames.cnode = cap; } } // SecurityRequestLoadModel @@ -141,12 +131,8 @@ pub struct LoadModelResponse { pub model_frames: ObjDescBundle, } impl SecurityCapability for LoadModelResponse { - fn get_container_cap(&self) -> Option { - Some(self.model_frames.cnode) - } - fn set_container_cap(&mut self, cap: seL4_CPtr) { - self.model_frames.cnode = cap; - } + fn get_container_cap(&self) -> Option { Some(self.model_frames.cnode) } + fn set_container_cap(&mut self, cap: seL4_CPtr) { self.model_frames.cnode = cap; } } // SecurityRequestReadKey @@ -374,11 +360,7 @@ pub fn kata_security_uninstall(bundle_id: &str) -> Result<(), SecurityRequestErr #[allow(dead_code)] pub fn kata_security_size_buffer(bundle_id: &str) -> Result { let reply = &mut [0u8; SECURITY_REPLY_DATA_SIZE]; - kata_security_request( - SecurityRequest::SrSizeBuffer, - &SizeBufferRequest { bundle_id }, - reply, - )?; + kata_security_request(SecurityRequest::SrSizeBuffer, &SizeBufferRequest { bundle_id }, reply)?; let response = postcard::from_bytes::(reply) .map_err(|_| SecurityRequestError::SreDeserializeFailed)?; Ok(response.buffer_size) @@ -474,11 +456,7 @@ pub fn kata_security_read_key( keyval: &mut [u8], ) -> Result<(), SecurityRequestError> { let reply = &mut [0u8; SECURITY_REPLY_DATA_SIZE]; - kata_security_request( - SecurityRequest::SrReadKey, - &ReadKeyRequest { bundle_id, key }, - reply, - )?; + kata_security_request(SecurityRequest::SrReadKey, &ReadKeyRequest { bundle_id, key }, reply)?; let response = postcard::from_bytes::(reply) .map_err(|_| SecurityRequestError::SreDeserializeFailed)?; keyval.copy_from_slice(response.value); diff --git a/apps/system/components/StorageManager/kata-storage-component/src/run.rs b/apps/system/components/StorageManager/kata-storage-component/src/run.rs index c9a1099..6a39aac 100644 --- a/apps/system/components/StorageManager/kata-storage-component/src/run.rs +++ b/apps/system/components/StorageManager/kata-storage-component/src/run.rs @@ -53,11 +53,7 @@ pub unsafe extern "C" fn storage_write( Ok(key) => { // TODO(sleffler): de-badge reply cap to get bundle_id KATA_STORAGE - .write( - "fubar", - key, - slice::from_raw_parts(c_raw_value, c_raw_value_len), - ) + .write("fubar", key, slice::from_raw_parts(c_raw_value, c_raw_value_len)) .into() } Err(_) => StorageManagerError::SmeKeyInvalid, @@ -76,6 +72,4 @@ pub unsafe extern "C" fn storage_delete(c_key: *const cstr_core::c_char) -> Stor } #[no_mangle] -pub unsafe extern "C" fn storage_capscan() { - let _ = Camkes::capscan(); -} +pub unsafe extern "C" fn storage_capscan() { let _ = Camkes::capscan(); } diff --git a/apps/system/components/StorageManager/kata-storage-interface/src/lib.rs b/apps/system/components/StorageManager/kata-storage-interface/src/lib.rs index 067ce70..c113e4d 100644 --- a/apps/system/components/StorageManager/kata-storage-interface/src/lib.rs +++ b/apps/system/components/StorageManager/kata-storage-interface/src/lib.rs @@ -27,9 +27,7 @@ pub enum StorageError { } impl From for StorageError { - fn from(_err: postcard::Error) -> StorageError { - StorageError::SerializeFailed - } + fn from(_err: postcard::Error) -> StorageError { StorageError::SerializeFailed } } pub trait StorageManagerInterface { @@ -75,16 +73,12 @@ impl From for StorageManagerError { impl From> for StorageManagerError { fn from(result: Result<(), StorageError>) -> StorageManagerError { - result.map_or_else(StorageManagerError::from, |_| { - StorageManagerError::SmeSuccess - }) + result.map_or_else(StorageManagerError::from, |_| StorageManagerError::SmeSuccess) } } impl From for StorageManagerError { - fn from(_err: cstr_core::NulError) -> StorageManagerError { - StorageManagerError::SmeKeyInvalid - } + fn from(_err: cstr_core::NulError) -> StorageManagerError { StorageManagerError::SmeKeyInvalid } } impl From for Result<(), StorageManagerError> { diff --git a/apps/system/components/StorageManager/kata-storage-manager/src/lib.rs b/apps/system/components/StorageManager/kata-storage-manager/src/lib.rs index a7c7ffe..658515d 100644 --- a/apps/system/components/StorageManager/kata-storage-manager/src/lib.rs +++ b/apps/system/components/StorageManager/kata-storage-manager/src/lib.rs @@ -23,12 +23,7 @@ impl StorageManagerInterface for KataStorageManager { Ok(kata_security_read_key(bundle_id, key, &mut keyval).map(|_| keyval)?) } fn write(&self, bundle_id: &str, key: &str, value: &[u8]) -> Result<(), StorageError> { - trace!( - "write bundle_id:{} key:{} value:{:?}", - bundle_id, - key, - value - ); + trace!("write bundle_id:{} key:{} value:{:?}", bundle_id, key, value); Ok(kata_security_write_key(bundle_id, key, value)?) } diff --git a/apps/system/components/TimerService/kata-timer-component/src/run.rs b/apps/system/components/TimerService/kata-timer-component/src/run.rs index 13f856e..ba86f26 100644 --- a/apps/system/components/TimerService/kata-timer-component/src/run.rs +++ b/apps/system/components/TimerService/kata-timer-component/src/run.rs @@ -17,9 +17,7 @@ pub unsafe extern "C" fn pre_init() { } #[no_mangle] -pub unsafe extern "C" fn timer__init() { - TIMER_SRV.lock().init(); -} +pub unsafe extern "C" fn timer__init() { TIMER_SRV.lock().init(); } extern "C" { fn timer_get_sender_id() -> seL4_Word; @@ -78,6 +76,4 @@ pub unsafe extern "C" fn timer_interrupt_handle() { } #[no_mangle] -pub unsafe extern "C" fn timer_capscan() { - let _ = Camkes::capscan(); -} +pub unsafe extern "C" fn timer_capscan() { let _ = Camkes::capscan(); } diff --git a/apps/system/components/TimerService/kata-timer-service/src/lib.rs b/apps/system/components/TimerService/kata-timer-service/src/lib.rs index 223b030..fbe8a00 100644 --- a/apps/system/components/TimerService/kata-timer-service/src/lib.rs +++ b/apps/system/components/TimerService/kata-timer-service/src/lib.rs @@ -44,9 +44,7 @@ pub static mut TIMER_SRV: Mutex = Mutex::new(KataTimerService }); impl KataTimerService { - pub fn init(&mut self) { - self.timer.setup(); - } + pub fn init(&mut self) { self.timer.setup(); } pub fn completed_timers(&mut self, client_id: seL4_Word) -> u32 { assert!(0 < client_id && client_id <= NUM_CLIENTS); diff --git a/apps/system/components/TimerService/opentitan-timer/src/opentitan_timer.rs b/apps/system/components/TimerService/opentitan-timer/src/opentitan_timer.rs index c7f3a79..329c5a4 100644 --- a/apps/system/components/TimerService/opentitan-timer/src/opentitan_timer.rs +++ b/apps/system/components/TimerService/opentitan-timer/src/opentitan_timer.rs @@ -64,9 +64,7 @@ extern "C" { static csr: *mut u32; } -fn get_u32(idx: isize) -> u32 { - unsafe { ptr::read_volatile(csr.offset(idx)) } -} +fn get_u32(idx: isize) -> u32 { unsafe { ptr::read_volatile(csr.offset(idx)) } } fn set_u32(idx: isize, val: u32) { unsafe { @@ -74,82 +72,42 @@ fn set_u32(idx: isize, val: u32) { } } -fn get_bytes(idx: isize) -> [u8; 4] { - get_u32(idx).to_ne_bytes() -} +fn get_bytes(idx: isize) -> [u8; 4] { get_u32(idx).to_ne_bytes() } -fn set_bytes(idx: isize, bytes: [u8; 4]) { - set_u32(idx, u32::from_ne_bytes(bytes)); -} +fn set_bytes(idx: isize, bytes: [u8; 4]) { set_u32(idx, u32::from_ne_bytes(bytes)); } -pub fn get_ctrl() -> Ctrl { - Ctrl::from_bytes(get_bytes(1)) -} +pub fn get_ctrl() -> Ctrl { Ctrl::from_bytes(get_bytes(1)) } -pub fn set_ctrl(ctrl: Ctrl) { - set_bytes(1, ctrl.into_bytes()); -} +pub fn set_ctrl(ctrl: Ctrl) { set_bytes(1, ctrl.into_bytes()); } -pub fn get_config() -> Config { - Config::from_bytes(get_bytes(0x40)) -} +pub fn get_config() -> Config { Config::from_bytes(get_bytes(0x40)) } -pub fn set_config(config: Config) { - set_bytes(0x40, config.into_bytes()); -} +pub fn set_config(config: Config) { set_bytes(0x40, config.into_bytes()); } -pub fn get_value_low() -> u32 { - get_u32(0x41) -} +pub fn get_value_low() -> u32 { get_u32(0x41) } -pub fn set_value_low(val: u32) { - set_u32(0x41, val); -} +pub fn set_value_low(val: u32) { set_u32(0x41, val); } -pub fn get_value_high() -> u32 { - get_u32(0x42) -} +pub fn get_value_high() -> u32 { get_u32(0x42) } -pub fn set_value_high(val: u32) { - set_u32(0x42, val); -} +pub fn set_value_high(val: u32) { set_u32(0x42, val); } -pub fn get_compare_low() -> u32 { - get_u32(0x43) -} +pub fn get_compare_low() -> u32 { get_u32(0x43) } -pub fn set_compare_low(val: u32) { - set_u32(0x43, val); -} +pub fn set_compare_low(val: u32) { set_u32(0x43, val); } -pub fn get_compare_high() -> u32 { - get_u32(0x44) -} +pub fn get_compare_high() -> u32 { get_u32(0x44) } -pub fn set_compare_high(val: u32) { - set_u32(0x44, val); -} +pub fn set_compare_high(val: u32) { set_u32(0x44, val); } -pub fn get_intr_enable() -> Intr { - Intr::from_bytes(get_bytes(0x45)) -} +pub fn get_intr_enable() -> Intr { Intr::from_bytes(get_bytes(0x45)) } -pub fn set_intr_enable(intr_enable: Intr) { - set_bytes(0x45, intr_enable.into_bytes()); -} +pub fn set_intr_enable(intr_enable: Intr) { set_bytes(0x45, intr_enable.into_bytes()); } -pub fn get_intr_state() -> Intr { - Intr::from_bytes(get_bytes(0x46)) -} +pub fn get_intr_state() -> Intr { Intr::from_bytes(get_bytes(0x46)) } -pub fn set_intr_state(intr_state: Intr) { - set_bytes(0x46, intr_state.into_bytes()); -} +pub fn set_intr_state(intr_state: Intr) { set_bytes(0x46, intr_state.into_bytes()); } -pub fn get_intr_test() -> Intr { - Intr::from_bytes(get_bytes(0x47)) -} +pub fn get_intr_test() -> Intr { Intr::from_bytes(get_bytes(0x47)) } -pub fn set_intr_test(intr_test: Intr) { - set_bytes(0x47, intr_test.into_bytes()); -} +pub fn set_intr_test(intr_test: Intr) { set_bytes(0x47, intr_test.into_bytes()); } diff --git a/apps/system/components/kata-os-common/src/allocator/src/lib.rs b/apps/system/components/kata-os-common/src/allocator/src/lib.rs index 7849e12..359f76e 100644 --- a/apps/system/components/kata-os-common/src/allocator/src/lib.rs +++ b/apps/system/components/kata-os-common/src/allocator/src/lib.rs @@ -59,14 +59,10 @@ impl KataHeap { } /// Returns an estimate of the amount of bytes in use. - pub fn used(&self) -> usize { - (*self.heap.lock()).used() - } + pub fn used(&self) -> usize { (*self.heap.lock()).used() } /// Returns an estimate of the amount of bytes available. - pub fn free(&self) -> usize { - (*self.heap.lock()).free() - } + pub fn free(&self) -> usize { (*self.heap.lock()).free() } } unsafe impl GlobalAlloc for KataHeap { diff --git a/apps/system/components/kata-os-common/src/camkes/src/lib.rs b/apps/system/components/kata-os-common/src/camkes/src/lib.rs index 78fde75..854c78e 100644 --- a/apps/system/components/kata-os-common/src/camkes/src/lib.rs +++ b/apps/system/components/kata-os-common/src/camkes/src/lib.rs @@ -70,11 +70,7 @@ impl Camkes { unsafe { allocator::ALLOCATOR.init(heap.as_mut_ptr() as usize, heap.len()); } - trace!( - "setup heap: start_addr {:p} size {}", - heap.as_ptr(), - heap.len() - ); + trace!("setup heap: start_addr {:p} size {}", heap.as_ptr(), heap.len()); } pub fn init_slot_allocator(self: &Camkes, first_slot: seL4_CPtr, last_slot: seL4_CPtr) { @@ -110,14 +106,10 @@ impl Camkes { } // Returns the path specified with init_recv_path. - pub fn get_recv_path(self: &Camkes) -> seL4_CPath { - self.recv_path - } + pub fn get_recv_path(self: &Camkes) -> seL4_CPath { self.recv_path } // Returns the component name. - pub fn get_name(self: &Camkes) -> &'static str { - self.name - } + pub fn get_name(self: &Camkes) -> &'static str { self.name } // Returns the current receive path from the IPCBuffer. pub fn get_current_recv_path(self: &Camkes) -> seL4_CPath { @@ -180,9 +172,7 @@ impl Camkes { } // Clears any capability attached to a CAmkES RPC reply msg. - pub fn clear_reply_cap() { - Camkes::set_reply_cap(0); - } + pub fn clear_reply_cap() { Camkes::set_reply_cap(0); } // Wrappers for sel4_sys::debug_assert macros. pub fn debug_assert_slot_empty(tag: &str, path: &seL4_CPath) { diff --git a/apps/system/components/kata-os-common/src/capdl/mod.rs b/apps/system/components/kata-os-common/src/capdl/mod.rs index e919716..918e9e4 100644 --- a/apps/system/components/kata-os-common/src/capdl/mod.rs +++ b/apps/system/components/kata-os-common/src/capdl/mod.rs @@ -37,9 +37,7 @@ pub struct __BindgenBitfieldUnit { } impl __BindgenBitfieldUnit { #[inline] - pub const fn new(storage: Storage) -> Self { - Self { storage } - } + pub const fn new(storage: Storage) -> Self { Self { storage } } } impl __BindgenBitfieldUnit where @@ -134,9 +132,7 @@ pub const CDL_TCB_VCPU_Slot: seL4_Word = CDL_TCB_TemporalFaultEP_Slot + 1; pub type CDL_ObjID = seL4_Word; pub const CDL_ObjID_Invalid: CDL_ObjID = CDL_ObjID::MAX; // NB: some object id's are written in the spec as -1 -pub fn is_objid_valid(val: CDL_ObjID) -> bool { - val != CDL_ObjID_Invalid -} +pub fn is_objid_valid(val: CDL_ObjID) -> bool { val != CDL_ObjID_Invalid } pub type CDL_IRQ = seL4_Word; pub type CDL_Core = seL4_Word; @@ -234,21 +230,13 @@ impl CDL_CapData__bindgen_ty_1__bindgen_ty_1 { } } #[inline] - pub fn guard_bits(&self) -> seL4_Word { - self._bitfield.get(0, 18) as seL4_Word - } + pub fn guard_bits(&self) -> seL4_Word { self._bitfield.get(0, 18) as seL4_Word } #[inline] - pub fn set_guard_bits(&mut self, val: seL4_Word) { - self._bitfield.set(0, 18, val as u64) - } + pub fn set_guard_bits(&mut self, val: seL4_Word) { self._bitfield.set(0, 18, val as u64) } #[inline] - pub fn guard_size(&self) -> seL4_Word { - self._bitfield.get(18, 14) as seL4_Word - } + pub fn guard_size(&self) -> seL4_Word { self._bitfield.get(18, 14) as seL4_Word } #[inline] - pub fn set_guard_size(&mut self, val: seL4_Word) { - self._bitfield.set(18, 14, val as u64) - } + pub fn set_guard_size(&mut self, val: seL4_Word) { self._bitfield.set(18, 14, val as u64) } fn new_bitfield( guard_bits: seL4_Word, guard_size: seL4_Word, @@ -274,9 +262,7 @@ impl CDL_CapData { unsafe { ::core::mem::transmute::(self._bitfield.get(0, 2) as u32) } } #[inline] - pub fn set_tag(&mut self, val: u32) { - self._bitfield.set(0, 2, val as u64) - } + pub fn set_tag(&mut self, val: u32) { self._bitfield.set(0, 2, val as u64) } #[inline] pub fn guard_bits(&self) -> seL4_Word { unsafe { self.__bindgen_anon.__bindgen_anon.guard_bits() } @@ -294,21 +280,13 @@ impl CDL_CapData { unsafe { self.__bindgen_anon.__bindgen_anon.set_guard_size(val) } } #[inline] - pub fn badge(&self) -> seL4_Word { - unsafe { self.__bindgen_anon.badge } - } + pub fn badge(&self) -> seL4_Word { unsafe { self.__bindgen_anon.badge } } #[inline] - pub fn set_badge(&mut self, val: seL4_Word) { - self.__bindgen_anon.badge = val - } + pub fn set_badge(&mut self, val: seL4_Word) { self.__bindgen_anon.badge = val } #[inline] - pub fn data(&self) -> seL4_Word { - unsafe { self.__bindgen_anon.data } - } + pub fn data(&self) -> seL4_Word { unsafe { self.__bindgen_anon.data } } #[inline] - pub fn set_data(&mut self, val: seL4_Word) { - self.__bindgen_anon.data = val - } + pub fn set_data(&mut self, val: seL4_Word) { self.__bindgen_anon.data = val } } #[repr(C, packed)] @@ -326,31 +304,19 @@ pub struct CDL_Cap { } impl CDL_Cap { // data in an seL4-friendly format - pub fn cap_data(&self) -> seL4_Word { - self.data.get_cap_data() - } + pub fn cap_data(&self) -> seL4_Word { self.data.get_cap_data() } // Returns the sel4utils representation of a CDL_Cap's rights - pub fn cap_rights(&self) -> seL4_CapRights { - self.rights().into() - } + pub fn cap_rights(&self) -> seL4_CapRights { self.rights().into() } #[inline] - pub fn r#type(&self) -> CDL_CapType { - self.type_ - } + pub fn r#type(&self) -> CDL_CapType { self.type_ } #[inline] - pub fn vm_attribs(&self) -> u32 { - self._bitfield.get(0, 3) as u32 - } + pub fn vm_attribs(&self) -> u32 { self._bitfield.get(0, 3) as u32 } #[inline] - pub fn set_vm_attribs(&mut self, val: u32) { - self._bitfield.set(0, 3, val as u64) - } + pub fn set_vm_attribs(&mut self, val: u32) { self._bitfield.set(0, 3, val as u64) } #[inline] - pub fn is_orig(&self) -> bool { - self._bitfield.get(3, 1) != 0 - } + pub fn is_orig(&self) -> bool { self._bitfield.get(3, 1) != 0 } #[inline] pub fn set_is_orig(&mut self, val: bool) { self._bitfield.set(3, 1, if val { 1u64 } else { 0u64 }) @@ -393,9 +359,7 @@ impl<'a> CDL_CapMap { pub fn as_slice(&'a self) -> &'a [CDL_CapSlot] { unsafe { core::slice::from_raw_parts(self.slot, self.num) } } - pub fn get_slot(&self, index: usize) -> CDL_CapSlot { - self.as_slice()[index] - } + pub fn get_slot(&self, index: usize) -> CDL_CapSlot { self.as_slice()[index] } pub fn get_cap_at(&self, slot: seL4_Word) -> Option<&CDL_Cap> { self.as_slice() .iter() @@ -552,9 +516,7 @@ pub enum CDL_FrameFill_BootInfoEnum_t { CDL_FrameFill_BootInfo_BootInfo = SEL4_BOOTINFO_HEADER_BOOTINFO as isize, } impl From for usize { - fn from(bi_type: CDL_FrameFill_BootInfoEnum_t) -> usize { - bi_type as usize - } + fn from(bi_type: CDL_FrameFill_BootInfoEnum_t) -> usize { bi_type as usize } } #[repr(C)] @@ -636,18 +598,14 @@ impl<'a> CDL_Object { #[cfg(not(feature = "CONFIG_DEBUG_BUILD"))] #[inline] - pub fn name(&self) -> &str { - "" - } + pub fn name(&self) -> &str { "" } pub fn slots_slice(&'a self) -> &'a [CDL_CapSlot] { #[allow(unaligned_references)] self.slots.as_slice() } #[inline] - pub fn num_slots(&self) -> seL4_Word { - self.slots.num - } + pub fn num_slots(&self) -> seL4_Word { self.slots.num } // Returns the next available slot past those specified in the spec. // Note we cannot use num_slots since there may be gaps in the // numbering due to empty slots. @@ -669,13 +627,9 @@ impl<'a> CDL_Object { self.slots.get_cap_at(slot) } #[inline] - pub fn r#type(&self) -> CDL_ObjectType { - self.type_ - } + pub fn r#type(&self) -> CDL_ObjectType { self.type_ } #[inline] - pub fn size_bits(&self) -> seL4_Word { - self.size_bits as seL4_Word - } + pub fn size_bits(&self) -> seL4_Word { self.size_bits as seL4_Word } pub fn paddr(&self) -> Option { match self.type_ { CDL_Frame => Some(unsafe { self.extra.frame_extra.paddr }), @@ -702,9 +656,7 @@ impl<'a> CDL_Object { // TODO(sleffler): maybe assert type_ before referencing union members // NB: return everything as seL4_Word to minimize conversions #[inline] - pub fn tcb_ipcbuffer_addr(&self) -> seL4_Word { - unsafe { self.extra.tcb_extra.ipcbuffer_addr } - } + pub fn tcb_ipcbuffer_addr(&self) -> seL4_Word { unsafe { self.extra.tcb_extra.ipcbuffer_addr } } #[inline] pub fn tcb_priority(&self) -> seL4_Word { (unsafe { self.extra.tcb_extra.priority }) as seL4_Word @@ -718,25 +670,17 @@ impl<'a> CDL_Object { (unsafe { self.extra.tcb_extra.affinity }) as seL4_Word } #[inline] - pub fn tcb_domain(&self) -> seL4_Word { - (unsafe { self.extra.tcb_extra.domain }) as seL4_Word - } + pub fn tcb_domain(&self) -> seL4_Word { (unsafe { self.extra.tcb_extra.domain }) as seL4_Word } #[inline] - pub fn tcb_init(&self) -> *const seL4_Word { - unsafe { self.extra.tcb_extra.init } - } + pub fn tcb_init(&self) -> *const seL4_Word { unsafe { self.extra.tcb_extra.init } } #[inline] pub fn tcb_init_sz(&self) -> seL4_Word { (unsafe { self.extra.tcb_extra.init_sz }) as seL4_Word } #[inline] - pub fn tcb_pc(&self) -> seL4_Word { - unsafe { self.extra.tcb_extra.pc } - } + pub fn tcb_pc(&self) -> seL4_Word { unsafe { self.extra.tcb_extra.pc } } #[inline] - pub fn tcb_sp(&self) -> seL4_Word { - unsafe { self.extra.tcb_extra.sp } - } + pub fn tcb_sp(&self) -> seL4_Word { unsafe { self.extra.tcb_extra.sp } } pub fn tcb_elf_name(&'a self) -> Option<&'a str> { unsafe { if self.extra.tcb_extra.elf_name.is_null() { @@ -749,40 +693,24 @@ impl<'a> CDL_Object { } } #[inline] - pub fn tcb_resume(&self) -> bool { - unsafe { self.extra.tcb_extra.resume } - } + pub fn tcb_resume(&self) -> bool { unsafe { self.extra.tcb_extra.resume } } #[inline] - pub fn tcb_fault_ep(&self) -> seL4_CPtr { - unsafe { self.extra.tcb_extra.fault_ep } - } + pub fn tcb_fault_ep(&self) -> seL4_CPtr { unsafe { self.extra.tcb_extra.fault_ep } } #[inline] - pub fn cb_bank(&self) -> seL4_Word { - (unsafe { self.extra.cb_extra.bank }) as seL4_Word - } + pub fn cb_bank(&self) -> seL4_Word { (unsafe { self.extra.cb_extra.bank }) as seL4_Word } #[inline] - pub fn sc_period(&self) -> u64 { - unsafe { self.extra.sc_extra.period } - } + pub fn sc_period(&self) -> u64 { unsafe { self.extra.sc_extra.period } } #[inline] - pub fn sc_budget(&self) -> u64 { - unsafe { self.extra.sc_extra.budget } - } + pub fn sc_budget(&self) -> u64 { unsafe { self.extra.sc_extra.budget } } #[inline] - pub fn sc_data(&self) -> seL4_Word { - (unsafe { self.extra.sc_extra.data }) as seL4_Word - } + pub fn sc_data(&self) -> seL4_Word { (unsafe { self.extra.sc_extra.data }) as seL4_Word } #[inline] - pub fn other_start(&self) -> seL4_Word { - (unsafe { self.extra.other.start }) as seL4_Word - } + pub fn other_start(&self) -> seL4_Word { (unsafe { self.extra.other.start }) as seL4_Word } #[inline] - pub fn other_end(&self) -> seL4_Word { - (unsafe { self.extra.other.end }) as seL4_Word - } + pub fn other_end(&self) -> seL4_Word { (unsafe { self.extra.other.end }) as seL4_Word } #[inline] pub fn msi_pci_bus(&self) -> seL4_Word { diff --git a/apps/system/components/kata-os-common/src/copyregion/src/lib.rs b/apps/system/components/kata-os-common/src/copyregion/src/lib.rs index 2f05a08..50b8c75 100644 --- a/apps/system/components/kata-os-common/src/copyregion/src/lib.rs +++ b/apps/system/components/kata-os-common/src/copyregion/src/lib.rs @@ -55,9 +55,7 @@ impl CopyRegion { } // Returns the region size in bytes. - pub fn size(&self) -> usize { - self.size - } + pub fn size(&self) -> usize { self.size } // Returns the region size if mapped, otherwise 0. pub fn mapped_bytes(&self) -> usize { @@ -125,7 +123,5 @@ impl CopyRegion { } } impl Drop for CopyRegion { - fn drop(&mut self) { - self.unmap().expect("CopyRegion"); - } + fn drop(&mut self) { self.unmap().expect("CopyRegion"); } } diff --git a/apps/system/components/kata-os-common/src/cspace-slot/src/lib.rs b/apps/system/components/kata-os-common/src/cspace-slot/src/lib.rs index bd85b29..723e0e1 100644 --- a/apps/system/components/kata-os-common/src/cspace-slot/src/lib.rs +++ b/apps/system/components/kata-os-common/src/cspace-slot/src/lib.rs @@ -30,9 +30,7 @@ impl CSpaceSlot { // Release ownership of the slot; this inhibits the normal cleanup // done by drop. - pub fn release(&mut self) { - self.slot = seL4_CPtr::MAX; - } + pub fn release(&mut self) { self.slot = seL4_CPtr::MAX; } // Returns the (root, index, depth) seL4 path for the slot. pub fn get_path(&self) -> (seL4_CPtr, seL4_CPtr, u8) { diff --git a/apps/system/components/kata-os-common/src/logger/src/lib.rs b/apps/system/components/kata-os-common/src/logger/src/lib.rs index 14f0d8f..ea9351f 100644 --- a/apps/system/components/kata-os-common/src/logger/src/lib.rs +++ b/apps/system/components/kata-os-common/src/logger/src/lib.rs @@ -11,9 +11,7 @@ const MAX_MSG_LEN: usize = 2048; pub struct KataLogger; impl log::Log for KataLogger { - fn enabled(&self, _metadata: &Metadata) -> bool { - true - } + fn enabled(&self, _metadata: &Metadata) -> bool { true } fn log(&self, record: &Record) { if self.enabled(record.metadata()) { diff --git a/apps/system/components/kata-os-common/src/model/arch/x86.rs b/apps/system/components/kata-os-common/src/model/arch/x86.rs index 299ab64..f5faea3 100644 --- a/apps/system/components/kata-os-common/src/model/arch/x86.rs +++ b/apps/system/components/kata-os-common/src/model/arch/x86.rs @@ -47,32 +47,28 @@ pub fn create_irq_cap(irq: CDL_IRQ, obj: &CDL_Object, free_slot: seL4_CPtr) -> s let index = free_slot; let depth = seL4_WordBits as u8; match obj.r#type() { - CDL_IOAPICInterrupt => { - seL4_IRQControl_GetIOAPIC( - seL4_CapIRQControl, - root, - index, - depth, - obj.ioapicirq_ioapic(), - obj.ioapicirq_pin(), - obj.ioapicirq_level(), - obj.ioapicirq_polarity(), - irq, - ) - } - CDL_MSIInterrupt => { - seL4_IRQControl_GetMSI( - seL4_CapIRQControl, - root, - index, - depth, - obj.msiirq_pci_bus(), - obj.msiirq_pci_dev(), - obj.msiirq_pci_fun(), - obj.msiirq_handle(), - irq, - ) - } + CDL_IOAPICInterrupt => seL4_IRQControl_GetIOAPIC( + seL4_CapIRQControl, + root, + index, + depth, + obj.ioapicirq_ioapic(), + obj.ioapicirq_pin(), + obj.ioapicirq_level(), + obj.ioapicirq_polarity(), + irq, + ), + CDL_MSIInterrupt => seL4_IRQControl_GetMSI( + seL4_CapIRQControl, + root, + index, + depth, + obj.msiirq_pci_bus(), + obj.msiirq_pci_dev(), + obj.msiirq_pci_fun(), + obj.msiirq_handle(), + irq, + ), _ => seL4_IRQControl_Get(seL4_CapIRQControl, irq, root, index, depth), } } diff --git a/apps/system/components/kata-os-common/src/model/feature/no_vcpu.rs b/apps/system/components/kata-os-common/src/model/feature/no_vcpu.rs index 73ec035..457e946 100644 --- a/apps/system/components/kata-os-common/src/model/feature/no_vcpu.rs +++ b/apps/system/components/kata-os-common/src/model/feature/no_vcpu.rs @@ -7,7 +7,10 @@ use sel4_sys::seL4_CPtr; use sel4_sys::seL4_Result; use static_assertions::assert_cfg; -assert_cfg!(not(any(feature = "CONFIG_ARM_HYPERVISOR_SUPPORT", feature = "CONFIG_VTX"))); +assert_cfg!(not(any( + feature = "CONFIG_ARM_HYPERVISOR_SUPPORT", + feature = "CONFIG_VTX" +))); impl<'a> KataOsModel<'a> { pub fn set_tcb_vcpu(&self, _cdl_tcb: &CDL_Object, _sel4_tcb: seL4_CPtr) -> seL4_Result { diff --git a/apps/system/components/kata-os-common/src/model/feature/static_alloc.rs b/apps/system/components/kata-os-common/src/model/feature/static_alloc.rs index 4943d1d..62f80a6 100644 --- a/apps/system/components/kata-os-common/src/model/feature/static_alloc.rs +++ b/apps/system/components/kata-os-common/src/model/feature/static_alloc.rs @@ -63,7 +63,11 @@ impl<'a> KataOsModel<'a> { // XXX no break? } } - assert!(found, "Failed to find bootinfo to match untyped {:?}", ut.paddr().unwrap()); + assert!( + found, + "Failed to find bootinfo to match untyped {:?}", + ut.paddr().unwrap() + ); } Ok(()) } diff --git a/apps/system/components/kata-os-common/src/model/mod.rs b/apps/system/components/kata-os-common/src/model/mod.rs index 15ea3e7..65ce632 100644 --- a/apps/system/components/kata-os-common/src/model/mod.rs +++ b/apps/system/components/kata-os-common/src/model/mod.rs @@ -1091,7 +1091,11 @@ impl<'a> KataOsModel<'a> { // NB: tcb_args::maybe_spill_tcb_args may write arg data to the // stack causing the stack pointer to be adjusted. sp = self.maybe_spill_tcb_args(cdl_tcb, sp)?; - assert_eq!(sp % arch::STACK_ALIGNMENT_BYTES, 0, "Spilled TCB stack pointer mis-aligned"); + assert_eq!( + sp % arch::STACK_ALIGNMENT_BYTES, + 0, + "Spilled TCB stack pointer mis-aligned" + ); unsafe { seL4_TCB_WriteRegisters( diff --git a/apps/system/components/kata-os-common/src/model/rustfmt.toml b/apps/system/components/kata-os-common/src/model/rustfmt.toml deleted file mode 100644 index 5e2a514..0000000 --- a/apps/system/components/kata-os-common/src/model/rustfmt.toml +++ /dev/null @@ -1,4 +0,0 @@ -max_width = 100 -fn_call_width = 78 -fn_single_line = true -force_multiline_blocks = true diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch32.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch32.rs index bc91f25..7a69d17 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch32.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch32.rs @@ -130,12 +130,9 @@ pub enum seL4_ARM_VMAttributes { ExecuteNever = 4, } impl From for seL4_ARM_VMAttributes { - fn from(val: u32) -> seL4_ARM_VMAttributes { - unsafe { ::core::mem::transmute(val & 7) } - } + fn from(val: u32) -> seL4_ARM_VMAttributes { unsafe { ::core::mem::transmute(val & 7) } } } -pub const seL4_ARM_Default_VMAttributes: seL4_ARM_VMAttributes = - seL4_ARM_VMAttributes::Default; +pub const seL4_ARM_Default_VMAttributes: seL4_ARM_VMAttributes = seL4_ARM_VMAttributes::Default; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] @@ -177,7 +174,7 @@ impl seL4_ObjectType { match self { seL4_TCBObject => Some(seL4_TCBBits), seL4_EndpointObject => Some(seL4_EndpointBits), - seL4_NotificationObject => Some(seL4_NotificationBits), + seL4_NotificationObject => Some(seL4_NotificationBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] seL4_ReplyObject => Some(seL4_ReplyBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] @@ -197,9 +194,7 @@ impl seL4_ObjectType { } } impl From for seL4_Word { - fn from(type_: seL4_ObjectType) -> seL4_Word { - type_ as seL4_Word - } + fn from(type_: seL4_ObjectType) -> seL4_Word { type_ as seL4_Word } } #[inline(always)] @@ -214,9 +209,7 @@ pub unsafe fn seL4_GetIPCBuffer() -> *mut seL4_IPCBuffer { } #[inline(always)] -pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { - (*seL4_GetIPCBuffer()).msg[regnum] -} +pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { (*seL4_GetIPCBuffer()).msg[regnum] } #[inline(always)] pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { @@ -224,14 +217,10 @@ pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { } #[inline(always)] -pub unsafe fn seL4_GetUserData() -> seL4_Word { - (*seL4_GetIPCBuffer()).userData -} +pub unsafe fn seL4_GetUserData() -> seL4_Word { (*seL4_GetIPCBuffer()).userData } #[inline(always)] -pub unsafe fn seL4_SetUserData(data: seL4_Word) { - (*seL4_GetIPCBuffer()).userData = data; -} +pub unsafe fn seL4_SetUserData(data: seL4_Word) { (*seL4_GetIPCBuffer()).userData = data; } #[inline(always)] pub unsafe fn seL4_GetBadge(index: usize) -> seL4_Word { @@ -251,9 +240,11 @@ pub unsafe fn seL4_SetCap(index: usize, cptr: seL4_CPtr) { #[inline(always)] pub unsafe fn seL4_GetCapReceivePath() -> (seL4_CPtr, seL4_CPtr, seL4_CPtr) { let ipcbuffer = seL4_GetIPCBuffer(); - ((*ipcbuffer).receiveCNode, - (*ipcbuffer).receiveIndex, - (*ipcbuffer).receiveDepth) + ( + (*ipcbuffer).receiveCNode, + (*ipcbuffer).receiveIndex, + (*ipcbuffer).receiveDepth, + ) } #[inline(always)] diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch64.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch64.rs index 552fc38..2e52d5f 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch64.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/aarch64.rs @@ -67,8 +67,8 @@ pub type seL4_ARM_VSpace = seL4_CPtr; #[cfg(feature = "arch_generic")] include!("arm_generic.rs"); -pub use seL4_ARM_PageUpperDirectoryObject as seL4_PageUpperDirectoryObject; pub use seL4_ARM_PageGlobalDirectoryObject as seL4_PageGlobalDirectoryObject; +pub use seL4_ARM_PageUpperDirectoryObject as seL4_PageUpperDirectoryObject; error_types!(u64); @@ -122,12 +122,9 @@ pub enum seL4_ARM_VMAttributes { ExecuteNever = 4, } impl From for seL4_ARM_VMAttributes { - fn from(val: u32) -> seL4_ARM_VMAttributes { - unsafe { ::core::mem::transmute(val & 7) } - } + fn from(val: u32) -> seL4_ARM_VMAttributes { unsafe { ::core::mem::transmute(val & 7) } } } -pub const seL4_ARM_Default_VMAttributes: seL4_ARM_VMAttributes = - seL4_ARM_VMAttributes::Default; +pub const seL4_ARM_Default_VMAttributes: seL4_ARM_VMAttributes = seL4_ARM_VMAttributes::Default; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] @@ -171,7 +168,7 @@ impl seL4_ObjectType { match self { seL4_TCBObject => Some(seL4_TCBBits), seL4_EndpointObject => Some(seL4_EndpointBits), - seL4_NotificationObject => Some(seL4_EndpointBits), + seL4_NotificationObject => Some(seL4_EndpointBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] seL4_ReplyObject => Some(seL4_ReplyBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] @@ -193,9 +190,7 @@ impl seL4_ObjectType { } } impl From for seL4_Word { - fn from(type_: seL4_ObjectType) -> seL4_Word { - type_ as seL4_Word - } + fn from(type_: seL4_ObjectType) -> seL4_Word { type_ as seL4_Word } } #[inline(always)] @@ -210,9 +205,7 @@ pub unsafe fn seL4_GetIPCBuffer() -> *mut seL4_IPCBuffer { } #[inline(always)] -pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { - (*seL4_GetIPCBuffer()).msg[regnum] -} +pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { (*seL4_GetIPCBuffer()).msg[regnum] } #[inline(always)] pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { @@ -220,14 +213,10 @@ pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { } #[inline(always)] -pub unsafe fn seL4_GetUserData() -> seL4_Word { - (*seL4_GetIPCBuffer()).userData -} +pub unsafe fn seL4_GetUserData() -> seL4_Word { (*seL4_GetIPCBuffer()).userData } #[inline(always)] -pub unsafe fn seL4_SetUserData(data: seL4_Word) { - (*seL4_GetIPCBuffer()).userData = data; -} +pub unsafe fn seL4_SetUserData(data: seL4_Word) { (*seL4_GetIPCBuffer()).userData = data; } #[inline(always)] pub unsafe fn seL4_GetBadge(index: usize) -> seL4_Word { @@ -247,9 +236,11 @@ pub unsafe fn seL4_SetCap(index: usize, cptr: seL4_CPtr) { #[inline(always)] pub unsafe fn seL4_GetCapReceivePath() -> (seL4_CPtr, seL4_CPtr, seL4_CPtr) { let ipcbuffer = seL4_GetIPCBuffer(); - ((*ipcbuffer).receiveCNode, - (*ipcbuffer).receiveIndex, - (*ipcbuffer).receiveDepth) + ( + (*ipcbuffer).receiveCNode, + (*ipcbuffer).receiveIndex, + (*ipcbuffer).receiveDepth, + ) } #[inline(always)] diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/arm_generic.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/arm_generic.rs index 8408461..dfe3659 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/arm_generic.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/arm_generic.rs @@ -31,7 +31,6 @@ pub unsafe fn seL4_Page_Map( // NB: executable seL4_ARM_Page_Map(sel4_page, sel4_pd, vaddr, rights, vm_attribs) } else { - seL4_ARM_Page_Map(sel4_page, sel4_pd, vaddr, rights, - seL4_ARM_VMAttributes::ExecuteNever) + seL4_ARM_Page_Map(sel4_page, sel4_pd, vaddr, rights, seL4_ARM_VMAttributes::ExecuteNever) } } diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv32.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv32.rs index 4f15148..05e4a47 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv32.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv32.rs @@ -94,12 +94,10 @@ pub enum seL4_RISCV_VMAttributes { ExecuteNever = 0x1, } impl From for seL4_RISCV_VMAttributes { - fn from(val: u32) -> seL4_RISCV_VMAttributes { - unsafe { ::core::mem::transmute(val & 1) } - } + fn from(val: u32) -> seL4_RISCV_VMAttributes { unsafe { ::core::mem::transmute(val & 1) } } } pub const seL4_RISCV_Default_VMAttributes: seL4_RISCV_VMAttributes = - seL4_RISCV_VMAttributes::Default; + seL4_RISCV_VMAttributes::Default; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] @@ -132,7 +130,7 @@ impl seL4_ObjectType { match self { seL4_TCBObject => Some(seL4_TCBBits), seL4_EndpointObject => Some(seL4_EndpointBits), - seL4_NotificationObject => Some(seL4_EndpointBits), + seL4_NotificationObject => Some(seL4_EndpointBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] seL4_ReplyObject => Some(seL4_ReplyBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] @@ -145,16 +143,14 @@ impl seL4_ObjectType { // same for both 32- and 64-bit systems seL4_RISCV_PageTableObject => Some(seL4_PageTableBits), seL4_RISCV_Mega_Page => Some(seL4_LargePageBits), -// seL4_RISCV_Giga_Page => Some(seL4_HugePageBits), -// seL4_RISCV_Tera_Page => Some(seL4_TeraPageBits), + // seL4_RISCV_Giga_Page => Some(seL4_HugePageBits), + // seL4_RISCV_Tera_Page => Some(seL4_TeraPageBits), _ => None, } } } impl From for seL4_Word { - fn from(type_: seL4_ObjectType) -> seL4_Word { - type_ as seL4_Word - } + fn from(type_: seL4_ObjectType) -> seL4_Word { type_ as seL4_Word } } #[inline(always)] @@ -169,9 +165,7 @@ pub unsafe fn seL4_GetIPCBuffer() -> *mut seL4_IPCBuffer { } #[inline(always)] -pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { - (*seL4_GetIPCBuffer()).msg[regnum] -} +pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { (*seL4_GetIPCBuffer()).msg[regnum] } #[inline(always)] pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { @@ -179,14 +173,10 @@ pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { } #[inline(always)] -pub unsafe fn seL4_GetUserData() -> seL4_Word { - (*seL4_GetIPCBuffer()).userData -} +pub unsafe fn seL4_GetUserData() -> seL4_Word { (*seL4_GetIPCBuffer()).userData } #[inline(always)] -pub unsafe fn seL4_SetUserData(data: seL4_Word) { - (*seL4_GetIPCBuffer()).userData = data; -} +pub unsafe fn seL4_SetUserData(data: seL4_Word) { (*seL4_GetIPCBuffer()).userData = data; } #[inline(always)] pub unsafe fn seL4_GetBadge(index: usize) -> seL4_Word { @@ -206,9 +196,11 @@ pub unsafe fn seL4_SetCap(index: usize, cptr: seL4_CPtr) { #[inline(always)] pub unsafe fn seL4_GetCapReceivePath() -> (seL4_CPtr, seL4_CPtr, seL4_CPtr) { let ipcbuffer = seL4_GetIPCBuffer(); - ((*ipcbuffer).receiveCNode, - (*ipcbuffer).receiveIndex, - (*ipcbuffer).receiveDepth) + ( + (*ipcbuffer).receiveCNode, + (*ipcbuffer).receiveIndex, + (*ipcbuffer).receiveDepth, + ) } #[inline(always)] diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv64.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv64.rs index 609eebb..e87cca1 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv64.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv64.rs @@ -99,12 +99,10 @@ pub enum seL4_RISCV_VMAttributes { ExecuteNever = 0x1, } impl From for seL4_RISCV_VMAttributes { - fn from(val: u32) -> seL4_RISCV_VMAttributes { - unsafe { ::core::mem::transmute(val & 1) } - } + fn from(val: u32) -> seL4_RISCV_VMAttributes { unsafe { ::core::mem::transmute(val & 1) } } } pub const seL4_RISCV_Default_VMAttributes: seL4_RISCV_VMAttributes = - seL4_RISCV_VMAttributes::Default; + seL4_RISCV_VMAttributes::Default; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] @@ -139,7 +137,7 @@ impl seL4_ObjectType { match self { seL4_TCBObject => Some(seL4_TCBBits), seL4_EndpointObject => Some(seL4_EndpointBits), - seL4_NotificationObject => Some(seL4_EndpointBits), + seL4_NotificationObject => Some(seL4_EndpointBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] seL4_ReplyObject => Some(seL4_ReplyBits), #[cfg(feature = "CONFIG_KERNEL_MCS")] @@ -159,9 +157,7 @@ impl seL4_ObjectType { } } impl From for seL4_Word { - fn from(type_: seL4_ObjectType) -> seL4_Word { - type_ as seL4_Word - } + fn from(type_: seL4_ObjectType) -> seL4_Word { type_ as seL4_Word } } #[inline(always)] @@ -176,9 +172,7 @@ pub unsafe fn seL4_GetIPCBuffer() -> *mut seL4_IPCBuffer { } #[inline(always)] -pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { - (*seL4_GetIPCBuffer()).msg[regnum] -} +pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { (*seL4_GetIPCBuffer()).msg[regnum] } #[inline(always)] pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { @@ -186,14 +180,10 @@ pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { } #[inline(always)] -pub unsafe fn seL4_GetUserData() -> seL4_Word { - (*seL4_GetIPCBuffer()).userData -} +pub unsafe fn seL4_GetUserData() -> seL4_Word { (*seL4_GetIPCBuffer()).userData } #[inline(always)] -pub unsafe fn seL4_SetUserData(data: seL4_Word) { - (*seL4_GetIPCBuffer()).userData = data; -} +pub unsafe fn seL4_SetUserData(data: seL4_Word) { (*seL4_GetIPCBuffer()).userData = data; } #[inline(always)] pub unsafe fn seL4_GetBadge(index: usize) -> seL4_Word { @@ -213,9 +203,11 @@ pub unsafe fn seL4_SetCap(index: usize, cptr: seL4_CPtr) { #[inline(always)] pub unsafe fn seL4_GetCapReceivePath() -> (seL4_CPtr, seL4_CPtr, seL4_CPtr) { let ipcbuffer = seL4_GetIPCBuffer(); - ((*ipcbuffer).receiveCNode, - (*ipcbuffer).receiveIndex, - (*ipcbuffer).receiveDepth) + ( + (*ipcbuffer).receiveCNode, + (*ipcbuffer).receiveIndex, + (*ipcbuffer).receiveDepth, + ) } #[inline(always)] diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv_generic.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv_generic.rs index c922146..84a40f2 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv_generic.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/riscv_generic.rs @@ -6,10 +6,10 @@ pub type seL4_Page = seL4_RISCV_Page; pub type seL4_PageTable = seL4_RISCV_PageTable; pub type seL4_VMAttributes = seL4_RISCV_VMAttributes; +pub use seL4_ObjectType::seL4_RISCV_4K_Page as seL4_SmallPageObject; pub use seL4_ObjectType::seL4_RISCV_Mega_Page as seL4_LargePageObject; pub use seL4_ObjectType::seL4_RISCV_PageTableObject as seL4_PageDirectoryObject; pub use seL4_ObjectType::seL4_RISCV_PageTableObject as seL4_PageTableObject; -pub use seL4_ObjectType::seL4_RISCV_4K_Page as seL4_SmallPageObject; pub use seL4_RISCV_Default_VMAttributes as seL4_Default_VMAttributes; @@ -31,7 +31,12 @@ pub unsafe fn seL4_Page_Map( // NB: executable seL4_RISCV_Page_Map(sel4_page, sel4_pd, vaddr, rights, vm_attribs) } else { - seL4_RISCV_Page_Map(sel4_page, sel4_pd, vaddr, rights, - seL4_RISCV_VMAttributes::ExecuteNever) + seL4_RISCV_Page_Map( + sel4_page, + sel4_pd, + vaddr, + rights, + seL4_RISCV_VMAttributes::ExecuteNever, + ) } } diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/x86.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/x86.rs index 5a3c6bd..86e5b5f 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/x86.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/x86.rs @@ -86,9 +86,7 @@ pub enum seL4_ObjectType { seL4_LastObjectType, } impl From for seL4_Word { - fn from(type_: seL4_ObjectType) -> seL4_Word { - type_ as seL4_Word - } + fn from(type_: seL4_ObjectType) -> seL4_Word { type_ as seL4_Word } } #[repr(u32)] @@ -101,12 +99,9 @@ pub enum seL4_X86_VMAttributes { WriteCombining = 4, } impl From for seL4_X86_VMAttributes { - fn from(val: u32) -> seL4_x86_VMAttributes { - unsafe { ::core::mem::transmute(val & 7) } - } + fn from(val: u32) -> seL4_x86_VMAttributes { unsafe { ::core::mem::transmute(val & 7) } } } -pub const seL4_X86_Default_VMAttributes: seL4_X86_VMAttributes = - seL4_X86_VMAttributes::WriteBack; +pub const seL4_X86_Default_VMAttributes: seL4_X86_VMAttributes = seL4_X86_VMAttributes::WriteBack; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -175,9 +170,11 @@ pub unsafe fn seL4_SetCap(index: isize, cptr: seL4_CPtr) { } #[inline(always)] -pub unsafe fn seL4_GetCapReceivePath(receiveCNode: *mut seL4_CPtr, - receiveIndex: *mut seL4_CPtr, - receiveDepth: *mut seL4_Word) { +pub unsafe fn seL4_GetCapReceivePath( + receiveCNode: *mut seL4_CPtr, + receiveIndex: *mut seL4_CPtr, + receiveDepth: *mut seL4_Word, +) { if !receiveCNode.is_null() { asm!("movl %fs:500, $0" : "=r"(*receiveCNode) : : : "volatile"); } @@ -192,16 +189,24 @@ pub unsafe fn seL4_GetCapReceivePath(receiveCNode: *mut seL4_CPtr, } #[inline(always)] -pub unsafe fn seL4_SetCapReceivePath(receiveCNode: seL4_CPtr, - receiveIndex: seL4_CPtr, - receiveDepth: seL4_Word) { +pub unsafe fn seL4_SetCapReceivePath( + receiveCNode: seL4_CPtr, + receiveIndex: seL4_CPtr, + receiveDepth: seL4_Word, +) { asm!("movl $0, %fs:500" : : "r"(receiveCNode) : "memory" : "volatile"); asm!("movl $0, %fs:504" : : "r"(receiveIndex) : "memory" : "volatile"); asm!("movl $0, %fs:508" : : "r"(receiveDepth) : "memory" : "volatile"); } #[inline(always)] -unsafe fn x86_sys_send(sys: seL4_Word, mut dest: seL4_Word, info: seL4_Word, mr1: seL4_Word, mr2: seL4_Word) { +unsafe fn x86_sys_send( + sys: seL4_Word, + mut dest: seL4_Word, + info: seL4_Word, + mr1: seL4_Word, + mr2: seL4_Word, +) { asm!("pushl %ebp pushl %ebx movl %ecx, %ebp @@ -262,7 +267,14 @@ unsafe fn x86_sys_send_null(sys: seL4_Word, mut dest: seL4_Word, info: seL4_Word } #[inline(always)] -unsafe fn x86_sys_recv(sys: seL4_Word, src: seL4_Word, out_badge: *mut seL4_Word, out_info: *mut seL4_Word, out_mr1: *mut seL4_Word, out_mr2: *mut seL4_Word) { +unsafe fn x86_sys_recv( + sys: seL4_Word, + src: seL4_Word, + out_badge: *mut seL4_Word, + out_info: *mut seL4_Word, + out_mr1: *mut seL4_Word, + out_mr2: *mut seL4_Word, +) { asm!("pushl %ebp pushl %ebx movl %esx, %ecp @@ -285,7 +297,15 @@ unsafe fn x86_sys_recv(sys: seL4_Word, src: seL4_Word, out_badge: *mut seL4_Word } #[inline(always)] -unsafe fn x86_sys_send_recv(sys: seL4_Word, dest: seL4_Word, out_badge: *mut seL4_Word, info: seL4_Word, out_info: *mut seL4_Word, in_out_mr1: *mut seL4_Word, in_out_mr2: *mut seL4_Word) { +unsafe fn x86_sys_send_recv( + sys: seL4_Word, + dest: seL4_Word, + out_badge: *mut seL4_Word, + info: seL4_Word, + out_info: *mut seL4_Word, + in_out_mr1: *mut seL4_Word, + in_out_mr2: *mut seL4_Word, +) { asm!("pushl %ebp pushl %ebx movl %ecx, %ebp @@ -329,7 +349,13 @@ unsafe fn x86_sys_null(sys: seL4_Word) { #[inline(always)] pub unsafe fn seL4_Send(dest: seL4_CPtr, msgInfo: seL4_MessageInfo) { - x86_sys_send(SyscallId::Send as seL4_Word, dest, msgInfo.words[0], seL4_GetMR(0), seL4_GetMR(1)); + x86_sys_send( + SyscallId::Send as seL4_Word, + dest, + msgInfo.words[0], + seL4_GetMR(0), + seL4_GetMR(1), + ); } macro_rules! opt_deref { @@ -339,7 +365,7 @@ macro_rules! opt_deref { } else { 0 } - } + }; } macro_rules! opt_assign { @@ -347,47 +373,82 @@ macro_rules! opt_assign { if !$loc.is_null() { *$loc = $val; } - } + }; } #[inline(always)] -pub unsafe fn seL4_SendWithMRs(dest: seL4_CPtr, msgInfo: seL4_MessageInfo, - mr0: *mut seL4_Word, mr1: *mut seL4_Word) { - x86_sys_send(SyscallId::Send as seL4_Word, dest, msgInfo.words[0], - if mr0.is_null() { 0 } else { *mr0 }, - if mr1.is_null() { 0 } else { *mr1 }); +pub unsafe fn seL4_SendWithMRs( + dest: seL4_CPtr, + msgInfo: seL4_MessageInfo, + mr0: *mut seL4_Word, + mr1: *mut seL4_Word, +) { + x86_sys_send( + SyscallId::Send as seL4_Word, + dest, + msgInfo.words[0], + if mr0.is_null() { 0 } else { *mr0 }, + if mr1.is_null() { 0 } else { *mr1 }, + ); } #[inline(always)] pub unsafe fn seL4_NBSend(dest: seL4_CPtr, msgInfo: seL4_MessageInfo) { - x86_sys_send(SyscallId::NBSend as seL4_Word, dest, msgInfo.words[0], seL4_GetMR(0), seL4_GetMR(1)); + x86_sys_send( + SyscallId::NBSend as seL4_Word, + dest, + msgInfo.words[0], + seL4_GetMR(0), + seL4_GetMR(1), + ); } #[inline(always)] -pub unsafe fn seL4_NBSendWithMRs(dest: seL4_CPtr, msgInfo: seL4_MessageInfo, - mr0: *mut seL4_Word, mr1: *mut seL4_Word) { - x86_sys_send(SyscallId::NBSend as seL4_Word, dest, msgInfo.words[0], - if mr0.is_null() { 0 } else { *mr0 }, - if mr1.is_null() { 0 } else { *mr1 }); +pub unsafe fn seL4_NBSendWithMRs( + dest: seL4_CPtr, + msgInfo: seL4_MessageInfo, + mr0: *mut seL4_Word, + mr1: *mut seL4_Word, +) { + x86_sys_send( + SyscallId::NBSend as seL4_Word, + dest, + msgInfo.words[0], + if mr0.is_null() { 0 } else { *mr0 }, + if mr1.is_null() { 0 } else { *mr1 }, + ); } #[inline(always)] pub unsafe fn seL4_Reply(msgInfo: seL4_MessageInfo) { - x86_sys_reply(SyscallId::Reply as seL4_Word, msgInfo.words[0], seL4_GetMR(0), seL4_GetMR(1)); - + x86_sys_reply( + SyscallId::Reply as seL4_Word, + msgInfo.words[0], + seL4_GetMR(0), + seL4_GetMR(1), + ); } #[inline(always)] -pub unsafe fn seL4_ReplyWithMRs(msgInfo: seL4_MessageInfo, - mr0: *mut seL4_Word, mr1: *mut seL4_Word) { - x86_sys_reply(SyscallId::Reply as seL4_Word, msgInfo.words[0], - if mr0.is_null() { 0 } else { *mr0 }, - if mr1.is_null() { 0 } else { *mr1 }); +pub unsafe fn seL4_ReplyWithMRs( + msgInfo: seL4_MessageInfo, + mr0: *mut seL4_Word, + mr1: *mut seL4_Word, +) { + x86_sys_reply( + SyscallId::Reply as seL4_Word, + msgInfo.words[0], + if mr0.is_null() { 0 } else { *mr0 }, + if mr1.is_null() { 0 } else { *mr1 }, + ); } - #[inline(always)] pub unsafe fn seL4_Signal(dest: seL4_CPtr) { - x86_sys_send_null(SyscallId::Send as seL4_Word, dest, seL4_MessageInfo::new(0,0,0,0).words[0]); + x86_sys_send_null( + SyscallId::Send as seL4_Word, + dest, + seL4_MessageInfo::new(0, 0, 0, 0).words[0], + ); } #[inline(always)] @@ -397,7 +458,14 @@ pub unsafe fn seL4_Recv(src: seL4_CPtr, sender: *mut seL4_Word) -> seL4_MessageI let mut mr0: seL4_Word = uninitialized(); let mut mr1: seL4_Word = uninitialized(); - x86_sys_recv(SyscallId::Recv as seL4_Word, src, &mut badge, &mut info.words[0], &mut mr0 as *mut _, &mut mr1); + x86_sys_recv( + SyscallId::Recv as seL4_Word, + src, + &mut badge, + &mut info.words[0], + &mut mr0 as *mut _, + &mut mr1, + ); seL4_SetMR(0, mr0); seL4_SetMR(1, mr1); @@ -408,14 +476,25 @@ pub unsafe fn seL4_Recv(src: seL4_CPtr, sender: *mut seL4_Word) -> seL4_MessageI } #[inline(always)] -pub unsafe fn seL4_RecvWithMRs(src: seL4_CPtr, sender: *mut seL4_Word, - mr0: *mut seL4_Word, mr1: *mut seL4_Word) -> seL4_MessageInfo { +pub unsafe fn seL4_RecvWithMRs( + src: seL4_CPtr, + sender: *mut seL4_Word, + mr0: *mut seL4_Word, + mr1: *mut seL4_Word, +) -> seL4_MessageInfo { let mut info: seL4_MessageInfo = uninitialized(); let mut badge: seL4_Word = uninitialized(); let mut msg0: seL4_Word = uninitialized(); let mut msg1: seL4_Word = uninitialized(); - x86_sys_recv(SyscallId::Recv as seL4_Word, src, &mut badge, &mut info.words[0], &mut msg0, &mut msg1); + x86_sys_recv( + SyscallId::Recv as seL4_Word, + src, + &mut badge, + &mut info.words[0], + &mut msg0, + &mut msg1, + ); opt_assign!(mr0, msg0); opt_assign!(mr1, msg1); @@ -431,7 +510,14 @@ pub unsafe fn seL4_NBRecv(src: seL4_CPtr, sender: *mut seL4_Word) -> seL4_Messag let mut mr0: seL4_Word = uninitialized(); let mut mr1: seL4_Word = uninitialized(); - x86_sys_recv(SyscallId::NBRecv as seL4_Word, src, &mut badge, &mut info.words[0], &mut mr0, &mut mr1); + x86_sys_recv( + SyscallId::NBRecv as seL4_Word, + src, + &mut badge, + &mut info.words[0], + &mut mr0, + &mut mr1, + ); seL4_SetMR(0, mr0); seL4_SetMR(1, mr1); @@ -447,7 +533,15 @@ pub unsafe fn seL4_Call(mut dest: seL4_CPtr, msgInfo: seL4_MessageInfo) -> seL4_ let mut mr0 = seL4_GetMR(0); let mut mr1 = seL4_GetMR(1); - x86_sys_send_recv(SyscallId::Call as seL4_Word, dest, &mut dest, msgInfo.words[0], &mut info.words[0], &mut mr0, &mut mr1); + x86_sys_send_recv( + SyscallId::Call as seL4_Word, + dest, + &mut dest, + msgInfo.words[0], + &mut info.words[0], + &mut mr0, + &mut mr1, + ); seL4_SetMR(0, mr0); seL4_SetMR(1, mr1); @@ -456,8 +550,12 @@ pub unsafe fn seL4_Call(mut dest: seL4_CPtr, msgInfo: seL4_MessageInfo) -> seL4_ } #[inline(always)] -pub unsafe fn seL4_CallWithMRs(mut dest: seL4_CPtr, msgInfo: seL4_MessageInfo, - mr0: *mut seL4_Word, mr1: *mut seL4_Word) -> seL4_MessageInfo { +pub unsafe fn seL4_CallWithMRs( + mut dest: seL4_CPtr, + msgInfo: seL4_MessageInfo, + mr0: *mut seL4_Word, + mr1: *mut seL4_Word, +) -> seL4_MessageInfo { let mut info: seL4_MessageInfo = uninitialized(); let mut msg0: seL4_Word = 0; let mut msg1: seL4_Word = 0; @@ -473,7 +571,15 @@ pub unsafe fn seL4_CallWithMRs(mut dest: seL4_CPtr, msgInfo: seL4_MessageInfo, } } - x86_sys_send_recv(SyscallId::Call as seL4_Word, dest, &mut dest, msgInfo.words[0], &mut info.words[0], &mut msg0, &mut msg1); + x86_sys_send_recv( + SyscallId::Call as seL4_Word, + dest, + &mut dest, + msgInfo.words[0], + &mut info.words[0], + &mut msg0, + &mut msg1, + ); opt_assign!(mr0, msg0); opt_assign!(mr1, msg1); @@ -482,14 +588,25 @@ pub unsafe fn seL4_CallWithMRs(mut dest: seL4_CPtr, msgInfo: seL4_MessageInfo, } #[inline(always)] -pub unsafe fn seL4_ReplyRecv(dest: seL4_CPtr, msgInfo: seL4_MessageInfo, - sender: *mut seL4_Word) -> seL4_MessageInfo { +pub unsafe fn seL4_ReplyRecv( + dest: seL4_CPtr, + msgInfo: seL4_MessageInfo, + sender: *mut seL4_Word, +) -> seL4_MessageInfo { let mut info: seL4_MessageInfo = uninitialized(); let mut badge: seL4_Word = uninitialized(); let mut mr0 = seL4_GetMR(0); let mut mr1 = seL4_GetMR(1); - x86_sys_send_recv(SyscallId::ReplyRecv as seL4_Word, dest, &mut badge, msgInfo.words[0], &mut info.words[0], &mut mr0, &mut mr1); + x86_sys_send_recv( + SyscallId::ReplyRecv as seL4_Word, + dest, + &mut badge, + msgInfo.words[0], + &mut info.words[0], + &mut mr0, + &mut mr1, + ); seL4_SetMR(0, mr0); seL4_SetMR(1, mr1); @@ -500,8 +617,13 @@ pub unsafe fn seL4_ReplyRecv(dest: seL4_CPtr, msgInfo: seL4_MessageInfo, } #[inline(always)] -pub unsafe fn seL4_ReplyWaitWithMRs(dest: seL4_CPtr, msgInfo: seL4_MessageInfo, sender: *mut seL4_Word, - mr0: *mut seL4_Word, mr1: *mut seL4_Word) -> seL4_MessageInfo { +pub unsafe fn seL4_ReplyWaitWithMRs( + dest: seL4_CPtr, + msgInfo: seL4_MessageInfo, + sender: *mut seL4_Word, + mr0: *mut seL4_Word, + mr1: *mut seL4_Word, +) -> seL4_MessageInfo { let mut info: seL4_MessageInfo = uninitialized(); let mut badge: seL4_Word = uninitialized(); let mut msg0: seL4_Word = 0; @@ -518,7 +640,15 @@ pub unsafe fn seL4_ReplyWaitWithMRs(dest: seL4_CPtr, msgInfo: seL4_MessageInfo, } } - x86_sys_send_recv(SyscallId::ReplyRecv as seL4_Word, dest, &mut badge, msgInfo.words[0], &mut info.words[0], &mut msg0, &mut msg1); + x86_sys_send_recv( + SyscallId::ReplyRecv as seL4_Word, + dest, + &mut badge, + msgInfo.words[0], + &mut info.words[0], + &mut msg0, + &mut msg1, + ); opt_assign!(mr0, msg0); opt_assign!(mr1, msg1); @@ -540,7 +670,15 @@ pub unsafe fn seL4_VMEnter(vcpu: seL4_CPtr, sender: *mut seL4_Word) -> seL4_Word let mut mr0 = seL4_GetMR(0); let mut mr1 = seL4_GetMR(1); - x86_sys_send_recv(SyscallId::VMEnter as seL4_Word, vcpu, &mut badge, 0, &mut fault, &mut mr0, &mut mr1); + x86_sys_send_recv( + SyscallId::VMEnter as seL4_Word, + vcpu, + &mut badge, + 0, + &mut fault, + &mut mr0, + &mut mr1, + ); seL4_SetMR(0, mr0); seL4_SetMR(1, mr1); @@ -558,8 +696,15 @@ pub unsafe fn seL4_DebugPutChar(c: u8) { let mut unused1 = 0; let mut unused2 = 0; let mut unused3 = 0; - x86_sys_send_recv(SyscallId::DebugPutChar as seL4_Word, c as seL4_Word, &mut unused0, 0, &mut - unused1, &mut unused2, &mut unused3); + x86_sys_send_recv( + SyscallId::DebugPutChar as seL4_Word, + c as seL4_Word, + &mut unused0, + 0, + &mut unused1, + &mut unused2, + &mut unused3, + ); } #[inline(always)] @@ -579,8 +724,15 @@ pub unsafe fn seL4_DebugCapIdentify(mut cap: seL4_CPtr) -> u32 { let mut unused0 = 0; let mut unused1 = 0; let mut unused2 = 0; - x86_sys_send_recv(SyscallId::DebugCapIdentify as seL4_Word, - cap, &mut cap, 0, &mut unused0, &mut unused1, &mut unused2); + x86_sys_send_recv( + SyscallId::DebugCapIdentify as seL4_Word, + cap, + &mut cap, + 0, + &mut unused0, + &mut unused1, + &mut unused2, + ); cap as _ } @@ -590,27 +742,49 @@ pub unsafe fn seL4_DebugDumpCNode(mut cap: seL4_CPtr) { let mut unused0 = 0; let mut unused1 = 0; let mut unused2 = 0; - x86_sys_send_recv(SyscallId::DebugDumpCNode as seL4_Word, - cap, &mut cap, 0, &mut unused0, &mut unused1, &mut unused2); + x86_sys_send_recv( + SyscallId::DebugDumpCNode as seL4_Word, + cap, + &mut cap, + 0, + &mut unused0, + &mut unused1, + &mut unused2, + ); } /// Note: name MUST be NUL-terminated. #[inline(always)] pub unsafe fn seL4_DebugNameThread(tcb: seL4_CPtr, name: &[u8]) { - core::ptr::copy_nonoverlapping(name.as_ptr() as *mut u8, (&mut (*seL4_GetIPCBuffer()).msg).as_mut_ptr() as *mut u8,name.len()); + core::ptr::copy_nonoverlapping( + name.as_ptr() as *mut u8, + (&mut (*seL4_GetIPCBuffer()).msg).as_mut_ptr() as *mut u8, + name.len(), + ); let mut unused0 = 0; let mut unused1 = 0; let mut unused2 = 0; let mut unused3 = 0; - x86_sys_send_recv(SyscallId::DebugNameThread as seL4_Word, tcb, &mut unused0, 0, &mut unused1, - &mut unused2, &mut unused3); + x86_sys_send_recv( + SyscallId::DebugNameThread as seL4_Word, + tcb, + &mut unused0, + 0, + &mut unused1, + &mut unused2, + &mut unused3, + ); } #[inline(always)] #[cfg(feature = "SEL4_DANGEROUS_CODE_INJECTION")] -pub unsafe fn seL4_DebugRun(userfn: extern fn(*mut u8), userarg: *mut u8) { +pub unsafe fn seL4_DebugRun(userfn: extern "C" fn(*mut u8), userarg: *mut u8) { let userfnptr = userfn as *mut (); - x86_sys_send_null(SyscallId::DebugRun as seL4_Word, userfnptr as seL4_Word, userarg as seL4_Word); + x86_sys_send_null( + SyscallId::DebugRun as seL4_Word, + userfnptr as seL4_Word, + userarg as seL4_Word, + ); asm!("" ::: "%edi", "memory" : "volatile"); } @@ -623,7 +797,15 @@ pub unsafe fn seL4_BenchmarkResetLog() -> seL4_Word { let mut ret = 0; - x86_sys_send_recv(SyscallId::BenchmarkResetLog as seL4_Word, 0, &mut ret, 0, &mut unused0 as *mut _ as usize as seL4_Word, &mut unused1 as *mut _ as usize as seL4_Word, &mut unused2 as *mut _ as usize as seL4_Word); + x86_sys_send_recv( + SyscallId::BenchmarkResetLog as seL4_Word, + 0, + &mut ret, + 0, + &mut unused0 as *mut _ as usize as seL4_Word, + &mut unused1 as *mut _ as usize as seL4_Word, + &mut unused2 as *mut _ as usize as seL4_Word, + ); ret } @@ -641,8 +823,15 @@ pub unsafe fn seL4_BenchmarkSetLogBuffer(mut frame_cptr: seL4_Word) -> seL4_Word let mut unused0 = 0; let mut unused1 = 0; let mut unused2 = 0; - x86_sys_send_recv(SyscallId::BenchmarkSetLogBuffer as seL4_Word, - frame_cptr, &mut cap, 0, &mut unused0 as *mut _ as usize as seL4_Word, &mut unused1 as *mut _ as usize as seL4_Word, &mut unused2 as *mut _ as usize as seL4_Word); + x86_sys_send_recv( + SyscallId::BenchmarkSetLogBuffer as seL4_Word, + frame_cptr, + &mut cap, + 0, + &mut unused0 as *mut _ as usize as seL4_Word, + &mut unused1 as *mut _ as usize as seL4_Word, + &mut unused2 as *mut _ as usize as seL4_Word, + ); frame_cptr } @@ -667,8 +856,15 @@ pub unsafe fn seL4_BenchmarkGetThreadUtilization(tcb: seL4_Word) { let mut unused1 = 0; let mut unused2 = 0; let mut unused3 = 0; - x86_sys_send_recv(SyscallId::BenchmarkGetThreadUtilisation as seL4_Word, tcb, &mut unused0 as *mut _ as usize as seL4_Word, 0, - &mut unused1 as *mut _ as usize as seL4_Word, &mut unused2 as *mut _ as usize as seL4_Word, &mut unused3 as *mut _ as usize as seL4_Word); + x86_sys_send_recv( + SyscallId::BenchmarkGetThreadUtilisation as seL4_Word, + tcb, + &mut unused0 as *mut _ as usize as seL4_Word, + 0, + &mut unused1 as *mut _ as usize as seL4_Word, + &mut unused2 as *mut _ as usize as seL4_Word, + &mut unused3 as *mut _ as usize as seL4_Word, + ); } #[inline(always)] @@ -678,6 +874,13 @@ pub unsafe fn seL4_BenchmarkGetThreadUtilization(tcb: seL4_Word) { let mut unused1 = 0; let mut unused2 = 0; let mut unused3 = 0; - x86_sys_send_recv(SyscallId::BenchmarkResetThreadUtilisation as seL4_Word, tcb, &mut unused0 as *mut _ as usize as seL4_Word, 0, - &mut unused1 as *mut _ as usize as seL4_Word, &mut unused2 as *mut _ as usize as seL4_Word, &mut unused3 as *mut _ as usize as seL4_Word); + x86_sys_send_recv( + SyscallId::BenchmarkResetThreadUtilisation as seL4_Word, + tcb, + &mut unused0 as *mut _ as usize as seL4_Word, + 0, + &mut unused1 as *mut _ as usize as seL4_Word, + &mut unused2 as *mut _ as usize as seL4_Word, + &mut unused3 as *mut _ as usize as seL4_Word, + ); } diff --git a/apps/system/components/kata-os-common/src/sel4-sys/arch/x86_64.rs b/apps/system/components/kata-os-common/src/sel4-sys/arch/x86_64.rs index 501053f..ba4dc8b 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/arch/x86_64.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/arch/x86_64.rs @@ -93,9 +93,7 @@ pub enum seL4_ObjectType { seL4_LastObjectType, } impl From for seL4_Word { - fn from(type_: seL4_ObjectType) -> seL4_Word { - type_ as seL4_Word - } + fn from(type_: seL4_ObjectType) -> seL4_Word { type_ as seL4_Word } } #[repr(u32)] @@ -108,12 +106,9 @@ pub enum seL4_X86_VMAttributes { WriteCombining = 4, } impl From for seL4_X86_VMAttributes { - fn from(val: u32) -> seL4_x86_VMAttributes { - unsafe { ::core::mem::transmute(val & 7) } - } + fn from(val: u32) -> seL4_x86_VMAttributes { unsafe { ::core::mem::transmute(val & 7) } } } -pub const seL4_X86_Default_VMAttributes: seL4_X86_VMAttributes = - seL4_X86_VMAttributes::WriteBack; +pub const seL4_X86_Default_VMAttributes: seL4_X86_VMAttributes = seL4_X86_VMAttributes::WriteBack; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -237,9 +232,7 @@ pub unsafe fn seL4_GetIPCBuffer() -> *mut seL4_IPCBuffer { } #[inline(always)] -pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { - (*seL4_GetIPCBuffer()).msg[regnum] -} +pub unsafe fn seL4_GetMR(regnum: usize) -> seL4_Word { (*seL4_GetIPCBuffer()).msg[regnum] } #[inline(always)] pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { @@ -247,14 +240,10 @@ pub unsafe fn seL4_SetMR(regnum: usize, value: seL4_Word) { } #[inline(always)] -pub unsafe fn seL4_GetUserData() -> seL4_Word { - (*seL4_GetIPCBuffer()).userData -} +pub unsafe fn seL4_GetUserData() -> seL4_Word { (*seL4_GetIPCBuffer()).userData } #[inline(always)] -pub unsafe fn seL4_SetUserData(data: seL4_Word) { - (*seL4_GetIPCBuffer()).userData = data; -} +pub unsafe fn seL4_SetUserData(data: seL4_Word) { (*seL4_GetIPCBuffer()).userData = data; } #[inline(always)] pub unsafe fn seL4_GetBadge(index: usize) -> seL4_Word { @@ -274,9 +263,11 @@ pub unsafe fn seL4_SetCap(index: usize, cptr: seL4_CPtr) { #[inline(always)] pub unsafe fn seL4_GetCapReceivePath() -> (seL4_CPtr, seL4_CPtr, seL4_CPtr) { let ipcbuffer = seL4_GetIPCBuffer(); - ((*ipcbuffer).receiveCNode, - (*ipcbuffer).receiveIndex, - (*ipcbuffer).receiveDepth) + ( + (*ipcbuffer).receiveCNode, + (*ipcbuffer).receiveIndex, + (*ipcbuffer).receiveDepth, + ) } #[inline(always)] diff --git a/apps/system/components/kata-os-common/src/sel4-sys/build.rs b/apps/system/components/kata-os-common/src/sel4-sys/build.rs index 87780a5..67b99e6 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/build.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/build.rs @@ -145,11 +145,8 @@ fn main() { )) .unwrap(); println!("{}/types{}.rs", out_dir, cargo_target_pointer_width); - let bfout = File::create(&*format!( - "{}/types{}.rs", - out_dir, cargo_target_pointer_width - )) - .unwrap(); + let bfout = + File::create(&*format!("{}/types{}.rs", out_dir, cargo_target_pointer_width)).unwrap(); let mut cmd = Command::new("/usr/bin/env"); cmd.args(&[ &python_bin, diff --git a/apps/system/components/kata-os-common/src/sel4-sys/lib.rs b/apps/system/components/kata-os-common/src/sel4-sys/lib.rs index cfeb34c..d3369f3 100644 --- a/apps/system/components/kata-os-common/src/sel4-sys/lib.rs +++ b/apps/system/components/kata-os-common/src/sel4-sys/lib.rs @@ -256,9 +256,7 @@ pub struct seL4_IPCBuffer { } impl ::core::clone::Clone for seL4_IPCBuffer { - fn clone(&self) -> Self { - *self - } + fn clone(&self) -> Self { *self } } // From libsel4/include/sel4/shared_types.h; this is defined in C as an enum @@ -317,15 +315,9 @@ pub struct seL4_UntypedDesc { align: [seL4_Word; 0], } impl seL4_UntypedDesc { - pub fn is_device(&self) -> bool { - self.isDevice != 0 - } - pub fn is_tainted(&self) -> bool { - self.isTainted != 0 - } - pub fn size_bits(&self) -> usize { - self.sizeBits as usize - } + pub fn is_device(&self) -> bool { self.isDevice != 0 } + pub fn is_tainted(&self) -> bool { self.isTainted != 0 } + pub fn size_bits(&self) -> usize { self.sizeBits as usize } } // explicitly *not* Copy. the array at the end is tricky to handle. diff --git a/apps/system/components/kata-os-common/src/slot-allocator/src/lib.rs b/apps/system/components/kata-os-common/src/slot-allocator/src/lib.rs index 9d57b58..ba528c4 100644 --- a/apps/system/components/kata-os-common/src/slot-allocator/src/lib.rs +++ b/apps/system/components/kata-os-common/src/slot-allocator/src/lib.rs @@ -36,9 +36,7 @@ impl Slots { self.bits = Some(bitvec![u8, Lsb0; 0; size].into_boxed_bitslice()); self.name = name; } - fn used_slots(&self) -> usize { - self.used - } + fn used_slots(&self) -> usize { self.used } fn free_slots(&self) -> usize { let bits = self.bits.as_ref().unwrap(); bits.len() - self.used @@ -147,19 +145,13 @@ impl KataSlotAllocator { } /// Returns the base slot number. - pub fn base_slot(&self) -> usize { - self.base_slot - } + pub fn base_slot(&self) -> usize { self.base_slot } /// Returns the number of slots in use. - pub fn used_slots(&self) -> usize { - (*self.slots.lock()).used_slots() - } + pub fn used_slots(&self) -> usize { (*self.slots.lock()).used_slots() } /// Returns the number of slots available. - pub fn free_slots(&self) -> usize { - (*self.slots.lock()).free_slots() - } + pub fn free_slots(&self) -> usize { (*self.slots.lock()).free_slots() } pub fn alloc(&self, count: usize) -> Option { (*self.slots.lock()) diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..6ae54d5 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,2 @@ +fn_call_width = 70 +fn_single_line = true