Expand description
Virtual Memory Manager module.
This module provides the core functionality for managing virtual memory in the kernel. It handles address space management, memory mappings, and page table operations.
§Key Components
VirtualMemoryManager
: Main structure for managing virtual memory mappings and address spaces- Memory maps: Track mappings between virtual and physical memory areas
- ASID (Address Space ID): Identifies different address spaces
§Functionality
The manager enables:
- Creating and tracking virtual to physical memory mappings
- Managing different address spaces via ASIDs
- Searching for memory mappings by virtual address
- Accessing the root page table for the current address space
§Examples
let mut manager = VirtualMemoryManager::new();
manager.set_asid(42);
// Add a memory mapping
let vma = MemoryArea { start: 0x0, end: 0x1000 };
let pma = MemoryArea { start: 0x80000000, end: 0x80001000 };
let map = VirtualMemoryMap { vmarea: vma, pmarea: pma };
manager.add_memory_map(map);
// Search for a memory mapping
if let Some(found_map) = manager.search_memory_map(0x500) {
// Found the mapping
}