Dependencies and Configuration

Relevant source files

This document covers the project dependencies, build configuration, and integration aspects of the memory_set crate within the broader ArceOS ecosystem. It provides essential information for developers who need to understand how to build, configure, and integrate this memory management library.

For information about the actual usage patterns and API details, see Basic Usage Patterns. For development workflow and testing setup, see Development Workflow.

Package Configuration

The memory_set crate is configured as a foundational memory management library designed specifically for operating system development. The package configuration reflects its role as a core component in the ArceOS ecosystem.

Crate Metadata

ConfigurationValue
Package Namememory_set
Version0.1.0
Rust Edition2021
LicenseTriple licensed: GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0
Categoriesos,memory-management,no-std

The crate is explicitly designed for no-std environments, making it suitable for kernel-level and embedded development where the standard library is not available.

flowchart TD
subgraph subGraph2["ArceOS Integration"]
    HOMEPAGE["homepage = 'github.com/arceos-org/arceos'"]
    KEYWORDS["keywords = ['arceos', 'virtual-memory', 'memory-area', 'mmap']"]
    REPO["repository = 'github.com/arceos-org/memory_set'"]
end
subgraph subGraph1["Target Environment"]
    NOSTD["no-std compatible"]
    KERNEL["Kernel development"]
    EMBED["Embedded systems"]
    OS["Operating systems"]
end
subgraph subGraph0["Package Metadata"]
    PKG["memory_set v0.1.0"]
    ED["edition = '2021'"]
    LIC["Triple License"]
    CAT["Categories: os, memory-management, no-std"]
end
GPL["GPL-3.0-or-later"]
APACHE["Apache-2.0"]
MULAN["MulanPSL-2.0"]

HOMEPAGE --> PKG
KEYWORDS --> PKG
LIC --> APACHE
LIC --> GPL
LIC --> MULAN
PKG --> EMBED
PKG --> KERNEL
PKG --> NOSTD
PKG --> OS
REPO --> PKG

Crate Package Configuration Structure

Sources: Cargo.toml(L1 - L13) 

Dependencies

The memory_set crate maintains a minimal dependency footprint with only one external dependency, reflecting its design philosophy of being a lightweight, foundational library.

External Dependencies

The crate depends on a single external library:

  • memory_addr = "0.2" - Provides core address types and utilities for virtual memory management

This dependency provides the fundamental VirtAddr and VirtAddrRange types that are used throughout the memory management system.

flowchart TD
subgraph subGraph2["Standard Library"]
    CORE["core (no-std)"]
    ALLOC["alloc (BTreeMap)"]
end
subgraph subGraph1["External Dependencies"]
    MEMADDR["memory_addr v0.2"]
    VIRTADDR["VirtAddr"]
    VIRTADDRRANGE["VirtAddrRange"]
end
subgraph subGraph0["memory_set Crate"]
    MS["MemorySet"]
    MA["MemoryArea"]
    MB["MappingBackend"]
    VAR["VirtAddrRange usage"]
    VA["VirtAddr usage"]
end

MA --> CORE
MA --> VA
MA --> VAR
MB --> CORE
MS --> ALLOC
MS --> VA
MS --> VAR
VA --> VIRTADDR
VAR --> VIRTADDRRANGE
VIRTADDR --> MEMADDR
VIRTADDRRANGE --> MEMADDR

Dependency Graph and Type Flow

Internal Standard Library Usage

While the crate is no-std compatible, it uses specific components from the Rust standard library:

  • core - Fundamental types and traits (available in no-std)
  • alloc - For BTreeMap collection used in MemorySet (requires allocator)

The use of BTreeMap indicates that while the crate is no-std, it requires an allocator to be available in the target environment.

Sources: Cargo.toml(L14 - L15) 

Build Configuration

Rust Edition and Compiler Features

The crate uses Rust Edition 2021, which provides access to modern Rust language features while maintaining compatibility with no-std environments.

Key build characteristics:

  • No standard library dependency - Suitable for kernel and embedded development
  • Allocator requirement - Uses BTreeMap which requires heap allocation
  • Generic-heavy design - Relies on Rust's zero-cost abstractions

Target Environment Compatibility

flowchart TD
subgraph subGraph2["Required Components"]
    CORE["core library"]
    ALLOCLIB["alloc library"]
    BTREE["BTreeMap support"]
end
subgraph subGraph1["Supported Targets"]
    KERNEL["Kernel modules"]
    RTOS["Real-time OS"]
    EMBED["Embedded systems"]
    BAREMETAL["Bare metal"]
end
subgraph subGraph0["Build Requirements"]
    RUST2021["Rust Edition 2021"]
    NOSTD["no-std environment"]
    ALLOC["Allocator available"]
end

ALLOC --> ALLOCLIB
ALLOCLIB --> BTREE
BTREE --> CORE
NOSTD --> ALLOC
NOSTD --> BAREMETAL
NOSTD --> EMBED
NOSTD --> KERNEL
NOSTD --> RTOS
RUST2021 --> NOSTD

Build Environment and Target Compatibility

Sources: Cargo.toml(L4)  Cargo.toml(L12) 

ArceOS Ecosystem Integration

The memory_set crate is designed as a foundational component within the ArceOS operating system ecosystem. Its configuration reflects this tight integration while maintaining modularity.

Ecosystem Position

The crate serves as a core memory management building block within ArceOS:

  • Homepage: Points to the main ArceOS project (https://github.com/arceos-org/arceos)
  • Keywords: Explicitly includes "arceos" along with memory management terms
  • Repository: Maintains separate repository for modular development
  • License: Uses triple licensing compatible with various OS licensing requirements

Integration Points

AspectConfigurationPurpose
Keywords"arceos", "virtual-memory", "memory-area", "mmap"Discoverability and categorization
Categories"os", "memory-management", "no-std"Crate ecosystem positioning
Documentationdocs.rs/memory_setPublic API documentation
HomepageArceOS main projectEcosystem context

The triple licensing scheme (GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0) provides flexibility for integration into various operating system projects with different licensing requirements.

Sources: Cargo.toml(L7 - L12) 

Development Environment Setup

Prerequisites

To work with the memory_set crate, developers need:

  1. Rust toolchain with Edition 2021 support
  2. Target environment that supports no-std and alloc
  3. Allocator implementation for the target platform

Build Commands

Standard Rust cargo commands apply:

  • cargo build - Build the library
  • cargo test - Run tests (requires test environment with allocator)
  • cargo doc - Generate documentation

The crate's minimal dependency structure ensures fast build times and reduced complexity in integration scenarios.

Sources: Cargo.toml(L1 - L16)