memory_addr

Crates.iomemory_addr
lib.rsmemory_addr
version0.3.1
sourcesrc
created_at2023-05-09 15:53:38.463093
updated_at2024-09-14 02:02:33.233192
descriptionWrappers and helper functions for physical and virtual addresses
homepagehttps://github.com/arceos-org/arceos
repositoryhttps://github.com/arceos-org/axmm_crates
max_upload_size
id860647
size48,791
core (github:arceos-org:core)

documentation

https://docs.rs/memory_addr

README

memory_addr

Crates.io Docs.rs CI

Wrappers and helper functions for physical and virtual memory addresses.

Examples

use memory_addr::{pa, va, va_range, PhysAddr, VirtAddr, MemoryAddr};

let phys_addr = PhysAddr::from(0x12345678);
let virt_addr = VirtAddr::from(0x87654321);

assert_eq!(phys_addr.align_down(0x1000usize), pa!(0x12345000));
assert_eq!(phys_addr.align_offset_4k(), 0x678);
assert_eq!(virt_addr.align_up_4k(), va!(0x87655000));
assert!(!virt_addr.is_aligned_4k());
assert!(va!(0xabcedf0).is_aligned(16usize));

let va_range = va_range!(0x87654000..0x87655000);
assert_eq!(va_range.start, va!(0x87654000));
assert_eq!(va_range.size(), 0x1000);
assert!(va_range.contains(virt_addr));
assert!(va_range.contains_range(va_range!(virt_addr..virt_addr + 0x100)));
assert!(!va_range.contains_range(va_range!(virt_addr..virt_addr + 0x1000)));
Commit count: 0

cargo fmt