Expand description
ax-memory-addr
Wrappers and helper functions for physical and virtual addresses
English | 中文
§Introduction
ax-memory-addr provides Wrappers and helper functions for physical and virtual addresses. It is maintained as part of the TGOSKits component set and is intended for Rust projects that integrate with ArceOS, AxVisor, or related low-level systems software.
ax-memory-addr was derived from https://github.com/arceos-org/axmm_crates
§Quick Start
§Installation
Add this crate to your Cargo.toml:
[dependencies]
ax-memory-addr = "0.6.1"§Run Check and Test
# Enter the crate directory
cd components/axmm_crates/memory_addr
# Format code
cargo fmt --all
# Run clippy
cargo clippy --all-targets --all-features
# Run tests
cargo test --all-features
# Build documentation
cargo doc --no-deps§Integration
§Example
use ax_memory_addr as _;
fn main() {
// Integrate `ax-memory-addr` into your project here.
}§Documentation
Generate and view API documentation:
cargo doc --no-deps --openOnline documentation: docs.rs/ax-memory-addr
§Contributing
- Fork the repository and create a branch
- Run local format and checks
- Run local tests relevant to this crate
- Submit a PR and ensure CI passes
§License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Macros§
- addr_
range - Converts the given range expression into
AddrRange. Panics if the range is invalid. - def_
usize_ addr - Creates a new address type by wrapping an
usize. - def_
usize_ addr_ formatter - Creates implementations for the
Debug,LowerHex, andUpperHextraits for the given address types defined by thedef_usize_addr. - pa
- Alias for
PhysAddr::from_usize. - pa_
range - Converts the given range expression into
PhysAddrRange. Panics if the range is invalid. - va
- Alias for
VirtAddr::from_usize. - va_
range - Converts the given range expression into
VirtAddrRange. Panics if the range is invalid.
Structs§
- Addr
Range - A range of a given memory address type
A. - DynPage
Iter - A page-by-page iterator with dynamic page size.
- Page
Iter - A page-by-page iterator.
- Phys
Addr - A physical memory address.
- Virt
Addr - A virtual memory address.
Constants§
- PAGE_
SIZE_ 1G - The size of a 1G page (1073741824 bytes).
- PAGE_
SIZE_ 2M - The size of a 2M page (2097152 bytes).
- PAGE_
SIZE_ 4K - The size of a 4K page (4096 bytes).
Traits§
- Memory
Addr - A trait for memory address types.
Functions§
- align_
down - Align address downwards.
- align_
down_ 4k - Align address downwards to 4096 (bytes).
- align_
offset - Returns the offset of the address within the alignment.
- align_
offset_ 4k - Returns the offset of the address within a 4K-sized page.
- align_
up - Align address upwards.
- align_
up_ 4k - Align address upwards to 4096 (bytes).
- is_
aligned - Checks whether the address has the demanded alignment.
- is_
aligned_ 4k - Checks whether the address is 4K-aligned.
Type Aliases§
- Page
Iter1G - A
PageIterfor 1G pages. - Page
Iter2M - A
PageIterfor 2M pages. - Page
Iter4K - A
PageIterfor 4K pages. - Phys
Addr Range - A range of physical addresses
PhysAddr. - Virt
Addr Range - A range of virtual addresses
VirtAddr.