#low-level #aarch64 #register #cpu #arm #processor

no-std aarch64-cpu

Low level access to processors using the AArch64 execution state

7 stable releases

10.0.0 Oct 26, 2024
9.4.0 Sep 21, 2023
9.3.1 Dec 31, 2022
9.0.0 Nov 6, 2022

#34 in Embedded development

Download history 1902/week @ 2024-07-28 1527/week @ 2024-08-04 1943/week @ 2024-08-11 2164/week @ 2024-08-18 1971/week @ 2024-08-25 1926/week @ 2024-09-01 2044/week @ 2024-09-08 1469/week @ 2024-09-15 1808/week @ 2024-09-22 1044/week @ 2024-09-29 1709/week @ 2024-10-06 2791/week @ 2024-10-13 2401/week @ 2024-10-20 2483/week @ 2024-10-27 2035/week @ 2024-11-03 2437/week @ 2024-11-10

9,546 downloads per month
Used in 19 crates (10 directly)

MIT/Apache

345KB
4.5K SLoC

crates.io crates.io

aarch64-cpu

Low level access to processors using the AArch64 execution state.

This project is developed and maintained by the Cortex-A team.

Documentation

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on current stable Rust. It might compile with older versions but that may change in any new patch release.

Usage

Please note that for using this crate's register definitions (as provided by aarch64_cpu::registers::*), you need to also import aarch64_cpu::registers::{Readable, Writeable}.

Example

Check out https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials for usage examples. Listed below is a snippet of rust-raspberrypi-OS-tutorials's early boot code.

use aarch64_cpu::{asm, registers::*};

// Some parts omitted for brevity.

unsafe fn prepare_el2_to_el1_transition(
    virt_boot_core_stack_end_exclusive_addr: u64,
    virt_kernel_init_addr: u64,
) {
    // Enable timer counter registers for EL1.
    CNTHCTL_EL2.write(CNTHCTL_EL2::EL1PCEN::SET + CNTHCTL_EL2::EL1PCTEN::SET);

    // No offset for reading the counters.
    CNTVOFF_EL2.set(0);

    // Set EL1 execution state to AArch64.
    HCR_EL2.write(HCR_EL2::RW::EL1IsAarch64);

    // Set up a simulated exception return.
    SPSR_EL2.write(
        SPSR_EL2::D::Masked
            + SPSR_EL2::A::Masked
            + SPSR_EL2::I::Masked
            + SPSR_EL2::F::Masked
            + SPSR_EL2::M::EL1h,
    );
}

Disclaimer

Descriptive comments in the source files are taken from the ARM Architecture Reference Manual ARMv8, for ARMv8-A architecture profile.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Code of Conduct

Contribution to this crate is organized under the terms of the Rust Code of Conduct, the maintainer of this crate, the Cortex-A team, promises to intervene to uphold that code of conduct.

Dependencies