Expand description

This cache is a wrapper for connector objects that implement the PhysicalMemory trait. It enables a configurable caching layer when accessing physical pages.

Each page that is being read by the the connector will be placed into a PageCache object. If the cache is still valid then for consecutive reads this connector will just return the values from the cache and not issue out a new read. In case the cache is not valid anymore it will do a new read.

The cache time is determined by the customizable cache validator. The cache validator has to implement the CacheValidator trait.

To make it easier and quicker to construct and work with caches this module also contains a cache builder.

More examples can be found in the documentations for each of the structs in this module.

Examples

Building a simple cache with default settings:

use memflow::prelude::v1::*;
use memflow::dummy::DummyMemory;

let mut virt_mem = VirtualDma::new(phys_mem, x64::ARCH, translator);

let mut cached_mem = CachedView::builder(virt_mem)
    .arch(x64::ARCH)
    .validator(DefaultCacheValidator::default())
    .cache_size(size::mb(1))
    .build()
    .unwrap();

let addr = virt_base; // some arbitrary address

cached_mem.write(addr, &MAGIC_VALUE).unwrap();

let value: u64 = cached_mem.read(addr).unwrap();
assert_eq!(value, MAGIC_VALUE);

Structs