diff --git a/Cargo.lock b/Cargo.lock index 75dcd778cfcee371984c531d80e565f46c0a8183..d440fe7e30dfe00d39ddb4a8a4dde88eb8086c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,12 +3,20 @@ [[package]] name = "bit_field" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/hermitcore/rust-bit-field.git?branch=hermit#76a803090c0b836094582431c4318dee89ce2e41" +dependencies = [ + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "bitflags" version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/hermitcore/bitflags.git?branch=hermit#8381fe363cf4ad74c4b81295b70b45f3abd70f78" +dependencies = [ + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cc" @@ -19,6 +27,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "compiler_builtins" @@ -31,26 +43,39 @@ dependencies = [ [[package]] name = "log" version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/hermitcore/log.git?branch=hermit#bd48cf7e9f3163d8f14c224563e5d6569401fb52" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "multiboot" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.5.0" +source = "git+https://github.com/hermitcore/rust-multiboot.git?branch=hermit#782f9b333d065c5027662f7b5eca48aae66fcf73" +dependencies = [ + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "raw-cpuid" version = "7.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/hermitcore/rust-cpuid.git?branch=hermit#8e24f4d90117517bd793d27d3e203d0969661747" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (git+https://github.com/hermitcore/bitflags.git?branch=hermit)", "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-std-workspace-alloc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustc-std-workspace-core" version = "1.0.0" @@ -68,12 +93,13 @@ dependencies = [ name = "rusty-hermit" version = "0.3.11" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (git+https://github.com/hermitcore/bitflags.git?branch=hermit)", "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "multiboot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/hermitcore/log.git?branch=hermit)", + "multiboot 0.5.0 (git+https://github.com/hermitcore/rust-multiboot.git?branch=hermit)", + "rustc-std-workspace-alloc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "x86 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x86 0.27.0 (git+https://github.com/hermitcore/rust-x86.git?branch=hermit)", ] [[package]] @@ -92,24 +118,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "x86" version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/hermitcore/rust-x86.git?branch=hermit#f6643e9c32636aa964f5e56bb2ca002716ae50da" dependencies = [ - "bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bit_field 0.10.0 (git+https://github.com/hermitcore/rust-bit-field.git?branch=hermit)", + "bitflags 1.2.1 (git+https://github.com/hermitcore/bitflags.git?branch=hermit)", + "compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 7.0.3 (git+https://github.com/hermitcore/rust-cpuid.git?branch=hermit)", + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum bit_field 0.10.0 (git+https://github.com/hermitcore/rust-bit-field.git?branch=hermit)" = "<none>" +"checksum bitflags 1.2.1 (git+https://github.com/hermitcore/bitflags.git?branch=hermit)" = "<none>" "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum compiler_builtins 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "4e32b9fc11fdb3aefbd0a4761a8d3a2b7419608b759fa14a26525df4ea5deaba" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum multiboot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "745e351d4f128ea9e266fe2dd04a1bd7349c60441d45ec8677520bae08e25d43" -"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" +"checksum log 0.4.8 (git+https://github.com/hermitcore/log.git?branch=hermit)" = "<none>" +"checksum multiboot 0.5.0 (git+https://github.com/hermitcore/rust-multiboot.git?branch=hermit)" = "<none>" +"checksum raw-cpuid 7.0.3 (git+https://github.com/hermitcore/rust-cpuid.git?branch=hermit)" = "<none>" +"checksum rustc-std-workspace-alloc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff66d57013a5686e1917ed6a025d54dd591fcda71a41fe07edf4d16726aefa86" "checksum rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum x86 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "271bc2de3f2f7a7c416377205b86e2ed1098eddfbc44098a1e1ac41d50951e7a" +"checksum x86 0.27.0 (git+https://github.com/hermitcore/rust-x86.git?branch=hermit)" = "<none>" diff --git a/Cargo.toml b/Cargo.toml index 700fdceb6e2c6a04f33534164cf987fe26b02a3a..2d7bdeabd093b476cbb1797e9e2e54ae98f3b585 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,25 +25,32 @@ name = "hermit" [features] vga = [] newlib = [] -rustc-dep-of-std = ['core', 'compiler_builtins/rustc-dep-of-std'] +rustc-dep-of-std = ['core', 'compiler_builtins/rustc-dep-of-std', 'compiler_builtins/mem', 'x86/rustc-dep-of-std', 'log/rustc-dep-of-std', 'bitflags/rustc-dep-of-std', 'multiboot/rustc-dep-of-std'] + +[target.'cfg(target_arch = "x86_64")'] +rustflags = ["-C", "target-features", "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float"] [dependencies] core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' } +alloc = { version = '1.0.0', package = 'rustc-std-workspace-alloc' } compiler_builtins = { version = '0.1.10', optional = true } -bitflags = "1.2" -#cfg-if = "0.1" -#byteorder = { version = "1.0", default-features = false } +bitflags = { git = "https://github.com/hermitcore/bitflags.git", branch = "hermit" } [dependencies.log] -version = "0.4" +git = "https://github.com/hermitcore/log.git" +branch = "hermit" +#version = "0.4" default-features = false #features = ["release_max_level_info"] [target.'cfg(target_arch = "x86_64")'.dependencies.multiboot] -version = "0.*" +git = "https://github.com/hermitcore/rust-multiboot.git" +branch = "hermit" [target.'cfg(target_arch = "x86_64")'.dependencies.x86] -version = "0.*" +#version = "0.*" +git = "https://github.com/hermitcore/rust-x86.git" +branch = "hermit" default-features = false [package.metadata.cargo-xbuild] diff --git a/src/arch/x86_64/kernel/irq.rs b/src/arch/x86_64/kernel/irq.rs index 573a7cf7b70bd262aa03d497d4a3caf0f9fb7804..27140b6082ddbfa85e70708c50c20738656da816 100644 --- a/src/arch/x86_64/kernel/irq.rs +++ b/src/arch/x86_64/kernel/irq.rs @@ -37,10 +37,10 @@ pub struct ExceptionStackFrame { } impl fmt::Debug for ExceptionStackFrame { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { struct Hex(u64); impl fmt::Debug for Hex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:#x}", self.0) } } diff --git a/src/drivers/net/uhyve.rs b/src/drivers/net/uhyve.rs index 889e958f3eb8c6dcf8eb84da0ea6a4fc40ba48dc..6ce5383021478127eabc716ad1f426cdde522a88 100644 --- a/src/drivers/net/uhyve.rs +++ b/src/drivers/net/uhyve.rs @@ -13,7 +13,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::{ptr, str}; use drivers::net::NetworkInterface; use synch; -use syscalls::sys_sem_post; +//use syscalls::sys_sem_post; #[cfg(target_arch = "x86_64")] use arch::x86_64::kernel::apic; @@ -68,9 +68,9 @@ impl NetworkInterface for UhyveNetwork { fn set_polling(&mut self, mode: bool) { self.polling.store(mode, Ordering::SeqCst); - if mode && !self.sem.is_null() { + /*if mode && !self.sem.is_null() { sys_sem_post(self.sem as *const synch::semaphore::Semaphore); - } + }*/ } fn init( diff --git a/src/lib.rs b/src/lib.rs index 844cc7c56bce367a300f574c666799e9c4613190..9c4752e6028ee0e3af9bd2b5be3b0a9ba6af7482 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,7 @@ #![allow(clippy::cognitive_complexity)] #![allow(clippy::forget_copy)] #![feature(abi_x86_interrupt)] +#![feature(alloc_error_handler)] #![feature(allocator_api)] #![feature(asm)] #![feature(const_fn)] @@ -40,7 +41,6 @@ extern crate std; // EXTERNAL CRATES -#[macro_use] extern crate alloc; #[macro_use] extern crate bitflags; @@ -68,7 +68,7 @@ mod kernel_message_buffer; mod mm; mod runtime_glue; mod scheduler; -mod synch; +pub mod synch; mod syscalls; pub use arch::*; diff --git a/src/logging.rs b/src/logging.rs index 179d101ab88690a597fa4b5af272c08e8f6f02ed..18d50f4cd61c4d29121ed32386fe5262dd2205df 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -12,7 +12,7 @@ use log::{set_logger, set_max_level, LevelFilter, Metadata, Record}; struct KernelLogger; impl log::Log for KernelLogger { - fn enabled(&self, _: &Metadata) -> bool { + fn enabled(&self, _: &Metadata<'_>) -> bool { true } @@ -20,7 +20,7 @@ impl log::Log for KernelLogger { // nothing to do } - fn log(&self, record: &Record) { + fn log(&self, record: &Record<'_>) { if self.enabled(record.metadata()) { println!( "[{}][{}] {}", diff --git a/src/mm/mod.rs b/src/mm/mod.rs index b5aa9dccbe164a9099864e7287bb4bcba9a6dd7b..ab7e3f4763e27412e3d58741e5522e772c963f65 100644 --- a/src/mm/mod.rs +++ b/src/mm/mod.rs @@ -220,6 +220,7 @@ pub fn print_information() { arch::mm::virtualmem::print_information(); } +#[allow(dead_code)] pub fn allocate_iomem(sz: usize) -> usize { let size = align_up!(sz, BasePageSize::SIZE); diff --git a/src/runtime_glue.rs b/src/runtime_glue.rs index 8398781f3306cbca6c3a0fa60a5c29e6690cfb8a..2baba18bf163fa861fe303d2d72f5d1b2f7fb033 100644 --- a/src/runtime_glue.rs +++ b/src/runtime_glue.rs @@ -16,7 +16,7 @@ use core::panic::PanicInfo; // see https://users.rust-lang.org/t/psa-breaking-change-panic-fmt-language-item-removed-in-favor-of-panic-implementation/17875 #[cfg(not(test))] #[panic_handler] -fn panic(info: &PanicInfo) -> ! { +fn panic(info: &PanicInfo<'_>) -> ! { print!("[{}][!!!PANIC!!!] ", arch::percore::core_id()); if let Some(location) = info.location() { @@ -35,8 +35,8 @@ fn panic(info: &PanicInfo) -> ! { } #[cfg(not(test))] -#[lang = "oom"] -#[no_mangle] +#[doc(hidden)] +#[alloc_error_handler] pub fn rust_oom(layout: Layout) -> ! { println!( "[{}][!!!OOM!!!] Memory allocation of {} bytes failed", diff --git a/src/synch/spinlock.rs b/src/synch/spinlock.rs index e02e7f3ba445ea5654e235354958346c19fa95f1..62af74b8377e5c875f79675294281d43ac5d72d7 100644 --- a/src/synch/spinlock.rs +++ b/src/synch/spinlock.rs @@ -53,7 +53,7 @@ pub struct Spinlock<T: ?Sized> { /// A guard to which the protected data can be accessed /// /// When the guard falls out of scope it will release the lock. -pub struct SpinlockGuard<'a, T: ?Sized + 'a> { +pub struct SpinlockGuard<'a, T: ?Sized> { //queue: &'a AtomicUsize, dequeue: &'a AtomicUsize, data: &'a mut T, @@ -90,7 +90,7 @@ impl<T: ?Sized> Spinlock<T> { } } - pub fn lock(&self) -> SpinlockGuard<T> { + pub fn lock(&self) -> SpinlockGuard<'_, T> { self.obtain_lock(); SpinlockGuard { //queue: &self.queue, @@ -176,7 +176,7 @@ pub struct SpinlockIrqSave<T: ?Sized> { /// A guard to which the protected data can be accessed /// /// When the guard falls out of scope it will release the lock. -pub struct SpinlockIrqSaveGuard<'a, T: ?Sized + 'a> { +pub struct SpinlockIrqSaveGuard<'a, T: ?Sized> { //queue: &'a AtomicUsize, dequeue: &'a AtomicUsize, irq: &'a AtomicBool, @@ -219,7 +219,7 @@ impl<T: ?Sized> SpinlockIrqSave<T> { self.irq.store(irq, Ordering::SeqCst); } - pub fn lock(&self) -> SpinlockIrqSaveGuard<T> { + pub fn lock(&self) -> SpinlockIrqSaveGuard<'_, T> { self.obtain_lock(); SpinlockIrqSaveGuard { //queue: &self.queue, diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index e889298344df56809769c71888f595fb9f647123..b5fc7c1df80d6592e622564142794dd4aceda25e 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -12,8 +12,11 @@ mod interfaces; mod lwip; mod processor; mod random; +#[cfg(feature = "newlib")] mod recmutex; +#[cfg(feature = "newlib")] mod semaphore; +#[cfg(feature = "newlib")] mod spinlock; mod system; mod tasks; @@ -22,8 +25,11 @@ mod timer; pub use self::condvar::*; pub use self::processor::*; pub use self::random::*; +#[cfg(feature = "newlib")] pub use self::recmutex::*; +#[cfg(feature = "newlib")] pub use self::semaphore::*; +#[cfg(feature = "newlib")] pub use self::spinlock::*; pub use self::system::*; pub use self::tasks::*; diff --git a/src/syscalls/spinlock.rs b/src/syscalls/spinlock.rs index 44f0f2373196710cbfd8f863a05ab42765206d48..70e781ae672a44cdfc83ab566426272160683b73 100644 --- a/src/syscalls/spinlock.rs +++ b/src/syscalls/spinlock.rs @@ -20,7 +20,7 @@ pub struct SpinlockIrqSaveContainer<'a> { } #[no_mangle] -pub extern "C" fn sys_spinlock_init(lock: *mut *mut SpinlockContainer) -> i32 { +pub extern "C" fn sys_spinlock_init(lock: *mut *mut SpinlockContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -36,7 +36,7 @@ pub extern "C" fn sys_spinlock_init(lock: *mut *mut SpinlockContainer) -> i32 { } #[no_mangle] -pub extern "C" fn sys_spinlock_destroy(lock: *mut SpinlockContainer) -> i32 { +pub extern "C" fn sys_spinlock_destroy(lock: *mut SpinlockContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -49,7 +49,7 @@ pub extern "C" fn sys_spinlock_destroy(lock: *mut SpinlockContainer) -> i32 { } #[no_mangle] -pub extern "C" fn sys_spinlock_lock(lock: *mut SpinlockContainer) -> i32 { +pub extern "C" fn sys_spinlock_lock(lock: *mut SpinlockContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -64,7 +64,7 @@ pub extern "C" fn sys_spinlock_lock(lock: *mut SpinlockContainer) -> i32 { } #[no_mangle] -pub extern "C" fn sys_spinlock_unlock(lock: *mut SpinlockContainer) -> i32 { +pub extern "C" fn sys_spinlock_unlock(lock: *mut SpinlockContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -79,7 +79,7 @@ pub extern "C" fn sys_spinlock_unlock(lock: *mut SpinlockContainer) -> i32 { } #[no_mangle] -pub extern "C" fn sys_spinlock_irqsave_init(lock: *mut *mut SpinlockIrqSaveContainer) -> i32 { +pub extern "C" fn sys_spinlock_irqsave_init(lock: *mut *mut SpinlockIrqSaveContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -95,7 +95,7 @@ pub extern "C" fn sys_spinlock_irqsave_init(lock: *mut *mut SpinlockIrqSaveConta } #[no_mangle] -pub extern "C" fn sys_spinlock_irqsave_destroy(lock: *mut SpinlockIrqSaveContainer) -> i32 { +pub extern "C" fn sys_spinlock_irqsave_destroy(lock: *mut SpinlockIrqSaveContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -108,7 +108,7 @@ pub extern "C" fn sys_spinlock_irqsave_destroy(lock: *mut SpinlockIrqSaveContain } #[no_mangle] -pub extern "C" fn sys_spinlock_irqsave_lock(lock: *mut SpinlockIrqSaveContainer) -> i32 { +pub extern "C" fn sys_spinlock_irqsave_lock(lock: *mut SpinlockIrqSaveContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; } @@ -123,7 +123,7 @@ pub extern "C" fn sys_spinlock_irqsave_lock(lock: *mut SpinlockIrqSaveContainer) } #[no_mangle] -pub extern "C" fn sys_spinlock_irqsave_unlock(lock: *mut SpinlockIrqSaveContainer) -> i32 { +pub extern "C" fn sys_spinlock_irqsave_unlock(lock: *mut SpinlockIrqSaveContainer<'_>) -> i32 { if lock.is_null() { return -EINVAL; }