Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/rust-console/gba into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Mar 4, 2024
2 parents 4e14fa7 + cd4f2db commit 35724f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ track_caller = []
voladdress = "1.3.0"
bitfrob = "1"
bracer = "0.1.2"
critical-section = { version = "1.1.2", features = ["restore-state-bool"], optional = true }

[profile.dev]
opt-level = 3
Expand Down
18 changes: 18 additions & 0 deletions src/critical_section.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use critical_section::{set_impl, Impl, RawRestoreState};

use crate::mmio::IME;

struct GbaCriticalSection;
set_impl!(GbaCriticalSection);

unsafe impl Impl for GbaCriticalSection {
unsafe fn acquire() -> RawRestoreState {
let restore = IME.read();
IME.write(false);
restore
}

unsafe fn release(restore: RawRestoreState) {
IME.write(restore);
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ mod macros;
pub mod asm_runtime;
pub mod bios;
pub mod builtin_art;
#[cfg(feature = "critical-section")]
mod critical_section;
pub mod dma;
pub mod fixed;
pub mod gba_cell;
Expand Down

0 comments on commit 35724f5

Please sign in to comment.