11 releases (7 breaking)

0.8.0 Oct 15, 2024
0.7.0 Jul 19, 2024
0.5.0 Oct 25, 2023
0.4.1 Jun 16, 2023
0.2.1 Jun 29, 2022

#400 in Embedded development

Download history 112/week @ 2024-07-27 35/week @ 2024-08-03 6/week @ 2024-08-10 41/week @ 2024-08-17 36/week @ 2024-08-24 6/week @ 2024-08-31 20/week @ 2024-09-21 5/week @ 2024-09-28 1/week @ 2024-10-05 164/week @ 2024-10-12 75/week @ 2024-10-19 46/week @ 2024-10-26 137/week @ 2024-11-02 133/week @ 2024-11-09

407 downloads per month

MIT/Apache

145KB
2.5K SLoC

aarch64 page table manipulation

crates.io page docs.rs page

This crate provides a library to manipulate page tables conforming to the AArch64 Virtual Memory System Architecture.

Currently it only supports:

  • stage 1 page tables
  • 4 KiB pages
  • EL3, NS-EL2, NS-EL2&0 and NS-EL1&0 translation regimes

This is not an officially supported Google product.

License

Licensed under either of

at your option.

Contributing

If you want to contribute to the project, see details of how we accept contributions.


lib.rs:

A library to manipulate AArch64 VMSA page tables.

Currently it only supports:

  • stage 1 page tables
  • 4 KiB pages
  • EL3, NS-EL2, NS-EL2&0 and NS-EL1&0 translation regimes

Full support is provided for identity mapping (IdMap) and linear mapping (LinearMap). If you want to use a different mapping scheme, you must provide an implementation of the Translation trait and then use Mapping directly.

Example

use aarch64_paging::{
    idmap::IdMap,
    paging::{Attributes, MemoryRegion, TranslationRegime},
};

const ASID: usize = 1;
const ROOT_LEVEL: usize = 1;
const NORMAL_CACHEABLE: Attributes = Attributes::ATTRIBUTE_INDEX_1.union(Attributes::INNER_SHAREABLE);

// Create a new EL1 page table with identity mapping.
let mut idmap = IdMap::new(ASID, ROOT_LEVEL, TranslationRegime::El1And0);
// Map a 2 MiB region of memory as read-write.
idmap.map_range(
    &MemoryRegion::new(0x80200000, 0x80400000),
    NORMAL_CACHEABLE | Attributes::NON_GLOBAL | Attributes::VALID | Attributes::ACCESSED,
).unwrap();
// SAFETY: Everything the program uses is within the 2 MiB region mapped above.
unsafe {
    // Set `TTBR0_EL1` to activate the page table.
    idmap.activate();
}

Dependencies

~1.2–1.7MB
~29K SLoC