no-std ruspiro-arch-aarch64

This crate provides access to Aarch64 system registers as well as specific usefull aarch64 assembly instructions

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

Download history 36/week @ 2024-06-16 31/week @ 2024-06-23 9/week @ 2024-06-30 41/week @ 2024-07-07 40/week @ 2024-07-14 28/week @ 2024-07-21 33/week @ 2024-07-28 29/week @ 2024-08-04 26/week @ 2024-08-11 21/week @ 2024-08-18 17/week @ 2024-08-25 28/week @ 2024-09-01 31/week @ 2024-09-08 28/week @ 2024-09-15 41/week @ 2024-09-22 107/week @ 2024-09-29

211 downloads per month
Used in 10 crates (5 directly)

MIT/Apache

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.

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.

Dependencies

~14KB