diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a334b16048c3e2c22711c85900db4d450dc60929..6eed3dfb8f85193a40fccd1a9df56b0e7031e197 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,7 +120,7 @@ jobs: run: rustup show - uses: Swatinem/rust-cache@v2 - name: Build dev profile - run: cargo build -Zbuild-std=core,alloc,std,panic_abort --target x86_64-unknown-hermit + run: cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit - name: Download loader uses: dsaltares/fetch-gh-release-asset@1.1.0 with: @@ -134,7 +134,7 @@ jobs: -kernel rusty-loader-x86_64 \ -initrd target/x86_64-unknown-hermit/debug/rusty_demo - name: Build release profile - run: cargo build -Zbuild-std=core,alloc,std,panic_abort --target x86_64-unknown-hermit --release + run: cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit --release - name: Test release profile run: | qemu-system-x86_64 -display none -smp 1 -m 128M -serial stdio \ @@ -143,7 +143,7 @@ jobs: -kernel rusty-loader-x86_64 \ -initrd target/x86_64-unknown-hermit/release/rusty_demo - name: Build minimal profile - run: cargo build -Zbuild-std=core,alloc,std,panic_abort --target x86_64-unknown-hermit --no-default-features --release --package hello_world + run: cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit --no-default-features --release --package hello_world - name: Test minimal profile id: minimal run: | @@ -196,7 +196,7 @@ jobs: run: rustup show - uses: Swatinem/rust-cache@v2 - name: Build dev profile - run: cargo build -Zbuild-std=core,alloc,std,panic_abort --target aarch64-unknown-hermit --package hello_world + run: cargo build -Zbuild-std=std,panic_abort --target aarch64-unknown-hermit --package hello_world - run: rustup toolchain install nightly-2022-08-01 --target aarch64-unknown-none-softfloat --component llvm-tools-preview - name: Build loader run: cargo +nightly-2022-08-01 xtask build --target aarch64 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aaa63feaa78158eaaa43e68f69256492a4cdb135..7f021e1714919b575a5574cea1fa29dfc9d2e8f1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,8 +41,8 @@ build:demo: - if [ -d "libhermit-rs" ]; then rm -rf libhermit-rs; fi - mkdir libhermit-rs - shopt -s dotglob nullglob && mv $HOME/tmp_libhermit-rs/* libhermit-rs/. - - cargo build -Zbuild-std=core,alloc,std,panic_abort --target x86_64-unknown-hermit --package rusty_demo - - cargo build -Zbuild-std=core,alloc,std,panic_abort --target x86_64-unknown-hermit --package rusty_demo --release + - cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit --package rusty_demo + - cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit --package rusty_demo --release artifacts: paths: - rusty-hermit/target/x86_64-unknown-hermit/debug/rusty_demo diff --git a/.rustfmt.toml b/.rustfmt.toml deleted file mode 100644 index 218e203215e949dd53a7fef74c0bc306914d9e39..0000000000000000000000000000000000000000 --- a/.rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -hard_tabs = true diff --git a/Dockerfile b/Dockerfile index 477e6a4bcf05e14e5ff82c8680f8d7e3270c5b79..f2f359ca9cddd2b9d1b5e73c424fdb12287c9230 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,13 +12,13 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUN set -eux; \ dpkgArch="$(dpkg --print-architecture)"; \ case $dpkgArch in \ - amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='3dc5ef50861ee18657f9db2eeb7392f9c2a6c95c90ab41e45ab4ca71476b4338' ;; \ - armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='67777ac3bc17277102f2ed73fd5f14c51f4ca5963adadf7f174adf4ebc38747b' ;; \ - arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='32a1532f7cef072a667bac53f1a5542c99666c4071af0c9549795bbdb2069ec1' ;; \ - i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e50d1deb99048bc5782a0200aa33e4eea70747d49dffdc9d06812fd22a372515' ;; \ - *) echo >&2 "unsupported architecture: $dpkgArch"; exit 1 ;; \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='48c5ecfd1409da93164af20cf4ac2c6f00688b15eb6ba65047f654060c844d85' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e189948e396d47254103a49c987e7fb0e5dd8e34b200aa4481ecc4b8e41fb929' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='0e0be29c560ad958ba52fcf06b3ea04435cb3cd674fbe11ce7d954093b9504fd' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ esac; \ - url="https://static.rust-lang.org/rustup/archive/1.24.3/$rustArch/rustup-init"; \ + url="https://static.rust-lang.org/rustup/archive/1.25.1/${rustArch}/rustup-init"; \ wget "$url"; \ echo "$rustupSha256 *rustup-init" | sha256sum -c -; \ chmod +x rustup-init; \ diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000000000000000000000000000000000000..81780016f47f063fe7c76d72feeef866c93c2c0f --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +group_imports = "StdExternalCrate" +hard_tabs = true +imports_granularity = "Module" diff --git a/src/arch/aarch64/kernel/mod.rs b/src/arch/aarch64/kernel/mod.rs index 1cd98dd60e20d6db24501d5f1820d51022c26704..9461bbeee89fe1f879259cb4ac9aa4a0a1a9f3b3 100644 --- a/src/arch/aarch64/kernel/mod.rs +++ b/src/arch/aarch64/kernel/mod.rs @@ -9,9 +9,6 @@ pub mod stubs; pub mod switch; pub mod systemtime; -pub use crate::arch::aarch64::kernel::stubs::*; -pub use crate::arch::aarch64::kernel::systemtime::get_boot_time; - use core::arch::{asm, global_asm}; use core::ptr; @@ -19,6 +16,8 @@ use hermit_entry::boot_info::{BootInfo, PlatformInfo, RawBootInfo}; use crate::arch::aarch64::kernel::percore::*; use crate::arch::aarch64::kernel::serial::SerialPort; +pub use crate::arch::aarch64::kernel::stubs::*; +pub use crate::arch::aarch64::kernel::systemtime::get_boot_time; use crate::arch::aarch64::mm::{PhysAddr, VirtAddr}; use crate::config::*; use crate::env; diff --git a/src/arch/aarch64/kernel/pci.rs b/src/arch/aarch64/kernel/pci.rs index 1b4410eb76c21d6913374f666f36eddd09de5023..6456548fb6d89202c98e4715c234833d004765c8 100644 --- a/src/arch/aarch64/kernel/pci.rs +++ b/src/arch/aarch64/kernel/pci.rs @@ -1,7 +1,8 @@ -use crate::synch::spinlock::SpinlockIrqSave; use alloc::rc::Rc; use core::cell::RefCell; +use crate::synch::spinlock::SpinlockIrqSave; + // Currently, onbly a dummy implementation pub struct VirtioNetDriver; diff --git a/src/arch/aarch64/kernel/percore.rs b/src/arch/aarch64/kernel/percore.rs index bdab106f83565487da1201fefe4feef2fe68a78c..a7b3acad26568881a6411e11765fe69343b251a0 100644 --- a/src/arch/aarch64/kernel/percore.rs +++ b/src/arch/aarch64/kernel/percore.rs @@ -1,6 +1,7 @@ -use crate::scheduler::{CoreId, PerCoreScheduler}; use core::ptr; +use crate::scheduler::{CoreId, PerCoreScheduler}; + #[no_mangle] pub static mut PERCORE: PerCoreVariables = PerCoreVariables::new(0); diff --git a/src/arch/aarch64/kernel/scheduler.rs b/src/arch/aarch64/kernel/scheduler.rs index 2ffd284f46f26887f03571c67c089265bf831218..25f1a70d024cd576ede1f498231d58a82494272c 100644 --- a/src/arch/aarch64/kernel/scheduler.rs +++ b/src/arch/aarch64/kernel/scheduler.rs @@ -1,15 +1,15 @@ //! Architecture dependent interface to initialize a task +use alloc::rc::Rc; +use core::cell::RefCell; +use core::{mem, ptr}; + use crate::arch::aarch64::kernel::percore::*; use crate::arch::aarch64::kernel::processor; use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize, PageTableEntryFlags}; use crate::arch::aarch64::mm::{PhysAddr, VirtAddr}; -use crate::env; use crate::scheduler::task::{Task, TaskFrame}; -use crate::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE}; -use alloc::rc::Rc; -use core::cell::RefCell; -use core::{mem, ptr}; +use crate::{env, DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE}; extern "C" { static tls_start: u8; diff --git a/src/arch/aarch64/kernel/start.rs b/src/arch/aarch64/kernel/start.rs index 9f38396557a8488c154c07a5b09b7121f32d75da..0de42f8d7677d475102a478fc73c23d0908b6c51 100644 --- a/src/arch/aarch64/kernel/start.rs +++ b/src/arch/aarch64/kernel/start.rs @@ -1,14 +1,11 @@ use core::arch::asm; -use hermit_entry::{ - boot_info::{BootInfo, RawBootInfo}, - Entry, -}; +use hermit_entry::boot_info::{BootInfo, RawBootInfo}; +use hermit_entry::Entry; +use crate::arch::aarch64::kernel::scheduler::TaskStacks; use crate::arch::aarch64::kernel::serial::SerialPort; -use crate::arch::aarch64::kernel::{ - get_processor_count, scheduler::TaskStacks, BOOT_INFO, RAW_BOOT_INFO, -}; +use crate::arch::aarch64::kernel::{get_processor_count, BOOT_INFO, RAW_BOOT_INFO}; use crate::KERNEL_STACK_SIZE; extern "C" { diff --git a/src/arch/aarch64/mm/mod.rs b/src/arch/aarch64/mm/mod.rs index c1dfc5a7197198e827eaa759c809cca3c73e5ee6..47f2d71cdcb6b7a1b5d9546e0c21dd246b714bbe 100644 --- a/src/arch/aarch64/mm/mod.rs +++ b/src/arch/aarch64/mm/mod.rs @@ -2,8 +2,7 @@ pub mod paging; pub mod physicalmem; pub mod virtualmem; -pub use aarch64::paging::PhysAddr; -pub use aarch64::paging::VirtAddr; +pub use aarch64::paging::{PhysAddr, VirtAddr}; pub use self::physicalmem::init_page_tables; diff --git a/src/arch/aarch64/mm/paging.rs b/src/arch/aarch64/mm/paging.rs index 753c5791a6f0fe37d223bb1083cdf19b515b8cc1..4fc0ae0c3984b92c23bb1a6e864764efac541875 100644 --- a/src/arch/aarch64/mm/paging.rs +++ b/src/arch/aarch64/mm/paging.rs @@ -3,16 +3,11 @@ use core::marker::PhantomData; use core::{fmt, mem, ptr, usize}; use crate::arch::aarch64::kernel::percore::*; -use crate::arch::aarch64::kernel::processor; use crate::arch::aarch64::kernel::{ - get_base_address, get_boot_info_address, get_image_size, get_ram_address, is_uhyve, + get_base_address, get_boot_info_address, get_image_size, get_ram_address, is_uhyve, processor, }; -use crate::arch::aarch64::mm::physicalmem; -use crate::arch::aarch64::mm::virtualmem; -use crate::arch::aarch64::mm::{PhysAddr, VirtAddr}; -use crate::mm; -use crate::scheduler; -use crate::KERNEL_STACK_SIZE; +use crate::arch::aarch64::mm::{physicalmem, virtualmem, PhysAddr, VirtAddr}; +use crate::{mm, scheduler, KERNEL_STACK_SIZE}; /// Pointer to the root page table (called "Level 0" in ARM terminology). /// Setting the upper bits to zero tells the MMU to use TTBR0 for the base address for the first table. diff --git a/src/arch/mod.rs b/src/arch/mod.rs index ba2ad4a6667310f7caf3f806693dde9da825568d..4d724ff28fdfbf6a159533ca1f23c6d24381b1eb 100644 --- a/src/arch/mod.rs +++ b/src/arch/mod.rs @@ -7,41 +7,28 @@ pub mod x86_64; // Export our platform-specific modules. #[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::*; - -#[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::kernel::stubs::{set_oneshot_timer, wakeup_core}; - +pub use crate::arch::aarch64::kernel::irq; #[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::kernel::{ - application_processor_init, boot_application_processors, boot_processor_init, - get_processor_count, message_output_init, output_message_buf, output_message_byte, -}; - +pub use crate::arch::aarch64::kernel::percore; #[cfg(target_arch = "aarch64")] use crate::arch::aarch64::kernel::percore::core_scheduler; - #[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::kernel::percore; - +pub use crate::arch::aarch64::kernel::processor; #[cfg(target_arch = "aarch64")] pub use crate::arch::aarch64::kernel::scheduler; - #[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::kernel::processor; - +pub use crate::arch::aarch64::kernel::stubs::{set_oneshot_timer, wakeup_core}; #[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::kernel::irq; - +pub use crate::arch::aarch64::kernel::switch; #[cfg(target_arch = "aarch64")] pub use crate::arch::aarch64::kernel::systemtime::get_boot_time; - #[cfg(target_arch = "aarch64")] -pub use crate::arch::aarch64::kernel::switch; - -#[cfg(target_arch = "x86_64")] -pub use crate::arch::x86_64::*; - +pub use crate::arch::aarch64::kernel::{ + application_processor_init, boot_application_processors, boot_processor_init, + get_processor_count, message_output_init, output_message_buf, output_message_byte, +}; +#[cfg(target_arch = "aarch64")] +pub use crate::arch::aarch64::*; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::apic::{set_oneshot_timer, wakeup_core}; #[cfg(all(target_arch = "x86_64", target_os = "none", feature = "smp"))] @@ -66,6 +53,8 @@ pub use crate::arch::x86_64::kernel::{boot_application_processors, boot_processo pub use crate::arch::x86_64::kernel::{ get_processor_count, message_output_init, output_message_buf, output_message_byte, }; +#[cfg(target_arch = "x86_64")] +pub use crate::arch::x86_64::*; pub fn init_drivers() { // Initialize PCI Drivers if on x86_64 diff --git a/src/arch/x86_64/kernel/acpi.rs b/src/arch/x86_64/kernel/acpi.rs index e9cdc4e359fd7b38e0841aceac6f944cf1a5d9cf..ebd95c194b708d21154efe9cc17db5e868c29e50 100644 --- a/src/arch/x86_64/kernel/acpi.rs +++ b/src/arch/x86_64/kernel/acpi.rs @@ -1,14 +1,14 @@ +use core::convert::Infallible; +use core::{mem, ptr, slice, str}; + use x86_64::structures::paging::PhysFrame; use crate::arch::x86_64::kernel::processor; use crate::arch::x86_64::mm::paging::{ BasePageSize, PageSize, PageTableEntryFlags, PageTableEntryFlagsExt, }; -use crate::arch::x86_64::mm::{paging, virtualmem}; -use crate::arch::x86_64::mm::{PhysAddr, VirtAddr}; +use crate::arch::x86_64::mm::{paging, virtualmem, PhysAddr, VirtAddr}; use crate::x86::io::*; -use core::convert::Infallible; -use core::{mem, ptr, slice, str}; /// Memory at this physical address is supposed to contain a pointer to the Extended BIOS Data Area (EBDA). const EBDA_PTR_LOCATION: PhysAddr = PhysAddr(0x0000_040E); diff --git a/src/arch/x86_64/kernel/apic.rs b/src/arch/x86_64/kernel/apic.rs index 35040f95409dd0b89a8aad085196e4d103764da7..bde3b1c4462ce7ca82028b7ea8c9be4f52ab0e6d 100644 --- a/src/arch/x86_64/kernel/apic.rs +++ b/src/arch/x86_64/kernel/apic.rs @@ -1,4 +1,17 @@ -use crate::arch; +use alloc::boxed::Box; +use alloc::vec::Vec; +#[cfg(any(feature = "pci", feature = "smp"))] +use core::arch::x86_64::_mm_mfence; +use core::hint::spin_loop; +#[cfg(feature = "smp")] +use core::ptr; +use core::sync::atomic::Ordering; +use core::{cmp, fmt, mem, u32}; + +use arch::x86_64::kernel::percore::*; +use arch::x86_64::kernel::{idt, irq, processor}; +use crossbeam_utils::CachePadded; + #[cfg(feature = "acpi")] use crate::arch::x86_64::kernel::acpi; use crate::arch::x86_64::kernel::irq::IrqStatistics; @@ -6,28 +19,14 @@ use crate::arch::x86_64::kernel::{CURRENT_STACK_ADDRESS, IRQ_COUNTERS}; use crate::arch::x86_64::mm::paging::{ BasePageSize, PageSize, PageTableEntryFlags, PageTableEntryFlagsExt, }; -use crate::arch::x86_64::mm::{paging, virtualmem}; -use crate::arch::x86_64::mm::{PhysAddr, VirtAddr}; +use crate::arch::x86_64::mm::{paging, virtualmem, PhysAddr, VirtAddr}; use crate::collections::irqsave; use crate::config::*; -use crate::env; -use crate::mm; -use crate::scheduler; use crate::scheduler::CoreId; #[cfg(feature = "smp")] use crate::x86::controlregs::*; use crate::x86::msr::*; -use alloc::boxed::Box; -use alloc::vec::Vec; -use arch::x86_64::kernel::{idt, irq, percore::*, processor}; -#[cfg(any(feature = "pci", feature = "smp"))] -use core::arch::x86_64::_mm_mfence; -use core::hint::spin_loop; -#[cfg(feature = "smp")] -use core::ptr; -use core::sync::atomic::Ordering; -use core::{cmp, fmt, mem, u32}; -use crossbeam_utils::CachePadded; +use crate::{arch, env, mm, scheduler}; const MP_FLT_SIGNATURE: u32 = 0x5f504d5f; const MP_CONFIG_SIGNATURE: u32 = 0x504d4350; diff --git a/src/arch/x86_64/kernel/fuse.rs b/src/arch/x86_64/kernel/fuse.rs index 9f3ae3a1c3f54f64441802519e6d8d079bc2cf44..94a934bd834c9db6366d43f76d962f71c8b63b43 100644 --- a/src/arch/x86_64/kernel/fuse.rs +++ b/src/arch/x86_64/kernel/fuse.rs @@ -1,9 +1,10 @@ -use crate::arch::kernel::pci::get_filesystem_driver; -use crate::syscalls::fs::{FileError, FilePerms, PosixFile, PosixFileSystem, SeekWhence}; use alloc::boxed::Box; use alloc::vec::Vec; use core::{fmt, u32, u8}; +use crate::arch::kernel::pci::get_filesystem_driver; +use crate::syscalls::fs::{FileError, FilePerms, PosixFile, PosixFileSystem, SeekWhence}; + // response out layout eg @ https://github.com/zargony/fuse-rs/blob/bf6d1cf03f3277e35b580f3c7b9999255d72ecf3/src/ll/request.rs#L44 // op in/out sizes/layout: https://github.com/hanwen/go-fuse/blob/204b45dba899dfa147235c255908236d5fde2d32/fuse/opcode.go#L439 // possible responses for command: qemu/tools/virtiofsd/fuse_lowlevel.h diff --git a/src/arch/x86_64/kernel/gdt.rs b/src/arch/x86_64/kernel/gdt.rs index 5f8425800eb131947f6743472daaa7143d186919..93079a26a403366932adc88e390e859feb873d52 100644 --- a/src/arch/x86_64/kernel/gdt.rs +++ b/src/arch/x86_64/kernel/gdt.rs @@ -1,3 +1,9 @@ +use alloc::boxed::Box; +use core::mem; +use core::sync::atomic::Ordering; + +use super::scheduler::TaskStacks; +use super::CURRENT_STACK_ADDRESS; use crate::arch::x86_64::kernel::percore::*; use crate::config::*; use crate::x86::bits64::segmentation::*; @@ -6,12 +12,6 @@ use crate::x86::dtables::{self, DescriptorTablePointer}; use crate::x86::segmentation::*; use crate::x86::task::*; use crate::x86::Ring; -use alloc::boxed::Box; -use core::mem; -use core::sync::atomic::Ordering; - -use super::scheduler::TaskStacks; -use super::CURRENT_STACK_ADDRESS; pub const GDT_NULL: u16 = 0; pub const GDT_KERNEL_CODE: u16 = 1; diff --git a/src/arch/x86_64/kernel/idt.rs b/src/arch/x86_64/kernel/idt.rs index b8470851a3eac9a1fdabf1564ad825bc64e24b76..75c904d164d81b461fb815f81d1c3bfba221f601 100644 --- a/src/arch/x86_64/kernel/idt.rs +++ b/src/arch/x86_64/kernel/idt.rs @@ -1,9 +1,10 @@ +use core::sync::atomic::{AtomicBool, Ordering}; + use crate::arch::x86_64::kernel::gdt; use crate::x86::bits64::paging::VAddr; use crate::x86::dtables::{self, DescriptorTablePointer}; use crate::x86::segmentation::{SegmentSelector, SystemDescriptorTypes64}; use crate::x86::Ring; -use core::sync::atomic::{AtomicBool, Ordering}; /// An interrupt gate descriptor. /// diff --git a/src/arch/x86_64/kernel/irq.rs b/src/arch/x86_64/kernel/irq.rs index 231f20fad11d3f3bc410b02db605dcf6f25910e2..dd0e4a30ad9b9ba054cd616cbc431133e3f9848f 100644 --- a/src/arch/x86_64/kernel/irq.rs +++ b/src/arch/x86_64/kernel/irq.rs @@ -1,19 +1,17 @@ -use crate::arch::x86_64::kernel::apic; -use crate::arch::x86_64::kernel::idt; -use crate::arch::x86_64::kernel::percore::*; -use crate::arch::x86_64::kernel::processor; -use crate::scheduler; -use crate::synch::spinlock::SpinlockIrqSave; - -use crate::alloc::string::ToString; use alloc::collections::BTreeMap; use alloc::string::String; use core::arch::asm; use core::fmt; + use x86::bits64::rflags::{self, RFlags}; -use x86::controlregs; -use x86::irq; use x86::irq::PageFaultError; +use x86::{controlregs, irq}; + +use crate::alloc::string::ToString; +use crate::arch::x86_64::kernel::percore::*; +use crate::arch::x86_64::kernel::{apic, idt, processor}; +use crate::scheduler; +use crate::synch::spinlock::SpinlockIrqSave; static IRQ_NAMES: SpinlockIrqSave<BTreeMap<u32, String>> = SpinlockIrqSave::new(BTreeMap::new()); diff --git a/src/arch/x86_64/kernel/mmio.rs b/src/arch/x86_64/kernel/mmio.rs index 0f66ccfbaf74c5069c3bce14d7150c5d5152bb6d..4038b06926598284dd7f56bd2ab1d3dc05118ce1 100644 --- a/src/arch/x86_64/kernel/mmio.rs +++ b/src/arch/x86_64/kernel/mmio.rs @@ -1,17 +1,16 @@ -use crate::collections::irqsave; +use alloc::vec::Vec; +use core::str; -use crate::arch::x86_64::mm::paging; use crate::arch::x86_64::mm::paging::{ BasePageSize, PageSize, PageTableEntryFlags, PageTableEntryFlagsExt, }; -use crate::arch::x86_64::mm::PhysAddr; +use crate::arch::x86_64::mm::{paging, PhysAddr}; +use crate::collections::irqsave; use crate::drivers::net::virtio_net::VirtioNetDriver; use crate::drivers::net::NetworkInterface; use crate::drivers::virtio::transport::mmio as mmio_virtio; use crate::drivers::virtio::transport::mmio::{DevId, MmioRegisterLayout, VirtioDriver}; use crate::synch::spinlock::SpinlockIrqSave; -use alloc::vec::Vec; -use core::str; pub const MAGIC_VALUE: u32 = 0x74726976; diff --git a/src/arch/x86_64/kernel/pci.rs b/src/arch/x86_64/kernel/pci.rs index a6878c83130322619c48a2c6c30098b909098caa..db8606d8efdff3e526f6226ff4fc1cad4f20ad5f 100644 --- a/src/arch/x86_64/kernel/pci.rs +++ b/src/arch/x86_64/kernel/pci.rs @@ -1,3 +1,6 @@ +use alloc::vec::Vec; +use core::{fmt, u32, u8}; + use num_derive::{FromPrimitive, ToPrimitive}; use crate::arch::x86_64::mm::{PhysAddr, VirtAddr}; @@ -10,8 +13,6 @@ use crate::drivers::virtio::transport::pci as pci_virtio; use crate::drivers::virtio::transport::pci::VirtioDriver; use crate::synch::spinlock::SpinlockIrqSave; use crate::x86::io::*; -use alloc::vec::Vec; -use core::{fmt, u32, u8}; // TODO: should these be pub? currently needed since used in virtio.rs maybe use getter methods to be more flexible. pub const PCI_MAX_BUS_NUMBER: u8 = 32; diff --git a/src/arch/x86_64/kernel/percore.rs b/src/arch/x86_64/kernel/percore.rs index 21f111e1ec0538a88678f223bd13fcae65401d62..a817f888b53944e9671b092beb480d42bf8e2960 100644 --- a/src/arch/x86_64/kernel/percore.rs +++ b/src/arch/x86_64/kernel/percore.rs @@ -1,12 +1,13 @@ +use core::arch::asm; +use core::sync::atomic::{AtomicU64, Ordering}; +use core::{mem, ptr}; + +use crossbeam_utils::CachePadded; + use crate::arch::x86_64::kernel::irq::IrqStatistics; use crate::scheduler::{CoreId, PerCoreScheduler}; use crate::x86::bits64::task::TaskStateSegment; use crate::x86::msr::*; -use core::arch::asm; -use core::mem; -use core::ptr; -use core::sync::atomic::{AtomicU64, Ordering}; -use crossbeam_utils::CachePadded; pub static mut PERCORE: PerCoreVariables = CachePadded::new(PerCoreInnerVariables::new(0)); diff --git a/src/arch/x86_64/kernel/processor.rs b/src/arch/x86_64/kernel/processor.rs index e44ce3804442853f0b24c5bf42152d4d7b7d3930..098e87d14f21b3dae56d10190ddafbecf4f413bb 100644 --- a/src/arch/x86_64/kernel/processor.rs +++ b/src/arch/x86_64/kernel/processor.rs @@ -1,12 +1,5 @@ #![allow(dead_code)] -#[cfg(feature = "acpi")] -use crate::arch::x86_64::kernel::acpi; -use crate::arch::x86_64::kernel::{boot_info, idt, irq, pic, pit}; -use crate::env; -use crate::x86::controlregs::*; -use crate::x86::cpuid::*; -use crate::x86::msr::*; use core::arch::asm; use core::arch::x86_64::{ __rdtscp, _fxrstor, _fxsave, _mm_lfence, _rdrand32_step, _rdrand64_step, _rdtsc, _xrstor, @@ -16,10 +9,19 @@ use core::convert::Infallible; use core::hint::spin_loop; use core::num::NonZeroU32; use core::{fmt, u32}; + use hermit_entry::boot_info::PlatformInfo; use qemu_exit::QEMUExit; use x86::bits64::segmentation; +#[cfg(feature = "acpi")] +use crate::arch::x86_64::kernel::acpi; +use crate::arch::x86_64::kernel::{boot_info, idt, irq, pic, pit}; +use crate::env; +use crate::x86::controlregs::*; +use crate::x86::cpuid::*; +use crate::x86::msr::*; + const IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP: u64 = 1 << 16; const IA32_MISC_ENABLE_SPEEDSTEP_LOCK: u64 = 1 << 20; const IA32_MISC_ENABLE_TURBO_DISABLE: u64 = 1 << 38; diff --git a/src/arch/x86_64/kernel/scheduler.rs b/src/arch/x86_64/kernel/scheduler.rs index 6559214c40687ca75b6b212598bad5d631e7d101..49c99f6d8c60a859743821148b5422f50b3631fb 100644 --- a/src/arch/x86_64/kernel/scheduler.rs +++ b/src/arch/x86_64/kernel/scheduler.rs @@ -1,12 +1,11 @@ //! Architecture dependent interface to initialize a task use alloc::boxed::Box; -use core::{arch::asm, mem, ptr, slice}; +use core::arch::asm; +use core::{mem, ptr, slice}; -use crate::arch::x86_64::kernel::apic; -use crate::arch::x86_64::kernel::idt; -use crate::arch::x86_64::kernel::irq; use crate::arch::x86_64::kernel::percore::*; +use crate::arch::x86_64::kernel::{apic, idt, irq}; use crate::arch::x86_64::mm::paging::{ BasePageSize, PageSize, PageTableEntryFlags, PageTableEntryFlagsExt, }; diff --git a/src/arch/x86_64/kernel/serial.rs b/src/arch/x86_64/kernel/serial.rs index 6eaacf42f47e9af8a2b0ec958a19caad72199ced..4ec9e2d47769e68d17d296647fbe8e85e6ab78b0 100644 --- a/src/arch/x86_64/kernel/serial.rs +++ b/src/arch/x86_64/kernel/serial.rs @@ -1,6 +1,7 @@ +use core::hint::spin_loop; + use crate::env; use crate::x86::io::*; -use core::hint::spin_loop; const UART_TX: u16 = 0; const UART_IER: u16 = 1; diff --git a/src/arch/x86_64/kernel/start.rs b/src/arch/x86_64/kernel/start.rs index 99aeb7d0fd41bbaa86fe8d9aacc385612510d1dc..e96cc4824b74023435e0467d1371193e51b49d0a 100644 --- a/src/arch/x86_64/kernel/start.rs +++ b/src/arch/x86_64/kernel/start.rs @@ -1,11 +1,11 @@ use core::arch::asm; -use hermit_entry::{boot_info::RawBootInfo, Entry}; +use hermit_entry::boot_info::RawBootInfo; +use hermit_entry::Entry; -use crate::{ - kernel::{pre_init, scheduler::TaskStacks}, - KERNEL_STACK_SIZE, -}; +use crate::kernel::pre_init; +use crate::kernel::scheduler::TaskStacks; +use crate::KERNEL_STACK_SIZE; #[no_mangle] #[naked] diff --git a/src/arch/x86_64/kernel/switch.rs b/src/arch/x86_64/kernel/switch.rs index 6a39bf15c5c8db0fafcfc2c501361d575ea2869c..69ce1c5817f8049bc826fd73cbec0cd92796433a 100644 --- a/src/arch/x86_64/kernel/switch.rs +++ b/src/arch/x86_64/kernel/switch.rs @@ -1,7 +1,7 @@ -use core::{arch::asm, mem, ptr}; +use core::arch::asm; +use core::{mem, ptr}; -use crate::percore; -use crate::set_current_kernel_stack; +use crate::{percore, set_current_kernel_stack}; #[cfg(feature = "fsgsbase")] macro_rules! push_fs { diff --git a/src/arch/x86_64/kernel/systemtime.rs b/src/arch/x86_64/kernel/systemtime.rs index a47f08ff9ecae928ae406c00353515eb0b0994f3..9a95809e38bc9015c184cd20583c14674dc9ee37 100644 --- a/src/arch/x86_64/kernel/systemtime.rs +++ b/src/arch/x86_64/kernel/systemtime.rs @@ -1,12 +1,12 @@ -use crate::arch::x86_64::kernel::boot_info; -use crate::arch::x86_64::kernel::irq; -use crate::arch::x86_64::kernel::processor; use core::hint::spin_loop; use core::num::NonZeroU64; + use hermit_entry::boot_info::PlatformInfo; use time::OffsetDateTime; use x86::io::*; +use crate::arch::x86_64::kernel::{boot_info, irq, processor}; + const CMOS_COMMAND_PORT: u16 = 0x70; const CMOS_DATA_PORT: u16 = 0x71; diff --git a/src/arch/x86_64/mm/mod.rs b/src/arch/x86_64/mm/mod.rs index 81e25c21ab44f638b27735c7d861509b7e9d9a45..fe850b270e682961a65ad380ccfcc9e2ca8963e1 100644 --- a/src/arch/x86_64/mm/mod.rs +++ b/src/arch/x86_64/mm/mod.rs @@ -2,11 +2,11 @@ pub mod paging; pub mod physicalmem; pub mod virtualmem; -pub use self::paging::init_page_tables; use core::slice; -pub use x86::bits64::paging::PAddr as PhysAddr; -pub use x86::bits64::paging::VAddr as VirtAddr; +pub use x86::bits64::paging::{PAddr as PhysAddr, VAddr as VirtAddr}; + +pub use self::paging::init_page_tables; /// Memory translation, allocation and deallocation for MultibootInformation struct MultibootMemory; diff --git a/src/arch/x86_64/mm/paging.rs b/src/arch/x86_64/mm/paging.rs index 69f46cae3d83f94228192f2d6e96ab47c974f720..cde5fa7ed754d8d7745d3d5ae459b07330279768 100644 --- a/src/arch/x86_64/mm/paging.rs +++ b/src/arch/x86_64/mm/paging.rs @@ -3,16 +3,13 @@ use core::ptr; use x86_64::instructions::tlb; use x86_64::structures::paging::mapper::UnmapError; +pub use x86_64::structures::paging::PageTableFlags as PageTableEntryFlags; use x86_64::structures::paging::{ Mapper, Page, PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, }; -use crate::arch::x86_64::mm::physicalmem; -use crate::arch::x86_64::mm::{PhysAddr, VirtAddr}; -use crate::env; -use crate::mm; - -pub use x86_64::structures::paging::PageTableFlags as PageTableEntryFlags; +use crate::arch::x86_64::mm::{physicalmem, PhysAddr, VirtAddr}; +use crate::{env, mm}; pub trait PageTableEntryFlagsExt { fn device(&mut self) -> &mut Self; @@ -53,10 +50,9 @@ impl PageTableEntryFlagsExt for PageTableEntryFlags { } } -pub use x86_64::structures::paging::PageSize; -pub use x86_64::structures::paging::Size1GiB as HugePageSize; -pub use x86_64::structures::paging::Size2MiB as LargePageSize; -pub use x86_64::structures::paging::Size4KiB as BasePageSize; +pub use x86_64::structures::paging::{ + PageSize, Size1GiB as HugePageSize, Size2MiB as LargePageSize, Size4KiB as BasePageSize, +}; unsafe fn recursive_page_table() -> RecursivePageTable<'static> { let level_4_table_addr = 0xFFFF_FFFF_FFFF_F000; @@ -238,11 +234,8 @@ pub fn init_page_tables() { #[allow(dead_code)] unsafe fn disect(virt_addr: x86_64::VirtAddr) { - use x86_64::structures::paging::{ - mapper::{MappedFrame, TranslateResult}, - Translate, - }; - use x86_64::structures::paging::{Size1GiB, Size4KiB}; + use x86_64::structures::paging::mapper::{MappedFrame, TranslateResult}; + use x86_64::structures::paging::{Size1GiB, Size4KiB, Translate}; let recursive_page_table = unsafe { recursive_page_table() }; diff --git a/src/arch/x86_64/mm/physicalmem.rs b/src/arch/x86_64/mm/physicalmem.rs index 488d10d421e8c30fd22e690373adb5ec63469a27..10a19ce34207bce5fe5354b5e7f6bd3df5e3ae00 100644 --- a/src/arch/x86_64/mm/physicalmem.rs +++ b/src/arch/x86_64/mm/physicalmem.rs @@ -1,12 +1,12 @@ -use ::x86_64::structures::paging::{FrameAllocator, PhysFrame}; use core::alloc::AllocError; use core::sync::atomic::{AtomicUsize, Ordering}; + +use ::x86_64::structures::paging::{FrameAllocator, PhysFrame}; use multiboot::information::{MemoryType, Multiboot}; use crate::arch::x86_64::kernel::{get_limit, get_mbinfo}; use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize}; -use crate::arch::x86_64::mm::MEM; -use crate::arch::x86_64::mm::{PhysAddr, VirtAddr}; +use crate::arch::x86_64::mm::{PhysAddr, VirtAddr, MEM}; use crate::mm; use crate::mm::freelist::{FreeList, FreeListEntry}; use crate::synch::spinlock::*; diff --git a/src/config.rs b/src/config.rs index e62b7ed0142eca9350008928090846a1774ad327..d10ba3f906dec47295cada1aabd1cd170380d407 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,6 +15,7 @@ pub(crate) const DEFAULT_KEEP_ALIVE_INTERVAL: u64 = 75000; pub(crate) const HW_DESTRUCTIVE_INTERFERENCE_SIZE: usize = { use core::ptr; + use crossbeam_utils::CachePadded; let array = [CachePadded::new(0_u8); 2]; diff --git a/src/console.rs b/src/console.rs index 25f1d0f5c592ccf9fa8a3d2d0e4250b21218eb9b..3d06804954049cf382455a99d47237a620075d95 100644 --- a/src/console.rs +++ b/src/console.rs @@ -1,6 +1,7 @@ +use core::fmt; + use crate::arch; use crate::synch::spinlock::SpinlockIrqSave; -use core::fmt; pub struct Console(()); diff --git a/src/drivers/mod.rs b/src/drivers/mod.rs index 340a2d0ffb0204c7c3b174a31f0c310ac514eac8..099cb8d74257f7c23fafb5d6acb8d97f31c9d724 100644 --- a/src/drivers/mod.rs +++ b/src/drivers/mod.rs @@ -11,10 +11,11 @@ pub mod virtio; /// passed on to higher layers. #[cfg(not(target_arch = "aarch64"))] pub mod error { + use core::fmt; + #[cfg(feature = "pci")] use crate::drivers::net::rtl8139::RTL8139Error; use crate::drivers::virtio::error::VirtioError; - use core::fmt; #[derive(Debug)] pub enum DriverError { diff --git a/src/drivers/net/virtio_net.rs b/src/drivers/net/virtio_net.rs index 4986fc3cbde397e679fa8d2c8d84b58e32609497..abb20f0daca86a63ef88eae4b7a84355ebe30f7d 100644 --- a/src/drivers/net/virtio_net.rs +++ b/src/drivers/net/virtio_net.rs @@ -2,22 +2,24 @@ //! //! The module contains ... -use crate::arch::kernel::percore::increment_irq_counter; -use crate::config::VIRTIO_MAX_QUEUE_SIZE; -use crate::drivers::net::NetworkInterface; - use alloc::boxed::Box; use alloc::collections::VecDeque; use alloc::rc::Rc; use alloc::vec::Vec; +use core::cell::RefCell; +use core::cmp::Ordering; use core::mem; use core::result::Result; -use core::{cell::RefCell, cmp::Ordering}; +use self::constants::{FeatureSet, Features, NetHdrGSO, Status, MAX_NUM_VQ}; +use self::error::VirtioNetError; +use crate::arch::kernel::percore::increment_irq_counter; +use crate::config::VIRTIO_MAX_QUEUE_SIZE; #[cfg(not(feature = "pci"))] use crate::drivers::net::virtio_mmio::NetDevCfgRaw; #[cfg(feature = "pci")] use crate::drivers::net::virtio_pci::NetDevCfgRaw; +use crate::drivers::net::NetworkInterface; #[cfg(not(feature = "pci"))] use crate::drivers::virtio::transport::mmio::{ComCfg, IsrStatus, NotifCfg}; #[cfg(feature = "pci")] @@ -26,9 +28,6 @@ use crate::drivers::virtio::virtqueue::{ AsSliceU8, BuffSpec, BufferToken, Bytes, Transfer, Virtq, VqIndex, VqSize, VqType, }; -use self::constants::{FeatureSet, Features, NetHdrGSO, Status, MAX_NUM_VQ}; -use self::error::VirtioNetError; - pub const ETH_HDR: usize = 14usize; /// A wrapper struct for the raw configuration structure. @@ -1056,10 +1055,11 @@ impl VirtioNetDriver { } pub mod constants { - pub use super::error::VirtioNetError; use alloc::vec::Vec; use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign}; + pub use super::error::VirtioNetError; + // Configuration constants pub const MAX_NUM_VQ: u16 = 2; diff --git a/src/drivers/virtio/depr/virtio.rs b/src/drivers/virtio/depr/virtio.rs index 1f71589d830f30c505d7c44983f1aa9dd7bdbb0c..79a406d630e9cdf41c9c5a580362e7a9fe3f5723 100644 --- a/src/drivers/virtio/depr/virtio.rs +++ b/src/drivers/virtio/depr/virtio.rs @@ -1,19 +1,17 @@ #![allow(clippy::vec_box)] -use crate::arch::kernel::pci::{self, PciAdapter}; - -use crate::arch::mm::paging; -use crate::arch::mm::VirtAddr; -use crate::config::VIRTIO_MAX_QUEUE_SIZE; - use alloc::boxed::Box; use alloc::rc::Rc; use alloc::vec::Vec; +use core::cell::RefCell; use core::hint::spin_loop; +use core::ptr; use core::sync::atomic::{fence, Ordering}; -use core::{cell::RefCell, ptr}; use self::consts::*; +use crate::arch::kernel::pci::{self, PciAdapter}; +use crate::arch::mm::{paging, VirtAddr}; +use crate::config::VIRTIO_MAX_QUEUE_SIZE; #[allow(dead_code)] pub mod consts { diff --git a/src/drivers/virtio/depr/virtio_fs.rs b/src/drivers/virtio/depr/virtio_fs.rs index 1d83f15bd96563764849bcdbed1b5b0fba69a6de..bdb2394a5810bfd933a6c1e66e7841915a29dc61 100644 --- a/src/drivers/virtio/depr/virtio_fs.rs +++ b/src/drivers/virtio/depr/virtio_fs.rs @@ -1,14 +1,15 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::{fmt, str, u32, u8}; + use crate::arch::x86_64::kernel::fuse::{self, FuseInterface}; use crate::arch::x86_64::kernel::pci; +use crate::drivers::virtio::depr::virtio::consts::*; use crate::drivers::virtio::depr::virtio::{ - self, consts::*, virtio_pci_common_cfg, VirtioNotification, Virtq, + self, virtio_pci_common_cfg, VirtioNotification, Virtq, }; use crate::syscalls::fs; -use alloc::boxed::Box; -use alloc::vec::Vec; -use core::{fmt, str, u32, u8}; - /// Filesystem name (UTF-8, not NUL-terminated, padded with NULs) #[allow(non_camel_case_types)] #[repr(transparent)] diff --git a/src/drivers/virtio/depr/virtio_net.rs b/src/drivers/virtio/depr/virtio_net.rs index de0568f84e2c67a9778612df3a977515492fb2a8..d5468677fc0f3a081826643c8a2c479b7410c348 100644 --- a/src/drivers/virtio/depr/virtio_net.rs +++ b/src/drivers/virtio/depr/virtio_net.rs @@ -1,16 +1,17 @@ #![allow(dead_code)] +use alloc::vec::Vec; +use core::sync::atomic::{fence, Ordering}; +use core::{fmt, mem, slice, u32, u8}; + use crate::arch::kernel::pci; use crate::arch::mm::paging::{BasePageSize, PageSize}; use crate::arch::mm::VirtAddr; +use crate::drivers::virtio::depr::virtio::consts::*; use crate::drivers::virtio::depr::virtio::{ - self, consts::*, virtio_pci_common_cfg, VirtioNotification, Virtq, + self, virtio_pci_common_cfg, VirtioNotification, Virtq, }; -use alloc::vec::Vec; -use core::sync::atomic::{fence, Ordering}; -use core::{fmt, mem, slice, u32, u8}; - const VIRTIO_NET_F_CSUM: u64 = 0; const VIRTIO_NET_F_GUEST_CSUM: u64 = 1; const VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: u64 = 2; diff --git a/src/drivers/virtio/env.rs b/src/drivers/virtio/env.rs index 268179dbb9c7d69f64869a5bab74b12581b126ed..ca2b3ac5c7c80cf82dfcc282368d3488aa54e322 100644 --- a/src/drivers/virtio/env.rs +++ b/src/drivers/virtio/env.rs @@ -178,14 +178,15 @@ pub mod memory { /// are not changed on little endian machines. #[cfg(feature = "pci")] pub mod pci { + use alloc::vec::Vec; + use core::result::Result; + use crate::arch::x86_64::kernel::pci; use crate::arch::x86_64::kernel::pci::error::PciError; use crate::arch::x86_64::kernel::pci::{PciAdapter, PciBar}; use crate::arch::x86_64::mm::PhysAddr; use crate::drivers::virtio::env::memory::VirtMemAddr; use crate::drivers::virtio::transport::pci::PciBar as VirtioPciBar; - use alloc::vec::Vec; - use core::result::Result; /// Wrapper function to read the configuration space of a PCI /// device at the given register. Returns the registers value. diff --git a/src/drivers/virtio/mod.rs b/src/drivers/virtio/mod.rs index c4d2b00a1296c242056503c3eef4a7ed73c175af..3e33254dfebbbdb901aecec7696672f6e8ce5af8 100644 --- a/src/drivers/virtio/mod.rs +++ b/src/drivers/virtio/mod.rs @@ -8,10 +8,11 @@ pub mod transport; pub mod virtqueue; pub mod error { + use core::fmt; + #[cfg(feature = "pci")] use crate::arch::x86_64::kernel::pci::error::PciError; pub use crate::drivers::net::virtio_net::error::VirtioNetError; - use core::fmt; #[derive(Debug)] pub enum VirtioError { diff --git a/src/drivers/virtio/transport/mmio.rs b/src/drivers/virtio/transport/mmio.rs index b2ba4a38c9fdd81b2d521e1a01491fa09b574d8a..d8dd6e10530ace4dd276b336d07cd5b3b8990e8d 100644 --- a/src/drivers/virtio/transport/mmio.rs +++ b/src/drivers/virtio/transport/mmio.rs @@ -3,22 +3,20 @@ //! The module contains ... #![allow(dead_code)] -use crate::arch::mm::PhysAddr; use core::convert::TryInto; use core::ptr::{read_volatile, write_volatile}; use core::result::Result; -use core::sync::atomic::fence; -use core::sync::atomic::Ordering; +use core::sync::atomic::{fence, Ordering}; use core::u8; +use crate::arch::mm::PhysAddr; +use crate::arch::x86_64::kernel::irq::*; use crate::drivers::error::DriverError; +use crate::drivers::net::network_irqhandler; use crate::drivers::net::virtio_net::VirtioNetDriver; use crate::drivers::virtio::device; use crate::drivers::virtio::error::VirtioError; -use crate::arch::x86_64::kernel::irq::*; -use crate::drivers::net::network_irqhandler; - /// Virtio device ID's /// See Virtio specification v1.1. - 5 /// diff --git a/src/drivers/virtio/transport/pci.rs b/src/drivers/virtio/transport/pci.rs index 14151072cb0e6b2c65fbecf37cebc869ae2e003d..8e55dbc83c1241fa7669df533b965716dc548721 100644 --- a/src/drivers/virtio/transport/pci.rs +++ b/src/drivers/virtio/transport/pci.rs @@ -3,25 +3,23 @@ //! The module contains ... #![allow(dead_code)] -use crate::arch::kernel::pci as kernel_pci; -use crate::arch::kernel::pci::error::PciError; -use crate::arch::kernel::pci::{PciAdapter, PciDriver}; -use crate::arch::mm::PhysAddr; -use crate::synch::spinlock::SpinlockIrqSave; use alloc::vec::Vec; use core::mem; use core::result::Result; +use crate::arch::kernel::pci as kernel_pci; +use crate::arch::kernel::pci::error::PciError; +use crate::arch::kernel::pci::{PciAdapter, PciDriver}; +use crate::arch::mm::PhysAddr; +use crate::arch::x86_64::kernel::irq::*; use crate::drivers::error::DriverError; +use crate::drivers::net::network_irqhandler; use crate::drivers::net::virtio_net::VirtioNetDriver; -use crate::drivers::virtio::device; -use crate::drivers::virtio::env; +use crate::drivers::virtio::depr::virtio_fs; use crate::drivers::virtio::env::memory::{MemLen, MemOff, VirtMemAddr}; use crate::drivers::virtio::error::VirtioError; - -use crate::arch::x86_64::kernel::irq::*; -use crate::drivers::net::network_irqhandler; -use crate::drivers::virtio::depr::virtio_fs; +use crate::drivers::virtio::{device, env}; +use crate::synch::spinlock::SpinlockIrqSave; /// Virtio device ID's /// See Virtio specification v1.1. - 5 diff --git a/src/drivers/virtio/virtqueue/mod.rs b/src/drivers/virtio/virtqueue/mod.rs index d4715d8c52da9f9a8ae1940d690e02d9e1cca057..02eec3c4ae2b5ad14274499256153669e9b34d1b 100644 --- a/src/drivers/virtio/virtqueue/mod.rs +++ b/src/drivers/virtio/virtqueue/mod.rs @@ -13,23 +13,22 @@ pub mod packed; pub mod split; -use crate::arch::mm::paging::{BasePageSize, PageSize}; -use crate::arch::mm::{paging, VirtAddr}; +use alloc::boxed::Box; +use alloc::collections::VecDeque; +use alloc::rc::Rc; +use alloc::vec::Vec; +use core::cell::RefCell; +use core::ops::{BitAnd, Deref, DerefMut}; use self::error::{BufferError, VirtqError}; use self::packed::PackedVq; use self::split::SplitVq; - #[cfg(not(feature = "pci"))] use super::transport::mmio::{ComCfg, NotifCfg}; #[cfg(feature = "pci")] use super::transport::pci::{ComCfg, NotifCfg}; -use alloc::boxed::Box; -use alloc::collections::VecDeque; -use alloc::rc::Rc; -use alloc::vec::Vec; -use core::cell::RefCell; -use core::ops::{BitAnd, Deref, DerefMut}; +use crate::arch::mm::paging::{BasePageSize, PageSize}; +use crate::arch::mm::{paging, VirtAddr}; /// A u16 newtype. If instantiated via ``VqIndex::from(T)``, the newtype is ensured to be /// smaller-equal to `min(u16::MAX , T::MAX)`. diff --git a/src/drivers/virtio/virtqueue/packed.rs b/src/drivers/virtio/virtqueue/packed.rs index 7ca192c0c205e55d17b5cc5f7442c21d502b6be4..3dee9424fbe8692667f93dd8eefea85de6d721a4 100644 --- a/src/drivers/virtio/virtqueue/packed.rs +++ b/src/drivers/virtio/virtqueue/packed.rs @@ -2,6 +2,14 @@ //! See Virito specification v1.1. - 2.7 #![allow(dead_code)] +use alloc::boxed::Box; +use alloc::collections::VecDeque; +use alloc::rc::Rc; +use alloc::vec::Vec; +use core::cell::RefCell; +use core::ptr; +use core::sync::atomic::{fence, Ordering}; + use self::error::VqPackedError; use super::super::features::Features; #[cfg(not(feature = "pci"))] @@ -15,12 +23,6 @@ use super::{ }; use crate::arch::mm::paging::{BasePageSize, PageSize}; use crate::arch::mm::{paging, VirtAddr}; -use alloc::boxed::Box; -use alloc::collections::VecDeque; -use alloc::rc::Rc; -use alloc::vec::Vec; -use core::sync::atomic::{fence, Ordering}; -use core::{cell::RefCell, ptr}; /// A newtype of bool used for convenience in context with /// packed queues wrap counter. diff --git a/src/drivers/virtio/virtqueue/split.rs b/src/drivers/virtio/virtqueue/split.rs index fc2bbd2825ae5bfc8795e28f3f5dd8b2a7823b64..a956f3ce9fce4f260767a436a43d5e5627684504 100644 --- a/src/drivers/virtio/virtqueue/split.rs +++ b/src/drivers/virtio/virtqueue/split.rs @@ -2,6 +2,14 @@ //! See Virito specification v1.1. - 2.6 #![allow(dead_code)] +use alloc::boxed::Box; +use alloc::collections::VecDeque; +use alloc::rc::Rc; +use alloc::vec::Vec; +use core::cell::RefCell; +use core::ptr; +use core::sync::atomic::{fence, Ordering}; + #[cfg(not(feature = "pci"))] use super::super::transport::mmio::{ComCfg, NotifCfg, NotifCtrl}; #[cfg(feature = "pci")] @@ -13,12 +21,6 @@ use super::{ }; use crate::arch::mm::paging::{BasePageSize, PageSize}; use crate::arch::mm::{paging, VirtAddr}; -use alloc::boxed::Box; -use alloc::collections::VecDeque; -use alloc::rc::Rc; -use alloc::vec::Vec; -use core::sync::atomic::{fence, Ordering}; -use core::{cell::RefCell, ptr}; #[repr(C)] #[derive(Copy, Clone)] diff --git a/src/env.rs b/src/env.rs index 674b67388af00246908ce8c9ce2913273fa72073..23e743b759efc6dbdc1c314f44adacf19089fca2 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,10 +1,13 @@ //! Central parsing of the command-line parameters. -use ahash::RandomState; -use alloc::{boxed::Box, string::String, vec::Vec}; +use alloc::boxed::Box; +use alloc::string::String; +use alloc::vec::Vec; use core::{slice, str}; -use hashbrown::{hash_map::Iter, HashMap}; +use ahash::RandomState; +use hashbrown::hash_map::Iter; +use hashbrown::HashMap; use once_cell::race::OnceBox; pub use crate::arch::kernel::{ diff --git a/src/lib.rs b/src/lib.rs index 5b2b3450bd9467ad7edbd0089d5c652da1e03af1..2f36448d238e59722cd130fbb6cda99386b8f8b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,9 +56,11 @@ use core::hint::spin_loop; #[cfg(feature = "smp")] use core::sync::atomic::{AtomicU32, Ordering}; +// Used for integration test status. +#[doc(hidden)] +pub use arch::kernel::is_uhyve as _is_uhyve; use arch::percore::*; use mm::allocator::LockedHeap; - #[cfg(target_arch = "aarch64")] use qemu_exit::QEMUExit; @@ -66,10 +68,6 @@ pub(crate) use crate::arch::*; pub(crate) use crate::config::*; pub use crate::syscalls::*; -// Used for integration test status. -#[doc(hidden)] -pub use arch::kernel::is_uhyve as _is_uhyve; - #[macro_use] mod macros; diff --git a/src/mm/allocator.rs b/src/mm/allocator.rs index 4759aa0264ffff3e8f9b9f66c6ccfd5c862cf32b..1cba8fd12891f01386a48e3c0f68ffa893537b6c 100644 --- a/src/mm/allocator.rs +++ b/src/mm/allocator.rs @@ -7,15 +7,15 @@ #![allow(dead_code)] +use core::alloc::{AllocError, GlobalAlloc, Layout}; +use core::ops::Deref; +use core::ptr::NonNull; +use core::{cmp, mem, ptr}; + use crate::mm::hole::{Hole, HoleList}; use crate::mm::kernel_end_address; use crate::synch::spinlock::*; use crate::HW_DESTRUCTIVE_INTERFERENCE_SIZE; -use core::alloc::{AllocError, GlobalAlloc, Layout}; -use core::cmp; -use core::ops::Deref; -use core::ptr::NonNull; -use core::{mem, ptr}; /// Size of the preallocated space for the Bootstrap Allocator. const BOOTSTRAP_HEAP_SIZE: usize = 4096; diff --git a/src/mm/freelist.rs b/src/mm/freelist.rs index 2f995cccbb319dbf7de4ef2c58b9b0be592af220..fbd7b4432c31b4c4eed2c4cfd6d49945570fc0c4 100644 --- a/src/mm/freelist.rs +++ b/src/mm/freelist.rs @@ -1,5 +1,6 @@ use alloc::collections::linked_list::LinkedList; -use core::{alloc::AllocError, cmp::Ordering}; +use core::alloc::AllocError; +use core::cmp::Ordering; pub struct FreeListEntry { pub start: usize, diff --git a/src/mm/mod.rs b/src/mm/mod.rs index ea301110e8cdf27944b4d00ce97532c8bf12898e..caa5add4695f07666d2371e579c864972f8778d5 100644 --- a/src/mm/mod.rs +++ b/src/mm/mod.rs @@ -4,7 +4,8 @@ mod hole; #[cfg(test)] mod test; -use crate::arch; +use core::mem; + #[cfg(target_arch = "x86_64")] use crate::arch::mm::paging::PageTableEntryFlagsExt; use crate::arch::mm::paging::{ @@ -16,8 +17,7 @@ use crate::arch::mm::virtualmem::kernel_heap_end; #[cfg(feature = "pci")] use crate::arch::mm::PhysAddr; use crate::arch::mm::VirtAddr; -use crate::env; -use core::mem; +use crate::{arch, env}; /// Physical and virtual address of the first 2 MiB page that maps the kernel. /// Can be easily accessed through kernel_start_address() diff --git a/src/mm/test.rs b/src/mm/test.rs index 9800af2f9440c7384d1cfc8a40467f8beee1ed53..bcee90e331b18c54f12480df8051b280d4fd07ad 100644 --- a/src/mm/test.rs +++ b/src/mm/test.rs @@ -8,12 +8,12 @@ #[cfg(not(target_os = "none"))] #[cfg(test)] mod tests { - use super::*; use alloc::alloc::alloc; use core::alloc::Layout; use std::mem::{align_of, size_of}; use std::prelude::v1::*; + use super::*; use crate::mm::allocator::*; use crate::mm::hole::*; use crate::HW_DESTRUCTIVE_INTERFERENCE_SIZE; diff --git a/src/net/executor.rs b/src/net/executor.rs index 225bf4cdf19e3257b246b73212745a3282ed7668..ca38263a2cdc8aa7f458082019561603d74318ef 100644 --- a/src/net/executor.rs +++ b/src/net/executor.rs @@ -1,13 +1,11 @@ use alloc::sync::Arc; use alloc::task::Wake; use alloc::vec::Vec; +use core::future::Future; +use core::sync::atomic::{AtomicBool, Ordering}; +use core::task::{Context, Poll}; + use async_task::{Runnable, Task}; -use core::sync::atomic::Ordering; -use core::{ - future::Future, - sync::atomic::AtomicBool, - task::{Context, Poll}, -}; use futures_lite::pin; use smoltcp::time::{Duration, Instant}; diff --git a/src/net/mod.rs b/src/net/mod.rs index bc7d596fe79fad091f50e4e5eb895f76057de079..1adb1fa89ad8bfbbd012ff1f99faec6674c91cb4 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -4,6 +4,7 @@ pub(crate) mod executor; use alloc::boxed::Box; use core::ops::DerefMut; use core::str::FromStr; +use core::sync::atomic::{AtomicU16, Ordering}; use core::task::Poll; use futures_lite::future; @@ -20,13 +21,10 @@ use smoltcp::wire::IpAddress; use smoltcp::wire::{IpCidr, Ipv4Address, Ipv4Cidr}; use smoltcp::Error; -use core::sync::atomic::{AtomicU16, Ordering}; - -use crate::arch; use crate::net::device::HermitNet; use crate::net::executor::spawn; use crate::synch::spinlock::SpinlockIrqSave; -use crate::DEFAULT_KEEP_ALIVE_INTERVAL; +use crate::{arch, DEFAULT_KEEP_ALIVE_INTERVAL}; pub(crate) enum NetworkState { Missing, diff --git a/src/scheduler/mod.rs b/src/scheduler/mod.rs index 2f043a5bc4ed637d1cd8003161e74533a543859d..e76c2b8df8e2dccad58b8ff6f3ea0e2cc3054eac 100644 --- a/src/scheduler/mod.rs +++ b/src/scheduler/mod.rs @@ -4,6 +4,7 @@ use alloc::rc::Rc; use alloc::vec::Vec; use core::cell::RefCell; use core::sync::atomic::{AtomicU32, Ordering}; + use crossbeam_utils::Backoff; use crate::arch; diff --git a/src/scheduler/task.rs b/src/scheduler/task.rs index 1a0085f36cb16219e13332c8eaf15b6cc3b3cdc3..01290e3f0de43cce1fbd175716f45433ac06cc82 100644 --- a/src/scheduler/task.rs +++ b/src/scheduler/task.rs @@ -1,8 +1,3 @@ -use crate::arch; -use crate::arch::mm::VirtAddr; -use crate::arch::percore::*; -use crate::arch::scheduler::{TaskStacks, TaskTLS}; -use crate::scheduler::CoreId; use alloc::collections::{LinkedList, VecDeque}; use alloc::rc::Rc; use core::cell::RefCell; @@ -12,6 +7,12 @@ use core::num::NonZeroU64; #[cfg(feature = "tcp")] use core::ops::DerefMut; +use crate::arch; +use crate::arch::mm::VirtAddr; +use crate::arch::percore::*; +use crate::arch::scheduler::{TaskStacks, TaskTLS}; +use crate::scheduler::CoreId; + /// Returns the most significant bit. /// /// # Examples diff --git a/src/synch/futex.rs b/src/synch/futex.rs index 4d51709256edfc84de096406dcd6b66f7e6bd16f..e067c54fe8e537f2e87862feacbbd842caa18c44 100644 --- a/src/synch/futex.rs +++ b/src/synch/futex.rs @@ -1,14 +1,15 @@ -use ahash::RandomState; -use core::sync::atomic::{AtomicU32, Ordering::SeqCst}; -use hashbrown::{hash_map::Entry, HashMap}; +use core::sync::atomic::AtomicU32; +use core::sync::atomic::Ordering::SeqCst; -use crate::{ - arch::kernel::{percore::core_scheduler, processor::get_timer_ticks}, - errno::{EAGAIN, EINVAL, ETIMEDOUT}, - scheduler::task::TaskHandlePriorityQueue, -}; +use ahash::RandomState; +use hashbrown::hash_map::Entry; +use hashbrown::HashMap; use super::spinlock::SpinlockIrqSave; +use crate::arch::kernel::percore::core_scheduler; +use crate::arch::kernel::processor::get_timer_ticks; +use crate::errno::{EAGAIN, EINVAL, ETIMEDOUT}; +use crate::scheduler::task::TaskHandlePriorityQueue; // TODO: Replace with a concurrent hashmap. static PARKING_LOT: SpinlockIrqSave<HashMap<usize, TaskHandlePriorityQueue, RandomState>> = diff --git a/src/synch/semaphore.rs b/src/synch/semaphore.rs index e575ccbfe50b98455b23e3fa5e810e4dbc1bf013..fc02ddee2b53c93d59d6a15e2ed57fd64f1ae6c0 100644 --- a/src/synch/semaphore.rs +++ b/src/synch/semaphore.rs @@ -1,8 +1,9 @@ +#[cfg(feature = "smp")] +use crossbeam_utils::Backoff; + use crate::arch::percore::*; use crate::scheduler::task::TaskHandlePriorityQueue; use crate::synch::spinlock::SpinlockIrqSave; -#[cfg(feature = "smp")] -use crossbeam_utils::Backoff; struct SemaphoreState { /// Resource available count diff --git a/src/syscalls/fs.rs b/src/syscalls/fs.rs index 783190fb32f8fa480320f9b5108d537c513a25dd..e711fefb5d875f6a22be6139a21669420fbcaa8e 100644 --- a/src/syscalls/fs.rs +++ b/src/syscalls/fs.rs @@ -1,3 +1,9 @@ +use alloc::boxed::Box; +use alloc::collections::BTreeMap; +use alloc::string::String; +use alloc::vec::Vec; +use core::ops::Deref; + /// Design: /// - want to support different backends. One of them virtiofs. /// - want to support multiple mounted filesystems at once. @@ -35,11 +41,6 @@ /// - FileDescriptor newtype use crate::env::is_uhyve; use crate::synch::spinlock::Spinlock; -use alloc::boxed::Box; -use alloc::collections::BTreeMap; -use alloc::string::String; -use alloc::vec::Vec; -use core::ops::Deref; // TODO: lazy static could be replaced with explicit init on OS boot. pub static FILESYSTEM: Spinlock<Filesystem> = Spinlock::new(Filesystem::new()); diff --git a/src/syscalls/futex.rs b/src/syscalls/futex.rs index ffb5f5b81fcb5964c378df79743bca0be20f9fe4..db301880fc3532296484c55f9e78fd6300f30e1e 100644 --- a/src/syscalls/futex.rs +++ b/src/syscalls/futex.rs @@ -1,10 +1,8 @@ use core::sync::atomic::AtomicU32; -use crate::{ - errno::EINVAL, - synch::futex::{self as synch, Flags}, - timespec, timespec_to_microseconds, -}; +use crate::errno::EINVAL; +use crate::synch::futex::{self as synch, Flags}; +use crate::{timespec, timespec_to_microseconds}; /// Like `synch::futex_wait`, but does extra sanity checks and takes a `timespec`. /// diff --git a/src/syscalls/interfaces/mod.rs b/src/syscalls/interfaces/mod.rs index b273ae9fe143c4adae53046b266cfeb14c590284..b1509756641f5e2419c898daeafa49c2e1e5be3c 100644 --- a/src/syscalls/interfaces/mod.rs +++ b/src/syscalls/interfaces/mod.rs @@ -3,12 +3,6 @@ use alloc::vec::Vec; use core::ffi::CStr; use core::{isize, slice, str}; -use crate::arch; -use crate::console::CONSOLE; -use crate::env; -use crate::errno::*; -use crate::syscalls::fs::{self, FilePerms, PosixFile, SeekWhence}; - #[cfg(all(not(feature = "pci"), not(target_arch = "aarch64")))] use arch::kernel::mmio::get_network_driver; #[cfg(all(feature = "pci", not(target_arch = "aarch64")))] @@ -16,6 +10,10 @@ use arch::kernel::pci::get_network_driver; pub use self::generic::*; pub use self::uhyve::*; +use crate::console::CONSOLE; +use crate::errno::*; +use crate::syscalls::fs::{self, FilePerms, PosixFile, SeekWhence}; +use crate::{arch, env}; mod generic; mod uhyve; diff --git a/src/syscalls/interfaces/uhyve.rs b/src/syscalls/interfaces/uhyve.rs index 815d909ea45c232d69051b85b2bffe0381df2b15..2014ea052f283a535789ab4d7742264819ad39c8 100644 --- a/src/syscalls/interfaces/uhyve.rs +++ b/src/syscalls/interfaces/uhyve.rs @@ -1,12 +1,12 @@ -use alloc::{boxed::Box, vec::Vec}; +use alloc::boxed::Box; +use alloc::vec::Vec; use core::mem; #[cfg(target_arch = "x86_64")] use x86::io::*; use crate::arch; -use crate::arch::mm::paging; -use crate::arch::mm::{PhysAddr, VirtAddr}; +use crate::arch::mm::{paging, PhysAddr, VirtAddr}; use crate::syscalls::interfaces::SyscallInterface; #[cfg(feature = "newlib")] use crate::syscalls::lwip::sys_lwip_get_errno; diff --git a/src/syscalls/lwip.rs b/src/syscalls/lwip.rs index 797e41bb2b7a322da63b329c23fb73ebabc27ab9..ce028352db031c3105e455aecc4ca433e4eb4aae 100644 --- a/src/syscalls/lwip.rs +++ b/src/syscalls/lwip.rs @@ -1,7 +1,6 @@ -use crate::arch; use crate::arch::percore::*; -use crate::console; use crate::synch::spinlock::SpinlockIrqSaveGuard; +use crate::{arch, console}; /// Enables lwIP's printf to print a whole string without being interrupted by /// a message from the kernel. diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index d631357de45bd220dcf7eabebd9986c50041d460..33c78a6f6be2b2f6992475aaf3299b9e15dd7d5b 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -1,12 +1,5 @@ #![allow(clippy::result_unit_err)] -use crate::env; -#[cfg(feature = "newlib")] -use crate::synch::spinlock::SpinlockIrqSave; -use crate::syscalls::interfaces::SyscallInterface; -#[cfg(target_os = "none")] -use crate::{__sys_free, __sys_malloc, __sys_realloc}; - pub use self::condvar::*; pub use self::futex::*; pub use self::processor::*; @@ -17,6 +10,12 @@ pub use self::spinlock::*; pub use self::system::*; pub use self::tasks::*; pub use self::timer::*; +use crate::env; +#[cfg(feature = "newlib")] +use crate::synch::spinlock::SpinlockIrqSave; +use crate::syscalls::interfaces::SyscallInterface; +#[cfg(target_os = "none")] +use crate::{__sys_free, __sys_malloc, __sys_realloc}; mod condvar; pub(crate) mod fs; diff --git a/src/syscalls/net.rs b/src/syscalls/net.rs index 39f59d5bb9e066998b196e649f1b43d4523bc71c..033c7ee6e751ef02e7df92bc4e5bd26f5eb17e80 100644 --- a/src/syscalls/net.rs +++ b/src/syscalls/net.rs @@ -1,11 +1,11 @@ -use crate::net::executor::block_on; -use crate::net::{AsyncSocket, Handle}; -use crate::DEFAULT_KEEP_ALIVE_INTERVAL; - use smoltcp::socket::TcpSocket; use smoltcp::time::Duration; use smoltcp::wire::IpAddress; +use crate::net::executor::block_on; +use crate::net::{AsyncSocket, Handle}; +use crate::DEFAULT_KEEP_ALIVE_INTERVAL; + #[no_mangle] pub fn sys_tcp_stream_connect(ip: &[u8], port: u16, timeout: Option<u64>) -> Result<Handle, ()> { let socket = AsyncSocket::new(); diff --git a/src/syscalls/recmutex.rs b/src/syscalls/recmutex.rs index b3b48a00e2ec2eee5a451fdeac903c7c0bda7253..639e2dd1aeb6ce66b9a01c317b66d2bc3ce2052a 100644 --- a/src/syscalls/recmutex.rs +++ b/src/syscalls/recmutex.rs @@ -1,6 +1,7 @@ +use alloc::boxed::Box; + use crate::errno::*; use crate::synch::recmutex::RecursiveMutex; -use alloc::boxed::Box; extern "C" fn __sys_recmutex_init(recmutex: *mut *mut RecursiveMutex) -> i32 { if recmutex.is_null() { diff --git a/src/syscalls/semaphore.rs b/src/syscalls/semaphore.rs index 62d60ac58a8bf58c676726c652d781c02cda3311..da23043a22f70a42e54a49262273bd87d7ffce58 100644 --- a/src/syscalls/semaphore.rs +++ b/src/syscalls/semaphore.rs @@ -1,6 +1,7 @@ +use alloc::boxed::Box; + use crate::errno::*; use crate::synch::semaphore::Semaphore; -use alloc::boxed::Box; extern "C" fn __sys_sem_init(sem: *mut *mut Semaphore, value: u32) -> i32 { if sem.is_null() { diff --git a/src/syscalls/spinlock.rs b/src/syscalls/spinlock.rs index 6db2e079c545b5224540638d03ddb8d861b623a0..1b2a8833e07b4624d73ee80a455ceb4580d96689 100644 --- a/src/syscalls/spinlock.rs +++ b/src/syscalls/spinlock.rs @@ -1,6 +1,7 @@ +use alloc::boxed::Box; + use crate::errno::*; use crate::synch::spinlock::*; -use alloc::boxed::Box; pub struct SpinlockContainer<'a> { lock: Spinlock<()>, diff --git a/src/syscalls/tasks.rs b/src/syscalls/tasks.rs index 10431176bbdcee404e5eceedee0c52543cc68aeb..2ed17c95dc8eff2caf064ae33de0963feac441ca 100644 --- a/src/syscalls/tasks.rs +++ b/src/syscalls/tasks.rs @@ -4,7 +4,6 @@ use core::isize; use core::sync::atomic::AtomicUsize; use core::sync::atomic::{AtomicU32, Ordering}; -use crate::arch; use crate::arch::get_processor_count; use crate::arch::percore::*; use crate::arch::processor::{get_frequency, get_timestamp}; @@ -12,11 +11,10 @@ use crate::config::USER_STACK_SIZE; use crate::errno::*; #[cfg(feature = "newlib")] use crate::mm::{task_heap_end, task_heap_start}; -use crate::scheduler; use crate::scheduler::task::{Priority, TaskHandle, TaskId}; use crate::synch::spinlock::SpinlockIrqSave; -use crate::syscalls; use crate::syscalls::timer::timespec; +use crate::{arch, scheduler, syscalls}; #[cfg(feature = "newlib")] pub type SignalHandler = extern "C" fn(i32); diff --git a/tests/thread.rs b/tests/thread.rs index 785544fd34fa6e3f6f35952f82002fe63e8b1424..ef13ab21f16934e4c8813709bcfb90120ecc0388 100644 --- a/tests/thread.rs +++ b/tests/thread.rs @@ -8,19 +8,17 @@ extern crate hermit; -use core::{ - ptr, - sync::atomic::{AtomicU32, Ordering::Relaxed}, -}; +use core::ptr; +use core::sync::atomic::AtomicU32; +use core::sync::atomic::Ordering::Relaxed; use common::*; mod common; use alloc::vec; -use hermit::{ - errno::{EAGAIN, ETIMEDOUT}, - sys_futex_wait, sys_futex_wake, sys_join, sys_spawn2, sys_usleep, timespec, -}; + +use hermit::errno::{EAGAIN, ETIMEDOUT}; +use hermit::{sys_futex_wait, sys_futex_wake, sys_join, sys_spawn2, sys_usleep, timespec}; const USER_STACK_SIZE: usize = 1_048_576; const NORMAL_PRIO: u8 = 2; diff --git a/xtask/src/archive.rs b/xtask/src/archive.rs index 3ae0ffb1bf4058b4810fb3d02c263b97750d4662..a55dce542aadbbdc53a004c619bafff9c23cbc69 100644 --- a/xtask/src/archive.rs +++ b/xtask/src/archive.rs @@ -1,10 +1,9 @@ -use std::{ - env, - path::{Path, PathBuf}, -}; +use std::env; +use std::path::{Path, PathBuf}; use anyhow::{anyhow, Result}; -use goblin::{archive::Archive as GoblinArchive, elf64::header}; +use goblin::archive::Archive as GoblinArchive; +use goblin::elf64::header; use llvm_tools::LlvmTools; use xshell::cmd; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index dbd6eedbe04841a84aebb7cd3389e812cc6e37dd..0b71e92e1c3d92125ade7153bea7853b09fd2263 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -4,11 +4,9 @@ mod arch; mod archive; mod flags; -use std::{ - env::{self, VarError}, - ffi::OsStr, - path::{Path, PathBuf}, -}; +use std::env::{self, VarError}; +use std::ffi::OsStr; +use std::path::{Path, PathBuf}; use anyhow::Result; use arch::Arch;