Преглед изворни кода

style: fix or suppress warnings

No functional changes

- Add `{extern_,}symbol_addr` macro to retrieve symbol address.
- Remove manual impl Send and Sync for RawPage
- Make elided '_ lifetimes in return types explicit
- Suppress unused warnings by allowing them
- Remove really unused functions
- Refactor `println_trace` macro to suppress unused variable warnings

Signed-off-by: greatbridf <greatbridf@icloud.com>
greatbridf пре 2 недеља
родитељ
комит
b0c8ef4ccc

+ 26 - 0
crates/eonix_hal/src/lib.rs

@@ -43,3 +43,29 @@ pub mod arch_exported {
 
 pub use eonix_hal_macros::{ap_main, default_trap_handler, main};
 pub use eonix_hal_traits as traits;
+
+#[macro_export]
+macro_rules! symbol_addr {
+    ($sym:expr) => {{
+        ($sym) as *const () as usize
+    }};
+    ($sym:expr, $type:ty) => {{
+        ($sym) as *const () as *const $type
+    }};
+}
+
+#[macro_export]
+macro_rules! extern_symbol_addr {
+    ($sym:ident) => {{
+        unsafe extern "C" {
+            fn $sym();
+        }
+        $crate::symbol_addr!($sym)
+    }};
+    ($sym:ident, $type:ty) => {{
+        unsafe extern "C" {
+            fn $sym();
+        }
+        $crate::symbol_addr!($sym, $type)
+    }};
+}

+ 18 - 4
crates/eonix_log/src/lib.rs

@@ -2,6 +2,7 @@
 
 use alloc::sync::Arc;
 use core::fmt::{self, Write};
+
 use eonix_sync::{Spin, SpinIrq as _};
 
 extern crate alloc;
@@ -91,18 +92,31 @@ macro_rules! println_fatal {
 
 #[macro_export]
 macro_rules! println_trace {
-    ($feat:literal) => {
+    (feat:$feat:literal) => {
         #[deny(unexpected_cfgs)]
         {
             #[cfg(feature = $feat)]
-            $crate::println!("[kernel:trace] ")
+            $crate::println!("[kernel:trace]")
         }
     };
-    ($feat:literal, $($arg:tt)*) => {{
+    (feat:$feat:literal, $fmt:literal) => {{
         #[deny(unexpected_cfgs)]
         {
             #[cfg(feature = $feat)]
-            $crate::println!("[kernel:trace] {}", format_args!($($arg)*))
+            $crate::println!(concat!("[kernel:trace] ", $feat))
         }
     }};
+    (feat:$feat:literal, $fmt:literal, $($arg:expr $(,)?)*) => {
+        #[deny(unexpected_cfgs)]
+        {
+            // Suppress unused variables warning
+            #[cfg(not(feature = $feat))]
+            {
+                $(let _ = $arg;)*
+            }
+
+            #[cfg(feature = $feat)]
+            $crate::println!("[kernel:trace] {}", format_args!($fmt, $($arg,)*))
+        }
+    };
 }

+ 12 - 19
crates/eonix_percpu/src/lib.rs

@@ -1,28 +1,21 @@
 #![no_std]
 
 use core::alloc::Layout;
-use core::ptr::null_mut;
-use core::ptr::NonNull;
-use core::sync::atomic::AtomicPtr;
-use core::sync::atomic::Ordering;
-
-#[cfg(target_arch = "x86_64")]
-pub use eonix_percpu_macros::define_percpu_x86_64 as define_percpu;
-
-#[cfg(target_arch = "x86_64")]
-pub use eonix_percpu_macros::define_percpu_shared_x86_64 as define_percpu_shared;
-
-#[cfg(target_arch = "riscv64")]
-pub use eonix_percpu_macros::define_percpu_riscv64 as define_percpu;
-
-#[cfg(target_arch = "riscv64")]
-pub use eonix_percpu_macros::define_percpu_shared_riscv64 as define_percpu_shared;
+use core::ptr::{null_mut, NonNull};
+use core::sync::atomic::{AtomicPtr, Ordering};
 
 #[cfg(target_arch = "loongarch64")]
 pub use eonix_percpu_macros::define_percpu_loongarch64 as define_percpu;
-
+#[cfg(target_arch = "riscv64")]
+pub use eonix_percpu_macros::define_percpu_riscv64 as define_percpu;
 #[cfg(target_arch = "loongarch64")]
 pub use eonix_percpu_macros::define_percpu_shared_loongarch64 as define_percpu_shared;
+#[cfg(target_arch = "riscv64")]
+pub use eonix_percpu_macros::define_percpu_shared_riscv64 as define_percpu_shared;
+#[cfg(target_arch = "x86_64")]
+pub use eonix_percpu_macros::define_percpu_shared_x86_64 as define_percpu_shared;
+#[cfg(target_arch = "x86_64")]
+pub use eonix_percpu_macros::define_percpu_x86_64 as define_percpu;
 
 const MAX_CPUS: usize = 256;
 
@@ -41,7 +34,7 @@ impl PercpuArea {
         unsafe extern "C" {
             fn PERCPU_LENGTH();
         }
-        let len = PERCPU_LENGTH as usize;
+        let len = PERCPU_LENGTH as *const () as usize;
 
         assert_ne!(len, 0, "Percpu length should not be zero.");
         len
@@ -52,7 +45,7 @@ impl PercpuArea {
             fn PERCPU_DATA_START();
         }
 
-        let addr = PERCPU_DATA_START as usize;
+        let addr = PERCPU_DATA_START as *const () as usize;
         NonNull::new(addr as *mut _).expect("Percpu data should not be null.")
     }
 

+ 14 - 21
crates/eonix_runtime/src/scheduler.rs

@@ -1,20 +1,19 @@
-use crate::{
-    executor::OutputHandle,
-    ready_queue::{local_rq, ReadyQueue},
-    task::{Task, TaskAdapter, TaskHandle, TaskState},
-};
-use alloc::{sync::Arc, task::Wake};
-use core::{
-    ops::{Deref, DerefMut},
-    ptr::NonNull,
-    task::{Context, Poll, Waker},
-};
+use alloc::sync::Arc;
+use alloc::task::Wake;
+use core::ops::{Deref, DerefMut};
+use core::ptr::NonNull;
+use core::task::{Context, Poll, Waker};
+
 use eonix_hal::processor::halt;
 use eonix_log::println_trace;
 use eonix_sync::{LazyLock, Spin, SpinIrq as _};
 use intrusive_collections::RBTree;
 use pointers::BorrowedArc;
 
+use crate::executor::OutputHandle;
+use crate::ready_queue::{local_rq, ReadyQueue};
+use crate::task::{Task, TaskAdapter, TaskHandle, TaskState};
+
 #[eonix_percpu::define_percpu]
 static CURRENT_TASK: Option<NonNull<Task>> = None;
 
@@ -93,12 +92,6 @@ impl Runtime {
         }
     }
 
-    fn current(&self) -> Option<BorrowedArc<Task>> {
-        CURRENT_TASK
-            .get()
-            .map(|ptr| unsafe { BorrowedArc::from_raw(ptr) })
-    }
-
     fn remove_and_enqueue_current(&self, rq: &mut impl DerefMut<Target = dyn ReadyQueue>) {
         let Some(current) = CURRENT_TASK
             .swap(None)
@@ -116,7 +109,7 @@ impl Runtime {
         }) {
             Ok(TaskState::READY_RUNNING) => {
                 println_trace!(
-                    "trace_scheduler",
+                    feat: "trace_scheduler",
                     "Re-enqueueing task {:?} (CPU{})",
                     current.id,
                     eonix_hal::processor::CPU::local().cpuid(),
@@ -126,7 +119,7 @@ impl Runtime {
             }
             Ok(_) => {
                 println_trace!(
-                    "trace_scheduler",
+                    feat: "trace_scheduler",
                     "Current task {:?} (CPU{}) is blocked, not re-enqueueing",
                     current.id,
                     eonix_hal::processor::CPU::local().cpuid(),
@@ -184,7 +177,7 @@ impl Runtime {
             };
 
             println_trace!(
-                "trace_scheduler",
+                feat: "trace_scheduler",
                 "Switching to task {:?} (CPU{})",
                 next.id,
                 eonix_hal::processor::CPU::local().cpuid(),
@@ -212,7 +205,7 @@ impl Runtime {
                 );
 
                 println_trace!(
-                    "trace_scheduler",
+                    feat: "trace_scheduler",
                     "Task {:?} finished execution, removing...",
                     Task::current().id,
                 );

+ 6 - 8
crates/eonix_sync/eonix_spin/src/lib.rs

@@ -2,13 +2,11 @@
 
 mod guard;
 
-use core::{
-    cell::UnsafeCell,
-    marker::PhantomData,
-    sync::atomic::{AtomicBool, Ordering},
-};
-use eonix_sync_base::{Relax, SpinRelax};
+use core::cell::UnsafeCell;
+use core::marker::PhantomData;
+use core::sync::atomic::{AtomicBool, Ordering};
 
+use eonix_sync_base::{Relax, SpinRelax};
 pub use guard::{SpinGuard, UnlockedSpinGuard};
 
 pub trait SpinContext {
@@ -84,7 +82,7 @@ where
     T: ?Sized,
     R: Relax,
 {
-    pub fn lock_with_context<C>(&self, context: C) -> SpinGuard<T, C, R>
+    pub fn lock_with_context<C>(&self, context: C) -> SpinGuard<'_, T, C, R>
     where
         C: SpinContext,
     {
@@ -100,7 +98,7 @@ where
         )
     }
 
-    pub fn lock(&self) -> SpinGuard<T, DisablePreemption, R> {
+    pub fn lock(&self) -> SpinGuard<'_, T, DisablePreemption, R> {
         self.lock_with_context(DisablePreemption::save())
     }
 

+ 2 - 2
crates/eonix_sync/eonix_sync_rt/src/spin_irq.rs

@@ -12,7 +12,7 @@ pub trait SpinIrq {
     type Context: SpinContext;
     type Relax;
 
-    fn lock_irq(&self) -> SpinGuard<Self::Value, Self::Context, Self::Relax>;
+    fn lock_irq(&self) -> SpinGuard<'_, Self::Value, Self::Context, Self::Relax>;
 }
 
 impl SpinContext for IrqContext {
@@ -50,7 +50,7 @@ where
     type Context = IrqContext;
     type Relax = R;
 
-    fn lock_irq(&self) -> SpinGuard<Self::Value, Self::Context, Self::Relax> {
+    fn lock_irq(&self) -> SpinGuard<'_, Self::Value, Self::Context, Self::Relax> {
         self.lock_with_context(IrqContext::save())
     }
 }

+ 2 - 0
crates/posix_types/src/poll.rs

@@ -1,5 +1,7 @@
 pub const FDSET_LENGTH: usize = 1024 / (8 * size_of::<usize>());
 
+// TODO: Implement syscall pselect
+#[allow(unused)]
 pub struct FDSet {
     fds_bits: [usize; FDSET_LENGTH],
 }

+ 2 - 2
macros/src/lib.rs

@@ -123,7 +123,7 @@ fn define_syscall_impl(attrs: TokenStream, item: TokenStream) -> TokenStream {
                     Box::new_in(
                         async move {
                             eonix_log::println_trace!(
-                                "trace_syscall",
+                                feat: "trace_syscall",
                                 "tid{}: {}({}) => {{",
                                 thd.tid,
                                 #syscall_name_str,
@@ -133,7 +133,7 @@ fn define_syscall_impl(attrs: TokenStream, item: TokenStream) -> TokenStream {
                             let retval = #real_fn(thd, #(#args_call),*).await.into_retval();
 
                             eonix_log::println_trace!(
-                                "trace_syscall",
+                                feat: "trace_syscall",
                                 "}} => {:x?}",
                                 retval,
                             );

+ 3 - 1
src/driver/ahci/slot.rs

@@ -39,6 +39,8 @@ enum SlotState {
     Idle,
     Working,
     Finished,
+    // TODO: Implement AHCI error handling
+    #[allow(unused)]
     Error,
 }
 
@@ -67,7 +69,7 @@ impl CommandList {
             + (size_of::<UnsafeCell<CommandHeader>>() + size_of::<Spin<SlotControl>>()) * 32
     }
 
-    pub fn get(&self, index: usize) -> CommandSlot {
+    pub fn get(&self, index: usize) -> CommandSlot<'_> {
         CommandSlot {
             cmdheader: &self.cmdheaders()[index],
             control: &self.controls()[index],

+ 2 - 0
src/driver/e1000e.rs

@@ -61,6 +61,8 @@ struct E1000eDev {
     tx_tail: Option<u32>,
 
     rx_buffers: Box<[FolioOwned; RX_DESC_SIZE]>,
+    // TODO: Implement E1000e send
+    #[allow(unused)]
     tx_buffers: Box<[Option<FolioOwned>; TX_DESC_SIZE]>,
 }
 

+ 10 - 5
src/driver/serial/io.rs

@@ -1,10 +1,11 @@
-use super::SerialRegister;
 use core::ptr::NonNull;
-use eonix_hal::{fence::memory_barrier, mm::ArchPhysAccess};
-use eonix_mm::address::{PAddr, PhysAccess};
 
 #[cfg(target_arch = "x86_64")]
 use eonix_hal::arch_exported::io::Port8;
+use eonix_hal::mm::ArchPhysAccess;
+use eonix_mm::address::{PAddr, PhysAccess};
+
+use super::SerialRegister;
 
 #[cfg(target_arch = "x86_64")]
 pub struct SerialIO {
@@ -73,10 +74,12 @@ impl SerialIO {
         self.line_status
     }
 
+    #[allow(unused)]
     pub fn modem_status(&self) -> impl SerialRegister {
         self.modem_status
     }
 
+    #[allow(unused)]
     pub fn scratch(&self) -> impl SerialRegister {
         self.scratch
     }
@@ -100,7 +103,7 @@ impl SerialRegister for NonNull<u8> {
         let retval = unsafe { self.as_ptr().read_volatile() };
 
         #[cfg(target_arch = "loongarch64")]
-        memory_barrier();
+        eonix_hal::fence::memory_barrier();
 
         retval
     }
@@ -110,7 +113,7 @@ impl SerialRegister for NonNull<u8> {
         unsafe { self.as_ptr().write_volatile(data) };
 
         #[cfg(target_arch = "loongarch64")]
-        memory_barrier();
+        eonix_hal::fence::memory_barrier();
     }
 }
 
@@ -155,10 +158,12 @@ impl SerialIO {
         unsafe { self.base_addr.add(5) }
     }
 
+    #[allow(unused)]
     pub fn modem_status(&self) -> impl SerialRegister {
         unsafe { self.base_addr.add(6) }
     }
 
+    #[allow(unused)]
     pub fn scratch(&self) -> impl SerialRegister {
         unsafe { self.base_addr.add(7) }
     }

+ 2 - 0
src/fs/procfs.rs

@@ -26,6 +26,8 @@ enum NodeKind {
 
 struct FileInode {
     read: Option<Box<dyn Fn(&mut PageBuffer) -> KResult<()> + Send + Sync>>,
+    // TODO: Implement writes to procfs files
+    #[allow(unused)]
     write: Option<()>,
 }
 

+ 1 - 5
src/fs/tmpfs/file.rs

@@ -177,7 +177,6 @@ impl InodeOps for FileInode {
 }
 
 pub struct DeviceInode {
-    is_block: bool,
     devid: DeviceId,
 }
 
@@ -199,10 +198,7 @@ impl DeviceInode {
                 ctime: now,
                 mtime: now,
             },
-            Self {
-                is_block: mode.format() == Format::BLK,
-                devid,
-            },
+            Self { devid },
         )
     }
 }

+ 1 - 1
src/kernel/constants.rs

@@ -36,7 +36,7 @@ pub const ENOTDIR: u32 = 20;
 pub const EISDIR: u32 = 21;
 pub const EINVAL: u32 = 22;
 pub const ENOTTY: u32 = 25;
-pub const ENOSPC: u32 = 28;
+// pub const ENOSPC: u32 = 28;
 pub const ESPIPE: u32 = 29;
 // pub const EROFS: u32 = 30;
 pub const EPIPE: u32 = 32;

+ 1 - 1
src/kernel/mem/folio.rs

@@ -79,7 +79,7 @@ impl Folio {
         }
     }
 
-    pub fn lock(&self) -> LockedFolio {
+    pub fn lock(&self) -> LockedFolio<'_> {
         // TODO: actually perform the lock...
         LockedFolio(self)
     }

+ 6 - 13
src/kernel/mem/mm_list/page_fault.rs

@@ -1,3 +1,4 @@
+use eonix_hal::extern_symbol_addr;
 use eonix_hal::mm::flush_tlb;
 use eonix_hal::traits::fault::PageFaultErrorCode;
 use eonix_mm::address::{Addr as _, AddrOps as _, VRange};
@@ -24,27 +25,19 @@ impl FixEntry {
         VAddr::from((self.start + self.length) as usize)
     }
 
-    #[allow(dead_code)]
-    fn range(&self) -> VRange {
-        VRange::new(self.start(), self.end())
-    }
-
     fn jump_address(&self) -> VAddr {
         VAddr::from(self.jump_address as usize)
     }
 
     fn entries() -> &'static [FixEntry] {
-        extern "C" {
-            fn FIX_START();
-            fn FIX_END();
-        }
+        let fix_seg_len_bytes = extern_symbol_addr!(FIX_END) - extern_symbol_addr!(FIX_START);
 
         unsafe {
-            // SAFETY: `FIX_START` and `FIX_END` are defined in the
-            //         linker script in `.rodata` section.
+            // SAFETY: `FIX_START` and `FIX_END` are defined in the linker script
+            //         in `.rodata` section.
             core::slice::from_raw_parts(
-                FIX_START as usize as *const FixEntry,
-                (FIX_END as usize - FIX_START as usize) / size_of::<FixEntry>(),
+                extern_symbol_addr!(FIX_START, FixEntry),
+                fix_seg_len_bytes / size_of::<FixEntry>(),
             )
         }
     }

+ 0 - 4
src/kernel/mem/page_alloc/raw_page.rs

@@ -48,10 +48,6 @@ pub struct RawPage {
     shared_data: PageData,
 }
 
-// XXX: introduce Folio and remove this.
-unsafe impl Send for RawPage {}
-unsafe impl Sync for RawPage {}
-
 impl PageFlags {
     pub const LOCKED: u32 = 1 << 1;
     pub const BUDDY: u32 = 1 << 2;

+ 15 - 9
src/kernel/pcie/device.rs

@@ -1,14 +1,17 @@
-use super::{
-    header::{Bar, Command},
-    CommonHeader, Header,
-};
-use crate::kernel::mem::PhysAccess as _;
+use alloc::collections::btree_map::BTreeMap;
+use alloc::sync::Arc;
+use alloc::vec::Vec;
+use core::num::NonZero;
+use core::ops::RangeInclusive;
+
 use align_ext::AlignExt;
-use alloc::{collections::btree_map::BTreeMap, sync::Arc, vec::Vec};
-use core::{num::NonZero, ops::RangeInclusive};
 use eonix_mm::address::{Addr, PAddr, PRange};
 use eonix_sync::Spin;
 
+use super::header::{Bar, Command};
+use super::{CommonHeader, Header};
+use crate::kernel::mem::PhysAccess as _;
+
 pub(super) static PCIE_DEVICES: Spin<BTreeMap<u32, Vec<Arc<PCIDevice>>>> =
     Spin::new(BTreeMap::new());
 
@@ -20,7 +23,7 @@ pub struct PCIDevice<'a> {
     pub device_id: u16,
 }
 
-#[allow(dead_code)]
+#[allow(unused)]
 #[derive(Clone)]
 pub struct SegmentGroup {
     id: usize,
@@ -28,6 +31,7 @@ pub struct SegmentGroup {
     base_address: PAddr,
 }
 
+#[allow(unused)]
 #[derive(Clone)]
 pub struct ConfigSpace {
     pub bus: u8,
@@ -180,10 +184,12 @@ impl PCIDevice<'_> {
         );
     }
 
+    #[allow(unused)]
     pub fn config_space(&self) -> &ConfigSpace {
         &self.config_space
     }
 
+    #[allow(unused)]
     pub fn segment_group(&self) -> &SegmentGroup {
         &self.segment_group
     }
@@ -209,7 +215,7 @@ impl PciMemoryAllocator {
         self.start += size;
 
         eonix_log::println_trace!(
-            "trace_pci",
+            feat: "trace_pci",
             "PciMemoryAllocator: Allocated {} bytes at {:#x}",
             size,
             base

+ 8 - 9
src/kernel/pcie/header.rs

@@ -1,10 +1,9 @@
+use core::marker::PhantomData;
+use core::num::NonZero;
+use core::ops::{BitAnd, BitOr, Deref, Not};
+use core::sync::atomic::{AtomicU16, AtomicU32, Ordering};
+
 use bitflags::bitflags;
-use core::{
-    marker::PhantomData,
-    num::NonZero,
-    ops::{BitAnd, BitOr, Deref, Not},
-    sync::atomic::{AtomicU16, AtomicU32, Ordering},
-};
 use eonix_hal::fence::memory_barrier;
 
 pub trait BitFlag: Sized + Copy {
@@ -215,14 +214,14 @@ where
 }
 
 impl CommonHeader {
-    pub fn command(&self) -> Register<Command> {
+    pub fn command(&self) -> Register<'_, Command> {
         Register {
             register: unsafe { AtomicU16::from_ptr((&raw const self._command) as *mut u16) },
             _phantom: PhantomData,
         }
     }
 
-    pub fn status(&self) -> Register<Status> {
+    pub fn status(&self) -> Register<'_, Status> {
         Register {
             register: unsafe { AtomicU16::from_ptr((&raw const self._status) as *mut u16) },
             _phantom: PhantomData,
@@ -231,7 +230,7 @@ impl CommonHeader {
 }
 
 impl Bars<'_> {
-    pub fn iter(&self) -> impl Iterator<Item = BarsEntry> + '_ {
+    pub fn iter(&self) -> impl Iterator<Item = BarsEntry<'_>> + use<'_> {
         struct BarsIterator<'a> {
             bars: &'a [AtomicU32],
             pos: usize,

+ 2 - 3
src/kernel/pcie/init.rs

@@ -10,6 +10,7 @@ use super::error::PciError;
 use crate::kernel::mem::PhysAccess as _;
 use crate::kernel::pcie::device::PciMemoryAllocator;
 
+#[allow(unused)]
 #[derive(Clone)]
 struct AcpiHandlerImpl;
 
@@ -34,7 +35,6 @@ pub fn init_pcie() -> Result<(), PciError> {
     #[cfg(target_arch = "x86_64")]
     {
         use acpi::{AcpiTables, PciConfigRegions};
-        use eonix_mm::address::PAddr;
 
         let acpi_tables = unsafe {
             // SAFETY: Our impl should be correct.
@@ -69,7 +69,6 @@ pub fn init_pcie() -> Result<(), PciError> {
     #[cfg(any(target_arch = "riscv64", target_arch = "loongarch64"))]
     {
         use eonix_hal::arch_exported::fdt::FDT;
-        use eonix_mm::address::PRange;
 
         use crate::kernel::constants::{EINVAL, EIO, ENOENT};
 
@@ -88,7 +87,7 @@ pub fn init_pcie() -> Result<(), PciError> {
                     let size = u64::from_be_bytes(entry[20..28].try_into().unwrap());
 
                     println_trace!(
-                        "trace_pci",
+                        feat: "trace_pci",
                         "PCIe range: PCI address = {:#x}, CPU address = {:#x}, size = {:#x}",
                         pci_address,
                         cpu_address,

+ 11 - 12
src/kernel/syscall.rs

@@ -1,11 +1,17 @@
-use super::task::ThreadAlloc;
-use crate::kernel::task::Thread;
 use alloc::boxed::Box;
-use core::{future::Future, marker::PhantomData, ops::Deref, pin::Pin};
+use core::future::Future;
+use core::marker::PhantomData;
+use core::ops::Deref;
+use core::pin::Pin;
+
+use eonix_hal::extern_symbol_addr;
 use eonix_mm::address::{Addr, VAddr};
 use eonix_sync::LazyLock;
 use posix_types::ctypes::PtrT;
 
+use super::task::ThreadAlloc;
+use crate::kernel::task::Thread;
+
 pub mod file_rw;
 pub mod mm;
 pub mod net;
@@ -280,12 +286,6 @@ impl<T> core::fmt::Debug for UserMut<T> {
 }
 
 static SYSCALL_HANDLERS: LazyLock<[Option<SyscallHandler>; MAX_SYSCALL_NO]> = LazyLock::new(|| {
-    extern "C" {
-        // SAFETY: `SYSCALL_HANDLERS` is defined in linker script.
-        fn RAW_SYSCALL_HANDLERS();
-        fn RAW_SYSCALL_HANDLERS_SIZE();
-    }
-
     // DO NOT TOUCH THESE FUNCTIONS!!!
     // THEY ARE USED FOR KEEPING THE OBJECTS NOT STRIPPED BY THE LINKER!!!
     file_rw::keep_alive();
@@ -294,15 +294,14 @@ static SYSCALL_HANDLERS: LazyLock<[Option<SyscallHandler>; MAX_SYSCALL_NO]> = La
     procops::keep_alive();
     sysinfo::keep_alive();
 
-    let raw_handlers_addr = RAW_SYSCALL_HANDLERS as *const ();
-    let raw_handlers_size_byte = RAW_SYSCALL_HANDLERS_SIZE as usize;
+    let raw_handlers_size_byte = extern_symbol_addr!(RAW_SYSCALL_HANDLERS_SIZE);
     assert!(raw_handlers_size_byte % size_of::<RawSyscallHandler>() == 0);
 
     let raw_handlers_count = raw_handlers_size_byte / size_of::<RawSyscallHandler>();
 
     let raw_handlers = unsafe {
         core::slice::from_raw_parts(
-            raw_handlers_addr as *const RawSyscallHandler,
+            extern_symbol_addr!(RAW_SYSCALL_HANDLERS, RawSyscallHandler),
             raw_handlers_count,
         )
     };

+ 2 - 1
src/kernel/task.rs

@@ -11,6 +11,7 @@ mod thread;
 mod user_tls;
 
 pub use clone::{do_clone, CloneArgs, CloneFlags};
+use eonix_hal::symbol_addr;
 pub use futex::{futex_wait, futex_wake, parse_futexop, FutexFlags, FutexOp, RobustListHead};
 pub use kernel_stack::KernelStack;
 pub use loader::ProgramLoader;
@@ -185,7 +186,7 @@ where
     trap_ctx.set_user_mode(false);
     trap_ctx.set_interrupt_enabled(true);
     let _ = trap_ctx.set_user_call_frame(
-        execute::<F> as usize,
+        symbol_addr!(execute::<F>),
         Some(sp.addr().get()),
         None,
         &[(&raw mut future) as usize, output.get() as usize],

+ 26 - 28
src/kernel/task/process.rs

@@ -1,34 +1,30 @@
-use super::{
-    process_group::ProcessGroupBuilder, signal::RaiseResult, thread::ThreadBuilder, ProcessGroup,
-    ProcessList, Session, Thread,
-};
-use crate::kernel::constants::{ECHILD, EINTR, EINVAL, EPERM, ESRCH};
-use crate::kernel::task::{CloneArgs, CloneFlags};
-use crate::rcu::call_rcu;
-use crate::{
-    kernel::mem::MMList,
-    prelude::*,
-    rcu::{RCUPointer, RCUReadGuard},
-    sync::CondVar,
-};
-use alloc::{
-    collections::{btree_map::BTreeMap, vec_deque::VecDeque},
-    sync::{Arc, Weak},
-};
+use alloc::collections::btree_map::BTreeMap;
+use alloc::collections::vec_deque::VecDeque;
+use alloc::sync::{Arc, Weak};
 use core::sync::atomic::{AtomicU32, Ordering};
-use eonix_mm::address::VAddr;
+
 use eonix_sync::{
     AsProof as _, AsProofMut as _, Locked, Proof, ProofMut, RwLockReadGuard, SpinGuard,
     UnlockableGuard as _, UnlockedGuard as _,
 };
 use pointers::BorrowedArc;
 use posix_types::constants::{
-    CLD_CONTINUED, CLD_DUMPED, CLD_EXITED, CLD_KILLED, CLD_STOPPED, P_PGID, P_PIDFD,
+    CLD_CONTINUED, CLD_DUMPED, CLD_EXITED, CLD_KILLED, CLD_STOPPED, P_ALL, P_PGID, P_PID, P_PIDFD,
 };
-use posix_types::constants::{P_ALL, P_PID};
 use posix_types::signal::Signal;
 use posix_types::SIGNAL_COREDUMP;
 
+use super::process_group::ProcessGroupBuilder;
+use super::signal::RaiseResult;
+use super::thread::ThreadBuilder;
+use super::{ProcessGroup, ProcessList, Session, Thread};
+use crate::kernel::constants::{ECHILD, EINTR, EINVAL, EPERM, ESRCH};
+use crate::kernel::mem::MMList;
+use crate::kernel::task::{CloneArgs, CloneFlags};
+use crate::prelude::*;
+use crate::rcu::{call_rcu, RCUPointer, RCUReadGuard};
+use crate::sync::CondVar;
+
 pub struct ProcessBuilder {
     mm_list: Option<MMList>,
     exit_signal: Option<Signal>,
@@ -51,8 +47,6 @@ pub struct Process {
 
     pub exit_signal: Option<Signal>,
 
-    pub shm_areas: Spin<BTreeMap<VAddr, usize>>,
-
     /// Parent process
     ///
     /// `parent` must be valid during the whole life of the process.
@@ -256,7 +250,6 @@ impl ProcessBuilder {
             pid: self.pid.expect("should set pid before building"),
             wait_list: WaitList::new(),
             mm_list,
-            shm_areas: Spin::new(BTreeMap::new()),
             exit_signal: self.exit_signal,
             parent: RCUPointer::empty(),
             pgroup: RCUPointer::empty(),
@@ -522,17 +515,17 @@ impl Process {
     }
 
     /// Provide RCU locked (maybe inconsistent) access to the session.
-    pub fn session_rcu(&self) -> RCUReadGuard<'_, BorrowedArc<Session>> {
+    pub fn session_rcu(&self) -> RCUReadGuard<'_, BorrowedArc<'_, Session>> {
         self.session.load().unwrap()
     }
 
     /// Provide RCU locked (maybe inconsistent) access to the process group.
-    pub fn pgroup_rcu(&self) -> RCUReadGuard<'_, BorrowedArc<ProcessGroup>> {
+    pub fn pgroup_rcu(&self) -> RCUReadGuard<'_, BorrowedArc<'_, ProcessGroup>> {
         self.pgroup.load().unwrap()
     }
 
     /// Provide RCU locked (maybe inconsistent) access to the parent process.
-    pub fn parent_rcu(&self) -> Option<RCUReadGuard<'_, BorrowedArc<Process>>> {
+    pub fn parent_rcu(&self) -> Option<RCUReadGuard<'_, BorrowedArc<'_, Process>>> {
         self.parent.load()
     }
 
@@ -569,7 +562,7 @@ impl WaitList {
         self.cv_wait_procs.notify_all();
     }
 
-    pub fn drain_exited(&self) -> DrainExited {
+    pub fn drain_exited(&self) -> DrainExited<'_> {
         DrainExited {
             wait_procs: self.wait_procs.lock(),
         }
@@ -578,7 +571,12 @@ impl WaitList {
     /// # Safety
     /// Locks `ProcessList` and `WaitList` at the same time. When `wait` is called,
     /// releases the lock on `ProcessList` and `WaitList` and waits on `cv_wait_procs`.
-    pub async fn entry(&self, wait_id: WaitId, want_stop: bool, want_continue: bool) -> Entry {
+    pub async fn entry(
+        &self,
+        wait_id: WaitId,
+        want_stop: bool,
+        want_continue: bool,
+    ) -> Entry<'_, '_, '_> {
         Entry {
             process_list: ProcessList::get().read().await,
             wait_procs: self.wait_procs.lock(),

+ 4 - 2
src/kernel/vfs/dentry.rs

@@ -27,6 +27,8 @@ use crate::path::Path;
 use crate::prelude::*;
 use crate::rcu::{rcu_read_lock, RCUNode, RCUPointer, RCUReadGuard};
 
+// TODO: Implement slab reclaim
+#[allow(unused)]
 const D_INVALID: u8 = 0;
 const D_REGULAR: u8 = 1;
 const D_DIRECTORY: u8 = 2;
@@ -159,7 +161,7 @@ impl Dentry {
             && &***self.name() == &***other.name()
     }
 
-    pub fn name(&self) -> RCUReadGuard<BorrowedArc<Arc<[u8]>>> {
+    pub fn name(&self) -> RCUReadGuard<'_, BorrowedArc<'_, Arc<[u8]>>> {
         self.name.load().expect("Dentry has no name")
     }
 
@@ -167,7 +169,7 @@ impl Dentry {
         (***self.name()).clone()
     }
 
-    pub fn parent<'a>(&self) -> RCUReadGuard<'a, BorrowedArc<Dentry>> {
+    pub fn parent<'a>(&self) -> RCUReadGuard<'a, BorrowedArc<'_, Dentry>> {
         self.parent.load().expect("Dentry has no parent")
     }
 

+ 0 - 11
src/kernel/vfs/types/device_id.rs

@@ -10,17 +10,6 @@ impl DeviceId {
     pub const fn new(major: u16, minor: u16) -> Self {
         Self { major, minor }
     }
-
-    pub const fn from_raw(raw: u32) -> Self {
-        Self {
-            major: (raw >> 16) as u16,
-            minor: (raw & 0xFFFF) as u16,
-        }
-    }
-
-    pub const fn to_raw(self) -> u32 {
-        ((self.major as u32) << 16) | (self.minor as u32)
-    }
 }
 
 impl Debug for DeviceId {

+ 3 - 2
src/lib.rs

@@ -38,6 +38,7 @@ use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
 use eonix_hal::arch_exported::bootstrap::shutdown;
 use eonix_hal::context::TaskContext;
 use eonix_hal::processor::{halt, CPU, CPU_COUNT};
+use eonix_hal::symbol_addr;
 use eonix_hal::traits::context::RawTaskContext;
 use eonix_hal::traits::trap::IrqState;
 use eonix_hal::trap::disable_irqs_save;
@@ -136,7 +137,7 @@ fn kernel_init(mut data: eonix_hal::bootstrap::BootStrapData) -> ! {
         bottom
     };
     ctx.set_interrupt_enabled(true);
-    ctx.set_program_counter(standard_main as usize);
+    ctx.set_program_counter(symbol_addr!(standard_main));
     ctx.set_stack_pointer(stack_bottom);
 
     unsafe {
@@ -162,7 +163,7 @@ fn kernel_ap_main(_stack_range: PRange) -> ! {
         bottom
     };
     ctx.set_interrupt_enabled(true);
-    ctx.set_program_counter(standard_main as usize);
+    ctx.set_program_counter(symbol_addr!(standard_main));
     ctx.set_stack_pointer(stack_bottom);
 
     unsafe {

+ 4 - 2
src/path.rs

@@ -1,6 +1,8 @@
-use crate::{kernel::constants::ENOENT, prelude::*};
 use core::fmt::{self, Debug, Formatter};
 
+use crate::kernel::constants::ENOENT;
+use crate::prelude::*;
+
 #[repr(transparent)]
 pub struct Path {
     all: [u8],
@@ -23,7 +25,7 @@ impl Path {
         self.all.starts_with(&['/' as u8])
     }
 
-    pub fn iter(&self) -> PathIterator {
+    pub fn iter(&self) -> PathIterator<'_> {
         PathIterator::new(&self.all)
     }
 }

+ 5 - 6
src/sync/arcswap.rs

@@ -1,9 +1,8 @@
 use alloc::sync::Arc;
-use core::{
-    fmt::{self, Debug, Formatter},
-    ptr::NonNull,
-    sync::atomic::{AtomicPtr, Ordering},
-};
+use core::fmt::{self, Debug, Formatter};
+use core::ptr::NonNull;
+use core::sync::atomic::{AtomicPtr, Ordering};
+
 use pointers::BorrowedArc;
 
 unsafe impl<T> Send for ArcSwap<T> where T: Send + Sync {}
@@ -33,7 +32,7 @@ impl<T> ArcSwap<T> {
         }
     }
 
-    pub fn borrow(&self) -> BorrowedArc<T> {
+    pub fn borrow(&self) -> BorrowedArc<'_, T> {
         unsafe {
             BorrowedArc::from_raw(
                 NonNull::new(self.pointer.load(Ordering::Acquire))