8 releases
0.1.7 | Dec 28, 2021 |
---|---|
0.1.6 | Dec 28, 2021 |
0.1.5 | Aug 30, 2021 |
0.1.4 | Apr 23, 2021 |
0.1.3 | Sep 23, 2020 |
#306 in Embedded development
211 downloads per month
Used in 10 crates
(5 directly)
71KB
911 lines
RusPiRo Aarch64 API
This crate provides access to ARM Aarch64 system registers as well as specific assembly instructions. The system registers are organized based on the highest exception level they are available.
Usage
To use this crate simply add the dependency to your Cargo.toml
file:
[dependencies]
ruspiro-arch-aarch64 = "0.1.7"
With the dependency maintained in the Cargo.toml file the different defined system registers can be accessed as shown in the following code snipped.
For each available system register a mdule with the registers name is available providing functions to read/write the contents of the register. Those read/write accesses can be either use raw values (u32, u64 - based on register size) or predifined register fields. If a register field is used value contained in the field is properly shifted and masked when written to or read from a register.
use ruspiro_arch_aarch64::register::*;
fn some_function() {
// read the current exeption level - do this by accessing the predefined
// register field
let current_el = currentel::read(currentel::EL::Field);
if current_el == currentel::EL::EL2 {
// if a register definition provides predefined constants for specific
// register fields those can be used for instance to write to the register
mair_el2::write(
mair_el2::MAIR0::NGNRNE
| mair_el2::MAIR1::NGNRE
| mair_el2::MAIR2::GRE
| mair_el2::MAIR3::NC
| mair_el2::MAIR4::NORM,
);
}
}
License
Licensed under Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or MIT (LICENSE-MIT or http://opensource.org/licenses/MIT)) at your choice.
Dependencies
~14KB