std1.0.0-beta-7 SafeC docs

std :: kernel::mmu

Trait std::MmuFormat

#include <std/kernel/mmu.h> source

trait MmuFormat {
    int levels() const;
    int shift(int level) const;
    unsigned long entries(int level) const;
    unsigned long esize() const;
    unsigned long long table_desc(unsigned long phys) const;
    unsigned long long leaf_desc(unsigned long phys, unsigned int flags) const;
    int valid(unsigned long long e) const;
    int is_leaf(unsigned long long e, int level) const;
    unsigned long addr(unsigned long long e, int level) const;
    int load_root(unsigned long root) const;
    int flush_all() const;
    int flush_page(unsigned long virt) const;
}

Each format has the same methods (unused_ only gives the struct a size):

levels()            number of table levels
shift(l)            VA bit where level l's index starts (l = 0 is the root)
entries(l)          entries in a level-l table
esize()             bytes per entry (4 or 8)
table_desc(p)       entry pointing at the next-level table at physical p
leaf_desc(p, f)     4 KiB page entry for physical p with MMU_* flags f
valid(e)            entry present
is_leaf(e, l)       valid entry that maps memory (not a table pointer)
addr(e, l)          physical address an entry points at
load_root(root)     install root on this CPU (CR3/satp/TTBR0/TTBR0)
flush_all()/flush_page(v)  TLB maintenance

load_root/flush_* return 1 if they ran, 0 if this isn't the running CPU. MmuFormat names that set; MmuContext<F> requires it of F.

Required methods

§int levels() constsource
§int shift(int level) constsource
§unsigned long entries(int level) constsource
§unsigned long esize() constsource
§unsigned long long table_desc(unsigned long phys) constsource
§unsigned long long leaf_desc(unsigned long phys, unsigned int flags) constsource
§int valid(unsigned long long e) constsource
§int is_leaf(unsigned long long e, int level) constsource
§unsigned long addr(unsigned long long e, int level) constsource
§int load_root(unsigned long root) constsource
§int flush_all() constsource
§int flush_page(unsigned long virt) constsource