add lock support for libos mode

This commit is contained in:
DeathWish5 2022-03-28 17:39:54 +08:00
parent b517f543f8
commit 202f6296b2
72 changed files with 96 additions and 72 deletions

View File

@ -15,7 +15,6 @@ virtio = ["virtio-drivers"]
[dependencies] [dependencies]
log = "0.4" log = "0.4"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
cfg-if = "1.0" cfg-if = "1.0"
bitflags = "1.3" bitflags = "1.3"
lazy_static = "1.4" lazy_static = "1.4"
@ -27,10 +26,13 @@ rcore-console = { git = "https://github.com/rcore-os/rcore-console", default-fea
# smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "35e833e3", default-features = false, features = ["log", "alloc", "verbose", "proto-ipv4", "proto-ipv6", "proto-igmp", "medium-ip", "medium-ethernet", "socket-raw", "socket-udp", "socket-tcp", "socket-icmp"] } # smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "35e833e3", default-features = false, features = ["log", "alloc", "verbose", "proto-ipv4", "proto-ipv6", "proto-igmp", "medium-ip", "medium-ethernet", "socket-raw", "socket-udp", "socket-tcp", "socket-icmp"] }
smoltcp = { git = "https://gitee.com/gcyyfun/smoltcp", rev="043eb60", default-features = false, features = ["alloc","log", "async", "medium-ethernet","proto-ipv4", "proto-igmp", "socket-icmp", "socket-udp", "socket-tcp", "socket-raw"] } smoltcp = { git = "https://gitee.com/gcyyfun/smoltcp", rev="043eb60", default-features = false, features = ["alloc","log", "async", "medium-ethernet","proto-ipv4", "proto-igmp", "socket-icmp", "socket-udp", "socket-tcp", "socket-raw"] }
# LibOS mode
[target.'cfg(not(target_os = "none"))'.dependencies] [target.'cfg(not(target_os = "none"))'.dependencies]
async-std = { version = "1.10", optional = true } async-std = { version = "1.10", optional = true }
sdl2 = { version = "0.34", optional = true } sdl2 = { version = "0.34", optional = true }
[target.'cfg(target_os = "none")'.dependencies]
[target.'cfg(target_arch = "x86_64")'.dependencies] [target.'cfg(target_arch = "x86_64")'.dependencies]
acpi = "4.1" acpi = "4.1"
x2apic = "0.4" x2apic = "0.4"

View File

@ -1,6 +1,6 @@
use alloc::{boxed::Box, sync::Arc}; use alloc::{boxed::Box, sync::Arc};
use lock::mutex::Mutex; use lock::Mutex;
use crate::prelude::{CapabilityType, InputEvent, InputEventType}; use crate::prelude::{CapabilityType, InputEvent, InputEventType};
use crate::scheme::{impl_event_scheme, InputScheme}; use crate::scheme::{impl_event_scheme, InputScheme};

View File

@ -1,6 +1,6 @@
use riscv::register::sie; use riscv::register::sie;
// use spin::Mutex; // use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use spin::Once; use spin::Once;
use crate::prelude::IrqHandler; use crate::prelude::IrqHandler;

View File

@ -2,7 +2,7 @@ use core::arch::asm;
use core::ops::Range; use core::ops::Range;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use crate::io::{Io, Mmio}; use crate::io::{Io, Mmio};
use crate::prelude::IrqHandler; use crate::prelude::IrqHandler;

View File

@ -4,7 +4,7 @@ use core::{fmt, ptr::NonNull};
use acpi::platform::interrupt::InterruptModel; use acpi::platform::interrupt::InterruptModel;
use acpi::{AcpiHandler, AcpiTables, PhysicalMapping}; use acpi::{AcpiHandler, AcpiTables, PhysicalMapping};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use x2apic::ioapic::{IoApic as IoApicInner, IrqFlags, IrqMode}; use x2apic::ioapic::{IoApic as IoApicInner, IrqFlags, IrqMode};
use super::{IrqPolarity, IrqTriggerMode, Phys2VirtFn}; use super::{IrqPolarity, IrqTriggerMode, Phys2VirtFn};

View File

@ -5,7 +5,7 @@ mod lapic;
use core::ops::Range; use core::ops::Range;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use self::consts::{X86_INT_BASE, X86_INT_LOCAL_APIC_BASE}; use self::consts::{X86_INT_BASE, X86_INT_LOCAL_APIC_BASE};
use self::ioapic::{IoApic, IoApicList}; use self::ioapic::{IoApic, IoApicList};

View File

@ -2,7 +2,7 @@ use std::collections::VecDeque;
use async_std::{io, io::prelude::*, task}; use async_std::{io, io::prelude::*, task};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use crate::scheme::{impl_event_scheme, Scheme, UartScheme}; use crate::scheme::{impl_event_scheme, Scheme, UartScheme};
use crate::utils::EventListener; use crate::utils::EventListener;

View File

@ -8,7 +8,7 @@ use alloc::string::String;
use spin::Mutex; use spin::Mutex;
// TODO: fix this, should use no-irq lock, but can't pass build of libos // TODO: fix this, should use no-irq lock, but can't pass build of libos
// use lock::mutex::Mutex; // use lock::Mutex;
use crate::scheme::{NetScheme, Scheme}; use crate::scheme::{NetScheme, Scheme};
use crate::{DeviceError, DeviceResult}; use crate::{DeviceError, DeviceResult};

View File

@ -64,7 +64,7 @@ pub use loopback::LoopbackInterface;
use alloc::sync::Arc; use alloc::sync::Arc;
use alloc::vec; use alloc::vec;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use smoltcp::socket::SocketSet; use smoltcp::socket::SocketSet;

View File

@ -4,7 +4,7 @@ use alloc::sync::Arc;
use alloc::vec; use alloc::vec;
use alloc::vec::Vec; use alloc::vec::Vec;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use smoltcp::iface::*; use smoltcp::iface::*;
use smoltcp::phy::{self, Device, DeviceCapabilities, Medium}; use smoltcp::phy::{self, Device, DeviceCapabilities, Medium};

View File

@ -1,7 +1,7 @@
use alloc::{boxed::Box, collections::VecDeque, string::String, sync::Arc}; use alloc::{boxed::Box, collections::VecDeque, string::String, sync::Arc};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use crate::scheme::{impl_event_scheme, Scheme, UartScheme}; use crate::scheme::{impl_event_scheme, Scheme, UartScheme};
use crate::utils::EventListener; use crate::utils::EventListener;

View File

@ -3,7 +3,7 @@ use core::ops::{BitAnd, BitOr, Not};
use bitflags::bitflags; use bitflags::bitflags;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use crate::io::{Io, Mmio, ReadOnly}; use crate::io::{Io, Mmio, ReadOnly};
use crate::scheme::{impl_event_scheme, Scheme, UartScheme}; use crate::scheme::{impl_event_scheme, Scheme, UartScheme};

View File

@ -1,7 +1,7 @@
use alloc::{boxed::Box, vec::Vec}; use alloc::{boxed::Box, vec::Vec};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
pub type EventHandler<T = ()> = Box<dyn Fn(&T) + Send + Sync>; pub type EventHandler<T = ()> = Box<dyn Fn(&T) + Send + Sync>;

View File

@ -1,5 +1,5 @@
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use virtio_drivers::{VirtIOBlk as InnerDriver, VirtIOHeader}; use virtio_drivers::{VirtIOBlk as InnerDriver, VirtIOHeader};
use crate::scheme::{BlockScheme, Scheme}; use crate::scheme::{BlockScheme, Scheme};

View File

@ -1,7 +1,7 @@
use core::fmt::{Result, Write}; use core::fmt::{Result, Write};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use virtio_drivers::{VirtIOConsole as InnerDriver, VirtIOHeader}; use virtio_drivers::{VirtIOConsole as InnerDriver, VirtIOHeader};
use crate::prelude::DeviceResult; use crate::prelude::DeviceResult;

View File

@ -1,5 +1,5 @@
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use virtio_drivers::{VirtIOGpu as InnerDriver, VirtIOHeader}; use virtio_drivers::{VirtIOGpu as InnerDriver, VirtIOHeader};
use crate::prelude::{ColorFormat, DisplayInfo, FrameBuffer}; use crate::prelude::{ColorFormat, DisplayInfo, FrameBuffer};

View File

@ -1,7 +1,7 @@
use core::convert::TryFrom; use core::convert::TryFrom;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use virtio_drivers::{InputConfigSelect, VirtIOHeader, VirtIOInput as InnerDriver}; use virtio_drivers::{InputConfigSelect, VirtIOHeader, VirtIOInput as InnerDriver};
use crate::prelude::{CapabilityType, InputCapability, InputEvent, InputEventType}; use crate::prelude::{CapabilityType, InputCapability, InputEvent, InputEventType};

View File

@ -16,7 +16,6 @@ graphic = ["zcore-drivers/graphic"]
[dependencies] [dependencies]
log = "0.4" log = "0.4"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
cfg-if = "1.0" cfg-if = "1.0"
bitflags = "1.3" bitflags = "1.3"
trapframe = "0.9.0" trapframe = "0.9.0"
@ -33,11 +32,13 @@ nix = { version = "0.23", optional = true }
tempfile = { version = "3", optional = true } tempfile = { version = "3", optional = true }
async-std = { version = "1.10", optional = true } async-std = { version = "1.10", optional = true }
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "b3f9f51", optional = true } bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "b3f9f51", optional = true }
lock = { git = "https://github.com/DeathWish5/kernel-sync", features = ["libos"] }
# Bare-metal mode # Bare-metal mode
[target.'cfg(target_os = "none")'.dependencies] [target.'cfg(target_os = "none")'.dependencies]
executor = { git = "https://github.com/DeathWish5/PreemptiveScheduler" } executor = { git = "https://github.com/DeathWish5/PreemptiveScheduler" }
naive-timer = "0.2.0" naive-timer = "0.2.0"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
# All mode on x86_64 # All mode on x86_64
[target.'cfg(target_arch = "x86_64")'.dependencies] [target.'cfg(target_arch = "x86_64")'.dependencies]

