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