ruspiro-arch-aarch64

Crates.ioruspiro-arch-aarch64
lib.rsruspiro-arch-aarch64
version0.1.7
sourcesrc
created_at2020-09-16 13:31:03.959503
updated_at2021-12-28 09:32:08.529266
descriptionThis crate provides access to Aarch64 system registers as well as specific usefull aarch64 assembly instructions
homepage
repositoryhttps://github.com/RusPiRo/ruspiro-arch-aarch64/tree/v0.1.7
max_upload_size
id289413
size97,077
(2ndTaleStudio)

documentation

https://docs.rs/ruspiro-arch-aarch64/0.1.7

README

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.

CI Latest Version Documentation License

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.

Commit count: 0

cargo fmt