Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64: use aarch64-cpu crate #49

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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