diff --git a/kernel/src/arch/x86_64/cpu/pic.rs b/kernel/src/arch/x86_64/cpu/pic.rs index 3f9b250..b43313d 100644 --- a/kernel/src/arch/x86_64/cpu/pic.rs +++ b/kernel/src/arch/x86_64/cpu/pic.rs @@ -49,7 +49,7 @@ impl ChainedPics { /// conflict with one another, the resulting object will be useless and /// will likely cause problems for your system. pub const unsafe fn new(offset1: u8, offset2: u8) -> Self { - ChainedPics { + Self { pics: [ Pic { offset: offset1, diff --git a/kernel/src/arch/x86_64/memory/allocation/heap_alloc.rs b/kernel/src/arch/x86_64/memory/allocation/heap_alloc.rs index b7bd2c6..0f50818 100644 --- a/kernel/src/arch/x86_64/memory/allocation/heap_alloc.rs +++ b/kernel/src/arch/x86_64/memory/allocation/heap_alloc.rs @@ -26,7 +26,7 @@ pub struct Locked { impl Locked { pub const fn new(inner: T) -> Self { - Locked { + Self { inner: Mutex::new(inner), } } @@ -144,6 +144,12 @@ pub struct FoundryFallbackAllocator { head: FallbackListNode, } +impl Default for FoundryFallbackAllocator { + fn default() -> Self { + Self::new() + } +} + impl FoundryFallbackAllocator { pub const fn new() -> Self { Self { @@ -173,7 +179,7 @@ impl FoundryFallbackAllocator { let mut current = &mut self.head; // look for a large enough memory region in linked list while let Some(ref mut region) = current.next { - if let Ok(alloc_start) = Self::alloc_from_region(®ion, size, align) { + if let Ok(alloc_start) = Self::alloc_from_region(region, size, align) { // region suitable for allocation -> remove node from list let next = region.next.take(); let ret = Some((current.next.take().unwrap(), alloc_start)); diff --git a/kernel/src/arch/x86_64/memory/allocation/stack_alloc.rs b/kernel/src/arch/x86_64/memory/allocation/stack_alloc.rs index a5c21ca..7be4742 100644 --- a/kernel/src/arch/x86_64/memory/allocation/stack_alloc.rs +++ b/kernel/src/arch/x86_64/memory/allocation/stack_alloc.rs @@ -16,7 +16,7 @@ pub unsafe fn alloc_stack( size_in_pages: u64, mapper: &mut impl Mapper, frame_allocator: &mut impl FrameAllocator, -) -> Result> { +) -> Result> { unsafe { use x86_64::structures::paging::PageTableFlags as Flags; let guard_page = reserve_stack_memory(size_in_pages + 1); @@ -35,7 +35,7 @@ pub unsafe fn alloc_stack( start: stack_start.start_address(), end: stack_end.start_address(), }) -} +}} #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] @@ -45,15 +45,15 @@ pub struct StackBounds { } impl StackBounds { - pub fn new(start: VirtAddr, end: VirtAddr) -> Self { + pub const fn new(start: VirtAddr, end: VirtAddr) -> Self { Self { start, end } } - pub fn start(&self) -> VirtAddr { + pub const fn start(&self) -> VirtAddr { self.start } - pub fn end(&self) -> VirtAddr { + pub const fn end(&self) -> VirtAddr { self.end } } \ No newline at end of file diff --git a/kernel/src/arch/x86_64/processing/threading/mod.rs b/kernel/src/arch/x86_64/processing/threading/mod.rs index b6f6476..2aa540f 100644 --- a/kernel/src/arch/x86_64/processing/threading/mod.rs +++ b/kernel/src/arch/x86_64/processing/threading/mod.rs @@ -16,13 +16,13 @@ pub struct Thread { pub struct ThreadId(u64); impl ThreadId { - pub fn as_u64(&self) -> u64 { + pub const fn as_u64(&self) -> u64 { self.0 } fn new() -> Self { use core::sync::atomic::{AtomicU64, Ordering}; static NEXT_THREAD_ID: AtomicU64 = AtomicU64::new(1); - ThreadId(NEXT_THREAD_ID.fetch_add(1, Ordering::Relaxed)) + Self(NEXT_THREAD_ID.fetch_add(1, Ordering::Relaxed)) } } diff --git a/kernel/src/resources/font/mod.rs b/kernel/src/resources/font/mod.rs index 974739c..0b27bc2 100644 --- a/kernel/src/resources/font/mod.rs +++ b/kernel/src/resources/font/mod.rs @@ -15,8 +15,8 @@ pub struct Font { } impl Font { - pub const fn new(data: [[u8; 16]; 512]) -> Font { - Font { + pub const fn new(data: [[u8; 16]; 512]) -> Self { + Self { width: 8, height: 16, length: data.len() as u16, @@ -40,7 +40,7 @@ impl Font { self.height } - pub fn default() -> &'static Font { + pub fn default() -> &'static Self { &FONT_CP850_8X16 } } diff --git a/kernel/src/util/editor.rs b/kernel/src/util/editor.rs index 153e74f..594d2a8 100644 --- a/kernel/src/util/editor.rs +++ b/kernel/src/util/editor.rs @@ -1,6 +1,5 @@ use crate::serial_print; use crate::arch::x86_64::drivers::keyboard::{KeyStroke, get_keystroke_async}; -use crate::prelude::*; use crate::resources::font::Font; use crate::std::application::frame::Frame; use crate::std::application::render::RenderError;