Crate memory_addr
source ·Expand description
memory_addr
Wrappers and helper functions for physical and virtual memory addresses.
Examples
use memory_addr::{PhysAddr, VirtAddr};
let phys_addr = PhysAddr::from(0x12345678);
let virt_addr = VirtAddr::from(0x87654321);
assert_eq!(phys_addr.align_down(0x1000usize), PhysAddr::from(0x12345000));
assert_eq!(phys_addr.align_offset_4k(), 0x678);
assert_eq!(virt_addr.align_up_4k(), VirtAddr::from(0x87655000));
assert!(!virt_addr.is_aligned_4k());
assert!(VirtAddr::from(0xabcedf0).is_aligned(16usize));Structs
- A physical memory address.
 - A virtual memory address.
 
Constants
- The size of a 4K page (4096 bytes).
 
Functions
- Align address downwards.
 - Align address downwards to 4096 (bytes).
 - Returns the offset of the address within the alignment.
 - Returns the offset of the address within a 4K-sized page.
 - Align address upwards.
 - Align address upwards to 4096 (bytes).
 - Checks whether the address has the demanded alignment.
 - Checks whether the address is 4K-aligned.