Skip to content

Commit 72946b8

Browse files
Merge pull request #8 from Neotron-Compute/add-power-control
Add power-control and compare-and-swap.
2 parents f524ccc + f447056 commit 72946b8

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ clap = {version = "4.2", features = ["derive"]}
1313
env_logger = "0.9"
1414
libloading = "0.7"
1515
log = "0.4"
16-
neotron-common-bios = "0.10"
16+
neotron-common-bios = "0.11"
1717
pix-engine = "0.7"

src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ static BIOS_API: common::Api = common::Api {
151151
block_read,
152152
block_verify,
153153
power_idle,
154+
power_control,
155+
compare_and_swap_bool,
154156
};
155157

156158
/// Our standard 256 colour palette
@@ -1515,6 +1517,20 @@ extern "C" fn power_idle() {
15151517
std::thread::sleep(std::time::Duration::from_millis(1));
15161518
}
15171519

1520+
extern "C" fn power_control(mode: common::PowerMode) -> ! {
1521+
println!("Got power mode {:?}, but quitting...", mode);
1522+
std::process::exit(0);
1523+
}
1524+
1525+
extern "C" fn compare_and_swap_bool(
1526+
item: &std::sync::atomic::AtomicBool,
1527+
old_value: bool,
1528+
new_value: bool,
1529+
) -> bool {
1530+
item.compare_exchange(old_value, new_value, Ordering::SeqCst, Ordering::SeqCst)
1531+
.is_ok()
1532+
}
1533+
15181534
// ===========================================================================
15191535
// Impl Blocks
15201536
// ===========================================================================

0 commit comments

Comments
 (0)