data_type
large_stringclasses
3 values
source
large_stringclasses
29 values
code
large_stringlengths
98
49.4M
filepath
large_stringlengths
5
161
message
large_stringclasses
234 values
commit
large_stringclasses
234 values
subject
large_stringclasses
418 values
critique
large_stringlengths
101
1.26M
metadata
dict
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The PCI configuration space. //! //! Reference: <https://wiki.osdev.org/PCI> use alloc::sync::Arc; use bitflags::bitflags; use ostd::{ Error, Result, arch::device::io_port::{PortRead, PortWrite}, io::IoMem, mm::{PodOnce, VmIoOnce}, }; use spin::Once; use super...
kernel/comps/pci/src/cfg_space.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! PCI device common definitions or functions. use alloc::vec::Vec; use super::{ capability::Capability, cfg_space::{AddrLen, Bar, Command, Status}, device_info::PciDeviceId, }; use crate::{ cfg_space::{PciBridgeCfgOffset, PciCommonCfgOffset}, device_info::Pci...
kernel/comps/pci/src/common_device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! PCI device Information use crate::cfg_space::PciCommonCfgOffset; /// PCI device location. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct PciDeviceLocation { /// Bus number pub bus: u8, /// Device number with max 31 pub device: u8, ...
kernel/comps/pci/src/device_info.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The PCI bus of Asterinas. //! //! Users can implement the bus under the `PciDriver` to register devices to //! the PCI bus. When the physical device and the driver match successfully, it //! will be provided through the driver's `construct` function to construct a //! structure ...
kernel/comps/pci/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! PCI bus access use core::{alloc::Layout, ops::RangeInclusive}; use align_ext::AlignExt; use fdt::node::FdtNode; use log::warn; use ostd::{ Error, arch::boot::DEVICE_TREE, io::IoMem, mm::VmIoOnce, prelude::Paddr, sync::SpinLock, }; use spin::Once; use crate::PciDeviceLocat...
kernel/comps/pci/src/arch/loongarch/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! PCI bus access use core::ops::RangeInclusive; use log::warn; use ostd::{Error, arch::boot::DEVICE_TREE, io::IoMem, mm::VmIoOnce}; use spin::Once; use crate::PciDeviceLocation; static PCI_ECAM_CFG_SPACE: Once<IoMem> = Once::new(); pub(crate) fn write32(location: &PciDeviceLo...
kernel/comps/pci/src/arch/riscv/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! PCI bus access use core::ops::RangeInclusive; use ostd::{ Error, arch::{ device::io_port::{ReadWriteAccess, WriteOnlyAccess}, kernel::ACPI_INFO, }, io::{IoMem, IoPort}, mm::VmIoOnce, sync::SpinLock, }; use spin::Once; use crate::device_...
kernel/comps/pci/src/arch/x86/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! PCI device capabilities. use alloc::vec::Vec; use align_ext::AlignExt; use self::{msix::CapabilityMsixData, vendor::CapabilityVndrData}; use super::{cfg_space::Status, common_device::PciCommonDevice}; use crate::cfg_space::PciGeneralDeviceCfgOffset; pub mod msix; pub mod ven...
kernel/comps/pci/src/capability/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! MSI-X capability support. use alloc::{sync::Arc, vec::Vec}; use ostd::{irq::IrqLine, mm::VmIoOnce}; use crate::{ PciDeviceLocation, arch::{MSIX_DEFAULT_MSG_ADDR, construct_remappable_msix_address}, cfg_space::{Bar, Command, MemoryBar}, common_device::PciCommon...
kernel/comps/pci/src/capability/msix.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Vendor-specific capability support. use ostd::{Error, Result}; use crate::{PciDeviceLocation, common_device::PciCommonDevice}; /// Vendor specific capability. Users can access this capability area at will, /// except for the PCI configuration space which cannot be accessed at...
kernel/comps/pci/src/capability/vendor.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Software interrupt. #![no_std] #![deny(unsafe_code)] extern crate alloc; use alloc::boxed::Box; use core::sync::atomic::{AtomicU8, Ordering}; use aster_util::per_cpu_counter::PerCpuCounter; use component::{ComponentInitError, init_component}; use lock::is_softirq_enabled; use...
kernel/comps/softirq/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::{ cpu_local_cell, irq::{InterruptLevel, disable_local}, sync::{GuardTransfer, SpinGuardian}, task::{ DisabledPreemptGuard, atomic_mode::{AsAtomicModeGuard, InAtomicMode}, disable_preempt, }, }; use crate::process_all_pending; c...
kernel/comps/softirq/src/lock.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Defines the used IDs of software interrupt (softirq) lines. /// The corresponding softirq line is used to schedule urgent taskless jobs. pub const TASKLESS_URGENT_SOFTIRQ_ID: u8 = 0; /// The corresponding softirq line is used to manage timers and handle /// time-related jobs. ...
kernel/comps/softirq/src/softirq_id.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use aster_util::per_cpu_counter::PerCpuCounter; use ostd::cpu::CpuId; use spin::Once; use super::SoftIrqLine; /// The maximum number of IRQ lines we track (256 should have covered most common hardware). pub(super) const NR_IRQ_LINES: usize = 256; /// Counters of each IRQ line for...
kernel/comps/softirq/src/stats.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::{ cell::RefCell, ops::DerefMut, sync::atomic::{AtomicBool, Ordering}, }; use intrusive_collections::{LinkedList, LinkedListAtomicLink, intrusive_adapter}; use ostd::{cpu::local::StaticCpuLocal, cpu_local, irq, sync::SpinLock...
kernel/comps/softirq/src/taskless.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::collections::BTreeMap; use core::fmt::Debug; use super::{Error, Result, SysStr}; use crate::SysPerms; /// An attribute may be fetched or updated via the methods of `SysNode` /// such as `SysNode::read_attr` and `SysNode::write_attr`. #[derive(Debug, Clone)] pub struct ...
kernel/comps/systree/src/attr.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This crate organizes the kernel information //! about the entire system in a tree structure called `SysTree`. //! //! Each `SysTree` instance represents a hierarchical model of system state, //! suitable for use by various subsystems. For example, sysfs, cgroup, and //! configfs...
kernel/comps/systree/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{ borrow::ToOwned, string::String, sync::{Arc, Weak}, vec, vec::Vec, }; use core::{ any::Any, fmt::Debug, sync::atomic::{AtomicU64, Ordering}, }; use bitflags::bitflags; use ostd::mm::{VmReader, VmWriter}; use super::{Error, Result, SysAt...
kernel/comps/systree/src/node.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{borrow::Cow, string::ToString, sync::Arc, vec::Vec}; use core::fmt::Debug; use aster_util::printer::VmPrinter; use inherit_methods_macro::inherit_methods; use ostd::{ mm::{FallibleVmRead, VmReader, VmWriter}, prelude::ktest, }; use super::{ BranchNodeFields...
kernel/comps/systree/src/test.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Defines the main `SysTree` structure and its root node implementation. use alloc::sync::{Arc, Weak}; use inherit_methods_macro::inherit_methods; use super::{ Result, SysStr, attr::SysAttrSet, node::{SysBranchNode, SysObj}, }; use crate::{BranchNodeFields, SysPerms...
kernel/comps/systree/src/tree.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Utility definitions and helper structs for implementing `SysTree` nodes. use alloc::{ collections::BTreeMap, string::String, sync::{Arc, Weak}, }; use inherit_methods_macro::inherit_methods; use ostd::{ mm::{VmReader, VmWriter}, sync::RwMutex, }; use spin::...
kernel/comps/systree/src/utils.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module provides abstractions for hardware-assisted timing mechanisms, encapsulated //! by the `ClockSource` struct. //! //! A `ClockSource` can be constructed from any counter with a stable frequency, enabling precise //! time measurements to be taken by retrieving instance...
kernel/comps/time/src/clocksource.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The system time of Asterinas. #![no_std] #![deny(unsafe_code)] extern crate alloc; use alloc::sync::Arc; use core::time::Duration; pub use clocksource::{ClockSource, Instant}; use component::{ComponentInitError, init_component}; use rtc::Driver; use spin::Once; mod clocksou...
kernel/comps/time/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module provide a instance of `ClockSource` based on TSC. use alloc::sync::Arc; use core::sync::atomic::{AtomicU64, Ordering}; use ostd::{ arch::{read_tsc, tsc_freq}, timer::{self, TIMER_FREQ}, }; use spin::Once; use crate::{ START_TIME, VDSO_DATA_HIGH_RES_UPD...
kernel/comps/time/src/tsc.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! CMOS RTC. //! //! "CMOS" is a tiny bit of very low power static memory that lives on the same chip as the //! Real-Time Clock (RTC). //! //! According to the Linux implementation, in x86, if the CMOS/RTC is present at the legacy //! addresses (I/O Ports 0x70 and 0x71), then it i...
kernel/comps/time/src/rtc/cmos.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use chrono::{DateTime, Datelike, Timelike}; use log::warn; use ostd::{arch::boot::DEVICE_TREE, io::IoMem, mm::VmIoOnce}; use crate::{rtc::Driver, SystemTime}; pub struct RtcGoldfish { io_mem: IoMem, } impl Driver for RtcGoldfish { fn try_new() -> Option<Self> { co...
kernel/comps/time/src/rtc/goldfish.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::{arch::boot::DEVICE_TREE, io::IoMem, mm::VmIoOnce}; use crate::{rtc::Driver, SystemTime}; pub struct RtcLoongson { io_mem: IoMem, } impl Driver for RtcLoongson { fn try_new() -> Option<Self> { let chosen = DEVICE_TREE.get().unwrap().find_node("/rtc").unw...
kernel/comps/time/src/rtc/loongson.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use crate::SystemTime; /// Generic interface for RTC drivers pub trait Driver { /// Creates a RTC driver. /// Returns [`Some<Self>`] on success, [`None`] otherwise (e.g. platform unsupported). fn try_new() -> Option<Self> where Self: S...
kernel/comps/time/src/rtc/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{sync::Arc, vec::Vec}; use core::fmt::Debug; use aster_console::{AnyConsoleDevice, ConsoleCallback}; use inherit_methods_macro::inherit_methods; use ostd::{ console::uart_ns16650a::{Ns16550aAccess, Ns16550aUart}, mm::VmReader, sync::{LocalIrqDisabled, SpinLoc...
kernel/comps/uart/src/console.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Universal asynchronous receiver-transmitter (UART). #![no_std] #![deny(unsafe_code)] extern crate alloc; use component::{ComponentInitError, init_component}; #[cfg_attr(target_arch = "x86_64", path = "arch/x86/mod.rs")] #[cfg_attr(target_arch = "riscv64", path = "arch/riscv/...
kernel/comps/uart/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::serial::SERIAL_PORT; use crate::{ CONSOLE_NAME, alloc::string::ToString, console::{Uart, UartConsole}, }; pub(super) fn init() { let Some(uart) = SERIAL_PORT.get() else { return; }; let uart_console = UartConsole::new(uart); as...
kernel/comps/uart/src/arch/loongarch/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::boot::DEVICE_TREE; mod ns16550a; pub(super) fn init() { let device_tree = DEVICE_TREE.get().unwrap(); if let Some(ns16550a_node) = device_tree.find_compatible(&["ns16550a"]) { ns16550a::init(ns16550a_node); } }
kernel/comps/uart/src/arch/riscv/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::string::ToString; use fdt::node::FdtNode; use ostd::{ arch::irq::{IRQ_CHIP, InterruptSourceInFdt, MappedIrqLine}, console::uart_ns16650a::{Ns16550aAccess, Ns16550aRegister, Ns16550aUart}, io::IoMem, irq::IrqLine, mm::VmIoOnce, sync::SpinLock, }; u...
kernel/comps/uart/src/arch/riscv/ns16550a.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::string::ToString; use ostd::{ arch::{ irq::{IRQ_CHIP, MappedIrqLine}, serial::SERIAL_PORT, }, irq::IrqLine, }; use spin::Once; use crate::{ CONSOLE_NAME, console::{Uart, UartConsole}, }; /// ISA interrupt number for UART serial. // F...
kernel/comps/uart/src/arch/x86/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use aster_network::{DmaSegment, RxBuffer, TxBuffer}; use aster_util::mem_obj_slice::Slice; use ostd::mm::{ HasDaddr, HasSize, dma::{DmaCoherent, DmaDirection, DmaStream}, }; /// A DMA-capable buffer. /// /// Any type implements this trait should also ...
kernel/comps/virtio/src/dma_buf.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use id_alloc::IdAlloc; use ostd::sync::{SpinLock, WaitQueue}; /// A synchronized ID allocator that manages a fixed-size pool of IDs. /// /// We say this ID allocator "synchronized" because /// its `alloc` method may be used by multiple threads to allocate IDs concurrently /// and i...
kernel/comps/virtio/src/id_alloc.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The virtio of Asterinas. #![no_std] #![deny(unsafe_code)] #![feature(linked_list_cursors)] #![feature(trait_alias)] extern crate alloc; #[macro_use] extern crate ostd_pod; use alloc::boxed::Box; use core::hint::spin_loop; use aster_block::MajorIdOwner; use bitflags::bitflags;...
kernel/comps/virtio/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Virtqueue use alloc::{sync::Arc, vec::Vec}; use core::{ mem::{offset_of, size_of}, sync::atomic::{Ordering, fence}, }; use aster_rights::{Dup, TRightSet, TRights, Write}; use aster_util::{field_ptr, safe_ptr::SafePtr}; use bitflags::bitflags; use log::debug; use ostd::...
kernel/comps/virtio/src/queue.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use int_to_c_enum::TryFromInt; use crate::queue::QueueError; pub mod block; pub mod console; pub mod input; pub mod network; pub mod socket; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, TryFromInt)] #[repr(u8)] pub enum VirtioDeviceType { Invalid = 0, Netw...
kernel/comps/virtio/src/device/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{ boxed::Box, collections::BTreeMap, format, string::String, sync::{Arc, Weak}, vec::Vec, }; use core::{ fmt::Debug, sync::atomic::{AtomicU32, Ordering}, }; use aster_block::{ BlockDeviceMeta, EXTENDED_DEVICE_ID_ALLOCATOR, PartitionInf...
kernel/comps/virtio/src/device/block/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod device; use core::mem::offset_of; use aster_block::SECTOR_SIZE; use aster_util::safe_ptr::SafePtr; use bitflags::bitflags; use int_to_c_enum::TryFromInt; use ostd_pod::FromZeros; use crate::transport::{ConfigManager, VirtioTransport}; pub const DEVICE_NAME: &str = "Virti...
kernel/comps/virtio/src/device/block/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::mem::offset_of; use aster_util::safe_ptr::SafePtr; use ostd_pod::FromZeros; use crate::transport::{ConfigManager, VirtioTransport}; bitflags::bitflags! { pub struct ConsoleFeatures: u64{ /// Configuration cols and rows are valid. const VIRTIO_CONSOLE...
kernel/comps/virtio/src/device/console/config.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, fmt::Debug, string::ToString, sync::Arc, vec::Vec}; use core::hint::spin_loop; use aster_console::{AnyConsoleDevice, ConsoleCallback}; use aster_util::mem_obj_slice::Slice; use log::debug; use ostd::{ arch::trap::TrapFrame, mm::{VmReader, dma::DmaStr...
kernel/comps/virtio/src/device/console/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod config; pub mod device; pub const DEVICE_NAME: &str = "Virtio-Console";
kernel/comps/virtio/src/device/console/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{ boxed::Box, string::{String, ToString}, sync::Arc, vec::Vec, }; use core::fmt::Debug; use aster_input::{ event_type_codes::{EventTypes, KeyCode, KeyStatus, RelCode, SynEvent}, input_dev::{ InputCapability, InputDevice as InputDeviceTrait...
kernel/comps/virtio/src/device/input/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 // Modified from input.rs in virtio-drivers project // // MIT License // // Copyright (c) 2022-2023 Ant Group // Copyright (c) 2019-2020 rCore Developers // // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inclu...
kernel/comps/virtio/src/device/input/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::mem::offset_of; use aster_network::EthernetAddr; use aster_util::safe_ptr::SafePtr; use bitflags::bitflags; use ostd_pod::FromZeros; use crate::transport::{ConfigManager, VirtioTransport}; bitflags! { /// Virtio Net Feature bits. pub struct NetworkFeatures: u64 ...
kernel/comps/virtio/src/device/network/config.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{ boxed::Box, collections::linked_list::LinkedList, string::ToString, sync::Arc, vec::Vec, }; use core::fmt::Debug; use aster_bigtcp::device::{Checksum, DeviceCapabilities, Medium}; use aster_network::{AnyNetworkDevice, EthernetAddr, NetError, RX_BUFFER_POOL, RxBuffe...
kernel/comps/virtio/src/device/network/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use bitflags::bitflags; use int_to_c_enum::TryFromInt; pub const VIRTIO_NET_HDR_LEN: usize = size_of::<VirtioNetHdr>(); /// VirtioNet header precedes each packet #[repr(C)] #[derive(Default, Debug, Clone, Copy, Pod)] pub struct VirtioNetHdr { flags: Flags, gso_type: u8, ...
kernel/comps/virtio/src/device/network/header.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod config; pub mod device; pub mod header; pub const DEVICE_NAME: &str = "Virtio-Net";
kernel/comps/virtio/src/device/network/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{collections::linked_list::LinkedList, sync::Arc}; use aster_network::dma_pool::DmaPool; use aster_softirq::BottomHalfDisabled; use ostd::{ mm::dma::{DmaStream, FromDevice, ToDevice}, sync::SpinLock, }; use spin::Once; const RX_BUFFER_LEN: usize = 4096; pub stat...
kernel/comps/virtio/src/device/socket/buffer.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use aster_util::safe_ptr::SafePtr; use bitflags::bitflags; use ostd::{io::IoMem, mm::PodOnce}; use crate::transport::VirtioTransport; bitflags! { pub struct VsockFeatures: u64 { const VIRTIO_VSOCK_F_STREAM = 1 << 0; // stream socket type is supported. const VIR...
kernel/comps/virtio/src/device/socket/config.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 // Modified from vsock.rs in virtio-drivers project // // MIT License // // Copyright (c) 2022-2023 Ant Group // Copyright (c) 2019-2020 rCore Developers // // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inclu...
kernel/comps/virtio/src/device/socket/connect.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, string::ToString, sync::Arc, vec}; use core::{fmt::Debug, hint::spin_loop}; use aster_network::{RxBuffer, TxBuffer}; use aster_util::{field_ptr, slot_vec::SlotVec}; use log::debug; use ostd::{arch::trap::TrapFrame, mm::VmWriter, sync::SpinLock}; use ostd_pod...
kernel/comps/virtio/src/device/socket/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 // Modified from error.rs in virtio-drivers project // // MIT License // // Copyright (c) 2022-2023 Ant Group // Copyright (c) 2019-2020 rCore Developers // // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inclu...
kernel/comps/virtio/src/device/socket/error.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 // Modified from protocol.rs in virtio-drivers project // // MIT License // // Copyright (c) 2022-2023 Ant Group // Copyright (c) 2019-2020 rCore Developers // // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, in...
kernel/comps/virtio/src/device/socket/header.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec}; use ostd::sync::SpinLock; use spin::Once; use self::device::SocketDevice; pub mod buffer; pub mod config; pub mod connect; pub mod device; pub mod error; pub mod header; pub const DEVICE_NAME: &str = "Virtio...
kernel/comps/virtio/src/device/socket/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::fmt::Debug; use aster_pci::cfg_space::Bar; use aster_util::safe_ptr::SafePtr; use ostd::{ arch::device::io_port::{PortRead, PortWrite}, io::IoMem, irq::IrqCallbackFunction, mm::{PodOnce, dma::DmaCoherent}, }; use ostd_po...
kernel/comps/virtio/src/transport/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::mem::offset_of; use aster_rights::{ReadOp, WriteOp}; use aster_util::{field_ptr, safe_ptr::SafePtr}; use log::warn; use ostd::{ io::IoMem, irq::IrqCallbackFunction, mm::{HasDaddr, PAGE_SIZE, dma::DmaCoherent}, sync::RwLo...
kernel/comps/virtio/src/transport/mmio/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{sync::Arc, vec::Vec}; use ostd::{bus::BusProbeError, sync::SpinLock}; use super::{ bus::{ bus::{MmioDevice, MmioDriver}, common_device::MmioCommonDevice, }, device::VirtioMmioTransport, }; #[derive(Debug)] pub struct VirtioMmioDriver { ...
kernel/comps/virtio/src/transport/mmio/driver.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::fmt::Debug; #[derive(Clone, Copy, Pod)] #[repr(C)] pub struct VirtioMmioLayout { /// Magic value: 0x74726976. **Read-only** pub magic_value: u32, /// Device version. 1 => Legacy, 2 => Normal. **Read-only** pub version: u32, /// Virtio Subsystem Device ...
kernel/comps/virtio/src/transport/mmio/layout.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use bus::MMIO_BUS; use spin::Once; use self::driver::VirtioMmioDriver; mod bus; pub mod device; pub mod driver; pub mod layout; pub mod multiplex; pub static VIRTIO_MMIO_DRIVER: Once<Arc<VirtioMmioDriver>> = Once::new(); pub fn virtio_mmio_init() { bus...
kernel/comps/virtio/src/transport/mmio/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc, vec::Vec}; use core::fmt::Debug; use aster_rights::{ReadOp, TRightSet, WriteOp}; use aster_util::safe_ptr::SafePtr; use ostd::{ arch::trap::TrapFrame, io::IoMem, irq::{IrqCallbackFunction, IrqLine}, sync::RwLock, }; /// Multiplexi...
kernel/comps/virtio/src/transport/mmio/multiplex.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! MMIO bus. use alloc::{collections::VecDeque, fmt::Debug, sync::Arc, vec::Vec}; use log::{debug, error}; use ostd::bus::BusProbeError; use super::common_device::MmioCommonDevice; /// MMIO device trait pub trait MmioDevice: Sync + Send + Debug { /// Device ID fn device...
kernel/comps/virtio/src/transport/mmio/bus/bus.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! MMIO device common definitions or functions. use int_to_c_enum::TryFromInt; use log::info; use ostd::{ Error, Result, io::IoMem, irq::IrqLine, mm::{HasPaddr, VmIoOnce}, }; use super::arch::MappedIrqLine; /// A MMIO common device. #[derive(Debug)] pub struct Mm...
kernel/comps/virtio/src/transport/mmio/bus/common_device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Virtio over MMIO use core::ops::Range; use bus::MmioBus; use log::debug; use ostd::{io::IoMem, irq::IrqLine, sync::SpinLock}; use crate::transport::mmio::bus::common_device::{ MmioCommonDevice, mmio_check_magic, mmio_read_device_id, }; #[cfg_attr(target_arch = "x86_64", ...
kernel/comps/virtio/src/transport/mmio/bus/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 // TODO: Add `MappedIrqLine` support for LoongArch. pub(super) use ostd::irq::IrqLine as MappedIrqLine; pub(super) fn probe_for_device() { // TODO: Probe virtio devices on the MMIO bus in LoongArch. // Then, register them by calling `super::try_register_mmio_device`. }
kernel/comps/virtio/src/transport/mmio/bus/arch/loongarch.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub(super) use ostd::arch::irq::MappedIrqLine; use ostd::arch::{ boot::DEVICE_TREE, irq::{IRQ_CHIP, InterruptSourceInFdt}, }; pub(super) fn probe_for_device() { // The device tree parsing logic here assumed a Linux-compatible device // tree. // Reference: <https...
kernel/comps/virtio/src/transport/mmio/bus/arch/riscv.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use log::debug; use ostd::arch::irq::IRQ_CHIP; pub(super) use ostd::arch::irq::MappedIrqLine; use crate::transport::mmio::bus::MmioRegisterError; pub(super) fn probe_for_device() { // TODO: The correct method for detecting VirtIO-MMIO devices on x86_64 systems is to parse the ...
kernel/comps/virtio/src/transport/mmio/bus/arch/x86.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use aster_pci::{ capability::vendor::CapabilityVndrData, cfg_space::{Bar, MemoryBar}, common_device::BarManager, }; use log::warn; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] #[repr(u8)] #[expect(clippy::enum_variant_names)] pub enum V...
kernel/comps/virtio/src/transport/pci/capability.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use aster_util::safe_ptr::SafePtr; use ostd::io::IoMem; use super::capability::VirtioPciCapabilityData; use crate::transport::pci::capability::VirtioPciCpabilityType; #[derive(Debug, Default, Copy, Clone, Pod)] #[repr(C)] pub struct VirtioPciCommonCfg { pub device_feature_sele...
kernel/comps/virtio/src/transport/pci/common_cfg.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::fmt::Debug; use aster_pci::{ PciDeviceId, bus::PciDevice, capability::CapabilityData, cfg_space::Bar, common_device::PciCommonDevice, }; use aster_util::{field_ptr, safe_ptr::SafePtr}; use log::{info, warn}; use ostd::{ bus:...
kernel/comps/virtio/src/transport/pci/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, collections::vec_deque::VecDeque, sync::Arc}; use aster_pci::{ bus::{PciDevice, PciDriver}, capability::CapabilityData, common_device::PciCommonDevice, }; use ostd::{bus::BusProbeError, sync::SpinLock}; use super::device::VirtioPciModernTranspor...
kernel/comps/virtio/src/transport/pci/driver.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::fmt::Debug; use aster_pci::{capability::CapabilityData, cfg_space::Bar, common_device::PciCommonDevice}; use aster_util::safe_ptr::SafePtr; use log::{info, warn}; use ostd::{ bus::BusProbeError, io::IoMem, irq::IrqCallbackFu...
kernel/comps/virtio/src/transport/pci/legacy.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod capability; pub mod common_cfg; pub mod device; pub mod driver; pub mod legacy; pub(super) mod msix; use alloc::sync::Arc; use aster_pci::PCI_BUS; use spin::Once; use self::driver::VirtioPciDriver; pub static VIRTIO_PCI_DRIVER: Once<Arc<VirtioPciDriver>> = Once::new(); p...
kernel/comps/virtio/src/transport/pci/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::vec::Vec; use aster_pci::capability::msix::CapabilityMsixData; use ostd::irq::IrqLine; pub struct VirtioMsixManager { config_msix_vector: u16, /// Shared interrupt vector used by queue. shared_interrupt_vector: u16, /// The MSI-X vectors allocated to que...
kernel/comps/virtio/src/transport/pci/msix.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// Defines a struct representing a boolean value. /// /// In some cases, it is beneficial to use a struct instead of /// a plain boolean value to clarify the semantics. /// This macro provides a convenient way to define a struct /// that represents a boolean value. #[macro_export] ...
kernel/libs/aster-bigtcp/src/boolean_value.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub use smoltcp::phy::{ Checksum, ChecksumCapabilities, Device, DeviceCapabilities, Loopback, Medium, RxToken, TxToken, }; /// A trait that allows to obtain a mutable reference of [`Device`]. /// /// A [`Device`] is usually protected by a lock (e.g., a spin lock or a mutex), an...
kernel/libs/aster-bigtcp/src/device.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// An error describing the reason why `bind` failed. #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum BindError { /// All ephemeral ports is exhausted. Exhausted, /// The specified address is in use. InUse, } pub mod tcp { /// An error returned by [`TcpLis...
kernel/libs/aster-bigtcp/src/errors.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{iface::ScheduleNextPoll, socket::SocketEventObserver}; /// Extension to be implemented by users of this crate. /// /// This should be implemented on an empty type that carries no data, since the type will never /// actually be instantiated. /// /// The purpose of having...
kernel/libs/aster-bigtcp/src/ext.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! _bigtcp_ is a crate that wraps [`smoltcp`]. //! //! [`smoltcp`] is designed for embedded systems where the number of sockets is always small. It //! turns out that such a design cannot satisfy the need to implement the network stack of a //! general-purpose OS kernel, in terms o...
kernel/libs/aster-bigtcp/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module defines the socket table, which manages all TCP and UDP sockets, //! for efficiently inserting, looking up, and removing sockets. use alloc::{boxed::Box, sync::Arc, vec::Vec}; use core::net::Ipv4Addr; use jhash::{jhash_1vals, jhash_3vals}; use ostd::const_assert; u...
kernel/libs/aster-bigtcp/src/socket_table.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, IpEndpoint, Ipv4Address, Ipv4Cidr}; pub type PortNum = u16;
kernel/libs/aster-bigtcp/src/wire.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{ collections::btree_map::{BTreeMap, Entry}, string::String, sync::Arc, vec::Vec, }; use core::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use aster_softirq::BottomHalfDisabled; use bitflags::bitflags; use int_to_c_enum::TryFromInt; use ostd::sync::{...
kernel/libs/aster-bigtcp/src/iface/common.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; use super::{BoundPort, InterfaceFlags, InterfaceType, port::BindPortConfig}; use crate::{errors::BindError, ext::Ext}; /// A network interface. /// /// A network interface (abbreviated as iface) is a hardware or so...
kernel/libs/aster-bigtcp/src/iface/iface.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod common; #[expect(clippy::module_inception)] mod iface; mod phy; mod poll; mod poll_iface; mod port; mod sched; mod time; pub use common::{BoundPort, InterfaceFlags, InterfaceType}; pub use iface::Iface; pub use phy::{EtherIface, IpIface}; pub(crate) use poll_iface::{PollKey, Po...
kernel/libs/aster-bigtcp/src/iface/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{sync::Arc, vec, vec::Vec}; use smoltcp::{ iface::{ Context, packet::{IpPayload, Packet, icmp_reply_payload_len}, }, phy::{ChecksumCapabilities, Device, RxToken, TxToken}, wire::{ IPV4_HEADER_LEN, IPV4_MIN_MTU, Icmpv4DstUnreachable...
kernel/libs/aster-bigtcp/src/iface/poll.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{collections::btree_set::BTreeSet, sync::Arc}; use core::{ borrow::Borrow, sync::atomic::{AtomicU64, Ordering}, }; use crate::{ ext::Ext, socket::{NeedIfacePoll, TcpConnectionBg}, }; /// An interface with auxiliary data that makes it pollable. /// /// Th...
kernel/libs/aster-bigtcp/src/iface/poll_iface.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// The configuration using for bind to a TCP/UDP port. pub enum BindPortConfig { /// Binds to the specified non-reusable port. CanReuse(u16), /// Binds to the specified reusable port. Specified(u16), /// Allocates an ephemeral port to bind. Ephemeral(bool), ...
kernel/libs/aster-bigtcp/src/iface/port.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// A trait to provide the `schedule_next_poll` method for ifaces. pub trait ScheduleNextPoll: Send + Sync { /// Schedules the next poll at the specific time. /// /// This is invoked with the time at which the next poll should be performed, or `None` if no /// next p...
kernel/libs/aster-bigtcp/src/iface/sched.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::timer::Jiffies; pub(super) fn get_network_timestamp() -> smoltcp::time::Instant { let millis = Jiffies::elapsed().as_duration().as_millis(); smoltcp::time::Instant::from_millis(millis as i64) }
kernel/libs/aster-bigtcp/src/iface/time.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{collections::btree_map::BTreeMap, string::String, sync::Arc}; use aster_softirq::BottomHalfDisabled; use ostd::sync::SpinLock; use smoltcp::{ iface::{Config, Context, packet::Packet}, phy::{Device, DeviceCapabilities, TxToken}, wire::{ self, ArpOpera...
kernel/libs/aster-bigtcp/src/iface/phy/ether.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{string::String, sync::Arc}; use smoltcp::{ iface::Config, phy::{Device, TxToken}, wire::{self, Ipv4Cidr, Ipv4Packet}, }; use crate::{ device::WithDevice, ext::Ext, iface::{ Iface, ScheduleNextPoll, common::{IfaceCommon, Interface...
kernel/libs/aster-bigtcp/src/iface/phy/ip.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod ether; mod ip; pub use ether::EtherIface; pub use ip::IpIface;
kernel/libs/aster-bigtcp/src/iface/phy/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// A observer that will be invoked whenever events occur on the socket. pub trait SocketEventObserver: Send + Sync { /// Notifies that events occurred on the socket. fn on_events(&self, events: SocketEvents); } impl SocketEventObserver for () { fn on_events(&self, _eve...
kernel/libs/aster-bigtcp/src/socket/event.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod bound; mod event; mod option; mod unbound; pub use bound::{ ConnectState, NeedIfacePoll, RawTcpSocketExt, TcpConnection, TcpListener, UdpSocket, }; pub(crate) use bound::{TcpConnectionBg, TcpListenerBg, TcpProcessResult, UdpSocketBg}; pub use event::{SocketEventObserver, So...
kernel/libs/aster-bigtcp/src/socket/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use smoltcp::time::Duration; use super::{NeedIfacePoll, unbound::RawTcpSocket}; /// A trait defines setting socket options on a raw socket. pub trait RawTcpSetOption { /// Sets the keep alive interval. /// /// Polling the iface _may_ be required after this method succe...
kernel/libs/aster-bigtcp/src/socket/option.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, vec}; pub(super) type RawTcpSocket = smoltcp::socket::tcp::Socket<'static>; pub type RawUdpSocket = smoltcp::socket::udp::Socket<'static>; pub(super) fn new_tcp_socket() -> Box<RawTcpSocket> { let raw_tcp_socket = { let rx_buffer = smoltcp::sock...
kernel/libs/aster-bigtcp/src/socket/unbound.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::{Arc, Weak}; use smoltcp::wire::IpEndpoint; use spin::once::Once; use takeable::Takeable; use crate::{ define_boolean_value, ext::Ext, iface::{BoundPort, Iface}, socket::event::{SocketEventObserver, SocketEvents}, }; pub struct Socket<T: Inner<E>,...
kernel/libs/aster-bigtcp/src/socket/bound/common.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod common; mod tcp_conn; mod tcp_listen; mod udp; pub use common::NeedIfacePoll; pub use tcp_conn::{ConnectState, RawTcpSocketExt, TcpConnection}; pub(crate) use tcp_conn::{TcpConnectionBg, TcpProcessResult}; pub use tcp_listen::TcpListener; pub(crate) use tcp_listen::TcpListenerB...
kernel/libs/aster-bigtcp/src/socket/bound/mod.rs
null
null
null
null
null