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 | # Running an OS in Intel TDX env
The OSDK supports running your OS in an [Intel TDX](https://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/overview.html) environment conveniently.
Intel TDX can provide a more secure environment for your OS.
## Prepare the Intel TDX Environment
Please make s... | book/src/osdk/guide/intel-tdx.md | null | null | null | null | null |
source | asterinas | # Running or Testing an OS Project
The OSDK allows for convenient building, running,
and testing of an OS project.
The following example shows the typical workflow.
Suppose you have created a new kernel project named `myos`
and you are in the project directory:
```bash
cargo osdk new --kernel myos && cd myos
```
##... | book/src/osdk/guide/run-project.md | null | null | null | null | null |
source | asterinas | # Why OSDK
OSDK is designed to elevate the development experience
for Rust OS developers to the ease and convenience
typically associated with Rust application development.
Imagine crafting operating systems
with the same simplicity as applications!
This is important to Asterinas
as we believe that the project's succe... | book/src/osdk/guide/why.md | null | null | null | null | null |
source | asterinas | # Working in a Workspace
Typically, an operating system may consist of multiple crates,
and these crates may be organized in a workspace.
The OSDK also supports managing projects in a workspace.
Below is an example that demonstrates
how to create, build, run, and test projects in a workspace.
## Creating a new worksp... | book/src/osdk/guide/work-in-workspace.md | null | null | null | null | null |
source | asterinas | # OSDK User Reference
The Asterinas OSDK is a command line tool that can be used
as a subcommand of Cargo.
The common usage of OSDK is:
```bash
cargo osdk <COMMAND>
```
You can use `cargo osdk -h`
to see the full list of available commands.
For the specific usage of a subcommand,
you can use `cargo osdk help <COMMAN... | book/src/osdk/reference/README.md | null | null | null | null | null |
source | asterinas | # Environment Variables
The OSDK tool uses the following environment variables to customize compilation and target behavior.
## OSDK-Specific Variables
- `OSDK_TARGET_ARCH`: If set, OSDK will use the specified value as its default target architecture (e.g., x86_64, riscv64).
If not set, OSDK will default to the hos... | book/src/osdk/reference/environment-variables.md | null | null | null | null | null |
source | asterinas | # Manifest
## Overview
The OSDK tool utilizes a manifest to define its precise behavior.
Typically, the configuration file is named `OSDK.toml`
and is placed in the root directory of the workspace
(the same directory as the workspace's `Cargo.toml`).
If there is only one crate and no workspace,
the file is placed in ... | book/src/osdk/reference/manifest.md | null | null | null | null | null |
source | asterinas | # Commands
OSDK provides similar subcommands as Cargo,
and these subcommands have similar meanings
as corresponding Cargo subcommands.
Currently, OSDK supports the following subcommands:
- **new**: Create a new kernel package or library package
- **build**: Compile the project and its dependencies
- **run**: Run the... | book/src/osdk/reference/commands/README.md | null | null | null | null | null |
source | asterinas | # cargo osdk build
## Overview
The `cargo osdk build` command is used to
compile the project and its dependencies.
The usage is as follows:
```bash
cargo osdk build [OPTIONS]
```
## Options
The options can be divided into two types:
Cargo options that can be accepted by Cargo,
and Manifest options that can also be ... | book/src/osdk/reference/commands/build.md | null | null | null | null | null |
source | asterinas | # cargo osdk debug
## Overview
`cargo osdk debug` is used to debug a remote target via GDB. You need to start
a running server to debug with. This is accomplished by the `run` subcommand
with `--gdb-server`. Then you can use the following command to attach to the
server and do debugging.
```bash
cargo osdk debug [OP... | book/src/osdk/reference/commands/debug.md | null | null | null | null | null |
source | asterinas | # cargo osdk new
## Overview
The `cargo osdk new` command
is used to create a kernel project
or a new library project.
The usage is as follows:
```bash
cargo osdk new [OPTIONS] <name>
```
## Arguments
`<name>`: the name of the crate.
## Options
`--kernel`:
Use the kernel template.
If this option is not set,
the ... | book/src/osdk/reference/commands/new.md | null | null | null | null | null |
source | asterinas | # cargo osdk profile
## Overview
The profile command is used to collect stack traces when running the target
kernel in QEMU. It attaches to the GDB server, initiated with the run subcommand,
and collects the stack trace periodically. The collected information can be
used to directly generate a flame graph, or be stor... | book/src/osdk/reference/commands/profile.md | null | null | null | null | null |
source | asterinas | # cargo osdk run
## Overview
`cargo osdk run` is used to run the kernel with QEMU.
The usage is as follows:
```bash
cargo osdk run [OPTIONS]
```
## Options
Most options are the same as those of `cargo osdk build`.
Refer to the [documentation](build.md) of `cargo osdk build`
for more details.
Additionally, when ru... | book/src/osdk/reference/commands/run.md | null | null | null | null | null |
source | asterinas | # cargo osdk test
`cargo osdk test` is used to
execute kernel mode unit test by starting QEMU.
The usage is as follows:
```bash
cargo osdk test [TESTNAME] [OPTIONS]
```
## Arguments
`TESTNAME`:
Only run tests containing this string in their names
## Options
The options are the same as those of `cargo osdk build... | book/src/osdk/reference/commands/test.md | null | null | null | null | null |
source | asterinas | # Asterinas OSTD
> Confucious remarked,
> "I could follow whatever my heart desired
> without transgressing the law."
>
> 子曰:
> "从心所欲,不逾矩。"
With the Asterinas OSTD (Operating System Standard Library),
you don't have to learn the dark art of unsafe Rust programming
and risk shooting yourself in the foot.
You will be ... | book/src/ostd/README.md | null | null | null | null | null |
source | asterinas | # Example: Writing a Kernel in About 100 Lines of Safe Rust
To give you a sense of
how Asterinas OSTD enables writing kernels in safe Rust,
we will show a new kernel in about 100 lines of safe Rust.
Our new kernel will be able to run the following Hello World program.
```s
{{#include ../../../osdk/tests/examples_in_... | book/src/ostd/a-100-line-kernel.md | null | null | null | null | null |
source | asterinas | # RFC-0001: RFC process
* Status: Implemented
* Pull request: https://github.com/asterinas/asterinas/pull/2365/
* Date submitted: 2025-08-24
* Date approved: 2025-09-05
## Summary
The "RFC" (request for comments) process is intended to provide a consistent, transparent, structured path for the community to make "big... | book/src/rfcs/0001-rfc-process.md | null | null | null | null | null |
source | asterinas | # RFC-0002: Asterinas NixOS
* Status: Approved
* Pull request: https://github.com/asterinas/asterinas/pull/2584
* Date submitted: 2025-11-14
* Date approved: 2025-12-01
## Summary
This RFC formally proposes the establishment of an Asterinas distribution as a new, top-level sub-project of Asterinas. We intend for thi... | book/src/rfcs/0002-asterinas-nixos.md | null | null | null | null | null |
source | asterinas | # RFC Overview
The Asterinas RFC process is intended to provide a consistent, transparent, structured path for the community to make "big" decisions. For example, the RFC process can be used to evolve the project roadmap and the system architecture.
For more details, see the [RFC-0001 RFC process](0001-rfc-process.md... | book/src/rfcs/README.md | null | null | null | null | null |
source | asterinas | # RFC-0000: Your short, descriptive title
* Status: Draft
* Pull request: (link to PR)
* Date submitted: YYYY-MM-DD
* Date approved: YYYY-MM-DD
## Summary
Provide a concise, one-paragraph summary of the proposed change. This should explain the core idea at a high level, making it understandable to someone without de... | book/src/rfcs/rfc-template.md | null | null | null | null | null |
source | asterinas | # Boterinas
## Introduction
`@boterinas` is a general-purpose bot designed for a wide variety of tasks in Asterinas. It streamlines maintenance tasks to enhance workflow efficiency.
Commands are issued by writing comments that start with the text `@boterinas`. The available commands depend on which repository you ... | book/src/to-contribute/boterinas.md | null | null | null | null | null |
source | asterinas | # Version Bump
## Version Numbers
Currently, Asterinas regularly releases two main artifacts
for the Rust OS developer community:
the [OSDK](https://crates.io/crates/cargo-osdk) and [OSTD](https://crates.io/crates/ostd).
To support development with these tools,
we also publish companion Docker images on DockerHub,
(i... | book/src/to-contribute/version-bump.md | null | null | null | null | null |
source | asterinas | # Assembly Guidelines
## Define sections
To define built-in sections, such as the text section,
it is preferable to use the short directive, e.g., `.text`.
For other sections,
the section directive with the desired flags and type should be used,
e.g., `.section ".bsp_boot", "awx", @progbits`.
To ensure consistency a... | book/src/to-contribute/style-guidelines/asm-guidelines.md | null | null | null | null | null |
source | asterinas | # Rust Guidelines
## API Documentation Guidelines
API documentation describes the meanings and usage of APIs,
and will be rendered into web pages by rustdoc.
It is necessary to add documentation to all public APIs,
including crates, modules, structs, traits, functions, macros, and more.
The use of the `#[warn(missin... | book/src/to-contribute/style-guidelines/rust-guidelines.md | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::AtomicU64;
use align_ext::AlignExt;
use aster_util::mem_obj_slice::Slice;
use bitvec::array::BitArray;
use int_to_c_enum::TryFromInt;
use ostd::{
Error,
mm::{
HasSize, Infallible, USegment, VmReader, VmWriter,
dma::DmaStream,
... | kernel/comps/block/src/bio.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::collections::btree_set::BTreeSet;
use device_id::{DeviceId, MajorId, MinorId};
use id_alloc::IdAlloc;
use ostd::sync::Mutex;
use spin::Once;
use crate::Error;
/// The maximum value of the major device ID of a block device.
///
/// Reference: <https://elixir.bootlin.com... | kernel/comps/block/src/device_id.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
iter::Step,
ops::{Add, Sub},
};
use ostd::const_assert;
/// The block index used in the filesystem.
pub type Bid = BlockId<BLOCK_SIZE>;
/// The sector index used in the device.
pub type Sid = BlockId<SECTOR_SIZE>;
impl From<Bid> for Sid {
fn from(bid: Bid)... | kernel/comps/block/src/id.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::mm::{VmIo, VmReader, VmWriter};
use super::{
BLOCK_SIZE, BlockDevice,
bio::{Bio, BioEnqueueError, BioSegment, BioStatus, BioType, BioWaiter, SubmittedBio},
id::{Bid, Sid},
};
use crate::{
bio::{BioDirection, is_sector_aligned},
prelude::*,
};
/// Impl... | kernel/comps/block/src/impl_block_device.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The block devices of Asterinas.
//!
//!This crate provides a number of base components for block devices, including
//! an abstraction of block devices, as well as the registration and lookup of block devices.
//!
//! Block devices use a queue-based model for asynchronous I/O op... | kernel/comps/block/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use device_id::DeviceId;
use ostd::mm::VmIo;
use ostd_pod::Pod;
use crate::{
BlockDevice, BlockDeviceMeta, SECTOR_SIZE,
bio::{BioEnqueueError, SubmittedBio},
prelude::*,
};
/// Represents a partition entry.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Partitio... | kernel/comps/block/src/partition.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
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},
}; | kernel/comps/block/src/prelude.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::sync::{Mutex, WaitQueue};
use super::{
bio::{BioEnqueueError, BioType, SubmittedBio},
id::Sid,
};
use crate::prelude::*;
/// A simple block I/O request queue backed by one internal FIFO queue.
///
/// It is a FIFO producer-consumer queue, where the producer (e.g.... | kernel/comps/block/src/request_queue.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The module to parse kernel command-line arguments.
//!
//! The format of the Asterinas command line string conforms
//! to the Linux kernel command line rules:
//!
//! <https://www.kernel.org/doc/html/v6.4/admin-guide/kernel-parameters.html>
//!
#![no_std]
#![deny(unsafe_code)]
... | kernel/comps/cmdline/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Font types.
use alloc::{boxed::Box, vec::Vec};
use font8x8::UnicodeFonts;
/// A bitmap font.
///
/// Currently it's mainly used to draw texts on the framebuffer console.
#[derive(Debug)]
pub struct BitmapFont {
width: usize,
height: usize,
char_size: usize,
bi... | kernel/comps/console/src/font.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The console device of Asterinas.
#![no_std]
#![deny(unsafe_code)]
extern crate alloc;
pub mod font;
pub mod mode;
use alloc::{collections::BTreeMap, fmt::Debug, string::String, sync::Arc, vec::Vec};
use core::any::Any;
use component::{ComponentInitError, init_component};
us... | kernel/comps/console/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Mode types.
use int_to_c_enum::TryFromInt;
/// The console mode (text or graphics).
///
/// Reference: <https://elixir.bootlin.com/linux/v6.17.4/source/include/uapi/linux/kd.h#L45>.
#[derive(Debug, Clone, Copy, PartialEq, Eq, TryFromInt)]
#[repr(i32)]
pub enum ConsoleMode {
... | kernel/comps/console/src/mode.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::Pixel;
/// A finite-state machine (FSM) to handle ANSI escape sequences.
#[derive(Debug)]
pub(super) struct EscapeFsm {
state: WaitFor,
params: [u32; MAX_PARAMS],
}
/// A trait to execute operations from ANSI escape sequences.
pub(super) trait EscapeOp {
///... | kernel/comps/framebuffer/src/ansi_escape.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{sync::Arc, vec::Vec};
use aster_console::{
AnyConsoleDevice, ConsoleCallback, ConsoleSetFontError,
font::BitmapFont,
mode::{ConsoleMode, KeyboardMode},
};
use ostd::{
mm::{HasSize, VmReader},
sync::{LocalIrqDisabled, SpinLock},
};
use spin::Once;
us... | kernel/comps/framebuffer/src/console.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use core::sync::atomic::{AtomicBool, Ordering};
use aster_input::{
event_type_codes::{KeyCode, KeyStatus},
input_dev::{InputDevice, InputEvent},
input_handler::{ConnectError, InputHandler, InputHandlerClass},
};
use crate::FRAMEBUFFER_CONSOLE;
#[... | kernel/comps/framebuffer/src/console_input.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_console::{
AnyConsoleDevice, ConsoleCallback, ConsoleSetFontError,
font::BitmapFont,
mode::{ConsoleMode, KeyboardMode},
};
/// A dummy console device.
///
/// This is used when no framebuffer is available. All operations are no-ops.
#[derive(Debug)]
pub struct... | kernel/comps/framebuffer/src/dummy_console.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{sync::Arc, vec::Vec};
use ostd::{
Error, Result,
boot::boot_info,
io::IoMem,
mm::{CachePolicy, HasSize, VmIo},
sync::Mutex,
};
use spin::Once;
use crate::{Pixel, PixelFormat, RenderedPixel};
/// Maximum number of colormap entries (standard 8-bit pa... | kernel/comps/framebuffer/src/framebuffer.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The framebuffer of Asterinas.
#![no_std]
#![deny(unsafe_code)]
extern crate alloc;
mod ansi_escape;
mod console;
mod console_input;
mod dummy_console;
mod framebuffer;
mod pixel;
use component::{ComponentInitError, init_component};
pub use console::{CONSOLE_NAME, FRAMEBUFFER_... | kernel/comps/framebuffer/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
/// Individual pixel data containing raw channel values.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Pixel {
pub red: u8,
pub green: u8,
pub blue: u8,
}
/// Pixel format that defines the memory layout of each pixel in the framebuffer.
#[derive(Debug, Copy, C... | kernel/comps/framebuffer/src/pixel.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Provides i8042 PS/2 Controller I/O port access.
//!
//! Reference: <https://wiki.osdev.org/I8042_PS/2_Controller>
//!
use aster_cmdline::{KCMDLINE, ModuleArg};
use bitflags::bitflags;
use ostd::{
arch::{device::io_port::ReadWriteAccess, kernel::ACPI_INFO},
io::IoPort,
... | kernel/comps/i8042/src/controller.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The i8042 keyboard driver.
use alloc::{
string::{String, ToString},
sync::Arc,
};
use core::sync::atomic::{AtomicBool, Ordering};
use aster_input::{
event_type_codes::{KeyCode, KeyStatus, SynEvent},
input_dev::{InputCapability, InputDevice, InputEvent, InputId,... | kernel/comps/i8042/src/keyboard.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Handle keyboard input.
#![no_std]
#![deny(unsafe_code)]
#![cfg(target_arch = "x86_64")]
extern crate alloc;
use component::{ComponentInitError, init_component};
mod controller;
mod keyboard;
mod mouse;
mod ps2;
#[init_component]
fn init() -> Result<(), ComponentInitError> {
... | kernel/comps/i8042/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The i8042 mouse driver.
use alloc::{
string::{String, ToString},
sync::Arc,
vec::Vec,
};
use aster_input::{
event_type_codes::{KeyCode, KeyStatus, RelCode, SynEvent},
input_dev::{InputCapability, InputDevice, InputEvent, InputId, RegisteredInputDevice},
};
... | kernel/comps/i8042/src/mouse.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Common utilities for PS/2 devices.
use crate::controller::{I8042Controller, I8042ControllerError};
const PS2_CMD_RESET: u8 = 0xFF;
const PS2_BAT_OK: u8 = 0xAA;
const PS2_ACK: u8 = 0xFA;
const PS2_NAK: u8 = 0xFE;
const PS2_ERR: u8 = 0xFC;
const PS2_RESULTS: &[u8] = &[PS2_ACK, ... | kernel/comps/i8042/src/ps2.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Event types and codes.
//!
//! This file is based on the USB HUT 1.12 specification
//! (see <http://www.usb.org/developers/hidpage>) and follows the
//! Linux input event codes standard for maximum compatibility.
//!
//! The USB HUT standard ensures consistent event type and va... | kernel/comps/input/src/event_type_codes.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 ostd::sync::{RwLock, WriteIrqDisabled};
use crate::{
InputDevice,
input_dev::RegisteredInputDevice,
input_handler::{BoundInputHandler, InputHandlerClass},
};
/// Registry entry for each registered device.
///... | kernel/comps/input/src/input_core.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{sync::Arc, vec::Vec};
use core::{any::Any, fmt::Debug};
use ostd::sync::{RwLock, WriteIrqDisabled};
use crate::{
event_type_codes::{EventTypes, KeyCode, KeyCodeSet, KeyStatus, RelCode, RelCodeSet, SynEvent},
input_handler::BoundInputHandler,
unregister_devi... | kernel/comps/input/src/input_dev.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use core::{any::Any, fmt::Debug};
use crate::{InputDevice, input_dev::InputEvent, unregister_handler_class};
/// Errors that can occur when connecting to an input device.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConnectError {
/// Device is n... | kernel/comps/input/src/input_handler.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The input devices of Asterinas.
//!
//! This crate provides a comprehensive input subsystem for handling various input devices,
//! including keyboards, mice, etc. It implements an event-driven architecture similar to
//! the Linux input subsystem.
//!
//! # Architecture
//!
//!... | kernel/comps/input/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::time::Duration;
use log::{Metadata, Record};
use ostd::timer::Jiffies;
/// The logger used for Asterinas.
struct AsterLogger;
static LOGGER: AsterLogger = AsterLogger;
impl log::Log for AsterLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
true
... | kernel/comps/logger/src/aster_logger.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! `print` and `println` macros
//!
//! FIXME: It will print to all `virtio-console` devices, which is not a good choice.
//!
use alloc::{collections::btree_map::BTreeMap, fmt, string::String, sync::Arc};
use core::fmt::Write;
use aster_console::AnyConsoleDevice;
use ostd::sync::... | kernel/comps/logger/src/console.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The logger implementation for Asterinas.
//!
//! This logger now has the most basic logging functionality, controls the output
//! based on the globally set log level. Different log levels will be represented
//! with different colors if enabling `log_color` feature.
//!
//! Thi... | kernel/comps/logger/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::fmt;
/// The error types used in this crate.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Errno {
/// Transaction aborted.
TxAborted,
/// Not found.
NotFound,
/// Invalid arguments.
InvalidArgs,
/// Out of memory.
OutOfMemory,
... | kernel/comps/mlsdisk/src/error.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![no_std]
#![deny(unsafe_code)]
#![feature(negative_impls)]
#![allow(unfulfilled_lint_expectations)]
#![expect(dead_code, deprecated, unused_imports)]
mod error;
mod layers;
mod os;
mod prelude;
mod tx;
mod util;
extern crate alloc;
#[macro_use]
extern crate ostd_pod;
use alloc:... | kernel/comps/mlsdisk/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub(crate) use crate::{
error::{Errno::*, Error},
layers::bio::{BLOCK_SIZE, BlockId},
os::{Arc, Box, String, ToString, Vec, Weak},
return_errno, return_errno_with_msg,
util::{Aead as _, RandomInit, Rng as _, Skcipher as _, align_down, align_up},
};
pub(crate) ty... | kernel/comps/mlsdisk/src/prelude.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#[path = "0-bio/mod.rs"]
pub mod bio;
#[path = "1-crypto/mod.rs"]
pub mod crypto;
#[path = "5-disk/mod.rs"]
pub mod disk;
#[path = "2-edit/mod.rs"]
pub mod edit;
#[path = "3-log/mod.rs"]
pub mod log;
#[path = "4-lsm/mod.rs"]
pub mod lsm; | kernel/comps/mlsdisk/src/layers/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module provides API to represent buffers whose
//! sizes are block aligned. The advantage of using the
//! APIs provided this module over Rust std's counterparts
//! is to ensure the invariance of block-aligned length
//! at type level, eliminating the need for runtime chec... | kernel/comps/mlsdisk/src/layers/0-bio/block_buf.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicUsize, Ordering};
use inherit_methods_macro::inherit_methods;
use super::{Buf, BufMut, BufRef};
use crate::{os::Mutex, prelude::*};
/// A log of data blocks that can support random reads and append-only
/// writes.
///
/// # Thread safety
///
/// `B... | kernel/comps/mlsdisk/src/layers/0-bio/block_log.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{BlockLog, BlockSet, BufMut, BufRef};
use crate::{os::Mutex, prelude::*};
/// `BlockRing<S>` emulates a blocks log (`BlockLog`) with infinite
/// storage capacity by using a block set (`S: BlockSet`) of finite storage
/// capacity.
///
/// `BlockRing<S>` uses the entire ... | kernel/comps/mlsdisk/src/layers/0-bio/block_ring.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::Range;
use inherit_methods_macro::inherit_methods;
use super::{Buf, BufMut, BufRef};
use crate::{error::Errno, os::Mutex, prelude::*};
/// A fixed set of data blocks that can support random reads and writes.
///
/// # Thread safety
///
/// `BlockSet` is a data stru... | kernel/comps/mlsdisk/src/layers/0-bio/block_set.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The layer of untrusted block I/O.
mod block_buf;
mod block_log;
mod block_ring;
mod block_set;
use ostd::const_assert;
pub use self::{
block_buf::{Buf, BufMut, BufRef},
block_log::{BlockLog, MemLog},
block_ring::BlockRing,
block_set::{BlockSet, MemDisk},
};
p... | kernel/comps/mlsdisk/src/layers/0-bio/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd_pod::{FromZeros, IntoBytes, Pod};
use super::{Iv, Key, Mac, VersionId};
use crate::{
layers::bio::{BLOCK_SIZE, BlockSet, Buf},
os::{Aead, Mutex},
prelude::*,
};
/// A cryptographically-protected blob of user data.
///
/// `CryptoBlob<B>` allows a variable-leng... | kernel/comps/mlsdisk/src/layers/1-crypto/crypto_blob.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::Range;
use lending_iterator::prelude::*;
use ostd_pod::{IntoBytes, Pod};
use super::{Iv, Key, Mac};
use crate::{
layers::bio::{BLOCK_SIZE, BlockId, BlockLog, Buf},
os::Aead,
prelude::*,
};
/// A cryptographically-protected chain of blocks.
///
/// `Cryp... | kernel/comps/mlsdisk/src/layers/1-crypto/crypto_chain.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::vec;
use core::any::Any;
use ostd::const_assert;
use ostd_pod::{FromZeros, IntoBytes, Pod};
use serde::{Deserialize, Serialize};
use super::{Iv, Key, Mac};
use crate::{
layers::bio::{BLOCK_SIZE, BlockId, BlockLog, Buf, BufMut, BufRef},
os::{Aead, HashMap, Mutex,... | kernel/comps/mlsdisk/src/layers/1-crypto/crypto_log.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The layer of cryptographical constructs.
mod crypto_blob;
mod crypto_chain;
mod crypto_log;
pub use self::{
crypto_blob::CryptoBlob,
crypto_chain::CryptoChain,
crypto_log::{CryptoLog, NodeCache, RootMhtMeta},
};
pub type Key = crate::os::AeadKey;
pub type Iv = cra... | kernel/comps/mlsdisk/src/layers/1-crypto/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::marker::PhantomData;
use serde::{Deserialize, Serialize, ser::SerializeSeq};
use crate::prelude::*;
/// An edit of `Edit<S>` is an incremental change to a state of `S`.
pub trait Edit<S>: Serialize + for<'de> Deserialize<'de> {
/// Apply this edit to a state.
fn... | kernel/comps/mlsdisk/src/layers/2-edit/edits.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::marker::PhantomData;
use lending_iterator::LendingIterator;
use ostd_pod::{IntoBytes, Pod};
use serde::{
Deserialize, Serialize,
de::{VariantAccess, Visitor},
};
use super::{Edit, EditGroup};
use crate::{
layers::{
bio::{BlockRing, BlockSet, Buf},
... | kernel/comps/mlsdisk/src/layers/2-edit/journal.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The layer of edit journal.
mod edits;
mod journal;
pub use self::{
edits::{Edit, EditGroup},
journal::{
CompactPolicy, DefaultCompactPolicy, EditJournal, EditJournalMeta, NeverCompactPolicy,
},
}; | kernel/comps/mlsdisk/src/layers/2-edit/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Chunk-based storage management.
//!
//! A chunk is a group of consecutive blocks.
//! As the size of a chunk is much greater than that of a block,
//! the number of chunks is naturally far smaller than that of blocks.
//! This makes it possible to keep all metadata for chunks in... | kernel/comps/mlsdisk/src/layers/3-log/chunk.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The layer of transactional logging.
//!
//! `TxLogStore` is a transactional, log-oriented file system.
//! It supports creating, deleting, listing, reading, and writing `TxLog`s.
//! Each `TxLog` is an append-only log, and assigned an unique `TxLogId`.
//! All `TxLogStore`'s API... | kernel/comps/mlsdisk/src/layers/3-log/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! A store of raw (untrusted) logs.
//!
//! `RawLogStore<D>` allows creating, deleting, reading and writing
//! `RawLog<D>`. Each raw log is uniquely identified by its ID (`RawLogId`).
//! Writing to a raw log is append only.
//!
//! `RawLogStore<D>` stores raw logs on a disk of `D... | kernel/comps/mlsdisk/src/layers/3-log/raw_log.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! A store of transactional logs.
//!
//! `TxLogStore<D>` supports creating, deleting, listing, reading,
//! and writing `TxLog<D>`s within transactions. Each `TxLog<D>`
//! is uniquely identified by its ID (`TxLogId`). Writing to a TX log
//! is append only. TX logs are categorize... | kernel/comps/mlsdisk/src/layers/3-log/tx_log.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Compaction in `TxLsmTree`.
use core::marker::PhantomData;
use super::{
LsmLevel, RecordKey, RecordValue, SyncId, TxEventListener, mem_table::ValueEx,
sstable::SSTable, tx_lsm_tree::SSTABLE_CAPACITY,
};
use crate::{
layers::{bio::BlockSet, log::TxLogStore},
os::{... | kernel/comps/mlsdisk/src/layers/4-lsm/compaction.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! MemTable.
use core::ops::Range;
use super::{AsKV, RangeQueryCtx, RecordKey, RecordValue, SyncId, tx_lsm_tree::OnDropRecodeFn};
use crate::{
os::{BTreeMap, Condvar, CvarMutex, Mutex, RwLock, RwLockReadGuard},
prelude::*,
};
/// Manager for an mutable `MemTable` and an i... | kernel/comps/mlsdisk/src/layers/4-lsm/mem_table.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The layer of transactional Lsm-Tree.
//!
//! This module provides the implementation for `TxLsmTree`.
//! `TxLsmTree` is similar to general-purpose LSM-Tree, supporting `put()`, `get()`, `get_range()`
//! key-value records, which are managed in MemTables and SSTables.
//!
//! `T... | kernel/comps/mlsdisk/src/layers/4-lsm/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
// Context for range query.
use core::ops::RangeInclusive;
use super::{RecordKey, RecordValue};
use crate::{prelude::*, util::BitMap};
/// Context for a range query request.
/// It tracks the completing process of each slot within the range.
/// A "slot" indicates one specific key... | kernel/comps/mlsdisk/src/layers/4-lsm/range_query_ctx.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Sorted String Table.
use alloc::vec;
use core::{marker::PhantomData, num::NonZeroUsize, ops::RangeInclusive};
use lru::LruCache;
use ostd_pod::{IntoBytes, Pod};
use super::{
RangeQueryCtx, RecordKey, RecordValue, SyncId, TxEventListener, mem_table::ValueEx,
tx_lsm_tree... | kernel/comps/mlsdisk/src/layers/4-lsm/sstable.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Transactional LSM-Tree.
//!
//! API: `format()`, `recover()`, `get()`, `put()`, `get_range()`, `sync()`
//!
//! Responsible for managing two `MemTable`s, WAL and SSTs as `TxLog`s
//! backed by a `TxLogStore`. All operations are executed based
//! on internal transactions.
use al... | kernel/comps/mlsdisk/src/layers/4-lsm/tx_lsm_tree.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Transactions in WriteAhead Log.
use alloc::vec;
use core::fmt::Debug;
use ostd_pod::Pod;
use super::{AsKV, SyncId};
use crate::{
layers::{
bio::{BlockId, BlockSet, Buf, BufRef},
log::{TxLog, TxLogId, TxLogStore},
},
os::Mutex,
prelude::*,
tx... | kernel/comps/mlsdisk/src/layers/4-lsm/wal.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Block I/O (BIO).
use alloc::collections::VecDeque;
use core::{
any::{Any, TypeId},
ptr::NonNull,
sync::atomic::{AtomicUsize, Ordering},
};
use hashbrown::HashMap;
use crate::{
Buf,
os::{Mutex, MutexGuard},
prelude::*,
};
/// A queue for managing block ... | kernel/comps/mlsdisk/src/layers/5-disk/bio.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Block allocation.
use alloc::vec;
use core::{
num::NonZeroUsize,
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};
use ostd_pod::{IntoBytes, Pod};
use serde::{Deserialize, Serialize};
use super::mlsdisk::Hba;
use crate::{
layers::{
bio::{BID_SIZE, Block... | kernel/comps/mlsdisk/src/layers/5-disk/block_alloc.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Data buffering.
use core::ops::RangeInclusive;
use super::mlsdisk::RecordKey;
use crate::{
layers::bio::{BufMut, BufRef},
os::{BTreeMap, Condvar, CvarMutex, Mutex},
prelude::*,
};
/// A buffer to cache data blocks before they are written to disk.
#[derive(Debug)]
p... | kernel/comps/mlsdisk/src/layers/5-disk/data_buf.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! MlsDisk as a block device.
//!
//! API: submit_bio(), submit_bio_sync(), create(), open(),
//! read(), readv(), write(), writev(), sync().
//!
//! Responsible for managing a `TxLsmTree`, whereas the TX logs (WAL and SSTs)
//! are stored; an untrusted disk storing user data, a `B... | kernel/comps/mlsdisk/src/layers/5-disk/mlsdisk.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The layer of secure virtual disk.
//!
//! `MlsDisk` provides three block I/O interfaces, `read()`, `write()` and `sync()`.
//! `MlsDisk` protects a logical block of user data using authenticated encryption.
//! The metadata of the encrypted logical blocks are inserted into a sec... | kernel/comps/mlsdisk/src/layers/5-disk/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! OS-specific or OS-dependent APIs.
pub use alloc::{
boxed::Box,
collections::BTreeMap,
string::{String, ToString},
sync::{Arc, Weak},
vec::Vec,
};
use core::{
fmt,
sync::atomic::{AtomicBool, Ordering},
};
use aes_gcm::{
Aes128Gcm,
aead::{Aead... | kernel/comps/mlsdisk/src/os/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Get and set the current transaction of the current thread.
use core::sync::atomic::Ordering::{Acquire, Release};
use super::{Tx, TxData, TxId, TxProvider, TxStatus};
use crate::{os::CurrentThread, prelude::*};
/// The current transaction on a thread.
#[derive(Clone)]
pub struc... | kernel/comps/mlsdisk/src/tx/current.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Transaction management.
//!
//! Transaction management APIs serve two sides:
//!
//! * The user side of TXs uses `Tx` to use, commit, or abort TXs.
//! * The implementation side of TXs uses `TxProvider` to get notified
//! when TXs are created, committed, or aborted by registe... | kernel/comps/mlsdisk/src/tx/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::Index;
use bittle::{Bits, BitsMut};
use serde::{Deserialize, Serialize};
use crate::prelude::*;
/// A compact array of bits.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BitMap {
bits: Vec<u64>,
nbits: usize,
}
impl BitMap {
/// The one b... | kernel/comps/mlsdisk/src/util/bitmap.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::Deref;
use crate::prelude::Result;
/// Random initialization for Key, Iv and Mac.
pub trait RandomInit: Default {
fn random() -> Self;
}
/// Authenticated Encryption with Associated Data (AEAD) algorithm.
pub trait Aead {
type Key: Deref<Target = [u8]> + Ra... | kernel/comps/mlsdisk/src/util/crypto.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
fmt,
ops::{Deref, DerefMut},
sync::atomic::{AtomicBool, Ordering},
};
use crate::prelude::*;
/// An object that may be deleted lazily.
///
/// Lazy-deletion is a technique to postpone the real deletion of an object.
/// This technique allows an object to re... | kernel/comps/mlsdisk/src/util/lazy_delete.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Utilities.
mod bitmap;
mod crypto;
mod lazy_delete;
pub use self::{
bitmap::BitMap,
crypto::{Aead, RandomInit, Rng, Skcipher},
lazy_delete::LazyDelete,
};
/// Aligns `x` up to the next multiple of `align`.
pub(crate) const fn align_up(x: usize, align: usize) -> usi... | kernel/comps/mlsdisk/src/util/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_softirq::BottomHalfDisabled;
use ostd::{
mm::{
Daddr, FrameAllocOptions, HasDaddr, HasSize, Infallible, PAGE_SIZE, VmReader, VmWriter,
dma::{DmaStream, FromDevice, ToDevice},
io_util... | kernel/comps/network/src/buffer.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(unused)]
use alloc::{
collections::VecDeque,
sync::{Arc, Weak},
};
use core::ops::Range;
use aster_softirq::BottomHalfDisabled;
use bitvec::{array::BitArray, prelude::Lsb0};
use ostd::{
mm::{
Daddr, FrameAllocOptions, HasDaddr, Infallible, PAGE_SIZE, ... | kernel/comps/network/src/dma_pool.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::vec;
use aster_bigtcp::{
device::{self, NotifyDevice},
time::Instant,
};
use ostd::mm::VmWriter;
use crate::{AnyNetworkDevice, buffer::RxBuffer};
impl device::Device for dyn AnyNetworkDevice {
type RxToken<'a> = RxToken;
type TxToken<'a> = TxToken<'a>;
... | kernel/comps/network/src/driver.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![no_std]
#![deny(unsafe_code)]
#![feature(trait_alias)]
mod buffer;
pub mod dma_pool;
mod driver;
extern crate alloc;
#[macro_use]
extern crate ostd_pod;
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};
use core::{any::Any, fmt::Debug};
use aster_bigtcp... | kernel/comps/network/src/lib.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! PCI bus
use alloc::{collections::VecDeque, sync::Arc, vec::Vec};
use core::fmt::Debug;
use log::{debug, error};
use ostd::bus::BusProbeError;
use super::{PciCommonDevice, device_info::PciDeviceId};
/// A trait that represents PCI devices.
pub trait PciDevice: Sync + Send + D... | kernel/comps/pci/src/bus.rs | null | null | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.