Trait MemIf

Source
pub trait MemIf {
    // Required methods
    fn phys_ram_ranges() -> &'static [RawRange];
    fn reserved_phys_ram_ranges() -> &'static [RawRange];
    fn mmio_ranges() -> &'static [RawRange];
    fn phys_to_virt(paddr: PhysAddr) -> VirtAddr;
    fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr;
}
Expand description

Physical memory interface.

Required Methods§

Source

fn phys_ram_ranges() -> &'static [RawRange]

Returns all physical memory (RAM) ranges on the platform.

All memory ranges except reserved ranges (including the kernel loaded range) are free for allocation.

Source

fn reserved_phys_ram_ranges() -> &'static [RawRange]

Returns all reserved physical memory ranges on the platform.

Reserved memory can be contained in phys_ram_ranges, they are not allocatable but should be mapped to kernel’s address space.

Note that the ranges returned should not include the range where the kernel is loaded.

Source

fn mmio_ranges() -> &'static [RawRange]

Returns all device memory (MMIO) ranges on the platform.

Source

fn phys_to_virt(paddr: PhysAddr) -> VirtAddr

Translates a physical address to a virtual address.

It is just an easy way to access physical memory when virtual memory is enabled. The mapping may not be unique, there can be multiple vaddrs mapped to that paddr.

Source

fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr

Translates a virtual address to a physical address.

It is a reverse operation of phys_to_virt. It requires that the vaddr must be available through the phys_to_virt translation. It cannot be used to translate arbitrary virtual addresses.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§