View File

@ -5,7 +5,7 @@ use core::slice;
use riscv::{asm, register::satp}; use riscv::{asm, register::satp};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use crate::utils::page_table::{GenericPTE, PageTableImpl, PageTableLevel3}; use crate::utils::page_table::{GenericPTE, PageTableImpl, PageTableLevel3};
use crate::{mem::phys_to_virt, MMUFlags, PhysAddr, VirtAddr, KCONFIG}; use crate::{mem::phys_to_virt, MMUFlags, PhysAddr, VirtAddr, KCONFIG};

View File

@ -12,7 +12,7 @@ use alloc::sync::Arc;
use alloc::string::String; use alloc::string::String;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use crate::drivers::add_device; use crate::drivers::add_device;
use crate::drivers::all_net; use crate::drivers::all_net;

View File

@ -6,7 +6,7 @@ use core::time::Duration;
use naive_timer::Timer; use naive_timer::Timer;
// use spin::Mutex; // use spin::Mutex;
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use lock::mutex::Mutex; use lock::Mutex;
#[allow(dead_code)] #[allow(dead_code)]
pub(super) const TICKS_PER_SEC: u64 = 100; pub(super) const TICKS_PER_SEC: u64 = 100;

View File

@ -3,7 +3,7 @@
use crate::drivers; use crate::drivers;
use core::fmt::{Arguments, Result, Write}; use core::fmt::{Arguments, Result, Write};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
struct SerialWriter; struct SerialWriter;

