Skip to content

Commit

Permalink
arm64: use aarch64-cpu crate
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Maslowski <[email protected]>
  • Loading branch information
orangecms authored and gmacd committed Nov 29, 2024
1 parent fe5c0c1 commit f476a32
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions aarch64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
default-target = "aarch64-unknown-none"

[dependencies]
aarch64-cpu = "9.4.0"
bitstruct = "0.1"
port = { path = "../port" }
num_enum = { version = "0.7", default-features = false }
13 changes: 3 additions & 10 deletions aarch64/src/registers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![allow(non_upper_case_globals)]

use aarch64_cpu::registers::{Readable, Writeable};
use aarch64_cpu::{asm, registers::MIDR_EL1};
use bitstruct::bitstruct;
use core::fmt;
use num_enum::TryFromPrimitive;
Expand Down Expand Up @@ -46,16 +48,7 @@ bitstruct! {

impl MidrEl1 {
pub fn read() -> Self {
#[cfg(not(test))]
{
let mut value: u64;
unsafe {
core::arch::asm!("mrs {value}, midr_el1", value = out(reg) value);
}
Self(value)
}
#[cfg(test)]
Self(0)
Self(if cfg!(test) { 0 } else { MIDR_EL1.extract().into() })
}

pub fn partnum_enum(&self) -> Result<PartNum, u16> {
Expand Down

0 comments on commit f476a32

Please sign in to comment.