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 use alloc::{ boxed::Box, sync::{Arc, Weak}, }; use core::ops::{Deref, DerefMut}; use aster_softirq::BottomHalfDisabled; use ostd::sync::{SpinLock, SpinLockGuard}; use smoltcp::{ socket::{PollAt, tcp::State}, time::Duration, wire::{IpEndpoint, IpRepr, TcpControl,...
kernel/libs/aster-bigtcp/src/socket/bound/tcp_conn.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, collections::btree_map::BTreeMap, sync::Arc, vec::Vec}; use aster_softirq::BottomHalfDisabled; use ostd::sync::SpinLock; use smoltcp::{ socket::PollAt, time::Duration, wire::{IpEndpoint, IpRepr, TcpRepr}, }; use super::{ common::{Inner, Need...
kernel/libs/aster-bigtcp/src/socket/bound/tcp_listen.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::sync::atomic::{AtomicBool, Ordering}; use aster_softirq::BottomHalfDisabled; use ostd::sync::SpinLock; use smoltcp::{ iface::Context, socket::udp::UdpMetadata, wire::{IpRepr, UdpRepr}, }; use super::common::{Inner, Socket, ...
kernel/libs/aster-bigtcp/src/socket/bound/udp.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //!This crate defines the require procedural macros to implement capability for Asterinas. //! When use this crate, typeflags and typeflags-util should also be added as dependency. //! //! The require macro are used to ensure that an object has the enough capability to call the func...
kernel/libs/aster-rights-proc/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! expand the require macro use proc_macro2::{Ident, TokenStream}; use quote::quote; use syn::{ GenericParam, Generics, Token, Type, WhereClause, fold::Fold, parse::Parse, parse_quote, punctuated::Punctuated, token::Comma, }; use super::require_item::RequireItem; pub str...
kernel/libs/aster-rights-proc/src/require_attr.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use syn::{ItemFn, ItemImpl, Token, parse::Parse}; pub enum RequireItem { Impl(ItemImpl), Fn(ItemFn), } impl Parse for RequireItem { fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> { let token = input.lookahead1(); if token.peek(Token!(impl...
kernel/libs/aster-rights-proc/src/require_item.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![no_std] use core::ops::{Deref, DerefMut}; bitflags::bitflags! { /// Value-based access rights. /// /// These access rights are provided to cover a wide range of use cases. /// The access rights' semantics and how they would restrict the behaviors /// of a ca...
kernel/libs/aster-rights/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module provides an abstraction `Coeff` to server for efficient and accurate calculation //! of fraction multiplication. use core::ops::Mul; /// A `Coeff` is used to do a fraction multiplication operation with an unsigned integer. /// It can achieve accurate and efficient ...
kernel/libs/aster-util/src/coeff.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// This trait is a _fallible_ version of `Clone`. /// /// If any object of a type `T` is duplicable, then `T` should implement /// `Clone`. However, if whether an object is duplicable must be determined /// on a per-object basis at runtime, then `T` should implement `Dup` as /// th...
kernel/libs/aster-util/src/dup.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! A lightweight fixed-point number implementation optimized for kernel use. //! //! This crate provides a minimal, safe fixed-point arithmetic implementation //! designed specifically for kernel development where zero `unsafe` code usage //! throughout the entire implementation. ...
kernel/libs/aster-util/src/fixed_point.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The util of Asterinas. #![no_std] #![deny(unsafe_code)] #![feature(int_roundings)] extern crate alloc; pub mod coeff; pub mod dup; pub mod fixed_point; pub mod mem_obj_slice; pub mod per_cpu_counter; pub mod printer; pub mod ranged_integer; pub mod safe_ptr; pub mod slot_vec;
kernel/libs/aster-util/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0 //! Provides [`Slice`] for quick duplication and slicing over memory //! objects, such as [`UFrame`], [`USegment`], [`IoMem`], [`DmaStream`], etc. //! //! [`UFrame`]: ostd::mm::UFrame //! [`USegment`]: ostd::mm::USegment //! [`IoMem`]: ostd::io::...
kernel/libs/aster-util/src/mem_obj_slice.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! A fast and scalable per-CPU counter. use core::sync::atomic::{AtomicIsize, Ordering}; use osdk_heap_allocator::{CpuLocalBox, alloc_cpu_local}; use ostd::cpu::{CpuId, all_cpus}; /// A fast, SMP-friendly, dynamically allocated, per-CPU counter. /// /// Updating it is fast and s...
kernel/libs/aster-util/src/per_cpu_counter.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::fmt::{Arguments, Write}; use ostd::mm::{FallibleVmWrite, VmReader, VmWriter}; /// A specialized printer for formatted text output. /// /// `VmPrinter` is designed to handle the common pattern in kernel where kernel /// code needs to generate formatted text output (like s...
kernel/libs/aster-util/src/printer.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Ranged integer types. //! //! This module provides generic ranged integer types that enforce value always stay //! within the specified range. macro_rules! define_ranged_integer { ($visibility: vis, $name: ident, $type: ty) => { #[derive(Copy, Clone, Debug, Eq, Part...
kernel/libs/aster-util/src/ranged_integer.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::{fmt::Debug, marker::PhantomData}; use aster_rights::{Dup, Exec, Full, Read, Signal, TRightSet, TRights, Write}; use aster_rights_proc::require; use ostd::{ Error, Result, mm::{ Daddr, HasDaddr, HasPaddr, Paddr, PodOnce, VmIo, VmIoOnce, dma::DmaDir...
kernel/libs/aster-util/src/safe_ptr.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::vec::Vec; /// SlotVec is the variant of Vector. /// It guarantees that the index of one item remains unchanged during adding /// or deleting other items of the vector. #[derive(Debug, Clone)] pub struct SlotVec<T> { // The slots to store items. slots: Vec<Option<...
kernel/libs/aster-util/src/slot_vec.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This crate provides a function-like macro for defining atomic version of integer-like type. //! //! By integer-like type we mean types that implement `Into<Integer>` and `From<Integer>/TryFrom<integer>` //! where `Integer` is a built-in integer type, e.g. u8. //! //! Below is a ...
kernel/libs/atomic-integer-wrapper/src/lib.rs
null
null
null
null
null
source
asterinas
## Overview The crate contains cargo-component, a cargo subcommand to enable component-level access control in Asterinas. For more info about Asterinas component system, see the [RFC](https://github.com/asterinas/Asterinas/issues/58). The implementation mainly follows [rust clippy](https://github.com/rust-lang/rust-cli...
kernel/libs/comp-sys/cargo-component/README.md
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. // This implementation is from rust clippy. We modified the code. fn main() { // Forward the profile to the main compilation println!( "cargo:rustc-env=PROFILE={}", std::env::var("PROFIL...
kernel/libs/comp-sys/cargo-component/build.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. use std::collections::{BTreeMap, HashSet}; use std::{env, fs, io, path::PathBuf}; use once_cell::sync::OnceCell; use toml::Value; pub static CONFIG: OnceCell<Config> = OnceCell::new(); #[derive(Debug, Clone)]...
kernel/libs/comp-sys/cargo-component/analysis/src/conf.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. #![feature(rustc_private)] extern crate rustc_ast; extern crate rustc_driver; extern crate rustc_hir; extern crate rustc_lint; extern crate rustc_middle; extern crate rustc_session; extern crate rustc_span; mo...
kernel/libs/comp-sys/cargo-component/analysis/src/lib.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. // This implementation is from rust clippy. We modified the code. #![feature(rustc_private)] #![feature(once_cell)] extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_interface; extern cr...
kernel/libs/comp-sys/cargo-component/src/driver.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. // This implementation is from rust clippy. We modified the code. use std::env; use std::path::PathBuf; use std::process::{self, Command}; const CARGO_COMPONENT_HELP: &str = r#"Checks whether a package violate...
kernel/libs/comp-sys/cargo-component/src/main.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. //! This test checks that if two components have same name, the compiler will panic. #![feature(once_cell)] mod test_utils; #[test] fn duplicate_lib_name() { let stderr = run_cargo_component_cmd!(); a...
kernel/libs/comp-sys/cargo-component/tests/duplicate_lib_name.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. //! This test checks that if Components.toml is missed, the compiler will panic. #![feature(once_cell)] mod test_utils; #[test] fn missing_toml() { let stderr = run_cargo_component_cmd!(); assert!(std...
kernel/libs/comp-sys/cargo-component/tests/missing_toml.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. //! This test checks that if cargo-component can control reexported entry points. #![feature(once_cell)] mod test_utils; #[test] fn reexport() { let stderr = run_cargo_component_cmd!(); assert!(!stder...
kernel/libs/comp-sys/cargo-component/tests/reexport.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. //! This test checks that visiting controlled resources in whitelist is allowed. #![feature(once_cell)] mod test_utils; #[test] fn test() { let stderr = run_cargo_component_cmd!(); assert!(!stderr.con...
kernel/libs/comp-sys/cargo-component/tests/regression.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. //! This test checks that if cargo-component can control method and trait method #![feature(once_cell)] mod test_utils; #[test] fn trait_method() { let stderr = run_cargo_component_cmd!(); assert!(std...
kernel/libs/comp-sys/cargo-component/tests/trait_method.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. //! This test checks that if controlled resource not in whitelist is visited, cargo-component will //! report warning message. #![feature(once_cell)] mod test_utils; #[test] fn violate_policy() { let std...
kernel/libs/comp-sys/cargo-component/tests/violate_policy.rs
null
null
null
null
null
source
asterinas
pub fn reexport_fn() { foo::f1(); bar::f1(); } pub fn reexport_method() { let foo_struct = foo::Foo::new(); foo_struct.get(); let another_foo = bar::Foo::new(); another_foo.get(); } pub fn reexport_trait_1() { use foo::FooTrait; let foo_struct = foo::Foo::t_new(); foo_struct.t_get...
kernel/libs/comp-sys/cargo-component/tests/reexport_test/baz/src/lib.rs
null
null
null
null
null
source
asterinas
#![feature(register_tool)] #![register_tool(component_access_control)] #[macro_use] extern crate controlled; #[controlled] pub fn f1() {} pub struct Foo; impl Foo { #[controlled] pub fn new() -> Self { Foo } #[controlled] pub fn get(&self) -> usize { 42 } } pub trait FooTra...
kernel/libs/comp-sys/cargo-component/tests/reexport_test/foo/src/lib.rs
null
null
null
null
null
source
asterinas
pub static BAR: &'static usize = &foo1::FOO_ITEM; pub fn add(left: usize, right: usize) -> usize { foo1::foo_add(left, right) }
kernel/libs/comp-sys/cargo-component/tests/regression_test/bar1/src/lib.rs
null
null
null
null
null
source
asterinas
#![feature(register_tool)] #![register_tool(component_access_control)] #[macro_use] extern crate controlled; #[controlled] pub static FOO_ITEM: usize = 0; #[controlled] pub fn foo_add(left: usize, right: usize) -> usize { left + right }
kernel/libs/comp-sys/cargo-component/tests/regression_test/foo1/src/lib.rs
null
null
null
null
null
source
asterinas
// Licensed under the Apache License, Version 2.0 or the MIT License. // Copyright (C) 2023-2024 Ant Group. #![expect(unused)] use std::path::PathBuf; use std::process::Command; use std::process::Output; use std::sync::LazyLock; #[macro_export] macro_rules! run_cargo_component_cmd { () => ({ let file = f...
kernel/libs/comp-sys/cargo-component/tests/test_utils/mod.rs
null
null
null
null
null
source
asterinas
use foo2::{ObjectSafeTrait, Foo, FooTrait}; pub fn method() { let foo_struct = Foo::associate_fn(); let val = foo_struct.method(); println!("val = {}", val); } pub fn trait_method() { Foo::trait_associate_fn(); let foo_struct = Foo::associate_fn(); foo_struct.trait_method(); } pub fn dyn_trai...
kernel/libs/comp-sys/cargo-component/tests/trait_method_test/bar2/src/lib.rs
null
null
null
null
null
source
asterinas
#![feature(register_tool)] #![register_tool(component_access_control)] #[macro_use] extern crate controlled; pub struct Foo; impl Foo { #[controlled] pub fn associate_fn() -> Self { todo!() } #[controlled] pub fn method(&self) -> usize { todo!() } } pub trait FooTrait { ...
kernel/libs/comp-sys/cargo-component/tests/trait_method_test/foo2/src/lib.rs
null
null
null
null
null
source
asterinas
pub static BAR: &'static usize = &foo3::FOO_ITEM; pub fn add(left: usize, right: usize) -> usize { foo3::foo_add(left, right) }
kernel/libs/comp-sys/cargo-component/tests/violate_policy_test/bar3/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use proc_macro2::{TokenStream, TokenTree}; use quote::{ToTokens, TokenStreamExt}; use syn::parse::Parse; /// The content inside typeflag macro pub struct ComponentInitFunction { function: Vec<TokenTree>, pub function_name: TokenTree, } impl Parse for ComponentInitFunction ...
kernel/libs/comp-sys/component-macro/src/init_comp.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //!This crate defines the component system related macros. #![feature(proc_macro_diagnostic)] #![deny(unsafe_code)] mod init_comp; mod priority; use init_comp::ComponentInitFunction; use proc_macro::TokenStream; use quote::quote; use syn::parse_macro_input; pub(crate) const COMP...
kernel/libs/comp-sys/component-macro/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use std::{ collections::HashMap, fs::File, io::Read, ops::Add, path::PathBuf, process::Command, str::FromStr, }; use json::JsonValue; use proc_macro2::{Group, TokenStream}; use quote::{ToTokens, TokenStreamExt}; use crate::COMPONENT_FILE_NAME; #[derive(Debug)] pub struct ...
kernel/libs/comp-sys/component-macro/src/priority.rs
null
null
null
null
null
source
asterinas
# Component ## Overview This crate is used for the initialization of the component system, which provides a priority initialization scheme based on the inventory crate. ## Initialization Stages The component system supports three distinct initialization stages that execute in a specific order during system boot: 1. *...
kernel/libs/comp-sys/component/README.md
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Component system //! #![no_std] #![deny(unsafe_code)] extern crate alloc; use alloc::{ borrow::ToOwned, collections::BTreeMap, fmt::Debug, string::{String, ToString}, vec::Vec, }; pub use component_macro::*; pub use inventory::submit; use log::{debug, err...
kernel/libs/comp-sys/component/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::Relaxed; use component::init_component; pub static HAS_INIT: AtomicBool = AtomicBool::new(false); #[init_component] fn bar_init() -> Result<(), component::ComponentInitError> { assert_eq!(HAS_INIT.load(Relaxe...
kernel/libs/comp-sys/component/tests/init-order/first-init/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use std::sync::atomic::{Ordering::Relaxed, AtomicBool}; use component::init_component; pub static HAS_INIT: AtomicBool = AtomicBool::new(false); #[init_component] fn foo_init() -> Result<(), component::ComponentInitError> { assert_eq!(first_init::HAS_INIT.load(Relaxed), true)...
kernel/libs/comp-sys/component/tests/init-order/second-init/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use second_init::HAS_INIT; use std::sync::atomic::Ordering::Relaxed; #[test] fn test() { simple_logger::init_with_level(log::Level::Debug).unwrap(); component::init_all(component::InitStage::Bootstrap, component::parse_metadata!()).unwrap(); assert_eq!(HAS_INIT.load(Rel...
kernel/libs/comp-sys/component/tests/init-order/second-init/tests/test.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use std::sync::atomic::{Ordering::Relaxed, AtomicBool}; use component::init_component; static HAS_INIT: AtomicBool = AtomicBool::new(false); #[init_component] fn kernel_init() -> Result<(), component::ComponentInitError> { assert_eq!(first_init::HAS_INIT.load(Relaxed), true);...
kernel/libs/comp-sys/component/tests/init-order/src/main.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use first_init::HAS_INIT; use component::init_component; use std::sync::atomic::Ordering::Relaxed; #[init_component] fn kernel_init() -> Result<(), component::ComponentInitError> { Ok(()) } #[test] fn test() { simple_logger::init_with_level(log::Level::Debug).unwrap(); ...
kernel/libs/comp-sys/component/tests/init-order/tests/test.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; use component::{init_component, InitStage}; pub static INIT_BOOTSTRAP: AtomicBool = AtomicBool::new(false); pub static INIT_KTHREAD: AtomicBool = AtomicBool::new(false); pub static INIT_PROCESS: AtomicBool = AtomicBool::new(f...
kernel/libs/comp-sys/component/tests/init-stage/foo/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; use component::{init_component, InitStage}; use foo::{INIT_BOOTSTRAP, INIT_KTHREAD, INIT_PROCESS}; fn main() { simple_logger::init_with_level(log::Level::Debug).unwrap(); component::init_all(component::InitStage::Boot...
kernel/libs/comp-sys/component/tests/init-stage/src/main.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This crate defines two attribute macros `controlled` and `uncontrolled`. //! This two macros are attached to functions or static variables to enable crate level access control. //! To use these two macros, a crate must at first registers a tool named `component_access_control`, ...
kernel/libs/comp-sys/controlled/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub type Result<T> = core::result::Result<T, self::Error>; /// Errors of CPIO decoder. #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Error { MagicError, Utf8Error, ParseIntError, FileTypeError, FileNameError, BufferShortError, IoError, } impl Fr...
kernel/libs/cpio-decoder/src/error.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! A safe Rust CPIO (the newc format) decoder. //! //! # Example //! //! ```rust //! use cpio_decoder::CpioDecoder; //! use lending_iterator::LendingIterator; //! //! let short_buffer: Vec<u8> = Vec::new(); //! let mut decoder = CpioDecoder::new(short_buffer.as_slice()); //! if let...
kernel/libs/cpio-decoder/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use lending_iterator::LendingIterator; use super::{CpioDecoder, FileType, error::*}; #[test] fn decoder() { use std::process::{Command, Stdio}; let manifest_path = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let manifest_path = std::path::Path::new(manifest_path.as_...
kernel/libs/cpio-decoder/src/test.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! A module represents Linux kernel device IDs. //! //! In Linux, each device is identified by a **major** number and a **minor** number. //! These two numbers together form a unique identifier for the device, which is used //! in device files (e.g., `/dev/sda`, `/dev/null`) and sy...
kernel/libs/device-id/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module implements hash algorithms developed by Bob Jenkins. //! //! For further information, visit: www.burtleburtle.net/bob/hash/doobs.html //! //! The hash functions in this module facilitate the production of 32-bit values for hash table lookups. //! Although the [Linux ...
kernel/libs/jhash/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Same as the standard `Arc`, except that it can be used as the key type of a hash table. //! //! # Motivation //! //! A type `K` is _keyable_ if it can be used as the key type for a hash map. Specifically, //! according to the document of `std::collections::HashMap`, the type `K`...
kernel/libs/keyable-arc/src/lib.rs
null
null
null
null
null
source
asterinas
# logo-ascii-art This crate provides ASCII art representations of the Asterinas logo. The ASCII art are offered as two static string slices containing the logo: * A classic black-and-white version; and * A vibrant, gradient-colored one, suitable for splash screens or command-line tool branding.
kernel/libs/logo-ascii-art/README.md
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Provides ASCII art representations of the Asterinas logo. //! //! This crate offers two static string slices containing the logo: //! a classic black-and-white version and //! a vibrant, gradient-colored one, //! suitable for splash screens or command-line tool branding. #![no_...
kernel/libs/logo-ascii-art/src/lib.rs
null
null
null
null
null
source
asterinas
...... .-++++=: .=+++++=: :+++++++=: .-++++++++=. .=**++==+++=. :****+-.=+++=. .=****+: .++++=. .+*...
kernel/libs/logo-ascii-art/src/logo_ascii_art.txt
null
null
null
null
null
source
asterinas
...... .-++++[39...
kernel/libs/logo-ascii-art/src/logo_ascii_art_gradient.txt
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use logo_ascii_art::get_black_white_version; /// Generates the ASCII art of the Asterinas logo in gradient colors. /// /// The gradient-color version is generated /// by applying a horizontal gradient color transformation /// on the black-and-white version. fn gen_gradient_color_ve...
kernel/libs/logo-ascii-art/src/main.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! define macro assert_type_same use crate::same::SameAs; pub type AssertTypeSame<Lhs, Rhs> = <Lhs as SameAs<Rhs>>::Output; #[macro_export] macro_rules! assert_type_same { ($lhs:ty, $rhs:ty) => { const _: $crate::assert::AssertTypeSame<$lhs, $rhs> = $crate::True; ...
kernel/libs/typeflags-util/src/assert.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Type level bools pub use core::ops::{BitAnd as And, BitOr as Or, Not}; use core::unimplemented; pub trait Bool {} /// Type-level "true". pub struct True; /// Type-level "false". pub struct False; impl Bool for True {} impl Bool for False {} impl Not for True { type Out...
kernel/libs/typeflags-util/src/bool.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{Cons, Nil}; /// This trait will extend a set with another item. /// /// If the set already contains the item, it will return the original set. /// Otherwise, it will return the new set with the new item. /// The implementation should care about the item orders when exte...
kernel/libs/typeflags-util/src/extend.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Type Level If use crate::bool::{False, True}; pub trait If<B1, B2> { type Output; } impl<B1, B2> If<B1, B2> for True { type Output = B1; } impl<B1, B2> If<B1, B2> for False { type Output = B2; } pub type IfOp<Cond, B1, B2> = <Cond as If<B1, B2>>::Output; #[cfg(...
kernel/libs/typeflags-util/src/if_.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The content of this crate is from another project CapComp. //! This crate defines common type level operations, like SameAsOp, and Bool type operations. //! Besides, this crate defines operations to deal with type sets, like SetContain and SetInclude. //! When use typeflags or a...
kernel/libs/typeflags-util/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Traits used to check if two types are the same, returning a Bool. //! This check happens at compile time use crate::bool::{Bool, False, True}; pub trait SameAs<T> { type Output: Bool; } // A type is always same as itself impl<T> SameAs<T> for T { type Output = True; }...
kernel/libs/typeflags-util/src/same.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Common types and traits to deal with type-level sets use core::{marker::PhantomData, ops::BitOr as Or}; use crate::{ And, AndOp, False, OrOp, SameAs, SameAsOp, True, if_::{If, IfOp}, }; /// A marker trait for type-level sets. pub trait Set {} /// An non-empty type-le...
kernel/libs/typeflags-util/src/set.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use itertools::Itertools; use proc_macro2::{Ident, TokenStream}; use quote::{TokenStreamExt, quote}; use syn::Expr; use crate::type_flag::TypeFlagDef; /// A flagSet represent the combination of different flag item. /// e.g. [Read, Write], [Read], [] are all flag sets. /// The orde...
kernel/libs/typeflags/src/flag_set.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //!This crate defines the procedural macro typeflags to implement capability for Asterinas. //! When using this crate, typeflags-util should also be added as dependency. //! This is due to typeflgas is a proc-macro crate, which is only allowed to export proc-macro interfaces. //! So...
kernel/libs/typeflags/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use proc_macro2::TokenStream; use quote::quote; use syn::{ Attribute, Expr, Ident, Token, Type, Visibility, braced, parse::{Parse, ParseStream}, punctuated::Punctuated, }; /// The content inside typeflag macro pub struct TypeFlagDef { attributes: Vec<Attribute>, ...
kernel/libs/typeflags/src/type_flag.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use proc_macro2::{Ident, TokenStream}; use quote::{TokenStreamExt, quote}; use crate::{ flag_set::{FlagSet, generate_flag_sets}, type_flag::TypeFlagDef, }; pub fn expand_type_flag(type_flags_def: &TypeFlagDef) -> TokenStream { let mut all_tokens = TokenStream::new(); ...
kernel/libs/typeflags/src/util.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use core::ops::{Deref, DerefMut}; use ostd::{ sync::{SpinGuardian, SpinLockGuard, non_null::NonNullPtr}, task::atomic_mode::{AsAtomicModeGuard, InAtomicMode}, util::Either, }; use crate::{ SLOT_SIZE, XArray, XLockGuard, entry::NodeEntryRef...
kernel/libs/xarray/src/cursor.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use ostd::{ sync::non_null::{ArcRef, NonNullPtr}, util::Either, }; use crate::node::XNode; /// A type serving as the basic unit of storage for `XArray`s, used in the head of the `XArray` and /// the slots of `XNode`s. /// /// There are the following ...
kernel/libs/xarray/src/entry.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This crate introduces a RCU-based [`XArray`] implementation. //! //! `XArray` is an abstract data type functioning like an expansive array of items //! where each item is a [`NonNullPtr`], such as `Arc<T>` or `Box<T>`. It facilitates //! efficient sequential access to adjacent e...
kernel/libs/xarray/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::{AtomicU64, Ordering}; use crate::XLockGuard; /// A mark used to indicate which slots in an [`XNode`] contain items that have been marked. /// /// [`Xnode`]: super::node::XNode /// /// It internally stores an `AtomicU64`, functioning as a bitmap, where each...
kernel/libs/xarray/src/mark.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use core::{ cmp::Ordering, ops::{Deref, DerefMut}, }; use ostd::{ sync::{RcuOption, non_null::NonNullPtr}, task::atomic_mode::InAtomicMode, util::Either, }; use crate::{ BITS_PER_LAYER, SLOT_MASK, SLOT_SIZE, XLockGuard, entry::{Nod...
kernel/libs/xarray/src/node.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::sync::non_null::NonNullPtr; use crate::{cursor::Cursor, mark::NoneMark}; /// An iterator over a range of entries in an [`XArray`]. /// /// The typical way to obtain a `Range` instance is to call [`XArray::range`]. /// /// [`XArray`]: super::XArray /// [`XArray::range`]: ...
kernel/libs/xarray/src/range.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{boxed::Box, sync::Arc}; use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use ostd::{ prelude::ktest, task::{Task, disable_preempt}, }; use super::*; macro_rules! n { ( $x:expr ) => { $x * 10 }; } fn init_continuous_with_arc<M>(xarr...
kernel/libs/xarray/src/test.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The context that can be accessed from the current task, thread or process. use core::cell::Ref; use inherit_methods_macro::inherit_methods; use ostd::{ mm::{Fallible, PodAtomic, VmIo, VmReader, VmWriter}, task::Task, }; use crate::{ prelude::*, process::{ ...
kernel/src/context.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// A trait that describes the Linux system call convention (ABI) for the user context. pub trait LinuxAbi { /// Gets the system call number. fn syscall_num(&self) -> usize; /// Gets the return value of the system call. fn syscall_ret(&self) -> usize; /// Sets ...
kernel/src/cpu.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 /// Error number. #[expect(clippy::upper_case_acronyms)] #[repr(i32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum Errno { EPERM = 1, /* Operation not permitted */ ENOENT = 2, /* No such file or directory */ ESRCH = 3, /* No such process...
kernel/src/error.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Kernel initialization. use aster_cmdline::KCMDLINE; use component::InitStage; use ostd::{cpu::CpuId, util::id_set::Id}; use spin::once::Once; use crate::{ fs::path::{MountNamespace, PathResolver}, prelude::*, process::{Process, spawn_init_process}, sched::Sched...
kernel/src/init.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Aster-nix is the Asterinas kernel, a safe, efficient unix-like //! operating system kernel built on top of OSTD and OSDK. #![no_std] #![no_main] #![deny(unsafe_code)] #![feature(associated_type_defaults)] #![feature(btree_cursors)] #![feature(debug_closure_helpers)] #![feature(...
kernel/src/lib.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![expect(unused)] pub(crate) use alloc::{ boxed::Box, collections::{BTreeMap, BTreeSet, LinkedList, VecDeque}, ffi::CString, string::{String, ToString}, sync::{Arc, Weak}, vec, vec::Vec, }; pub(crate) use core::{any::Any, ffi::CStr, fmt::Debug}; pub(cr...
kernel/src/prelude.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Virtual Dynamic Shared Object (vDSO). //! //! vDSO enables user space applications to execute routines that access kernel space data without //! the need for user mode and kernel mode switching. This is particularly useful for frequently //! invoked, read-only operations such as...
kernel/src/vdso.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::fmt; use ostd::{ arch::cpu::context::{CpuExceptionInfo, UserContext}, cpu::PinCurrentCpu, task::DisabledPreemptGuard, user::UserContextApi, }; use crate::{cpu::LinuxAbi, thread::exception::PageFaultInfo, vm::perms::VmPerms}; impl LinuxAbi for UserContext...
kernel/src/arch/loongarch/cpu.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod cpu; mod power; pub mod signal; pub fn init() { power::init(); }
kernel/src/arch/loongarch/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::{ arch::boot::DEVICE_TREE, io::IoMem, mm::VmIoOnce, power::{ExitCode, inject_poweroff_handler}, }; use spin::Once; static POWEROFF_REG_AND_VAL: Once<(IoMem, u8)> = Once::new(); fn try_poweroff(_code: ExitCode) { // If possible, keep this method panic-...
kernel/src/arch/loongarch/power.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::cpu::context::{CpuExceptionInfo, UserContext}; use crate::process::signal::{SignalContext, sig_num::SigNum, signals::fault::FaultSignal}; impl SignalContext for UserContext { fn set_arguments(&mut self, sig_num: SigNum, siginfo_addr: usize, ucontext_addr: usize...
kernel/src/arch/loongarch/signal.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::fmt; use ostd::{ arch::cpu::context::{CpuException, UserContext}, cpu::PinCurrentCpu, task::DisabledPreemptGuard, user::UserContextApi, }; use crate::{cpu::LinuxAbi, thread::exception::PageFaultInfo, vm::perms::VmPerms}; impl LinuxAbi for UserContext { ...
kernel/src/arch/riscv/cpu.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::cpu::context::{CpuException, UserContext}; use crate::process::signal::{SignalContext, sig_num::SigNum, signals::fault::FaultSignal}; impl SignalContext for UserContext { fn set_arguments(&mut self, sig_num: SigNum, siginfo_addr: usize, ucontext_addr: usize) { ...
kernel/src/arch/riscv/signal.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{borrow::ToOwned, collections::btree_set::BTreeSet, string::String, vec::Vec}; use core::{arch::x86_64::CpuidResult, ffi::CStr, fmt, str}; use ostd::{ arch::{ cpu::{ context::{CpuException, PageFaultErrorCode, RawPageFaultInfo, UserContext}, ...
kernel/src/arch/x86/cpu.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::{ arch::{device::io_port::WriteOnlyAccess, kernel::ACPI_INFO}, io::IoPort, power::{ExitCode, inject_restart_handler}, }; use spin::Once; static ACPI_RESET_PORT_AND_VAL: Once<(IoPort<u8, WriteOnlyAccess>, u8)> = Once::new(); fn try_acpi_reset(_code: ExitCode) ...
kernel/src/arch/x86/power.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::cpu::context::{CpuException, PageFaultErrorCode, UserContext}; use crate::process::signal::{ SignalContext, constants::*, sig_num::SigNum, signals::fault::FaultSignal, }; impl SignalContext for UserContext { fn set_arguments(&mut self, sig_num: SigNum, sigi...
kernel/src/arch/x86/signal.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use aster_framebuffer::{ColorMapEntry, FRAMEBUFFER, FrameBuffer, MAX_CMAP_SIZE, PixelFormat}; use device_id::{DeviceId, MajorId, MinorId}; use ostd::mm::{HasPaddr, HasSize, VmIo, io_util::HasVmReaderWriter}; use super::registry::char; use crate::{ current...
kernel/src/device/fb.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod evdev; mod fb; mod mem; pub mod misc; mod pty; mod registry; mod shm; pub mod tty; pub use mem::{getrandom, geturandom}; pub use pty::{PtyMaster, PtySlave, new_pty_pair}; pub use registry::lookup; use crate::{ fs::{ path::{FsPath, PerMountFlags}, ramfs::Ram...
kernel/src/device/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{ fs::{ path::{FsPath, PathResolver, PerMountFlags}, ramfs::RamFs, utils::{InodeType, chmod}, }, prelude::*, }; /// Initializes "/dev/shm" for POSIX shared memory usage. pub fn init_in_first_process(path_resolver: &PathResolver, ctx: &...
kernel/src/device/shm.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Weak; use core::{ fmt::Debug, sync::atomic::{AtomicU8, AtomicUsize, Ordering}, time::Duration, }; use aster_input::{ event_type_codes::{EventTypes, SynEvent}, input_dev::InputEvent, }; use atomic_integer_wrapper::define_atomic_version_of_integer...
kernel/src/device/evdev/file.rs
null
null
null
null
null