Skip to content

Commit

Permalink
Merge pull request #1 from yfblock/main
Browse files Browse the repository at this point in the history
feat: Support loongarch64 and fmt clippy
  • Loading branch information
equation314 authored Jan 13, 2025
2 parents af24f4d + b96ed3f commit 4581870
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
rust-toolchain: [nightly]
targets: [x86_64-unknown-linux-gnu, x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none-softfloat]
targets: [x86_64-unknown-linux-gnu, x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none-softfloat, loongarch64-unknown-none-softfloat]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
Expand Down
17 changes: 17 additions & 0 deletions src/arch/loongarch64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use core::arch::asm;

const IE_MASK: usize = 1 << 2;

#[inline]
pub fn local_irq_save_and_disable() -> usize {
let mut flags: usize = 0;
// clear the `IE` bit, and return the old CSR
unsafe { asm!("csrxchg {}, {}, 0x0", inout(reg) flags, in(reg) IE_MASK) };
flags & IE_MASK
}

#[inline]
pub fn local_irq_restore(flags: usize) {
// restore the `IE` bit
unsafe { asm!("csrxchg {}, {}, 0x0", in(reg) flags, in(reg) IE_MASK) };
}
3 changes: 3 additions & 0 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ cfg_if::cfg_if! {
} else if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else if #[cfg(target_arch = "loongarch64")] {
mod loongarch64;
pub use self::loongarch64::*;
}
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
//! ```
#![no_std]
#![feature(asm_const)]

mod arch;

Expand Down

0 comments on commit 4581870

Please sign in to comment.