mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 19:03:27 +00:00
Adjust the format of imports in Asterinas
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
92e488e727
commit
cfcef6965a
@ -1,15 +1,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
use super::{id::Sid, BlockDevice};
|
||||
|
||||
use aster_frame::{
|
||||
sync::WaitQueue,
|
||||
vm::{VmFrame, VmReader, VmSegment, VmWriter},
|
||||
};
|
||||
use int_to_c_enum::TryFromInt;
|
||||
|
||||
use super::{id::Sid, BlockDevice};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// The unit for block I/O.
|
||||
///
|
||||
/// Each `Bio` packs the following information:
|
||||
|
@ -4,6 +4,7 @@ use core::{
|
||||
iter::Step,
|
||||
ops::{Add, Sub},
|
||||
};
|
||||
|
||||
use pod::Pod;
|
||||
use static_assertions::const_assert;
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::prelude::*;
|
||||
use aster_frame::vm::{VmAllocOptions, VmFrame, VmIo, VmSegment};
|
||||
|
||||
use super::{
|
||||
bio::{Bio, BioEnqueueError, BioSegment, BioStatus, BioType, BioWaiter, SubmittedBio},
|
||||
id::{Bid, Sid},
|
||||
BlockDevice, BLOCK_SIZE, SECTOR_SIZE,
|
||||
};
|
||||
|
||||
use aster_frame::vm::{VmAllocOptions, VmFrame, VmIo, VmSegment};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Implements several commonly used APIs for the block device to conveniently
|
||||
/// read and write block(s).
|
||||
|
@ -40,15 +40,15 @@ mod impl_block_device;
|
||||
mod prelude;
|
||||
pub mod request_queue;
|
||||
|
||||
use self::bio::{BioEnqueueError, SubmittedBio};
|
||||
use self::prelude::*;
|
||||
|
||||
use aster_frame::sync::SpinLock;
|
||||
use component::init_component;
|
||||
use component::ComponentInitError;
|
||||
|
||||
use component::{init_component, ComponentInitError};
|
||||
use spin::Once;
|
||||
|
||||
use self::{
|
||||
bio::{BioEnqueueError, SubmittedBio},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub const BLOCK_SIZE: usize = aster_frame::config::PAGE_SIZE;
|
||||
pub const SECTOR_SIZE: usize = 512;
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
pub(crate) use alloc::collections::{BTreeMap, VecDeque};
|
||||
pub(crate) use alloc::string::String;
|
||||
pub(crate) use alloc::sync::Arc;
|
||||
pub(crate) use alloc::vec;
|
||||
pub(crate) use alloc::vec::Vec;
|
||||
pub(crate) use core::any::Any;
|
||||
pub(crate) use core::fmt::Debug;
|
||||
pub(crate) use core::ops::Range;
|
||||
pub(crate) use core::sync::atomic::{AtomicU32, AtomicUsize, Ordering};
|
||||
pub(crate) use alloc::{
|
||||
collections::{BTreeMap, VecDeque},
|
||||
string::String,
|
||||
sync::Arc,
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
pub(crate) use core::{
|
||||
any::Any,
|
||||
fmt::Debug,
|
||||
ops::Range,
|
||||
sync::atomic::{AtomicU32, AtomicUsize, Ordering},
|
||||
};
|
||||
|
@ -1,13 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::prelude::*;
|
||||
use aster_frame::sync::{Mutex, WaitQueue};
|
||||
|
||||
use super::{
|
||||
bio::{BioEnqueueError, BioType, SubmittedBio},
|
||||
id::Sid,
|
||||
};
|
||||
|
||||
use aster_frame::sync::{Mutex, WaitQueue};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// A simple block I/O request queue backed by one internal FIFO queue.
|
||||
///
|
||||
|
@ -8,12 +8,13 @@
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use aster_frame::{boot, config::PAGE_SIZE, io_mem::IoMem, sync::SpinLock, vm::VmIo};
|
||||
use component::{init_component, ComponentInitError};
|
||||
use core::{
|
||||
fmt,
|
||||
ops::{Index, IndexMut},
|
||||
};
|
||||
|
||||
use aster_frame::{boot, config::PAGE_SIZE, io_mem::IoMem, sync::SpinLock, vm::VmIo};
|
||||
use component::{init_component, ComponentInitError};
|
||||
use font8x8::UnicodeFonts;
|
||||
use spin::Once;
|
||||
|
||||
|
@ -9,22 +9,14 @@ extern crate alloc;
|
||||
|
||||
pub mod key;
|
||||
|
||||
use core::any::Any;
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::vec::Vec;
|
||||
use component::init_component;
|
||||
use component::ComponentInitError;
|
||||
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};
|
||||
use core::{any::Any, fmt::Debug};
|
||||
|
||||
use aster_frame::sync::SpinLock;
|
||||
use component::{init_component, ComponentInitError};
|
||||
use key::{Key, KeyStatus};
|
||||
use spin::Once;
|
||||
|
||||
use key::Key;
|
||||
use key::KeyStatus;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum InputEvent {
|
||||
KeyBoard(Key, KeyStatus),
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::vec;
|
||||
|
||||
use smoltcp::{phy, time::Instant};
|
||||
|
||||
use crate::{
|
||||
|
@ -10,19 +10,13 @@ pub mod driver;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, vec::Vec};
|
||||
use core::{any::Any, fmt::Debug};
|
||||
|
||||
use aster_frame::sync::SpinLock;
|
||||
use aster_util::safe_ptr::Pod;
|
||||
use buffer::RxBuffer;
|
||||
use buffer::TxBuffer;
|
||||
use component::init_component;
|
||||
use component::ComponentInitError;
|
||||
use core::any::Any;
|
||||
use core::fmt::Debug;
|
||||
use buffer::{RxBuffer, TxBuffer};
|
||||
use component::{init_component, ComponentInitError};
|
||||
use smoltcp::phy;
|
||||
use spin::Once;
|
||||
|
||||
|
@ -8,9 +8,10 @@
|
||||
//! It can be integrated into larger systems to provide timing capabilities, or used standalone for time tracking and elapsed time measurements.
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use core::{cmp::max, ops::Add, time::Duration};
|
||||
|
||||
use aster_frame::sync::SpinLock;
|
||||
use aster_util::coeff::Coeff;
|
||||
use core::{cmp::max, ops::Add, time::Duration};
|
||||
|
||||
use crate::NANOS_PER_SECOND;
|
||||
|
||||
|
@ -7,15 +7,14 @@
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use aster_frame::sync::Mutex;
|
||||
use component::{init_component, ComponentInitError};
|
||||
use core::{sync::atomic::Ordering::Relaxed, time::Duration};
|
||||
use spin::Once;
|
||||
|
||||
use aster_frame::sync::Mutex;
|
||||
use clocksource::ClockSource;
|
||||
use rtc::{get_cmos, is_updating, CENTURY_REGISTER};
|
||||
|
||||
pub use clocksource::Instant;
|
||||
use component::{init_component, ComponentInitError};
|
||||
use rtc::{get_cmos, is_updating, CENTURY_REGISTER};
|
||||
use spin::Once;
|
||||
|
||||
mod clocksource;
|
||||
mod rtc;
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::sync::atomic::{AtomicU8, Ordering::Relaxed};
|
||||
|
||||
use aster_frame::arch::x86::device::cmos::{get_century_register, CMOS_ADDRESS, CMOS_DATA};
|
||||
use core::sync::atomic::AtomicU8;
|
||||
use core::sync::atomic::Ordering::Relaxed;
|
||||
|
||||
pub(crate) static CENTURY_REGISTER: AtomicU8 = AtomicU8::new(0);
|
||||
|
||||
|
@ -4,13 +4,18 @@
|
||||
//!
|
||||
//! Use `init` to initialize this module.
|
||||
use alloc::sync::Arc;
|
||||
use aster_frame::arch::{read_tsc, x86::tsc_freq};
|
||||
use aster_frame::timer::Timer;
|
||||
use core::time::Duration;
|
||||
|
||||
use aster_frame::{
|
||||
arch::{read_tsc, x86::tsc_freq},
|
||||
timer::Timer,
|
||||
};
|
||||
use spin::Once;
|
||||
|
||||
use crate::clocksource::{ClockSource, Instant};
|
||||
use crate::{START_TIME, VDSO_DATA_UPDATE};
|
||||
use crate::{
|
||||
clocksource::{ClockSource, Instant},
|
||||
START_TIME, VDSO_DATA_UPDATE,
|
||||
};
|
||||
|
||||
/// A instance of TSC clocksource.
|
||||
pub static CLOCK: Once<Arc<ClockSource>> = Once::new();
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, string::ToString, sync::Arc, vec::Vec};
|
||||
use core::{fmt::Debug, hint::spin_loop, mem::size_of};
|
||||
|
||||
use alloc::{boxed::Box, string::ToString, sync::Arc, vec::Vec};
|
||||
use aster_block::{
|
||||
bio::{BioEnqueueError, BioStatus, BioType, SubmittedBio},
|
||||
id::Sid,
|
||||
@ -18,15 +18,16 @@ use aster_util::safe_ptr::SafePtr;
|
||||
use log::info;
|
||||
use pod::Pod;
|
||||
|
||||
use super::{BlockFeatures, VirtioBlockConfig};
|
||||
use crate::{
|
||||
device::block::{ReqType, RespStatus},
|
||||
device::VirtioDeviceError,
|
||||
device::{
|
||||
block::{ReqType, RespStatus},
|
||||
VirtioDeviceError,
|
||||
},
|
||||
queue::VirtQueue,
|
||||
transport::VirtioTransport,
|
||||
};
|
||||
|
||||
use super::{BlockFeatures, VirtioBlockConfig};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BlockDevice {
|
||||
device: DeviceInner,
|
||||
|
@ -1,21 +1,20 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, fmt::Debug, string::ToString, sync::Arc, vec::Vec};
|
||||
use core::hint::spin_loop;
|
||||
|
||||
use alloc::{boxed::Box, fmt::Debug, string::ToString, sync::Arc, vec::Vec};
|
||||
use aster_console::{AnyConsoleDevice, ConsoleCallback};
|
||||
use aster_frame::{config::PAGE_SIZE, io_mem::IoMem, sync::SpinLock, trap::TrapFrame};
|
||||
use aster_util::safe_ptr::SafePtr;
|
||||
use log::debug;
|
||||
|
||||
use super::{config::VirtioConsoleConfig, DEVICE_NAME};
|
||||
use crate::{
|
||||
device::{console::config::ConsoleFeatures, VirtioDeviceError},
|
||||
queue::VirtQueue,
|
||||
transport::VirtioTransport,
|
||||
};
|
||||
|
||||
use super::{config::VirtioConsoleConfig, DEVICE_NAME};
|
||||
|
||||
pub struct ConsoleDevice {
|
||||
config: SafePtr<VirtioConsoleConfig, IoMem>,
|
||||
transport: Box<dyn VirtioTransport>,
|
||||
|
@ -1,14 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::fmt::Debug;
|
||||
|
||||
use crate::{device::VirtioDeviceError, queue::VirtQueue, transport::VirtioTransport};
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
string::{String, ToString},
|
||||
sync::Arc,
|
||||
vec::Vec,
|
||||
};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use aster_frame::{io_mem::IoMem, offset_of, sync::SpinLock, trap::TrapFrame};
|
||||
use aster_input::{
|
||||
key::{Key, KeyStatus},
|
||||
@ -20,6 +19,7 @@ use log::{debug, info};
|
||||
use pod::Pod;
|
||||
|
||||
use super::{InputConfigSelect, VirtioInputConfig, VirtioInputEvent, QUEUE_EVENT, QUEUE_STATUS};
|
||||
use crate::{device::VirtioDeviceError, queue::VirtQueue, transport::VirtioTransport};
|
||||
|
||||
bitflags! {
|
||||
/// The properties of input device.
|
||||
|
@ -27,11 +27,12 @@
|
||||
//
|
||||
|
||||
pub mod device;
|
||||
use crate::transport::VirtioTransport;
|
||||
use aster_frame::io_mem::IoMem;
|
||||
use aster_util::safe_ptr::SafePtr;
|
||||
use pod::Pod;
|
||||
|
||||
use crate::transport::VirtioTransport;
|
||||
|
||||
pub static DEVICE_NAME: &str = "Virtio-Input";
|
||||
|
||||
/// Select value used for [`VirtIOInput::query_config_select()`].
|
||||
|
@ -1,8 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::queue::QueueError;
|
||||
use int_to_c_enum::TryFromInt;
|
||||
|
||||
use crate::queue::QueueError;
|
||||
|
||||
pub mod block;
|
||||
pub mod console;
|
||||
pub mod input;
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, string::ToString, sync::Arc, vec::Vec};
|
||||
use core::{fmt::Debug, hint::spin_loop, mem::size_of};
|
||||
|
||||
use alloc::{boxed::Box, string::ToString, sync::Arc, vec::Vec};
|
||||
use aster_frame::{offset_of, sync::SpinLock, trap::TrapFrame};
|
||||
use aster_network::{
|
||||
buffer::{RxBuffer, TxBuffer},
|
||||
@ -13,14 +13,13 @@ use log::debug;
|
||||
use pod::Pod;
|
||||
use smoltcp::phy::{DeviceCapabilities, Medium};
|
||||
|
||||
use super::{config::VirtioNetConfig, header::VirtioNetHdr};
|
||||
use crate::{
|
||||
device::{network::config::NetworkFeatures, VirtioDeviceError},
|
||||
queue::{QueueError, VirtQueue},
|
||||
transport::VirtioTransport,
|
||||
};
|
||||
|
||||
use super::{config::VirtioNetConfig, header::VirtioNetHdr};
|
||||
|
||||
pub struct NetworkDevice {
|
||||
config: VirtioNetConfig,
|
||||
mac_addr: EthernetAddr,
|
||||
|
@ -8,11 +8,10 @@
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use component::init_component;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use component::ComponentInitError;
|
||||
use component::{init_component, ComponentInitError};
|
||||
use device::{
|
||||
block::device::BlockDevice, console::device::ConsoleDevice, input::device::InputDevice,
|
||||
network::device::NetworkDevice, VirtioDeviceType,
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
//! Virtqueue
|
||||
|
||||
use crate::transport::VirtioTransport;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::{
|
||||
mem::size_of,
|
||||
sync::atomic::{fence, Ordering},
|
||||
};
|
||||
|
||||
use aster_frame::{
|
||||
io_mem::IoMem,
|
||||
offset_of,
|
||||
@ -13,13 +16,11 @@ use aster_frame::{
|
||||
use aster_rights::{Dup, TRightSet, TRights, Write};
|
||||
use aster_util::{field_ptr, safe_ptr::SafePtr};
|
||||
use bitflags::bitflags;
|
||||
use core::{
|
||||
mem::size_of,
|
||||
sync::atomic::{fence, Ordering},
|
||||
};
|
||||
use log::debug;
|
||||
use pod::Pod;
|
||||
|
||||
use crate::transport::VirtioTransport;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum QueueError {
|
||||
InvalidArgs,
|
||||
|
@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, sync::Arc};
|
||||
use core::mem::size_of;
|
||||
|
||||
use aster_frame::{
|
||||
bus::mmio::{
|
||||
bus::MmioDevice,
|
||||
@ -15,17 +17,15 @@ use aster_frame::{
|
||||
};
|
||||
use aster_rights::{ReadOp, WriteOp};
|
||||
use aster_util::{field_ptr, safe_ptr::SafePtr};
|
||||
use core::mem::size_of;
|
||||
use log::warn;
|
||||
|
||||
use super::{layout::VirtioMmioLayout, multiplex::MultiplexIrq};
|
||||
use crate::{
|
||||
queue::{AvailRing, Descriptor, UsedRing},
|
||||
transport::{DeviceStatus, VirtioTransport, VirtioTransportError},
|
||||
VirtioDeviceType,
|
||||
};
|
||||
|
||||
use super::{layout::VirtioMmioLayout, multiplex::MultiplexIrq};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VirtioMmioDevice {
|
||||
device_id: u32,
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
|
||||
use aster_frame::{
|
||||
bus::{
|
||||
mmio::{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use aster_frame::bus::mmio::MMIO_BUS;
|
||||
use spin::Once;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||
use aster_frame::{
|
||||
io_mem::IoMem,
|
||||
sync::RwLock,
|
||||
|
@ -1,18 +1,17 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use aster_frame::{io_mem::IoMem, trap::IrqCallbackFunction, vm::DmaCoherent};
|
||||
use aster_util::safe_ptr::SafePtr;
|
||||
|
||||
use self::{mmio::virtio_mmio_init, pci::virtio_pci_init};
|
||||
use crate::{
|
||||
queue::{AvailRing, Descriptor, UsedRing},
|
||||
VirtioDeviceType,
|
||||
};
|
||||
|
||||
use self::{mmio::virtio_mmio_init, pci::virtio_pci_init};
|
||||
|
||||
pub mod mmio;
|
||||
pub mod pci;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use aster_frame::bus::pci::{
|
||||
capability::vendor::CapabilityVndrData,
|
||||
cfg_space::{Bar, IoBar, MemoryBar},
|
||||
|
@ -4,9 +4,8 @@ use aster_frame::io_mem::IoMem;
|
||||
use aster_util::safe_ptr::SafePtr;
|
||||
use pod::Pod;
|
||||
|
||||
use crate::transport::pci::capability::VirtioPciCpabilityType;
|
||||
|
||||
use super::capability::VirtioPciCapabilityData;
|
||||
use crate::transport::pci::capability::VirtioPciCpabilityType;
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, Pod)]
|
||||
#[repr(C)]
|
||||
|
@ -1,5 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, sync::Arc};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use aster_frame::{
|
||||
bus::{
|
||||
pci::{
|
||||
@ -12,10 +15,7 @@ use aster_frame::{
|
||||
trap::IrqCallbackFunction,
|
||||
vm::DmaCoherent,
|
||||
};
|
||||
|
||||
use alloc::{boxed::Box, sync::Arc};
|
||||
use aster_util::{field_ptr, safe_ptr::SafePtr};
|
||||
use core::fmt::Debug;
|
||||
use log::{info, warn};
|
||||
|
||||
use super::{common_cfg::VirtioPciCommonCfg, msix::VirtioMsixManager};
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
|
||||
use aster_frame::{
|
||||
bus::{
|
||||
pci::{
|
||||
|
@ -7,6 +7,7 @@ pub mod driver;
|
||||
pub(super) mod msix;
|
||||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use aster_frame::bus::pci::PCI_BUS;
|
||||
use spin::Once;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use aster_frame::{bus::pci::capability::msix::CapabilityMsixData, trap::IrqLine};
|
||||
|
||||
pub struct VirtioMsixManager {
|
||||
|
Reference in New Issue
Block a user