View File

@ -4,7 +4,7 @@ use alloc::{sync::Arc, vec::Vec};
use core::convert::From; use core::convert::From;
// use spin::{RwLock, RwLockReadGuard}; // use spin::{RwLock, RwLockReadGuard};
use lock::rwlock::{RwLock, RwLockReadGuard}; use lock::{RwLock, RwLockReadGuard};
use zcore_drivers::scheme::{ use zcore_drivers::scheme::{
BlockScheme, DisplayScheme, InputScheme, IrqScheme, NetScheme, Scheme, UartScheme, BlockScheme, DisplayScheme, InputScheme, IrqScheme, NetScheme, Scheme, UartScheme,

View File

@ -5,7 +5,7 @@ use core::ops::Range;
use bitmap_allocator::BitAlloc; use bitmap_allocator::BitAlloc;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use super::mock_mem::MockMemory; use super::mock_mem::MockMemory;
use crate::{PhysAddr, VirtAddr, PAGE_SIZE}; use crate::{PhysAddr, VirtAddr, PAGE_SIZE};

View File

@ -12,7 +12,7 @@ use alloc::sync::Arc;
use alloc::string::String; use alloc::string::String;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use crate::drivers::add_device; use crate::drivers::add_device;
use crate::drivers::all_net; use crate::drivers::all_net;

View File

@ -7,7 +7,7 @@ use crate::common::vm::*;
use crate::{mem::PhysFrame, MMUFlags, PhysAddr, VirtAddr}; use crate::{mem::PhysFrame, MMUFlags, PhysAddr, VirtAddr};
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
pub trait PageTableLevel: Sync + Send { pub trait PageTableLevel: Sync + Send {
const LEVEL: usize; const LEVEL: usize;

View File

@ -11,7 +11,6 @@ description = "Linux kernel objects"
async-trait = "0.1" async-trait = "0.1"
log = "0.4" log = "0.4"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
xmas-elf = "0.7" xmas-elf = "0.7"
bitflags = "1.3" bitflags = "1.3"
hashbrown = "0.9" hashbrown = "0.9"

View File

@ -3,7 +3,7 @@ use core::task::{Context, Poll};
use core::{any::Any, future::Future, mem::size_of, pin::Pin}; use core::{any::Any, future::Future, mem::size_of, pin::Pin};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use kernel_hal::drivers::prelude::{InputEvent, InputEventType}; use kernel_hal::drivers::prelude::{InputEvent, InputEventType};
use kernel_hal::drivers::scheme::InputScheme; use kernel_hal::drivers::scheme::InputScheme;

View File

@ -3,7 +3,7 @@ use core::task::{Context, Poll};
use core::{any::Any, future::Future, pin::Pin}; use core::{any::Any, future::Future, pin::Pin};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use kernel_hal::drivers::prelude::input::{Mouse, MouseFlags, MouseState}; use kernel_hal::drivers::prelude::input::{Mouse, MouseFlags, MouseState};
use kernel_hal::drivers::scheme::{EventScheme, InputScheme}; use kernel_hal::drivers::scheme::{EventScheme, InputScheme};

View File

@ -6,7 +6,7 @@ use core::any::Any;
use rcore_fs::vfs::*; use rcore_fs::vfs::*;
use rcore_fs_devfs::DevFS; use rcore_fs_devfs::DevFS;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// random INode data struct /// random INode data struct
pub struct RandomINodeData { pub struct RandomINodeData {

View File

@ -2,7 +2,7 @@
use rcore_fs::dev::{Device, Result}; use rcore_fs::dev::{Device, Result};
// use spin::RwLock; // use spin::RwLock;
use lock::rwlock::RwLock; use lock::RwLock;
/// memory buffer for device /// memory buffer for device
pub struct MemBuf(RwLock<&'static mut [u8]>); pub struct MemBuf(RwLock<&'static mut [u8]>);

View File

@ -4,7 +4,7 @@ use alloc::{boxed::Box, string::String, sync::Arc};
use async_trait::async_trait; use async_trait::async_trait;
use spin::RwLock; use spin::RwLock;
// use lock::rwlock::RwLock; // use lock::RwLock;
use rcore_fs::vfs::{FileType, FsError, INode, Metadata, PollStatus}; use rcore_fs::vfs::{FileType, FsError, INode, Metadata, PollStatus};
use zircon_object::object::*; use zircon_object::object::*;

View File

@ -11,7 +11,7 @@ use core::{
}; };
use rcore_fs::vfs::*; use rcore_fs::vfs::*;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]

View File

@ -8,7 +8,7 @@ extern crate rcore_fs;
use kernel_hal::drivers::scheme::BlockScheme; use kernel_hal::drivers::scheme::BlockScheme;
use rcore_fs::dev::{BlockDevice, DevError, Device, Result}; use rcore_fs::dev::{BlockDevice, DevError, Device, Result};
use spin::RwLock; use spin::RwLock;
// use lock::rwlock::RwLock; // use lock::RwLock;
/// A naive LRU cache layer for `BlockDevice`, re-exported from `rcore-fs`. /// A naive LRU cache layer for `BlockDevice`, re-exported from `rcore-fs`.
pub use rcore_fs::dev::block_cache::BlockCache; pub use rcore_fs::dev::block_cache::BlockCache;

View File

@ -14,7 +14,7 @@ use kernel_hal::console::{self, ConsoleWinSize};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use rcore_fs::vfs::*; use rcore_fs::vfs::*;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
lazy_static! { lazy_static! {
/// STDIN global reference /// STDIN global reference

View File

@ -9,7 +9,7 @@ use alloc::collections::BTreeMap;
use alloc::sync::Arc; use alloc::sync::Arc;
use bitflags::*; use bitflags::*;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// Semaphore table in a process /// Semaphore table in a process
#[derive(Default)] #[derive(Default)]

View File

@ -14,7 +14,7 @@ pub mod udp;
pub use udp::*; pub use udp::*;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// missing documentation /// missing documentation
// pub mod raw; // pub mod raw;

View File

@ -16,7 +16,7 @@ use crate::net::TCP_RECVBUF;
use crate::net::TCP_SENDBUF; use crate::net::TCP_SENDBUF;
use alloc::sync::Arc; use alloc::sync::Arc;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
// alloc // alloc
use alloc::boxed::Box; use alloc::boxed::Box;

View File

@ -24,7 +24,7 @@ use crate::net::UDP_METADATA_BUF;
use crate::net::UDP_RECVBUF; use crate::net::UDP_RECVBUF;
use crate::net::UDP_SENDBUF; use crate::net::UDP_SENDBUF;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
// alloc // alloc
use alloc::boxed::Box; use alloc::boxed::Box;

View File

@ -10,7 +10,7 @@ use core::{
task::{Context, Poll}, task::{Context, Poll},
}; };
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]

View File

@ -12,7 +12,7 @@ use core::ops::Deref;
use core::pin::Pin; use core::pin::Pin;
use core::task::{Context, Poll}; use core::task::{Context, Poll};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// A counting, blocking, semaphore. /// A counting, blocking, semaphore.
pub struct Semaphore { pub struct Semaphore {

View File

@ -10,7 +10,6 @@ description = "Linux syscalls implementation"
[dependencies] [dependencies]
log = "0.4" log = "0.4"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
bitflags = "1.3" bitflags = "1.3"
numeric-enum-macro = "0.2" numeric-enum-macro = "0.2"
zircon-object = { path = "../zircon-object" } zircon-object = { path = "../zircon-object" }
@ -19,3 +18,11 @@ kernel-hal = { path = "../kernel-hal", default-features = false }
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec" } rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec" }
lazy_static = { version = "1.4", features = ["spin_no_std"] } lazy_static = { version = "1.4", features = ["spin_no_std"] }
bitvec = { version = "0.22", default-features = false, features = ["alloc"] } bitvec = { version = "0.22", default-features = false, features = ["alloc"] }
# LibOS mode
[target.'cfg(not(target_os = "none"))'.dependencies]
lock = { git = "https://github.com/DeathWish5/kernel-sync", features = ["libos"] }
# Bare-metal mode
[target.'cfg(target_os = "none")'.dependencies]
lock = { git = "https://github.com/DeathWish5/kernel-sync" }

View File

@ -7,7 +7,7 @@ use linux_object::net::TcpSocketState;
use linux_object::net::UdpSocketState; use linux_object::net::UdpSocketState;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
impl Syscall<'_> { impl Syscall<'_> {
/// net socket /// net socket

View File

@ -45,7 +45,6 @@ board-d1 = ["link-user-img"]
[dependencies] [dependencies]
log = "0.4" log = "0.4"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
cfg-if = "1.0" cfg-if = "1.0"
lazy_static = { version = "1.4", features = ["spin_no_std" ] } lazy_static = { version = "1.4", features = ["spin_no_std" ] }
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "b3f9f51" } bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "b3f9f51" }
@ -61,11 +60,13 @@ rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec",
async-std = { version = "1.10", optional = true } async-std = { version = "1.10", optional = true }
chrono = { version = "0.4", optional = true } chrono = { version = "0.4", optional = true }
rcore-fs-hostfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec", optional = true } rcore-fs-hostfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7c232ec", optional = true }
lock = { git = "https://github.com/DeathWish5/kernel-sync", features = ["libos"]}
# Bare-metal mode # Bare-metal mode
[target.'cfg(target_os = "none")'.dependencies] [target.'cfg(target_os = "none")'.dependencies]
buddy_system_allocator = "0.7" buddy_system_allocator = "0.7"
executor = { git = "https://github.com/DeathWish5/PreemptiveScheduler" } executor = { git = "https://github.com/DeathWish5/PreemptiveScheduler" }
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
# Bare-metal mode on x86_64 # Bare-metal mode on x86_64
[target.'cfg(all(target_os = "none", target_arch = "x86_64"))'.dependencies] [target.'cfg(all(target_os = "none", target_arch = "x86_64"))'.dependencies]

View File

@ -5,7 +5,7 @@ use core::ops::Range;
use bitmap_allocator::BitAlloc; use bitmap_allocator::BitAlloc;
use kernel_hal::PhysAddr; use kernel_hal::PhysAddr;
// use spin::Mutex; // use spin::Mutex;
use lock::mutex::Mutex; use lock::Mutex;
use super::platform::consts::*; use super::platform::consts::*;

View File

@ -15,7 +15,6 @@ elf = ["xmas-elf"]
[dependencies] [dependencies]
bitflags = "1.3" bitflags = "1.3"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
log = "0.4" log = "0.4"
hashbrown = "0.9" hashbrown = "0.9"
downcast-rs = { version = "1.2", default-features = false } downcast-rs = { version = "1.2", default-features = false }
@ -30,3 +29,11 @@ cfg-if = "1.0"
[dev-dependencies] [dev-dependencies]
async-std = { version = "1.10", features = ["attributes", "unstable"] } async-std = { version = "1.10", features = ["attributes", "unstable"] }
# LibOS mode
[target.'cfg(not(target_os = "none"))'.dependencies]
lock = { git = "https://github.com/DeathWish5/kernel-sync", features = ["libos"] }
# Bare-metal mode
[target.'cfg(target_os = "none")'.dependencies]
lock = { git = "https://github.com/DeathWish5/kernel-sync" }

View File

@ -5,7 +5,7 @@ use {
alloc::{sync::Arc, vec::Vec}, alloc::{sync::Arc, vec::Vec},
lazy_static::lazy_static, lazy_static::lazy_static,
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
lazy_static! { lazy_static! {

View File

@ -5,7 +5,7 @@ use {
alloc::{sync::Arc, vec::Vec}, alloc::{sync::Arc, vec::Vec},
dev::Iommu, dev::Iommu,
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
/// Bus Transaction Initiator. /// Bus Transaction Initiator.

View File

@ -2,7 +2,7 @@ use kernel_hal::interrupt;
use { use {
super::*, super::*,
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
pub struct EventInterrupt { pub struct EventInterrupt {

View File

@ -8,7 +8,7 @@ use {
alloc::{boxed::Box, sync::Arc}, alloc::{boxed::Box, sync::Arc},
bitflags::bitflags, bitflags::bitflags,
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
mod event_interrupt; mod event_interrupt;

View File

@ -1,6 +1,6 @@
use alloc::{boxed::Box, sync::Arc}; use alloc::{boxed::Box, sync::Arc};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use super::InterruptTrait; use super::InterruptTrait;
use crate::dev::pci::{constants::PCIE_IRQRET_MASK, IPciNode}; use crate::dev::pci::{constants::PCIE_IRQRET_MASK, IPciNode};

View File

@ -18,7 +18,7 @@ use core::marker::{Send, Sync};
use lazy_static::*; use lazy_static::*;
use region_alloc::RegionAllocator; use region_alloc::RegionAllocator;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// PCIE Bus Driver. /// PCIE Bus Driver.
pub struct PCIeBusDriver { pub struct PCIeBusDriver {

View File

@ -5,7 +5,7 @@ use alloc::boxed::Box;
use core::convert::TryFrom; use core::convert::TryFrom;
use kernel_hal::interrupt; use kernel_hal::interrupt;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// Enumeration for PCI capabilities. /// Enumeration for PCI capabilities.
#[derive(Debug)] #[derive(Debug)]

View File

@ -14,7 +14,7 @@ cfg_if::cfg_if! {
if #[cfg(all(target_arch = "x86_64", target_os = "none"))] { if #[cfg(all(target_arch = "x86_64", target_os = "none"))] {
use kernel_hal::x86_64::{Io, Pio}; use kernel_hal::x86_64::{Io, Pio};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
static PIO_LOCK: Mutex<()> = Mutex::new(()); static PIO_LOCK: Mutex<()> = Mutex::new(());
const PCI_CONFIG_ADDR: u16 = 0xcf8; const PCI_CONFIG_ADDR: u16 = 0xcf8;

View File

@ -9,7 +9,7 @@ use {
core::convert::TryInto, core::convert::TryInto,
rvm::{self, Vcpu as VcpuInner}, rvm::{self, Vcpu as VcpuInner},
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
/// Virtual CPU within a Guest, which allows for execution within the virtual machine. /// Virtual CPU within a Guest, which allows for execution within the virtual machine.

View File

@ -8,7 +8,7 @@ use {
futures::channel::oneshot::{self, Sender}, futures::channel::oneshot::{self, Sender},
hashbrown::HashMap, hashbrown::HashMap,
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
/// Bidirectional interprocess communication /// Bidirectional interprocess communication

View File

@ -3,7 +3,7 @@ use {
alloc::collections::VecDeque, alloc::collections::VecDeque,
alloc::sync::{Arc, Weak}, alloc::sync::{Arc, Weak},
spin::Mutex, spin::Mutex,
// lock::mutex::Mutex, // lock::Mutex,
}; };
/// First-In First-Out inter-process queue. /// First-In First-Out inter-process queue.

View File

@ -3,7 +3,7 @@ use {
alloc::collections::VecDeque, alloc::collections::VecDeque,
alloc::sync::{Arc, Weak}, alloc::sync::{Arc, Weak},
bitflags::bitflags, bitflags::bitflags,
// lock::mutex::Mutex, // lock::Mutex,
spin::Mutex, spin::Mutex,
}; };

View File

@ -105,7 +105,7 @@ use {
task::{Context, Poll}, task::{Context, Poll},
}, },
downcast_rs::{impl_downcast, DowncastSync}, downcast_rs::{impl_downcast, DowncastSync},
// lock::mutex::Mutex, // lock::Mutex,
spin::Mutex, spin::Mutex,
}; };

View File

@ -7,7 +7,7 @@ use core::pin::Pin;
use core::sync::atomic::*; use core::sync::atomic::*;
use core::task::{Context, Poll, Waker}; use core::task::{Context, Poll, Waker};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// A primitive for creating userspace synchronization tools. /// A primitive for creating userspace synchronization tools.
/// ///

View File

@ -5,7 +5,7 @@ use alloc::collections::{BTreeSet, VecDeque};
use alloc::sync::Arc; use alloc::sync::Arc;
use bitflags::bitflags; use bitflags::bitflags;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
#[path = "port_packet.rs"] #[path = "port_packet.rs"]
mod port_packet; mod port_packet;

View File

@ -4,7 +4,7 @@ use alloc::boxed::Box;
use alloc::sync::Arc; use alloc::sync::Arc;
use core::time::Duration; use core::time::Duration;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
/// An object that may be signaled at some point in the future /// An object that may be signaled at some point in the future
/// ///

View File

@ -4,7 +4,7 @@ use core::mem::size_of;
use futures::channel::oneshot; use futures::channel::oneshot;
use kernel_hal::context::{TrapReason, UserContext}; use kernel_hal::context::{TrapReason, UserContext};
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use super::{Job, Task, Thread}; use super::{Job, Task, Thread};
use crate::ipc::{Channel, MessagePacket}; use crate::ipc::{Channel, MessagePacket};

View File

@ -6,7 +6,7 @@ use {
crate::task::Task, crate::task::Task,
alloc::sync::{Arc, Weak}, alloc::sync::{Arc, Weak},
alloc::vec::Vec, alloc::vec::Vec,
// lock::mutex::Mutex, // lock::Mutex,
spin::Mutex, spin::Mutex,
}; };

View File

@ -4,7 +4,7 @@ use core::{any::Any, sync::atomic::AtomicI32};
use futures::channel::oneshot::{self, Receiver, Sender}; use futures::channel::oneshot::{self, Receiver, Sender};
use hashbrown::HashMap; use hashbrown::HashMap;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use super::exception::{ExceptionChannelType, Exceptionate}; use super::exception::{ExceptionChannelType, Exceptionate};
use super::job_policy::{JobPolicy, PolicyAction, PolicyCondition}; use super::job_policy::{JobPolicy, PolicyAction, PolicyCondition};

View File

@ -11,7 +11,7 @@ use bitflags::bitflags;
use futures::{channel::oneshot::*, future::FutureExt, pin_mut, select_biased}; use futures::{channel::oneshot::*, future::FutureExt, pin_mut, select_biased};
use kernel_hal::context::UserContext; use kernel_hal::context::UserContext;
use spin::Mutex; use spin::Mutex;
// use lock::mutex::Mutex; // use lock::Mutex;
use self::thread_state::ContextAccessState; use self::thread_state::ContextAccessState;
use super::{exception::*, Process, Task}; use super::{exception::*, Process, Task};

View File

@ -3,7 +3,7 @@ use {
crate::object::*, crate::object::*,
alloc::sync::Arc, alloc::sync::Arc,
numeric_enum_macro::numeric_enum, numeric_enum_macro::numeric_enum,
// lock::mutex::Mutex, // lock::Mutex,
spin::Mutex, spin::Mutex,
}; };

View File

@ -6,7 +6,7 @@ use {
kernel_hal::vm::{ kernel_hal::vm::{
GenericPageTable, IgnoreNotMappedErr, Page, PageSize, PageTable, PagingError, PagingResult, GenericPageTable, IgnoreNotMappedErr, Page, PageSize, PageTable, PagingError, PagingResult,
}, },
lock::mutex::Mutex, lock::Mutex,
// spin::Mutex, // spin::Mutex,
}; };

View File

@ -9,7 +9,7 @@ use {
bitflags::bitflags, bitflags::bitflags,
core::ops::Deref, core::ops::Deref,
kernel_hal::CachePolicy, kernel_hal::CachePolicy,
// lock::mutex::Mutex, // lock::Mutex,
spin::Mutex, spin::Mutex,
}; };

View File

@ -1,7 +1,7 @@
use { use {
super::*, super::*,
alloc::sync::Arc, alloc::sync::Arc,
lock::mutex::Mutex, lock::Mutex,
// spin::Mutex, // spin::Mutex,
}; };

View File

@ -14,10 +14,17 @@ deny-page-fault = []
[dependencies] [dependencies]
log = "0.4" log = "0.4"
spin = "0.9" spin = "0.9"
lock = { git = "https://github.com/DeathWish5/kernel-sync" }
bitflags = "1.3" bitflags = "1.3"
numeric-enum-macro = "0.2" numeric-enum-macro = "0.2"
zircon-object = { path = "../zircon-object" } zircon-object = { path = "../zircon-object" }
kernel-hal = { path = "../kernel-hal", default-features = false } kernel-hal = { path = "../kernel-hal", default-features = false }
futures = { version = "0.3", default-features = false, features = ["alloc", "async-await"] } futures = { version = "0.3", default-features = false, features = ["alloc", "async-await"] }
cfg-if = "1.0" cfg-if = "1.0"
# LibOS mode
[target.'cfg(not(target_os = "none"))'.dependencies]
lock = { git = "https://github.com/DeathWish5/kernel-sync", features = ["libos"] }
# Bare-metal mode
[target.'cfg(target_os = "none")'.dependencies]
lock = { git = "https://github.com/DeathWish5/kernel-sync" }

View File

@ -1,7 +1,7 @@
use { use {
super::*, super::*,
alloc::{string::String, vec::Vec}, alloc::{string::String, vec::Vec},
// lock::mutex::Mutex, // lock::Mutex,
spin::Mutex, spin::Mutex,
zircon_object::{ zircon_object::{
ipc::{Channel, MessagePacket}, ipc::{Channel, MessagePacket},